GeneralHow to create an appendix TOC ? [solved]

LaTeX specific issues not fitting into one of the other forums of this category.
User avatar
Skiron
Posts: 4
Joined: Fri Jul 25, 2008 1:28 pm

How to create an appendix TOC ? [solved]

Post by Skiron »

Hello,

I'm writting a document with appendices, I use the "appendix" package.
I'd like to have a table of content in the begining of my document with all the section of the document and only the "Appendix" title section (providing the page number where appendix starts) and not the details of the sections in the appendix.

Then, when appendix starts, I'd like another table of content, but this time with only the sections appearing in the appendix.

Here is a MWE:

Code: Select all

Code, edit and compile here:
\documentclass[a4paper]{article}
\usepackage[toc,page,header]{appendix}
\begin{document}
\tableofcontents % How to limit this TOC to main document sections ????
\newpage
\section{First}
First content.
\section{Second}
Second content.
\newpage
\appendix
\appendixpage
% How to insert here a TOC concerning only the appendix sections ????
\section{Appendix First}
Appendix first content.
\section{Appendix Second}
Appendix second content.
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
In this MWE, I don't want the TOC to display "A Appendix First" and "B Appendix Second", but I want them and their page numbers to be displayed in another TOC, after the "Appendices" keyword.

I searched in the minitoc, tocloft, appendix packages (and even some homemade TeX code) but they don't provide me what I want.

I was thinking about modifying the \tableofcontents command so that I can pass as argument the ".toc" file to use to generate the TOC, and I could separate by hand from the original ".toc" file lines for document or for appendix TOCs.
\tableofcontents command could also be changed to automatically stop reading the ".toc" file after the "Appendix" keyword for the Document TOC, and start from there for the Appendix TOC.



