2

How to write the chapter titles in Upper Case in the table of contents ?

3
  • Some more information is needed. What document class are you using?
    – egreg
    Apr 21, 2013 at 22:50
  • book document class
    – Muhammad
    Apr 21, 2013 at 22:50
  • Using uppercase only seems a bad decision. Do you mean a combination of uppercase and small caps? (Small caps substituted for lowercase.)
    – user10274
    Apr 22, 2013 at 7:17

1 Answer 1

6

The only change is \MakeUppercase.

\documentclass{book}

\begin{document}

\makeatletter
\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
                    \thispagestyle{plain}%
                    \global\@topnum\z@
                    \@afterindentfalse
                    \secdef\@chapter\@schapter}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                       \if@mainmatter
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}\MakeUppercase{#1}}%
                       \else
                         \addcontentsline{toc}{chapter}{\MakeUppercase{#1}}%
                       \fi
                    \else
                      \addcontentsline{toc}{chapter}{\MakeUppercase{#1}}%
                    \fi
                    \chaptermark{#1}%
                    \addtocontents{lof}{\protect\addvspace{10\p@}}%
                    \addtocontents{lot}{\protect\addvspace{10\p@}}%
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}

\makeatother

\tableofcontents

\chapter{First}

Blah, blah.

\chapter{Second}

Blah, blah.

\end{document}

enter image description here

6
  • 2
    Redefining \chapter doesn't seem necessary.
    – egreg
    Apr 21, 2013 at 23:08
  • 1
    @egreg You are right. Redefining the whole definition is for educational purposes. Apr 21, 2013 at 23:12
  • Thanks :) ... It works with \uppercase instead of \MakeUppercase
    – Muhammad
    Apr 21, 2013 at 23:17
  • @Muhammad Strange: \uppercase? Are you using LaTeX2.09? Apr 21, 2013 at 23:22
  • 1
    Your current solution only works for chapters in \mainmatter, but not for those in \frontmatter or \backmatter. You need to add \MakeUppercase also in the \else branch. Apr 21, 2013 at 23:45

Your Answer

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

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