TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was just reviewing my "capitalization standards" for titles and such and was wondering if there's a macro to do the same thing I'm forced to do by hand nowadays. My personal rules (feel free to disagree/comment on them) are as follows:

  1. the first letter (a number is a letter too for the sake of these rules) always gets capitalized,
  2. every word gets capitalized individually,
  3. the exception to the rule above (and just the rule above) are closed class words such as prepositions and the like.

In other words: I'd like a capitalization command (like \MakeUppercase) that will capitalize every word not included in a list of words and that will always capitalize the first word of its argument.


PS: one such "list" of closed class words (also known as "function words") can be found here.

share|improve this question
Thinking about this, I had to up it. It's probably nice to do as conventions do vary, but this sounds like a neat idea for a package. Unless, that is, it already exists. – qubyte Nov 14 '11 at 13:07
Doesn't bibTeX already do this? – Seamus Nov 14 '11 at 15:32
up vote 16 down vote accepted
\def\CapitalizeFirst#1{\MakeUppercase#1 \Capitalize}
  \ifcsname List@\detokenize{#1}\endcsname
  {\expandafter\let\csname List@\detokenize\expandafter{\next}\endcsname\empty}}

\capitalize{here is a list of words école}

Won't work with UTF-8 (unless XeLaTeX or LuaLaTeX are used).

It won't work with UTF-8 in pdflatex because \MakeUppercase will apply only to the first byte of a possible two, three or four byte combination (for Western languages probably only two). For that to work one has to feed the whole block of bytes to \MakeUppercase.

To be clearer: when we say \MakeUppercase, LaTeX will uppercase the argument; in general the call is \MakeUppercase{word}; here we're saying instead \MakeUppercase#1 (without braces), so only the first token (usually a character) will be uppercased; here's where it will fail with input such as \'ecole: the token passed to \MakeUppercase would be \', which it doesn't know what to do. Using école (and a one byte encoding such as latin1), \MakeUppercase will process é and give the correct result.

With UTF-8 this would fail: what we see as é on our screen when writing a LaTeX document is actually two bytes (C3 and A9, for é) and again \MakeUppercase would be passed only the first one. So a more complex routine is necessary.

In order to have this work with pdflatex and UTF-8, the definition of \CheckInList and \CapitalizeFirst above can be changed into the following

\def\CapitalizeFirst#1{\expandafter\UC@next#1 \Capitalize}
  \ifcsname List@\detokenize{#1}\endcsname

However accent commands are not allowed (they aren't also in the other version).

share|improve this answer
I'll test it in a moment. Care to explain why won't this work for UTF-8 under plain PDFLaTeX? – mpr Nov 15 '11 at 14:30
@mpr I added a short explanation; I'll think if I can provide a solution also for UTF-8 – egreg Nov 15 '11 at 14:36
You, sir, you. :) – mpr Nov 15 '11 at 14:42
This works great (even for UTF-8), except that if I add the word the phrase begins with to the list of ignored words it doesn't get capitalized. The first word should always get capitalized, irrespective of whether it belongs to the exceptions list or not. – mpr Nov 16 '11 at 13:20
@mpr I've changed both versions adding a macro \CapitalizeFirst – egreg Nov 16 '11 at 13:51

A ConTeXt solution:

You can use the command \applytosplitstringwordspaced for this:




  \CapitalizeWithIgnore{This is some of my input or another and to the end.}

which gives

enter image description here

The \applytosplitstringwordspaced command divides the input into words and applies each word to the macro \CapitalizeWithIgnoreWord, which takes one argument. Then I simply test, if the given word is a member of the word list and print it, or print it uppercased.

share|improve this answer
I edited your solution slightly to show how \processowrd is supposed to be used. I also changed \Words to \Word. – Aditya Nov 14 '11 at 16:19

The titlecaps package is newly introduced and demonstrated here: Headings in uppercase. It will take care of titling diacritical marks (e.g., umlauts, etc.) national symbols (e.g., oe) and is compatible with (i.e., can include in its argument) commands that change the font characteristics, such as \textit{}, \scshape, and \footnotesize. Further, it allows for words to be designated as lower-cased, for example prepositions and conjunctions, which are to be screened out and not titled. The presence of punctuation should not affect the ability of the package to either capitalize a word or detect it as a pre-designated lower-cased word.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.