2

I'm not that familiar with LaTeX and have a problem with the structure of my document. The table of contents has been created with "\tableofcontents", the appendix with "\appendix" (no further commands for both of them, they are filled completely automatically). In the appendix I have a subsection "MyDocument" which should represent a logically separate document (but actually I want to write in the same tex file). Only the subsection name should appear in the table of contents, not more (normally it would also include one hierarchy layer below). Within this subsection I have three further layers of hierarchy which should be numbered without the appendix prefix "A".

So, the toc should look like this:

1 Chapter

2 Chapter

...

A Appendix

A.1 One appendix

A.2 MyDocument

A.3 Another appendix

The subsection "MyDocument" is placed in a separate tex file (included into appendix) and should look like this (all headings numbered and formatted as headings):

A.2 My Document

1 abc

1.1 hello

1.2 world

1.2.1 world A

1.2.2 world B

2 xyz

Edit: some code

main document

...
\tableofcontents

\include{chapters/chapter1}

\include{chapters/chapter2}

\appendix 

\include{general/appendix} 

appendix.tex

\section{Appendix}

\input{appendices/one}

\input{appendices/mydocument}

\input{appendices/another}

mydocument.tex

\subsection{My Document}

\subsubsection{abc}

\paragraph{hello}

\paragraph{world}

\subparagraph{world 1}

\subparagraph{world 2}

\subsubsection{xyz}

I found a static solution which is not very comfortable, but ok for my case (I'm mainly interested in the pre-formatted headings, but I don't want the structure of mydocument appear in the table of contents): Remove automated numbering and adding to the toc, use hard-coded numbers instead (probably not a good idea if the structure of this document changes, but in this special case it really is fixed)

\subsubsection*{1. abc}

etc.

  • Welcome to TeX.SX! Could you add a minimal code which shows your case? It needs some time to reproduce your problem but we would prefer, just to solve it. Thanks. PS: how shall your ToC handle "1 Chapter" and "1 abc"? That's does not seem very intuitive to read. – LaRiFaRi Dec 4 '14 at 9:14
  • The minitoc manual (which had to be downloaded separately) says: Some users need a table of contents for the appendices, but without putting the entries of it into the main table of contents. The solution is to put the appendices in a \part subdivision of the document and ask for a table of contents at the \part level: – John Kormylo Dec 4 '14 at 16:42
  • LaTeXFan: See my possible solution – user31729 Dec 4 '14 at 21:07
2

I changed the names of the files and the structure slightly, for sake of easyness to provide a solution.

The standard macro \addcontentsline is responsible for the generation of ToC entries. If something should not be added to the ToC, but numbered anyway, it's better to kick out the meaning of \addcontentsline for while inside mydocument.tex. This is most easily done with a \begingroup...\endgroup pair right after \subsection{MyDocument}. Any redefinition of a command or length changes, counter formatting is only done with such a group and does not affect the outside code.

Please have a look on the ToC, that \section{Another appendix} behaves as usual whereas the Minidocument subsection has its own counter formatting,but is numbered by default, without hard-coding.

Remark If a book or report class is used, \appendix behaves best with \chapter subdivisions, not with \sections as top level structure units.

main.tex -- the main document frame

\documentclass{book}

\begin{document}
\tableofcontents

%\include{chapters/chapter1}

%\include{chapters/chapter2}

\chapter{chapter1}
\chapter{chapter2}

\appendix 
\renewcommand{\thesection}{\Alph{section}}

\input{appendixcontent} 


\end{document}

appendixcontent.tex

\section{Appendix}

\InputIfFileExists{one}{}{}%

\InputIfFileExists{mydocument}{}{}%

\InputIfFileExists{another}{}%

\section{Another appendix}% 

mydocument.tex

\setcounter{secnumdepth}{5}

\begingroup
\subsection{My Document}
\renewcommand{\thesubsubsection}{\arabic{subsubsection}}

\renewcommand{\addcontentsline}[3]{}% Do nothing

\subsubsection{abc}

\paragraph{hello}

\paragraph{world}

\subparagraph{world 1}

\subparagraph{world 2}

\subsubsection{xyz}

\endgroup

ToC without using the structure of the faked mini document

enter image description here

Structure of faked document

enter image description here

  • Thanks, this is exactly the kind of solution I've been looking for! – Progger Dec 4 '14 at 22:05
  • Ok, happy TeXing then... I only want to suggest to use \chapters in \appendix` but that's a matter of taste, actually – user31729 Dec 4 '14 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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