Smart Title Case
Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Smart Title Case
- This topic has 17 replies, 10 voices, and was last updated 6 years, 8 months ago by Morgan Crockett.
-
AuthorPosts
-
-
May 23, 2010 at 11:05 am #52851Anne-Marie ConcepcionKeymaster
The comments in my post about Configurator 2.0 and ID started veering to the topic of a “smart” Title Case function, so I'm redirecting people interested in that to this thread.
There actually *is* an intelligent Smart Title Case script around, written by Dave Saunders a while ago (2006): https://jsid.blogspot.com/2006/06/smart-title-case-revisited.html
Or you can include the following GREP Style in your paragraph style for the Title grafs. It finds the first lowercase character of every word and makes it a cap because in the GREP style you specify a Character style that sets the case to All Caps.<(?!(a|the|of)>)lThe words in the pipes are ignored, and you can add more if you want.
Thoughts?
-
May 24, 2010 at 12:34 am #52852KlausNordbyMember
Whoa! Yes, of course, GREP to the rescue again! I'm still very much a GREP newbie, hence I didn't think of that myself <kicks self>. I'll also check out the Saunders scripts, so thanks! (I have indeed been kind of scarce around here for a while, due to some travels and other personal stuff — thanks for “missing” me, even if only very, verrrry little! :-) )
-
May 24, 2010 at 12:45 am #52853HarbsMember
I don't think you can come up with a GREP to really solve this problem. The problem is: Smart Title Case is not just converting the first letter to caps except for cetain words.
The first word of a title should always be capitalised — even if it's “A” or “The” etc. There's also words like USA, InDesign, etc.
FWIW, my Formatting Tools solves all these problems and can convert by style: https://in-tools.com/wordpress/indesign/plugins/formatting-tools/formatting-tools-1-0-5
-
May 24, 2010 at 7:16 pm #52854Theunis De JongMember
Don't forget: a GREP style can only change lowercase to uppercase, since that's all that is possible with a character style. So a GREP style cannot convert an uppercase to a lowercase character to 'correct' from “InDesign Is A Rather Good Program” to “InDesign is a Rather Good Program”.
The same goes for the first word of a title — this would typically already be entered as a capital.
(Harbs' tool does not have these limitations.)
That said, A-M's GREP can be adjusted to this to change the first character as well (and it shows where the backslashes go):
(^\s*\l)|(\<(?!(the|an?|in|to|o[rfn]|for)>)\l)
-
May 24, 2010 at 11:34 pm #52855Phil FrankParticipant
So I must be doing something wrong. I've typed myself a few titles, all in lower case, and complete with instances of and, the, and of. I have a nice character style called all caps that sets the case to All Caps. When I use A-M's GREP, all the words in my titles stay all lower case. When I use Jongware's, each word is capitalized. Clearly I am missing something. Any ideas about what that might be?
Thanks.
-
May 25, 2010 at 12:15 am #52856Theunis De JongMember
Oops. Gremlins Ate My Backslash! :-(
(^\s*\l)|(\<(?!(the|an?|in|to|o[rfn]|for)\>)\l)
(It was the one right before '>' that went missing … this time.)
The Ye-Shall-Not-Find-This list is a bit obfuscated because of my shorthand notations:
an? = 'a', optionally followed by one 'n'
o[rfn] = 'o', followed by one of 'r', 'f', or 'n'
After that the word should end (A-M thought of that), which is done by the last \> code (End Word). If none of the above applies, the first lowercase character is matched.
The stuff at the start is “Beginning of line, any amount of whitespace (including zero), then a lowercase character. This ensures the first word is always capitalized — try it with “iPads are expensive toys” … (You'll see ID toggle between lowercase and uppercase while entering this.)
-
May 25, 2010 at 1:29 am #52857Eugene TysonMember
The Script is far easier imho, lol.
But the GREP stuff is pretty awesome.
I wish that Paragraph styles catered for more cases though, like Title Case or even implemented a Smart Title Case with a list of words in preferences to ignore.
But all the same, I prefer the script here rather than a Grep Style, imho too much can go wrong with the GREP.
-
May 25, 2010 at 1:33 am #52858Phil FrankParticipant
Yes, that makes a big difference. I haven't figured out why A-M's doesn't have any effect, but yours is now working as expected.
Much obliged.
-
May 25, 2010 at 1:53 pm #52859Anne-Marie ConcepcionKeymaster
Thank you Jongware!
It's not really “my” GREP, btw, I picked it up from a forum post somewhere. (not this forum.)
I like Harb's solution, myself. ;-)
-
November 3, 2015 at 10:05 am #79186Scott RudyParticipant
bringing this back from the dead….
this is working for me until i add a forced line break before a excluded word (i.e., and)
when I force break and the word i do not want to be capped is the first word on the next line it gets recognized as the first word of a new sentence capitalizing it. is there a remedy?
-
June 6, 2016 at 3:51 am #85470Chris HaynesMember
GREP style : CAPS
\<\w(?=\w{3,}\s)
Change first letter of any word larger than 3 letters
(It is not perfect)
-
June 6, 2016 at 8:46 am #85486Chris HaynesMember
– EDIT you dont want the space at the end
\<\w(?=\w{3,})
-
July 25, 2017 at 11:17 am #96345Rombout VersluijsMember
I found this post looking for a proper Sentence Case method. Found a post and editing it a bit i got it to work i think.
You make a Character Style CAPS with Caps as Casing of course. Then make a Paragraph Style with a grep using; ^.+~j|[\w-] If you add a + on the end it will take the complete word and make this TITLE Cased. Handy for index or so.But now i still need a version which takes the first word in a sentence and not per row.
-
July 25, 2017 at 11:26 am #96347Rombout VersluijsMember
I think i found it i replace +~j to \r, so it look at the paragraph letter??? Seems to work. So now the code is ^.\r|[\w-] this will automatically Sentence Case a Paragraph
-
July 25, 2017 at 12:16 pm #96357Scott RudyParticipant
would this work?
apply an all cap character style to…
(?<=\p{punctuation} )\l|^\l
it looks for any punctuation followed by a space then caps the next letter, then it caps all first letters of a paragraph
this will work for a multi sentenced paragraph.
-
July 25, 2017 at 4:22 pm #96362Rombout VersluijsMember
Yes this seems to work as well. So both codes work, thats great. Now i need to dive in this stuff, so much power here :)
With more knowledge hours of work can be solved in a couple of minutes of coding.
-
-
July 25, 2017 at 5:04 pm #96365Rombout VersluijsMember
After double checking yours works better and exaclty what i needed. My version some still did soft returns as regular returns
-
August 22, 2017 at 5:13 pm #97014Morgan CrockettMember
Just tried the original Smart Title Case script, but it doesn’t seem to be working with CC2017. Is there an updated version around?
-
-
AuthorPosts
- You must be logged in to reply to this topic.