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?

1

1 Answer 1

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}
...
5
  • For a \section* in the article class, shouldn't one use \markboth (to ensure correct headings with the twoside option)?
    – lockstep
    Commented Jan 13, 2014 at 10:00
  • 1
    @lockstep The example doesn't say twoside, but in that case \markboth{#1}{} should be used.
    – egreg
    Commented Jan 13, 2014 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
    Commented Jan 13, 2014 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
    Commented Jan 14, 2014 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
    Commented Jan 14, 2014 at 11:30

You must log in to answer this question.

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