Does anybody knows a way to not have to modify this command (because, I'm not sure to have sufficient knowledge to do so) ?

If not, can anybody tell me where I can find the sources of the \tableofcontents command ? (I can have a try to adapt it to my needs...)

Thanks for your help.
Last edited by Skiron on Sat Jul 26, 2008 11:30 am, edited 2 times in total.

Recommended reading 2024:

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

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

User avatar
Skiron
Posts: 4
Joined: Fri Jul 25, 2008 1:28 pm

How to create an appendix TOC ? [solved]

Post by Skiron »

Well... I tried to solve my problems, and, in a sense, I did.

I used the minitoc package and I put my document's content in a \part and my appendices in another. With minitoc I can generate one TOC per part, just as I wanted.

But, the part name are displayed in my document and it doesn't make sense in my case. So, I just don't name them (i.e. "\part{}") and I add in the hearder some command to note show the "Part I" text (see the MWE).


Two problems are left (plus one extra which does not concern me):
  • There is still a blank line instead of the "Part I Partname" text.
  • I'm using hyperref package to have hyperlink in the PDF file, and the parts have a bookmark, but no text, it doesn't look professional (I'm writing a Master Thesis) (not shown in the MWE).
  • (the extra problem) This solution doesn't suit people who want use the \part command
.

Anyway, despite this problems, it is a good solution and I'm going to keep it if nobody has a better idea.
Comments for solving my two last problems are welcome !!

Code: Select all

Code, edit and compile here:
\documentclass[a4paper]{article}
\usepackage[toc,page,header]{appendix}
\usepackage{minitoc}
% Make the "Part I" text invisible
\renewcommand \thepart{}
\renewcommand \partname{}
\begin{document}
\doparttoc % Tell to minitoc to generate a toc for the parts
\faketableofcontents % Run a fake tableofcontents command for the partocs
\part{} % Start the document part
\parttoc % Insert the document TOC
\section{First}
First content.
\section{Second}
Second content.
\newpage
\appendix
\addcontentsline{toc}{section}{Appendix} % Add the appendix text to the document TOC
\part{Appendix} % Start the appendix part
\parttoc % Insert the appendix TOC
\section{Appendix First}
Appendix first content.
\section{Appendix Second}
Appendix second content.
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Note that 3 compilations are needed to the minitoc package.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

How to create an appendix TOC ? [solved]

Post by gmedina »

Hi,

I would suggest you to use the titletoc package instead. I will use your initial code to give an example:

Code: Select all

Code, edit and compile here:
\documentclass[a4paper]{article}
\usepackage[page,header]{appendix}
\usepackage{titletoc}
\usepackage{lipsum}
\begin{document}
\startcontents[sections]
\printcontents[sections]{l}{1}{\setcounter{tocdepth}{2}}
\newpage
\section{First}
\lipsum[1-6]
\subsection{One one}
\lipsum[1-6]
\section{Second}
\lipsum[1-6]
\subsection{Two one}
\lipsum[1-6]
\newpage
\appendix
\appendixpage
\startcontents[sections]
\printcontents[sections]{l}{1}{\setcounter{tocdepth}{2}}
\section{Appendix First}
\lipsum[1-6]
\section{Appendix Second}
\lipsum[1-6]
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
Skiron
Posts: 4
Joined: Fri Jul 25, 2008 1:28 pm

How to create an appendix TOC ? [solved]

Post by Skiron »

Thank you a lot gmedina, that solve the remaining problems and that's perfect... ...on the MWE only unfortunately.

As I said, I'm using the hyperref package, and all is working well when I use it as follows:

Code: Select all

Code, edit and compile here:
\documentclass[a4paper]{article}
\usepackage{hyperref}
\usepackage[page,header]{appendix}
\usepackage{titletoc}
\usepackage{lipsum}
...
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
But, I made my own class which than call the "article" one, let's call it here "sample.cls", with the following WME
sample.cls file:

Code: Select all

Code, edit and compile here:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{sample}[2008/07/25]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\LoadClass{article}
\RequirePackage{hyperref}
\endinput
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Then, the only thing changed on the MWE you gave me is the first line:

Code: Select all

Code, edit and compile here:
\documentclass[a4paper]{sample}
...
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
And, in this case, there is an error while compiling:

Code: Select all

Code, edit and compile here:
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.8 ...umberline {A}Appendix First}{7}{appendix.A}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
And, in the final document, the TOCs are displayed, but all the remaining sections which should not appears are listed in normal text style.


I tried to pass the "a4paper" option the the hyperref package, (since I think that it is a problem of passing options), but it is still not working. I don't know what else I can do since the same code is working when I am not using my own "sample.cls" class.


This solution was the easiest and cleanest one ! I'd like to use it !! Any idea ?
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

How to create an appendix TOC ? [solved]

Post by gmedina »

It all comes down to the order in which titletoc and hyperref are loaded.

Refering to your sample class (sample.cls), if you use:

Code: Select all

Code, edit and compile here:
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{sample}[2008/07/25]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions
\LoadClass{article}
\RequirePackage{titletoc}
\RequirePackage{hyperref}
\endinput
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Then you will have no problems with

Code: Select all

Code, edit and compile here:
\documentclass[a4paper]{sample}
\usepackage[page,header]{appendix}
\usepackage{lipsum}
\begin{document}
\startcontents[sections]
\printcontents[sections]{l}{1}{\setcounter{tocdepth}{2}}
\newpage
\section{First}
\lipsum[1-6]
\subsection{One one}
\lipsum[1-6]
\section{Second}
\lipsum[1-6]
\subsection{Two one}
\lipsum[1-6]
\newpage
\appendix
\appendixpage
\startcontents[sections]
\printcontents[sections]{l}{1}{\setcounter{tocdepth}{2}}
\section{Appendix First}
\lipsum[1-6]
\section{Appendix Second}
\lipsum[1-6]
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
Skiron
Posts: 4
Joined: Fri Jul 25, 2008 1:28 pm

Re: How to create an appendix TOC ?

Post by Skiron »

Wonderfull !!!!

It's working perfectly !!
(I don't have a large experience in LaTeX, I didn't think about package order...)

Your solution suits me perfectly ! It is exactly what I was expecting ! Thank you a lot for your (fast) help !!
karpathos2
Posts: 1
Joined: Tue Aug 23, 2016 12:46 am

Re: How to create an appendix TOC ? [solved]

Post by karpathos2 »

Hi guys,

I have the same problem as skiron but with documentclass 'report' instead of 'article'
with 'chapters' instead of 'sections'.
When 'article' is substituted by 'report' in the solution by gmedina, a lot gets destroyed and i wasn't able to fix it. Can anyone adjust this solution so that it would yield the same results? Help greatly appreciated.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

How to create an appendix TOC ? [solved]

Post by Johannes_B »

Code: Select all

Code, edit and compile here:
\documentclass[a4paper]{report}
\usepackage{titletoc}
\usepackage{hyperref}
\usepackage[page,header]{appendix}
\usepackage{lipsum}
\begin{document}
\startcontents[chapters]
\printcontents[chapters]{l}{1}{\setcounter{tocdepth}{1}}
\newpage
\chapter{First}
\lipsum[1-6]
\section{One one}
\lipsum[1-6]
\chapter{Second}
\lipsum[1-6]
\section{Two one}
\lipsum[1-6]
\newpage
\appendix
\appendixpage
\startcontents[chapter]
\printcontents[chapter]{l}{0}{\setcounter{tocdepth}{1}}
\chapter{Wombat}
\lipsum[1-6]
\chapter{Capybara}
\lipsum[1-6]
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
hereilma
Posts: 1
Joined: Mon Jun 27, 2022 10:31 pm

How to create an appendix TOC ? [solved]

Post by hereilma »

It's been a few years since this was posted but you honestly saved me today ! Thank you so much gmedina !
byn
Posts: 56
Joined: Fri Jun 10, 2022 12:27 pm

How to create an appendix TOC ? [solved]

Post by byn »

I tried to follow your example to include in my own appendices to create on out put like this but I get an error; The link to the working template is here; https://drive.google.com/file/d/1cbUoc0 ... sp=sharing

And my log file is here;
main-file.log
Log file out put
(24.01 KiB) Downloaded 168 times
Your suggestions are highly appreaciated.
Post Reply