1

I have a table of contents which has the chapters as:


1. Chapter 1...............1
1.1 section 1..............1
1.1.1 Subsection 1.....1
2. Chapter 2...............2
etc..
Appendix...................12
A. Demostrations.......13
A.1 1º Demostration .12
B. Results...................13
B.1 1º result

But what I want is that the TOC in the appendix only goes to the subsection as follows:


1. Chapter 1...............1
1.1 section 1..............1
1.1.1 Subsection 1.....1
2. Chapter 2...............2
etc..
Appendix...................12
A. Demostrations.......13
B. Results...................13

My code is the following, I have not include the content as it is not necesary and to not make a huge question.

\documentclass{report}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[ddmmyyyy]{datetime}
\usepackage[T1]{fontenc}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{titlesec}
\usepackage[toc,page]{appendix}
\usepackage[unicode]{hyperref}

\setcounter{section}{-1}

\makeatletter
\newcommand{\usebetterlinkanchor}[1]{%
  \gdef\Hy@chapapp{#1}%
}
\makeatother

\newcommand{\compconj}[1]{%
  \overline{#1}
}

\pagestyle{fancy}
\fancyhf{}
\rhead{Miguel Sanz Narrillos}
\lhead{Apuntes procesamiento de señales aleatorias}
%\cfoot{Page \thepage\ of \pageref{LastPage}}
\cfoot{\thepage}
\lfoot{18/04/2018}
\title{Apuntes procesamiento de señales aleatorias}
\author{Miguel Sanz Narrillos}
\date{Finalizado en : \today}


\begin{document}


\maketitle

\tableofcontents

\include{01-Estimacion_lineal}
\include{02-Estimacion_lineal_iterativa}
\include{03-Prediccion_lineal_e_interpolacion_lineal}
\include{04-Filtro_de_Wiener}
\include{05-Aplicacion_del_filtro_de_Wiener_en_prediccion_interpolacion_y_ecualizacion}

\include{06-appendix}

\end{document}

The appendix structure is the following:

\begin{appendices}
\chapter{Demostraciones:}

\lfoot{}
\section{Demostración 1}\label{eqn:demostracion_1}



\section{Demostración 2}\label{eqn:demostracion_2}



\section{Demostración 3}\label{eqn:demostracion_3}


\end{appendices}
  • By saying 'I have not include the content as it is not necesary and to not make a huge question.' you have effectively posted a document,that does not really generate a ToC at all... We're not seeing how you generate the appendix -- is it \begin{appendices}...\end{appendices} or with \begin{subappendices}...\end{appendices}? Basically it could be very simple by changing \thesection etc. for the appendix, but again... we see no code and can guess only! – user31729 Apr 23 '18 at 15:06
  • @ChristianHupfer Thanks I have added the appendix structure, when I said the content I was referering to the content of each section, I should add the structure of the appendix – Miguel Sanz Narrillos Apr 23 '18 at 15:29
3

You could change tocdepth for the appendices:

\usepackage{xpatch}
\apptocmd\appendices
  {\addtocontents{toc}{\protect\begingroup\protect\value{tocdepth}=0}}
  {}{\appendicesPatchFailed}
\apptocmd\endappendices
  {\addtocontents{toc}{\protect\endgroup}}
  {}{\appendicesPatchFailed}

Example:

\documentclass{report}
\usepackage{blindtext}% only for dummy text
\usepackage[toc,page]{appendix}

\usepackage{xpatch}
\apptocmd\appendices
  {\addtocontents{toc}{\protect\begingroup\protect\value{tocdepth}=0}}
  {}{\appendicesPatchFailed}
\apptocmd\endappendices
  {\addtocontents{toc}{\protect\endgroup}}
  {}{\appendicesPatchFailed}

\begin{document}
\tableofcontents
\blinddocument
\blinddocument
\begin{appendices}
\blinddocument
\blinddocument
\end{appendices}
\end{document}

enter image description here

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.