Page LayoutAppendix in an article

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
dill03
Posts: 4
Joined: Mon Feb 15, 2010 8:37 pm

Appendix in an article

Post by dill03 »

Hi,

I'm writing a report for a project using the article document class, and am having issues with the Appendix.

I have been able to add the word "appendix" before the A and make it appear OK in the toc, but am not happy with the numbering of the tables/figures/equations.

In a report, any table/figure/equation inserted in Appendix A is labelled Table A.1, or equivalent for figure/equation. However, in an article, the labelling simply follows from the rest of the document.

How do I by-pass this and force LaTeX to rework the numbering so that it is labelled with the Appendix it is in?

Thanks,
Victor

PS: I'm relatively new to LaTex.



This is the code I would be kind of working with (esp. the appendix end);

\documentclass{article}

\usepackage{amsmath}
\usepackage{amssymb}

\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{Part 1}
\label{a}
This is sec~\ref{a}

\section{Part 2}
\label{b}
This is sec~\ref{b}

\appendix
\section{Additional Data}
\label{c}
This is app~\ref{c}

%Kinetic data table
\begin{table}[htdp]
\begin{center}
\caption{Kinetic Data} \label{table:kineticdata}
\begin{tabular}{ccc}
\hline \hline
$j$ & $E_{j}$ & $k_{0,j}$ \\
& (kcal.kmol$^{-1})$ & (kmol.m$^{-3}$.hr$^{-1}$.kPa$^{-2}$) \\ \hline
1 & $15000$ & $1.59\times10^5$ \\
2 & $20000$ & $8.83\times10^5$ \\
3 & $25000$ & $1.81\times10^8$ \\ \hline \hline
\end{tabular}
\end{center}
\end{table}

\subsection{Selectivity}

\begin{eqnarray}
S_{i} &=& \frac{\xi_{i}}{\sum_{i}\xi_{i}} \\
\therefore \ \xi_{2} &=& \frac{S_{2} \xi_{2}}{S_{1}} \\
\text{and} \ \xi_{3} &=& \frac{\xi_{1}}{S_{1}}-\xi_{1}-\xi_{2}
\end{eqnarray}\\


\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Appendix in an article

Post by localghost »

Please use the code environment of the forum to tag code as such. This keeps a post clear and legible.

You can load the caption package with some options to get the desired numbering with in sections.

Code: Select all

\usepackage[%
  figurewithin=section,
  tablewithin=section
]{caption}

Best regards and welcome to the board
Thorsten
dill03
Posts: 4
Joined: Mon Feb 15, 2010 8:37 pm

Re: Appendix in an article

Post by dill03 »

Thank you Thorsten,

Sorry about not loading the code in the correct place, this is the first time I am using this forum and wasn't quite sure how to do so.

Thank you very much for your reply. This works really well for tables and figures but does not seem to do so for equations. Furthermore, now that I have loaded the package, I have a table embedded in a subsection which does not get referenced anymore (I simply obtain "??").

My questions would be;

1. Can this specific labelling be applied to equations? If so how?

2. Can this specific labelling go further than simply section, such as subsection? i.e. table 2.1.1 or figure 2.1.1 (table & figure situated in section 2, subsection 1)?

Thank you.
Victor
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Appendix in an article

Post by localghost »

dill03 wrote:[...] Sorry about not loading the code in the correct place, this is the first time I am using this forum and wasn't quite sure how to do so. [...]
Read the Important Announcements of the forum team. The code button is very easy to find in the button list right above the input window when composing a post.
dill03 wrote:[...] Thank you very much for your reply. This works really well for tables and figures but does not seem to do so for equations. [...]
Oh. Seems that I missed this point. I give the solution below.
dill03 wrote:[...] Furthermore, now that I have loaded the package, I have a table embedded in a subsection which does not get referenced anymore (I simply obtain "??"). [...]
You have to run (pdf)latex at least twice to get all references right. In case the problem persists, build a minimal working example (MWE) that reproduces the misbehaviour.
dill03 wrote:[...] 1. Can this specific labelling be applied to equations? If so how? [...]
This cannot be done with the suggested package. It needs the amsmath package followed by a command for the desired numbering.

Code: Select all

...
\usepackage{amsmath}
...
\numberwithin{equation}{section}
dill03 wrote:[...] 2. Can this specific labelling go further than simply section, such as subsection? i.e. table 2.1.1 or figure 2.1.1 (table & figure situated in section 2, subsection 1)? [...]
From the code I gave in my last reply you should be able to recognize what you have to do to get the numbering within »subsection«.


For all packages there exist manuals which can be found on CTAN. It is strongly recommendable to read those manuals because they give detailed information about the capabilities and the usage.
dill03
Posts: 4
Joined: Mon Feb 15, 2010 8:37 pm

Re: Appendix in an article

Post by dill03 »

Thank you so much. I managed to get exactly what I wanted.

I got the equations labelled as per section. From the caption package, I found out how to specify the labelling of tables and figures (on page 16 of the english help document found on CTAN).

For this I used

\renewcommand\thetable{\Alph{section}.\arabic{subsection}.\arabic{table}}

For tables labelled A.1.1. (table 1 in appendix A.1.)
And equivalently for figures.

\renewcommand\thefigure{\Alph{section}.\arabic{subsection}.\arabic{figure}}

Placing these two commands at the begining of my appendix ensures that this labelling applies only to the appendix and not to the rest of the document.

Thanks again!
:D
Victor
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Appendix in an article

Post by localghost »

I would have done that in a much easier way.

Code: Select all

\captionsetup{%
  figurewithin=subsection,
  tablewithin=subsection
}
This can be placed in the document wherever it is needed.
Post Reply