How to make 'appendix' appear in toc in Latex?
Solution 1
This is probably most easily achieved by using the appendix package, or the memoir class.
If you don't want to use a prepackaged solution, you'll have to
hack the sectioning commands. When I needed to do this for my
dissertation, I cloned the report
class, and edited until I made
the margins lady happy. What you're looking for is the
definition of the \addcontentsline
macro.
Solution 2
There's a couple of ways to solve this problem; unfortunately, I've only got a hack for you at this stage. One problem is that if we redefine the section number "A" to include the word "Appendix", it messes up the formatting of the table of contents. So instead, I've just defined a new sectioning command that prints the section without a number and inserts "Appendix X" manually.
Kind of ugly, but at least it works without having to change any markup :)
\documentclass{article} \makeatletter \newcommand\appendix@section[1]{% \refstepcounter{section}% \orig@section*{Appendix \@Alph\c@section: #1}% \addcontentsline{toc}{section}{Appendix \@Alph\c@section: #1}% } \let\orig@section\section \g@addto@macro\appendix{\let\section\appendix@section} \makeatother \begin{document} \tableofcontents \section{goo} \label{a} This is sec~\ref{a} \section{har} \label{b} This is sec~\ref{b} \appendix \section{ji} \label{c} This is app~\ref{c} \subsection{me} does this look right? \end{document}
Solution 3
For my thesis, I did the following:
\appendix
\addcontentsline{toc}{section}{Appendix~\ref{app:scripts}: Training Scripts}
\section*{Sample Training Scripts}
\label{app:scripts}
Blah blah appendix content blah blah blah.
Explanation: I manually added a line to the TOC so I would have "Appendix X:..." show up in my TOC. Then I excluded the actual section command from the TOC by using an asterisk.
Solution 4
The appendix package is really good and simple solution. My answer can be helpful for who wants to change chapters numbering style, for example, with using cyrillic alphabet or roman digits. The appendices numbering style is hardcoded in the \@resets@pp command (I looked in sources here http://hal.in2p3.fr/docs/00/31/90/21/TEX/appendix.sty). I solved it by simple redefining this command to my own. Just add this code into your preamble:
\makeatletter
\renewcommand{\@resets@pp}{\par
\@ppsavesec
\stepcounter{@pps}
\setcounter{section}{0}
\if@chapter@pp
\setcounter{chapter}{0}
\renewcommand\@chapapp{\appendixname}
\gdef\thechapter{\Asbuk{chapter}} % changed
\else
\setcounter{subsection}{0}
\gdef\thechapter{\Asbuk{section}} % changed
\fi
\if@pphyper
\if@chapter@pp
\renewcommand{\theHchapter}{\theH@pps.\Asbuk{chapter}} % changed
\else
\renewcommand{\theHsection}{\theH@pps.\Asbuk{section}} % changed
\fi
\def\Hy@chapapp{\appendixname}%
\fi
\restoreapp
}
\makeatother
As a result,
Appendix A
Appendix B
Appendix C
...
will change to
Appendix A
Appendix Б
Appendix В
... etc
I'm not a latex expert, and I can't guarantee this code won't break something else.
chriss
Updated on July 09, 2022Comments
-
chriss almost 2 years
How to make word 'appendix' appear in the table of contents? Right now toc looks like this:
1 ...... 2 ...... . . A ..... B .....
I would like it to be:
1 ...... 2 ...... . . Appendix A ..... Appendix B .....
My latex source file structure is like this:
\begin{document} \tableofcontents \include{...} \include{...} \appendix \include{...} \include{...} \end{document}
-
mlt over 11 yearsWith appendix package, is there a way either not to use
[page]
option for appendices environment, or don't waste an entire page for just "Appendices" title? The problem is that when I skip[page]
(or\appendixpage
), I have TOC messed up, i.e. "Appendices" comes after "Appendix A". I guess this is relevant: stackoverflow.com/questions/2661774/… -
dmckee --- ex-moderator kitten over 11 years@mlt It's been so long that I can't recall.
-
Adobe about 11 yearsHow do I use that hack with
\asbuk
usingfontspec
? I need russian appendix numberings. -
Stanislav Mamontov about 11 yearsAdobe, I can't paste code here. I've posted my solution in the separate answer. Hope this will help you.
-
Ufos over 8 yearsWill, this works like magic! However, I get a strange side effect: the references (if you add them) are transformed into a new section Appndix B*. Any idea how to get rid of it?
-
Miguel over 7 yearsJust replace all
section
withchapter
if your appendix is by chapters