3

I'm using this and this approaches to get my appendix sections as I want, so a MWE of my code would look like:

\documentclass{article}
\pagestyle{headings}
\begin{document}
\tableofcontents
\clearpage
\section{abc}
def
\section{ghi}
jkl

\appendix
\clearpage
\section*{Ap: ETC}
\addcontentsline{toc}{section}{{Ap: ETC}}
\renewcommand{\thesubsection}{A.\arabic{subsection}}
App. content.

\subsection{First A.}
F. A. content.
\subsection{Second A.}
S. A. content.

\end{document}

The problem is that this makes the appendices pages heading to be the previous non-appendix section's one. One option may be to use \pagestyle{myheadings} and \markboth but, is there any more automatic solution?

4

If you have only one section in the appendix, it's better to define a command that does everything needed.

\documentclass{article}
\pagestyle{headings}

\newcommand{\appsection}[1]{%
  \clearpage
  \appendix
  \section*{#1}%
  \markboth{#1}{#1}%
  \addcontentsline{toc}{section}{#1}%
  \renewcommand{\thesubsection}{A.\arabic{subsection}}%
}

\begin{document}

\tableofcontents

\clearpage

\section{abc}
def

\section{ghi}
jkl

\appsection{Ap: ETC}

App. content.

\subsection{First A.}
F. A. content.
\subsection{Second A.}
S. A. content.

\end{document}

contents

appendix page

This might be easily changed if there's more than one section in the appendix. Say

\newcommand{\startappendix}{%
  \clearpage\appendix
  \setcounter{section}{0}%
  \renewcommand{\thesection}{\Alph{section}}%
}

\newcommand{\appsection}[1]{%
  \refstepcounter{section}%
  \section*{#1}%
  \markboth{#1}{#1}%
  \addcontentsline{toc}{section}{#1}%
}

so that you can say

\startappendix

\appsection{First}
...

\appsection{Second}
...
  • For a \section* in the article class, shouldn't one use \markboth (to ensure correct headings with the twoside option)? – lockstep Jan 13 '14 at 10:00
  • 1
    @lockstep The example doesn't say twoside, but in that case \markboth{#1}{} should be used. – egreg Jan 13 '14 at 10:01
  • I'd have thought that \markboth{#1}{#1} would yield correct results for both oneside and twoside. Did I overlook something? – lockstep Jan 13 '14 at 10:04
  • After checking this question I would suggest, to fake the heading properly, to change #1 with \MakeUppercase{#1}. Or even with 2 arguments: #1 for "Ap: " and \MakeUppercase{#2} for "Etc", if it is "Etc" and not "ETC". – Andrestand Jan 14 '14 at 11:16
  • @Andrestand This is assuming you like all uppercase headers. ;-) I don't. But, if you need they are that way, of course add \MakeUppercase. – egreg Jan 14 '14 at 11:30

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.