2

I am using report and I need to have chapter headings be in all caps (including the Appendix) but not in the TOC. E.g. instead of "Appendix A", it should appear as "APPENDIX A" inside the paper and "Appendix A" in the TOC. I seem to have fixed the regular chapters but cannot seem to figure out how to fix the Appendix.

I can just change \appendixname to APPENDIX, but then it will appear as all caps in the TOC (which I would prefer not be the case). Changing the definition of \appendix for report class seems to have the same effect (I believe because it's basically just redefining \@chapapp):

\renewcommand{\appendix}{\par
   \setcounter{chapter}{0}%
   \setcounter{section}{0}%
   \gdef\@chapapp{APPENDIX}% modified from \appendixname
   \gdef\thechapter{\@Alph\c@chapter}}

I was able to fix the regular chapter issue by keeping \chaptername as is and hard coding CHAPTER rather than using \@chapapp in the following (which was part of the original template--I did not create this so I don't fully understand what all this is doing):

\def\@chapter[#1]#2{
    \ifnum \c@secnumdepth >\m@ne
        \refstepcounter{chapter}%
        \typeout{CHAPTER\space\thechapter.} % originally used \@chapapp
        \addcontentsline{toc}{chapter}%
        {\@chapapp\space {\thechapter}: {#1}}
    \else
         \addcontentsline{toc}{chapter}{#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
}

Honestly, I don't understand why \uppercase doesn't work in the following but it doesn't capitalize "Chapter" from \@chapapp (this was from the original template as well) and still appears in the style file after the above (the chapter titles have always appeared in CAPS, just not the "Chapter x:" prefix).

\def\@makechapterhead#1{%
    \vspace*{-20\p@}%
    {\parindent \z@ \raggedright \normalfont
    \interlinepenalty\@M
    \ifnum \c@secnumdepth >\m@ne
        \centering  \large\bfseries 
        \uppercase{\@chapapp\space \thechapter: #1}
    \fi
    \vskip 20\p@
    }
}
4
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – user31729
    Jul 29, 2015 at 17:29
  • 1
    Basic rule: Never change the .cls file ;-)
    – user31729
    Jul 29, 2015 at 17:31
  • 1
    The reason, why \uppercase{\@chapapp} does not work is that the \@chapapp must be expanded first, before it can be fed to \uppercase, i.e. \uppercase\expandafter{\@chapapp} would work too
    – user31729
    Jul 29, 2015 at 17:47
  • One further suggestion: Perhaps a smallcaps approach of APPENDIX would be better than to use uppercase letters with the same fontsize completely, but this is a personal opinion.
    – user31729
    Jul 29, 2015 at 17:53

1 Answer 1

3

A solution without hardcoding or editing the .cls file directly:

The O.P. was right in his assumption about \@makechapterhead:

\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
        \huge\bfseries \@chapapp\space \thechapter
        \par\nobreak
        \vskip 20\p@
    \fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@
  }}

The line with \@chapapp does indeed print Chapter (or Appendix), followed by the chapter number.

To get this uppercase, it's necessary to use \MakeUppercase{\@chapapp}, not \uppercase.

Instead of editing the report.cls code, it's better to use \xpatchcmd, looking for the line \huge\bfseries\@chapapp.. and replacing this with the relevant code using \MakeUppercase.

However, this should be done only after \appendix, so append this patch to \appendix using \xapptocmd{\appendix}{...} (see the code please)

\documentclass{report}


\usepackage{xpatch}


\makeatletter

\xapptocmd{\appendix}{%
\xpatchcmd{\@makechapterhead}{%
  \huge\bfseries \@chapapp\space \thechapter
}{%
  \huge\bfseries \MakeUppercase{\@chapapp}\space \thechapter
}{\typeout{Patching \@makechapterhead succeeded}}{\typeout{Patching failed}}% Patching ends
}{\typeout{Appending succeeded}}{\typeout{Appending failed}}
\makeatother

\begin{document}

\chapter{First}

\appendix

\chapter{Appendix 1}

\end{document}

enter image description here

Please note that my code does not work for \chapter* like - appendices.

4
  • I figured the answer should be simple...still I feel dumb now that it was that simple.
    – Jared
    Jul 29, 2015 at 17:41
  • @Jared: Well, it's simple using \MakeUppercase, but it isn't simple if one don't want to copy code from a class to the document.
    – user31729
    Jul 29, 2015 at 17:43
  • I don't doubt that this style file is poorly written (it's old for one thing) and hardly commented at all (which means it's difficult for someone not familiar with style files, like me, to make adjustments). This was for a thesis document so the whole point of using latex was to not have to worry about formatting but then there ended up being all sorts of minor things wrong with the style file (the university provides a word template and an "unofficial" latex template).
    – Jared
    Jul 29, 2015 at 17:47
  • 1
    @Jared: Believe me, using the standard document classes such as report or book, or memoir is the better way than to use strange templates and hacks. There are so many good and well tested packages that can adapt the look of a document
    – user31729
    Jul 29, 2015 at 17:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .