How can I write in capitals the first letter of each word in a title?

In other words, I want to write the title normally

\chapter{Title of my chapter}

and to have the heading in this way

Title Of My Chapter

I have read this discussion but I cannot modify that solution for my case.


There is a wonderful package called inicap by the late Michael J Downes of AMS. It was part of the amsrefs package but is unfortunately not distributed any more. You can download inicap.dtx from the AMS FTP server for obsolete software or you can do a Google search with latex inicap.sty to obtain it.

inicap does not capitalize all the words. Words like "a", "an", "the", "and", etc. are not capitalized; this is in fact the right way to do it. From the Chicago Manual of Style for capitalizing titles of written works in English:

Capitalize each word, including pronouns and subordinate conjunctions, except for articles, coordinate conjunctions, and prepositions, or the word to in infinitives. Always capitalize the first and last word of the title and the first and last word of any subtitles that it may contain. Don’t capitalize the second or later word in a hyphenated compound unless it is a noun or proper adjective, or it has equal force with the first word.

Note that inicap do not change inline math or inserted macros

\inicap{title of my chapter}

will be typeset as

Title of My Chapter

EDIT: To change all chapters you can redefine the chapter command:

  • I want to "capitalize" the letters in the headings only.
    – user11960
    Feb 22 '12 at 6:55
  • @Jack TeX: I have edited my answer
    – Danie Els
    Feb 22 '12 at 8:15

I don't know if you are using LuaLaTeX, but here is an approach to do it with LuaLaTeX:

It is good practice to write the lua functions in a separate file with the extension .lua. For this MWE I use the filecontents environment instead to provide an extra file for the lua script.


function capitalize(input)
    --separate given string in words (separated by space)
    local split = string.explode(input, " ")

    for i,p in ipairs(split) do
        --make the first letter upper-case
        output, count = string.gsub(p, '^%l', string.upper)
        --print the word to TeX

% read the external lua file to declare the defined function,
% but without execute the Lua function

% latex command to execute the lua function

\caps{Title of my chapter}\\
\caps{read the external lua file to declare the defined function}
  • thank you so much for the lua code, but I have to use pdflatex.
    – user11960
    Feb 22 '12 at 6:47
  • I want to "capitalize" the letter in the headings only.
    – user11960
    Feb 22 '12 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy