Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 habe to pose another question for that? ;)

share|improve this question
    
The appendix package works with the article class too. (It checks to see whether the document has chapters or not and does the right stuff accordingly.) Can you show the code you used with article class that didn't work for you? –  Alan Munn Aug 2 '11 at 22:51
    
Thanks for your comment. I have added an update to my question with the erroneous code. –  deboerk Aug 2 '11 at 23:36
1  
Apparently package titlesec is conflicting with package appendix. If I add \usepackage{titlesec} the appendices in the toc are displayed wrong. –  deboerk Aug 2 '11 at 23:51
    
Yes, titlesec and appendix conflict. However, the modification for \paragraph is easy to achieve without titlesec. See my updated answer. –  Gonzalo Medina Aug 3 '11 at 0:03

1 Answer 1

up vote 12 down vote accepted

Here's a solution using the appendix package (adding the title package option) and a redefinition of \thetable and \thefigure:

\documentclass{article}
\usepackage[titletoc,toc,title]{appendix}

\begin{document}
\tableofcontents

\section{Dolor sit amet}
Have a look at \ref{app:foobar}

\begin{appendices}
  \renewcommand\thetable{\thesection\arabic{table}}
  \renewcommand\thefigure{\thesection\arabic{figure}}
  \section{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}
  \section{Mauris euismod}
\end{appendices}
\end{document}

enter image description here

To change the \paragraph formatting. add these lines to the preamble:

\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                    {3.25ex \@plus1ex \@minus.2ex}%
                                    {-1em}%
                                    {\normalfont\normalsize\itshape}}
\makeatother
share|improve this answer
    
thanks a lot! this is the perfect solution for my requirements! –  deboerk Aug 2 '11 at 23:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.