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 am writing my PhD dissertation. I have many appendices (like 6?), mostly tables.

As it happens automatically for tables and figures, I'd like to get a label plus progressive number before I define the title of the appendix on the top of the appendix page. Something like

Appendix 1: Bla bla bla.

Also, I'd like my appendix titles to be included in the ToC.

This is what I have:

\documentclass[11pt,a4paper,oneside]{report}
\usepackage[toc,page]{appendix}

\begin{document}

\tableofcontents
\addcontentsline{file}{sec_unit}{entry}

\begin{appendices}

\appendix{Cities Coordinates\label{appendix:Cities Coordinates}}
\begin{longtable}{ l l r r}
\toprule
\textsc{County}&\textsc{City}&\textsc{Latitude}&\textsc{Longitude}\\ \midrule
\endfirsthead
\caption[]{(continued)}\\
\toprule
\textsc{County}&\textsc{City}&\textsc{Latitude}&\textsc{Longitude}\\ \midrule
\endhead
\bottomrule
\endlastfoot
Alameda&Alameda&-122.24&37.76\\
&Albany&-122.29&37.88\\
&Berkeley&-122.27&37.87\\
&Dublin&-121.93&37.70\\
&Hayward&-122.08&37.66\\
&Emeryville&-122.28&37.83\\
&Oakland&-122.27&37.80\\
&Piedmont&-122.23&37.82\\
&San Leandro&-122.15&37.72\\
&Union City&-122.04&37.59\\
\end{longtable}
\end{document}

I still have some problems with the appendices:

  1. In the ToC I see only three appendixes represented, but I am providing four instead;
  2. I don't know where to type the title of my appendices so that it comes out uniformly, no matter if the appendix is a table or a list of examples;
  3. I would like the title of my appendix in the landscaped page to be at the top of the page.

Thank you in advance. And yes, I use longtables because I have a long list of data to display.

\documentclass[11pt,a4paper,oneside]{report}
\usepackage{array}
\usepackage{covington}
\usepackage[danish,english]{babel}
\usepackage{titlesec}
\usepackage[a4paper]{geometry}
\geometry{includefoot=false, heightrounded=true, top=4.5cm, bottom=6cm, left=4.7cm, right=4.7cm} 
\usepackage[toc,page]{appendix}
\usepackage{longtable}
\usepackage{caption}
\newif\ifappendix % snippet appendix
\makeatletter
\def\LT@c@ption#1[#2]#3{%
  \LT@makecaption#1\fnum@table{#3}%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else
     {\let\\\space
     \addcontentsline{\ifappendix toc\else lot\fi}{table}{\protect\numberline{\thetable}{#2}}}%
  \fi}
\makeatother
\usepackage{multirow}
\usepackage{morefloats}
\usepackage{booktabs}
\newcolumntype{R}{>{\raggedleft\arraybackslash}p{2cm}}
\setlength\belowcaptionskip{1\baselineskip} 
\usepackage{lscape} 

\begin{document}

\pagenumbering{arabic}  
\tableofcontents
 \addcontentsline{file}{sec_unit}{entry}

\chapter{How Do I Make a Nice Appendix?}

\section{Please Advise}

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 

\begin{appendices}
\appendixtrue

\setcounter{table}{0}
\renewcommand*{\thetable}{A.\arabic{table}}

\begin{longtable}{ l l r r}
\caption{text text\label{appendix:this is just the table caption. I would like this to be something like: Appendix A.1: bla bla bla}}\\
\toprule
\textsc{text}&\textsc{text}&\textsc{text}&\textsc{text}\\ \midrule
\endfirsthead
\caption[]{(continued)}\\
\toprule
\textsc{text}&\textsc{text}&\textsc{text}&\textsc{text}\\ \midrule
\endhead
\bottomrule
\endlastfoot
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
\end{longtable}

\newpage
\appendixtrue
\setcounter{table}{1}
\renewcommand*{\thechapter}{\arabic{chapter}}
\begin{landscape}
\begin{longtable}{l l l l}
\caption{this is a table caption that I would like to print at the top of my page\label{appendix:this is a table caption that I would like to print at the top of my page}}\\
\toprule
\textsc{text}&\textsc{text}&\textsc{text}&\textsc{website}\\ 
\midrule
\endfirsthead
\caption[]{(continued)}\\
\toprule
\textsc{text}&\textsc{text}&\textsc{text}&\textsc{website}\\ 
\midrule
\endhead
\bottomrule
\endlastfoot
text&text&text&www.nytimes.com\\
text&text&text&www.nytimes.com\\
text&text&text&www.nytimes.com\\
\end{longtable}
\end{landscape}

\newpage
\appendixtrue
\setcounter{table}{2}
\renewcommand*{\thetable}{A.\arabic{table}}
\begin{landscape}
\begin{longtable}{l l l r r r r r}
\caption{text\label{appendix:text3}}\\
\toprule
\textsc{text}&\textsc{text}&\textsc{text}&\textsc{text}&number&number&number&number\\
\midrule
\endfirsthead
\caption[]{(continued)}\\
\toprule
\textsc{text}&\textsc{text}&\textsc{text}&\textsc{text}&number&number&number&number\\
\midrule
\endhead
\bottomrule
\endfoot
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\

\end{longtable}
\end{landscape}

\newpage
\appendixtrue
\setcounter{table}{3}
\renewcommand*{\thetable}{A.\arabic{table}}
\appendix{I would like this to be Appendix A.4: bla bla bla\label{appendix:I would like this to be Appendix A.4: bla bla bla}}
\begin{examples}
\item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \label{ex:Lorem}
\item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\label{ex:ipsum}
\end{examples}

\end{appendices}

\end{document}
share|improve this question

2 Answers 2

up vote 2 down vote accepted
+100

I took the new example provided by the OP and added/changed the following:

  • I enclosed the examples environment in a minipage and put the minipage into a (single-column) longtable (requirement 1);

  • \renewcommand*{\tablename}{Appendix} at the start of the appendix provides the desired caption format (requirement 2);

  • I removed the recurring instances of \appendixtrue\setcounter{table}{<value>} etc. because there's no need for them.

I don't have a clue with regard to requirement 3 (rotated longtables with non-rotated captions).

\documentclass[11pt,a4paper,oneside]{report}
\usepackage{array}
\usepackage{covington}
\usepackage[danish,english]{babel}
\usepackage{titlesec}
\usepackage[a4paper]{geometry}
\geometry{includefoot=false, heightrounded=true, top=4.5cm, bottom=6cm, left=4.7cm, right=4.7cm} 
\usepackage[toc,page]{appendix}
\usepackage{longtable}
\usepackage{caption}
\newif\ifappendix % snippet appendix
\makeatletter
\def\LT@c@ption#1[#2]#3{%
  \LT@makecaption#1\fnum@table{#3}%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else
     {\let\\\space
     \addcontentsline{\ifappendix toc\else lot\fi}{table}{\protect\numberline{\thetable}{#2}}}%
  \fi}
\makeatother
\usepackage{multirow}
\usepackage{morefloats}
\usepackage{booktabs}
\newcolumntype{R}{>{\raggedleft\arraybackslash}p{2cm}}
\setlength\belowcaptionskip{1\baselineskip} 
\usepackage{lscape} 

\begin{document}

\pagenumbering{arabic}  
\tableofcontents
 \addcontentsline{file}{sec_unit}{entry}

\chapter{How Do I Make a Nice Appendix?}

\section{Please Advise}

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 

\begin{appendices}
\appendixtrue

\setcounter{table}{0}
\renewcommand*{\thetable}{A.\arabic{table}}

\renewcommand*{\tablename}{Appendix}

\begin{longtable}{ l l r r}
\caption{this is just the table caption. I would like this to be something like: Appendix A.1: bla bla bla\label{appendix:text1}}\\
\toprule
\textsc{text}&\textsc{text}&\textsc{text}&\textsc{text}\\ \midrule
\endfirsthead
\caption[]{(continued)}\\
\toprule
\textsc{text}&\textsc{text}&\textsc{text}&\textsc{text}\\ \midrule
\endhead
\bottomrule
\endlastfoot
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
text&text&123&123\\
&text&123&123\\
&text&123&123\\
\end{longtable}

\newpage

\begin{landscape}
\begin{longtable}{l l l l}
\caption{this is a table caption that I would like to print at the top of my page\label{appendix:text2}}\\
\toprule
\textsc{text}&\textsc{text}&\textsc{text}&\textsc{website}\\ 
\midrule
\endfirsthead
\caption[]{(continued)}\\
\toprule
\textsc{text}&\textsc{text}&\textsc{text}&\textsc{website}\\ 
\midrule
\endhead
\bottomrule
\endlastfoot
text&text&text&www.nytimes.com\\
text&text&text&www.nytimes.com\\
text&text&text&www.nytimes.com\\
\end{longtable}
\end{landscape}

\newpage

\begin{landscape}
\begin{longtable}{l l l r r r r r}
\caption{text\label{appendix:text3}}\\
\toprule
\textsc{text}&\textsc{text}&\textsc{text}&\textsc{text}&number&number&number&number\\
\midrule
\endfirsthead
\caption[]{(continued)}\\
\toprule
\textsc{text}&\textsc{text}&\textsc{text}&\textsc{text}&number&number&number&number\\
\midrule
\endhead
\bottomrule
\endfoot
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\
text&text&text&text&number&number&number&number\\

\end{longtable}
\end{landscape}

\newpage

\begin{longtable}{l}
\caption{I would like this to be Appendix A.4: bla bla bla\label{appendix:text4}}\\
\begin{minipage}{\linewidth}
\begin{examples}
\item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \label{ex:Lorem}
\item Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\label{ex:ipsum}
\end{examples}
\end{minipage}
\end{longtable}

\end{appendices}

\end{document}
share|improve this answer

Here's a solution that assumes chapters in the main text, but no chapters in the appendix -- only an "Appendices" starting page and some tables. As those tables should go into the normal ToC (!), I patched the \LT@c@ption command to include a test for the new \ifappendix boolean switch. Note that tables by default are formatted as sections in the ToC/LoT.

EDIT: After some discussion in chat, here's a hack that works (only) for longtables, but also if the caption and hyperref packages are loaded. ("Hack" because I basically revert captions changes to longtables LoT entries.)

\documentclass{report}

\usepackage[toc,page]{appendix}

\usepackage{longtable}

\usepackage{caption}

\newif\ifappendix

\makeatletter

\def\LT@c@ption#1[#2]#3{%
  \LT@makecaption#1\fnum@table{#3}%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else
     {\let\\\space
     \addcontentsline{\ifappendix toc\else lot\fi}{table}{\protect\numberline{\thetable}{#2}}}%
  \fi}

\makeatother

\usepackage{hyperref}

\begin{document}

\tableofcontents

\listoftables

\chapter{First}

\section{First-first}

Some text. See also table~\ref{tab:testl}.

\begin{longtable}{c}
(Some tabular material)\\
\caption{A longtable}\\
\end{longtable}

\begin{appendices}

\appendixtrue

\setcounter{table}{0}
\renewcommand*{\thetable}{A.\arabic{table}}

\begin{longtable}{c}
(Some tabular material)\\
\caption{An appendix longtable}\label{tab:testl}\\
\end{longtable}

\end{appendices}

\end{document}
share|improve this answer
1  
@Costi I re-checked my example, and table A.1 does show up in the ToC as requested. Did you compile several times? Have you copy-pasted parts of my code into your actual document, and missed something in the process (e.g., setting \appendixtrue at the start of the appendices environment)? –  lockstep Aug 9 '12 at 8:50
1  
@Costi You should have mentioned tocvsec2. I did some quick tests and my example still works with the package added, but that doesn't mean there aren't problems in your actual document. Try to remove \usepackage{tocvsec2} there. –  lockstep Aug 9 '12 at 9:32
1  
@Costi Doy you use longtable for your appendix tables? This could be the explanation! –  lockstep Aug 9 '12 at 9:47
1  
@Costi Answer updated to work with longtable. Re "examples": There's no list of appendices, only of chapters/sections, tables, figures, and possibly special environments like examples. Please consider to ask a follow-up question at our site. –  lockstep Aug 9 '12 at 9:59
1  
@Costi Answer updated again. –  lockstep Aug 9 '12 at 10:10

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.