GeneralSeperate List of Appendices

LaTeX specific issues not fitting into one of the other forums of this category.
S_David
Posts: 45
Joined: Tue Jul 07, 2009 4:16 am

Seperate List of Appendices

Post by S_David »

gmedina wrote:Hi,

yes, that line causes the appendices to be included in the standard ToC. To solve this problem, please tell me which is the first sectional unit that you are sure that you won't use in your document; I mean, obviously you use \chapter and \section, but which one of the following is the first one you won't use: \subsection, \subsubsection, \paragraph, \subparagraph?
I think \paragraph, but to be more confident let us say \subparagraph.

Recommended reading 2024:

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

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Seperate List of Appendices

Post by gmedina »

Edit: please read the next post first

The new code:

Code: Select all

\documentclass[a4paper,12pt,openany]{memoir}
\usepackage{titlesec}

\makeatletter
\newcommand\listappname{List of Appendices}
\newcommand\listofappendices{%
\chapter*{\listappname
\@mkboth{%
   \MakeUppercase\listappname}{\MakeUppercase\listappname}}%
\@starttoc{app}}
\newcounter{myapp}
\newcommand*{\l@myappendix}[2]{%
  \stepcounter{myapp}%
  \ifnum \c@tocdepth >\m@ne
 \vskip \cftbeforechapterskip
{\leftskip \cftchapterindent\relax
 \rightskip \@tocrmarg
 \parfillskip -\rightskip
 \parindent \cftchapterindent\relax\@afterindenttrue
 \interlinepenalty\@M
 \leavevmode
 \@tempdima \cftchapternumwidth\relax
 \let\@cftbsnum \cftchapterpresnum
 \let\@cftasnum \cftchapteraftersnum
 \let\@cftasnumb \cftchapteraftersnumb
 \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
 {\cftchapterfont\Alph{myapp}\enspace #1}\nobreak
 \cftchapterfillnum{#2}}
  \fi}
\makeatother

\begin{document}
\tableofcontents
\listofappendices

\chapter{A regular test chapter}
\section{A regular test section}
\chapter{Another regular test chapter}
\section{Another regular test section}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of main chapters.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\setcounter{secnumdepth}{5}
\titleformat{\subparagraph}[display]
  {\normalfont\huge\bfseries}{\appendixname\ \Alph{subparagraph}}{20pt}{\Huge}
\titlespacing*{\subparagraph}
  {0pt}{20pt}{20pt}
\clearpage

{\centering\LARGE\bfseries Appendices\par\vskip20pt}

\subparagraph{Case 1}
\markboth{}{}
\addcontentsline{app}{myappendix}{Case 1}
\subparagraph{Case 2}
\addcontentsline{app}{myappendix}{Case 2}

\end{document}
Now the previous problem with the appendices appearing in the standard ToC should be solved.
Last edited by gmedina on Sat Aug 22, 2009 5:04 am, edited 1 time in total.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Seperate List of Appendices

Post by gmedina »

I apologise for the obvious double post.

The code I just posted will produce undesired results if the appendices include sections or subsections created with \section or \subsection (those will be listed in the standard ToC, which is not desirable).

To correct this situation I used dome of the features of the titletoc package; the standard ToC now won't be generated by \tableofcontents, but by \startcontents[toc]\printcontents[toc]{...}{...}{...}...\stopcontents[toc].

If the appendices won't include sections nor subsections, the code that I posted in my previous response will work; if the appendices include sections or subsections, here's the code to be used (the code contains some explanatory comments):

Code: Select all

\documentclass[a4paper,12pt,openany]{memoir}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{chngcntr}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% definition of the "List of Appendices"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\newcommand\listappname{List of Appendices}
\newcommand\listofappendices{%
  \chapter*{\listappname
  \@mkboth{%
    \MakeUppercase\listappname}{\MakeUppercase\listappname}}%
  \@starttoc{app}}
  \newcounter{myapp}
\newcommand*{\l@myappendix}[2]{%
  \stepcounter{myapp}%
  \ifnum \c@tocdepth >\m@ne
  \vskip \cftbeforechapterskip
  {\leftskip \cftchapterindent\relax
    \rightskip \@tocrmarg
    \parfillskip -\rightskip
    \parindent \cftchapterindent\relax\@afterindenttrue
    \interlinepenalty\@M
    \leavevmode
    \@tempdima \cftchapternumwidth\relax
    \let\@cftbsnum \cftchapterpresnum
    \let\@cftasnum \cftchapteraftersnum
    \let\@cftasnumb \cftchapteraftersnumb
    \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
    {\cftchapterfont\Alph{myapp}\enspace #1}\nobreak
    \cftchapterfillnum{#2}}
  \fi}
\makeatother

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the following lines to produce a standard Table
% of Contents (don't forget the \stopcontents[toc] just before the appendices)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter*{\contentsname}
\markboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}

\startcontents[toc]
\printcontents[toc]{}{0}{\setcounter{tocdepth}{4}}
\clearpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% place the following two lines where the List of Appendices must be typeset
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\listofappendices
\clearpage


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Main chapters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\chapter{A regular test chapter}
\section{A regular test section}
\subsection{A regular test subsection}
\subsubsection{A regular test subsubsection}
\chapter{Another regular test chapter}
\section{Another regular test section}
\subsection{Another regular test subsection}
\subsubsection{Another regular test subsubsection}

\stopcontents[toc]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of main chapters.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Preparations for the Appendices
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setcounter{secnumdepth}{5}
\titleformat{\subparagraph}[display]
  {\normalfont\huge\bfseries}{\appendixname\ \Alph{subparagraph}}{20pt}{\Huge}
\titlespacing*{\subparagraph}
  {0pt}{20pt}{20pt}
\renewcommand\thesubparagraph{\Alph{subparagraph}}
\renewcommand\thesection{\Alph{subparagraph}.\arabic{section}}
\renewcommand\thesubsection{\thesection.\arabic{subsection}}
\counterwithin{section}{subparagraph}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Appendices
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage

{\centering\LARGE\bfseries Appendices\par\vskip20pt}

\subparagraph{Case 1}
\addcontentsline{app}{myappendix}{Case 1}
\markboth{}{}

\section{A test section in the first appendix}
\subsection{A test subsection in the first appendix}
\section{Another test section in the first appendix}

\subparagraph{Case 2}
\addcontentsline{app}{myappendix}{Case 2}
\markboth{}{}
\section{A test section in the second appendix}
\subsection{A test subsection in the second appendix}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
S_David
Posts: 45
Joined: Tue Jul 07, 2009 4:16 am

Seperate List of Appendices

Post by S_David »

That is great. So, I don't have to use the standard Table of Contents? But in that case how can I add unreferenced lines to the ToC like using this line

Code: Select all

\addcontentsline{toc}{chapter}{DEDICATION}
and I want to include appendices in the ToC, without details. Like this:

Table of Contents
...
...
...

Appendices ....................................................... 50
References ....................................................... 60

Thank you gmedina, you really helped me. Your code with the code of writting chapters in words will almost complete the rquired. But I still don't know how to write the chapter title and chapter number in the same line.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Seperate List of Appendices

Post by gmedina »

S_David wrote:That is great. So, I don't have to use the standard Table of Contents? But in that case how can I add unreferenced lines to the ToC like using this line

Code: Select all

\addcontentsline{toc}{chapter}{DEDICATION}
and I want to include appendices in the ToC, without details. Like this:

Table of Contents
...
...
...

Appendices ....................................................... 50
References ....................................................... 60
My code doesn't use the standard \tableofcontents command, but you still can use something like

Code: Select all

\addcontentlene{toc}{chapter}{NAME}
to add entries to the ToC; if that command will be used after the \stopcontents[toc] command, you will have to use

Code: Select all

\resumecontents[toc]
\addcontentlene{toc}{chapter}{NAME}
\stopcontents[toc]
The example code below contains examples.
S_David wrote:...Thank you gmedina, you really helped me. Your code with the code of writting chapters in words will almost complete the rquired. But I still don't know how to write the chapter title and chapter number in the same line.
You are welcome. To format the chapter headings, you can use the titlesec package. The following code contains this feature and examples on how to introduce information manually into the ToC:

Code: Select all

\documentclass[a4paper,12pt,openany]{memoir}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{chngcntr}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% definition of the "List of Appendices"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\newcommand\listappname{List of Appendices}
\newcommand\listofappendices{%
  \chapter*{\listappname
  \@mkboth{%
\MakeUppercase\listappname}{\MakeUppercase\listappname}}%
  \@starttoc{app}}
  \newcounter{myapp}
\newcommand*{\l@myappendix}[2]{%
  \stepcounter{myapp}%
  \ifnum \c@tocdepth >\m@ne
  \vskip \cftbeforechapterskip
  {\leftskip \cftchapterindent\relax
\rightskip \@tocrmarg
\parfillskip -\rightskip
\parindent \cftchapterindent\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima \cftchapternumwidth\relax
\let\@cftbsnum \cftchapterpresnum
\let\@cftasnum \cftchapteraftersnum
\let\@cftasnumb \cftchapteraftersnumb
\advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
{\cftchapterfont\Alph{myapp}\enspace #1}\nobreak
\cftchapterfillnum{#2}}
  \fi}
\makeatother

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use the following lines to produce a standard Table
% of Contents (don't forget the \stopcontents[toc] just before the appendices)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter*{\contentsname}
\markboth{\MakeUppercase\contentsname}{\MakeUppercase\contentsname}

\startcontents[toc]
\printcontents[toc]{}{0}{\setcounter{tocdepth}{4}}
\clearpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% place the following two lines where the List of Appendices must be typeset
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\listofappendices
\clearpage


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Main chapters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\titleformat{\chapter}
  {\normalfont\LARGE\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\LARGE}
\titlespacing*{\chapter} {0pt}{50pt}{40pt}

\chapter*{Dedication}
\addcontentsline{toc}{chapter}{DEDICATION}

\chapter{A regular test chapter}
\section{A regular test section}
\subsection{A regular test subsection}
\subsubsection{A regular test subsubsection}
\chapter{Another regular test chapter}
\section{Another regular test section}
\subsection{Another regular test subsection}
\subsubsection{Another regular test subsubsection}

\stopcontents[toc]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% End of main chapters.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Preparations for the Appendices
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setcounter{secnumdepth}{5}
\titleformat{\subparagraph}[display]
  {\normalfont\huge\bfseries}{\appendixname\ \Alph{subparagraph}}{20pt}{\Huge}
\titlespacing*{\subparagraph}
  {0pt}{20pt}{20pt}
\renewcommand\thesubparagraph{\Alph{subparagraph}}
\renewcommand\thesection{\Alph{subparagraph}.\arabic{section}}
\renewcommand\thesubsection{\thesection.\arabic{subsection}}
\counterwithin{section}{subparagraph}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Appendices
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\clearpage

\resumecontents[toc]
{\centering\LARGE\bfseries Appendices\par\vskip20pt}
\addcontentsline{toc}{chapter}{Appendices}
\stopcontents[toc]

\subparagraph{Case 1}
\addcontentsline{app}{myappendix}{Case 1}
\markboth{}{}

\section{A test section in the first appendix}
\subsection{A test subsection in the first appendix}
\section{Another test section in the first appendix}

\subparagraph{Case 2}
\addcontentsline{app}{myappendix}{Case 2}
\markboth{}{}
\section{A test section in the second appendix}
\subsection{A test subsection in the second appendix}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
S_David
Posts: 45
Joined: Tue Jul 07, 2009 4:16 am

Re: Seperate List of Appendices

Post by S_David »

That is great. But I noticed that the subsections and subsubsections are not numbered. Why?

Thanks in advance
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Seperate List of Appendices

Post by gmedina »

By default, the memoir document class assigns numbers to sectional units up to level 1 (sections); this behaviour is controlled by the secnumdepth counter. If you want numbering up to subsubsections (level 3) then you have to add this line to your document (in all LaTeX classes):

Code: Select all

\setcounter{secnumdepth}{3}
or (in the memoir class)

Code: Select all

\setsecnumdepth{subsubsection}
The memoir documentation (pages 146 and 147) contains an explanation about secnumdepth and \setsecnumdepth
1,1,2,3,5,8,13,21,34,55,89,144,233,...
S_David
Posts: 45
Joined: Tue Jul 07, 2009 4:16 am

Re: Seperate List of Appendices

Post by S_David »

Thank you friend, you rescued me, because I have to deliver my thesis to my professor in 10 days, and I am not familiar with Latex till now. All things are now just fine except a little thing. I will try to solve it by myself to learn more about Latex.

Best regards
s.david
Posts: 43
Joined: Thu Sep 10, 2009 5:22 pm

Seperate List of Appendices

Post by s.david »

Execuse me, but now how can I refer to the created page "List of Appendecies" in the table of content? This page does not exist in the document to just use:

Code: Select all

\addcontentsline{toc}{chapter}{List of Appendecies}.
Thanks in advance
s.david
Posts: 43
Joined: Thu Sep 10, 2009 5:22 pm

Re: Seperate List of Appendices

Post by s.david »

Ok, I figured it out, we must place the above command after \listofappendecies.
Post Reply