I have been trying to get the appendix for my thesis done.
I've read a lot about it and as always you can chose between a fiddly way and a magic package that doas the job to solve a problem (I usually prefer a magic package). Unfortunately both approaches didn't work out, so here is how far I got.
Four requirements
This is what my appendix should look like for a document with class 'article',
there are four requirements:
Sections should look like this:
Appendix A Title1
Appendix B Title2
They should appear in the same way in the TOC:
Appendix A Title1 56
Appendix B Title2 88
\ref{app:foo}
should be able to return the letter of the corresponding appendix.
Tables and Figures should be labeled as Table A1. or Figure A1.
Fiddly approach
\documentclass{article}
\renewcommand\appendix{\par
\setcounter{section}{0}
\setcounter{subsection}{0}
\setcounter{figure}{0}
\setcounter{table}{0}
\renewcommand\thesection{Appendix \Alph{section}}
\renewcommand\thefigure{\Alph{section}\arabic{figure}}
\renewcommand\thetable{\Alph{section}\arabic{table}}
}
\begin{document}
\tableofcontents
\section{Dolor sit amet}
Have a look at \ref{app:foobar}
\appendix
\section{foo} \label{app:foobar}
\begin{table}[h]
\caption{foo}
\begin{tabular}{cc}
\textbf{ a } & \textbf{ b }\\
1 & 3 \\
2 & 4\\
\end{tabular}
\end{table}
\end{document}
It worked out pretty good. The problem is that in the TOC the appendix title "foo" gets written onto "Appendix A". Is there a way to adjust the position of the title in the TOC?
Magic package 'appendix'
The solution I found here unfortunately applies only to the documentclass 'report' where chapters are used. But my document has the class 'article' and no chapters whatsoever. I also don't like it that the appendix titles are not in the same lines as "Appendix A" and in table labels there is a dot between the section and table number "Table A.1.".
\documentclass{report}
\usepackage[titletoc,toc]{appendix}
\begin{document}
\tableofcontents
\section{Dolor sit amet}
Have a look at \ref{app:foobar}
\begin{appendices}
\chapter{Consectetur adipiscing elit} \label{app:foobar}
\begin{table}[h]
\caption{foo}
\begin{tabular}{cc}
\textbf{ a } & \textbf{ b }\\
1 & 3 \\
2 & 4\\
\end{tabular}
\end{table}
\chapter{Mauris euismod}
\end{appendices}
\end{document}
Is there a proper way using the appendix package? I played around with the toc, title and titletoc arguments for the package. But it didn't do what it said in the manual.
It would great if someone could help me, no matter on which approach!
Update
Thank you very much for your help! The first comment from Alan Munn reassuring me that the appendix package should work as expected helped me to find the error. This is the erroneous code:
\documentclass[a4paper,12pt]{article}
%appendix
\usepackage[title,titletoc,toc]{appendix}
%format paragraphs
\usepackage{titlesec}
\titleformat{\paragraph}[runin]{\normalfont\normalsize\itshape}{\theparagraph}{}{}[.] %format paragraph italic and ser a period after it
\titlespacing{\paragraph}{0pt}{0pt}{*1} %remove spacing and add one characterspace after paragraph
\begin{document}
\tableofcontents
\section{Method}
(The entire results are detailed in Appendix \ref{app:bar}).
\begin{appendices}
\section{foo} \label{app:foo}
asd
\section{bar} \label{app:bar}
\end{appendices}
\end{document}
The three lines which format paragraphs cause the appendices to fail in the toc. If taken out, everything works fine. But what about my paragraphs then? Do I have to pose another question for that? 😉
Best Answer
Here's a solution using the
appendix
package (adding thetitle
package option) and a redefinition of\thetable
and\thefigure
:To change the
\paragraph
formatting. add these lines to the preamble: