GeneralSingle Appendix and Tables with a Single Label

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
spiderchee84
Posts: 9
Joined: Sat Feb 14, 2009 11:47 pm

Single Appendix and Tables with a Single Label

Post by spiderchee84 »

I am currently writing my thesis using the "report" document class. I encounter two probles:

(1) I have only one appendix and I want it to appear in the table of contents as "APPENDIX" (without the alphabetical numbering "A").

(2) In my appendix, I have a few tables under the same subject, which I want them to be labelled as Table A.1-1, Table A.1-2 and so on. But I want it to appear only once in the list of tables as "Table A.1".

Any suggestions or recommendation of packages?

Recommended reading 2024:

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

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

spiderchee84
Posts: 9
Joined: Sat Feb 14, 2009 11:47 pm

Re: Single Appendix and Tables with a Single Label

Post by spiderchee84 »

I figured out the solution for the 1st question. It's rather simple actually. Just add \setcounter{secnumdepth}{-1} before we start the appendix, i.e.,

\setcounter{secnumdepth}{-1}
\chapter{Appendix}

Then everything will be fine.

This is the best I could get so far, but I believe there must be some better way. Comments are welcomed.

Now the 2nd question is still unsolved. Any suggestion please?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Single Appendix and Tables with a Single Label

Post by Stefan Kottwitz »

spiderchee84 wrote:Now the 2nd question is still unsolved. Any suggestion please?
I recommend to use the caption package, its features should be sufficient.

Stefan
LaTeX.org admin
spiderchee84
Posts: 9
Joined: Sat Feb 14, 2009 11:47 pm

Single Appendix and Tables with a Single Label

Post by spiderchee84 »

I tried to use the \ContinuedFloat command. I added the following two lines:

\DeclareCaptionLabelFormat{cont}{#1˜#2-\arabic{ContinuedFloat}}
\captionsetup[ContinuedFloat]{labelformat=cont}

But I got a few errors after compilation.

The following codes are the closest to what I want, except for the List of Tables.

Code: Select all

\documentclass{report}

\begin{document}

\tableofcontents
\listoftables

\chapter{Introduction}

\setcounter{secnumdepth}{-1}
\chapter{Appendix}

\begin{table}[h]
\renewcommand\thetable{A.1-\arabic{table}}
\caption{My Table}
\centering
\begin{tabular}{|c|c|}\hline
1&2\\\hline
3&4\\\hline
\end{tabular}
\end{table}

\begin{table}[h]
\renewcommand\thetable{A.1-\arabic{table}}
\caption{My Table}
\centering
\begin{tabular}{|c|c|}\hline
5&6\\\hline
7&8\\\hline
\end{tabular}
\end{table}

\end{document}
I wish to have Table A.1 appeared only once in the List of Tables.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Single Appendix and Tables with a Single Label

Post by gmedina »

Hi,

try something like the following:

Code: Select all

\documentclass{report}
\usepackage{caption}

% to have more space in the LOF for the number of the table
\makeatletter
  \renewcommand\l@table{\@dottedtocline{1}{1.5em}{3em}}
\makeatother

\begin{document}

\tableofcontents
\listoftables

\chapter{Introduction}

\setcounter{secnumdepth}{-1}
\chapter{Appendix}

\renewcommand\thetable{A.1-\arabic{table}}

\begin{table}[!ht]
  \caption{My Table}
  \centering
  \begin{tabular}{|c|c|}\hline
    1&2\\\hline
    3&4\\\hline
  \end{tabular}
\end{table}

\begin{table}[!ht]
  \captionsetup{list=no}
  \caption{My Table}
  \centering
  \begin{tabular}{|c|c|}\hline
    5&6\\\hline
    7&8\\\hline
  \end{tabular}
\end{table}

\end{document}
Remarks: 1) Make sure that you are using a recent version of the caption package.
2) I changed [h] to [!ht] in the table environments, since the former is almost useless.
3) The redefinition of the \thetable command can be done just once (as in my code).
4) I included the code needed to avoid the table number overlapping the caption in the LOF.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
spiderchee84
Posts: 9
Joined: Sat Feb 14, 2009 11:47 pm

Re: Single Appendix and Tables with a Single Label

Post by spiderchee84 »

Thank you for your remarks, I've updated my caption package. This explains a lot why I always encountered errors when I tried the commands in the documentation.

Is it possible to have "Table A.1" instead of "Table A.1-1" in the List of Tables?
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Single Appendix and Tables with a Single Label

Post by gmedina »

Of course, using the \DeclareCaptionListFormat command (provided by tha caption package) you can achieve this:

Code: Select all

\documentclass{report}
\usepackage{caption}

\DeclareCaptionListFormat{mytab}{A.1}

\begin{document}

\tableofcontents
\listoftables

\chapter{Introduction}

\setcounter{secnumdepth}{-1}
\chapter{Appendix}

\renewcommand\thetable{A.1-\arabic{table}}

\begin{table}[!ht]
  \captionsetup{listformat=mytab}
  \caption{My Table}
  \centering
  \begin{tabular}{|c|c|}\hline
    1&2\\\hline
    3&4\\\hline
  \end{tabular}
\end{table}

\begin{table}[!ht]
  \captionsetup{list=no}
  \caption{My Table}
  \centering
  \begin{tabular}{|c|c|}\hline
    5&6\\\hline
    7&8\\\hline
  \end{tabular}
\end{table}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
spiderchee84
Posts: 9
Joined: Sat Feb 14, 2009 11:47 pm

Re: Single Appendix and Tables with a Single Label

Post by spiderchee84 »

Thank you, gmedina. Your help is very much appreciated.

A note for other users: the \DeclareCaptionListFormat command must be put before \begin{document}, else you'll get an error.
Post Reply