Copy link to clipboard
Copied
Our TOCs pull headings from the document that are in all caps, but we don't want the TOC entries to be in all caps. I've seen examples of grep styles that can apply a character style to make letters capitalized, but I don't think I've seen the opposite. Is it possible?
Although there is an attribute style called lowercase, in a sense, there is no such thing as the opposite as a style or attribute because InDesign cannot read and know when a word should be capitalized. But you can Find/Change Heading text to be typed (a new addition called Change Case) in Sentence Case, or Title Case, or lowercase. Next, the Heading style could be edited to apply the appearance of all caps. This basically gets you back to where you were before, except that it is now built corre
...Copy link to clipboard
Copied
Create a lower case character style and then use that as a nested style.
None through one character, lower case through a space. Repeat that as many times as you need to cover the full heading.
Edit: Characters and letters will both work here.
Copy link to clipboard
Copied
Although there is an attribute style called lowercase, in a sense, there is no such thing as the opposite as a style or attribute because InDesign cannot read and know when a word should be capitalized. But you can Find/Change Heading text to be typed (a new addition called Change Case) in Sentence Case, or Title Case, or lowercase. Next, the Heading style could be edited to apply the appearance of all caps. This basically gets you back to where you were before, except that it is now built correctly and typed correctly. Lastly, the ToC could be refreshed and it would pull in properly typed upper/n/lowercase characters.
Copy link to clipboard
Copied
Thanks Mike. But, in this case, it turns out that there is the opposite of all-caps: "Lowercase." It's just missing from the Character properties section of the Properties tab, which does show all-caps.
Copy link to clipboard
Copied
The appearance panel does not duplicate every function of the character and paragraph styles panel.
Copy link to clipboard
Copied
Yep. Which is why I didn't know there was a "lowercase" option for characters. Meanwhile, I'm looking at your suggestion (and thanks for that), but I don't think it can be made to respect "title"-style capitalization. So I probably need a grep style.
Copy link to clipboard
Copied
Look at it again. It honors the base style which is caps through one letter and then applies the lower case through the space. Lather, rinse and repeat.
Copy link to clipboard
Copied
But what if the word after the space is "the" or "a" or another that should not be capitalized?
Copy link to clipboard
Copied
Title case will capitalize them as well.
Copy link to clipboard
Copied
Someone (certainly not me) may come up with something but in the future, I'd type it properly in the first place and apply all caps to the heading style. Then when it comes into the TOC, it will already be done.
Copy link to clipboard
Copied
Yeah, good solution! That works. Thanks.
Copy link to clipboard
Copied
Which is what I said in my comment above! <LOL> Perhaps I should have said "intelligently" lower-cased in order to be better understood. My basic rule is: don't type in all caps, but rather apply the appearance attribute of all caps. That way, when you get in a situation like yours, it produces upper and lowercase intelligently, especially when you generate a ToC.
Copy link to clipboard
Copied
Way back in the day, Dave Saunders wrote a smart title case script. Maybe someone has it filed away somewhere.
Copy link to clipboard
Copied
Way back in the day, Dave Saunders wrote a smart title case script. Maybe someone has it filed away somewhere.
By @BobLevine
Ask and ye shall receive:
//DESCRIPTION: Converts selected text to title case smartly
// Customize this script by either editing these arrays:
var ignoreWords = ["a","and","the","to","with","in","on","as","of","or","at","is","into","by","from", "their", "then", "for"];
var intCaps = ["PineRidge","InDesign","NJ","UMC", "FCCLA", "SkillsUSA", "d’Oeuvres"];
// or by creating text files named ignoreWords.txt and intCaps.txt in the script's folder
ignoreWords = getIgnoreFile(ignoreWords);
intCaps = getIntCaps(intCaps);
try {
myText = app.selection[0].texts[0].contents;
} catch(e) {
exit();
}
theWordRanges = myText.split("/");
for (var i = theWordRanges.length - 1; i >= 0; i--) {
theWords = theWordRanges[i].toLowerCase().split(" ");
//First word must have a cap, but might have an internal cap
myNewText = "";
for (var j = 0; theWords.length > j; j++) {
k = isIn(intCaps,theWords[j])
if (k > -1) {
myNewText = myNewText + intCaps[k] + " ";
continue;
} else {
if ((isIn(ignoreWords,theWords[j]) > -1) && (j != 0)) {
myNewText = myNewText + theWords[j] + " ";
} else {
myNewText = myNewText + InitCap(theWords[j]) + " ";
}
}
}
theWordRanges[i] = myNewText.substring(0,myNewText.length - 1)
}
app.selection[0].texts[0].contents = theWordRanges.join("/");
// +++++++ Functions Start Here +++++++++++++++++++++++
function getIgnoreFile(theWords) {
var myFile = File(File(getScriptPath()).parent.fsName + "/ignoreWords.txt");
if (!myFile.exists) { return theWords }
// File exists, so use it instead
myFile.open("r");
var importedWords = myFile.read();
myFile.close();
return importedWords.split("\n"); // Could filter these, but what's the point?
}
function getIntCaps(theWords) {
var myFile = File(File(getScriptPath()).parent.fsName + "/intCaps.txt");
if (!myFile.exists) { return theWords }
// File exists, so use it instead
myFile.open("r");
var importedWords = myFile.read();
myFile.close();
return importedWords.split("\n"); // Could filter these, but what's the point?
}
function getScriptPath() {
// This function returns the path to the active script, even when running ESTK
try {
return app.activeScript;
} catch(e) {
return e.fileName;
}
}
function isIn(aList,aWord) {
for (var i = 0; aList.length > i; i++) {
if (aList[i].toLowerCase() == aWord) {
return i;
}
}
return -1;
}
function InitCap(aWord) {
if (aWord.length == 1) {
return (aWord.toUpperCase());
}
return (aWord.substr(0,1).toUpperCase() + aWord.substring(1,aWord.length))
}
With apologies to Dave if I shouldn't be posting this. Let Bob know and he can remove it.
No idea if it will run in a current version, but it might run if put in the correct Version X.0 subfolder. Date on the file I have is 2006.
Copy link to clipboard
Copied
Nice! Thanks for digging that up. Just looking at it quickly: Why split on slashes? Were those specific to the author's use case, or is there something I'm overlooking there?
Side question: Why can you arbitrarily not upvote some posts, but you can others? Clicking on "upvote" frequently does nothing.
Copy link to clipboard
Copied
you are not the first person to tell me upvoting is broken.
Copy link to clipboard
Copied
I've had trouble upvoting a post (not my own) right after I posted a reply. I find if I wait a minute and go back to the page, I can upvote. My unoficial thought is that the system needs a little time to cycle.
Copy link to clipboard
Copied
I've had trouble upvoting a post (not my own) right after I posted a reply. I find if I wait a minute and go back to the page, I can upvote. My unoficial thought is that the system needs a little time to cycle.
By @Dave Creamer of IDEAS
Yeah it's a known issue that affects some threads seemingly at random. One of Adobe reps said they were looking into this some time ago.
Copy link to clipboard
Copied
I just tried to upvote Peter's comment, to no avail.
Oh yeah, that's another fun aspect of this forum: trying to figure out who's replying to what, since the replies are just one big stack.
Copy link to clipboard
Copied
Yes, the one-level reply is a pain and has been complained about many times.
Copy link to clipboard
Copied
Packrat. 🙂
Copy link to clipboard
Copied
Guilty as charged.
Hard drives are cheap.
Copy link to clipboard
Copied
Yes, full credit to you as well, Mike. Your first sentence threw me off and I didn't absorb the rest of what you were saying, in my haste to read everything. Have an upvote. And 50 points for Gryffindor.
Copy link to clipboard
Copied
You cannot upvote your own post; only others.
Copy link to clipboard
Copied
I wasn't trying to upvote my own. I tried to upvote Peter's and couldn't. I'd say more than half the time you can't upvote other people's posts.
And on another side note, why does this forum E-mail you a notice of every one of your own posts? So dumb.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now