# Include Appendix as a Chapter in LOF and LOT, and chapters formatting in both lof and lot

I'm doing my thesis and I need a better display of the chapters that are shown on LoT and LoF, as well as I want to include the \appendix as a Chapter to LoT and LoF (notice that \appendixname is "Anexo" in the LoT picture below).

I read an answer here which recommends to use: \addcontentsline{lot}{chapter}{Anexo}, and it adds perfectly the "Anexo" chapter to LoT & LoF. The thing is that, as you can see on the image below, the "Anexo" is with hyperlink and with the page number also (in other color). The point is that it looks bad comparing to the other chapters style. I'd like all to look the same, with a bigger font size if possible :-). In order to add the chapters as it is shown for all chapters (not counting "Anexo", i.e II. Estado del Arte and III. Métodos y materiales), I used an answer suggested here.

My code is the following:

\documentclass[11pt,a4paper,twoside,openright]{report}
\usepackage[spanish,es-lcroman]{babel}

\usepackage[utf8x]{inputenc}
\usepackage{microtype}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{booktabs}
\usepackage{caption}
\captionsetup{labelfont=bf}
\usepackage{amsmath}

\usepackage{etoolbox}

\makeatletter
% initial definitions of the chapter info (name and number)
\def\thischaptertitle{}\def\thischapternumber{}
\newtoggle{noFigs}

\apptocmd{\@chapter}%
{\gdef\thischaptertitle{#1}\gdef\thischapternumber{\thechapter}%
\global\toggletrue{noFigs}}{}{}

% the figure environment does the job: the first time it is used after a \chapter command,
% it writes the information of the chapter to the LoF
\AtBeginDocument{%
\AtBeginEnvironment{figure}{%
\iftoggle{noFigs}{
{\protect\numberline {\thischapternumber} {\thischaptertitle}}{}{} }
\global\togglefalse{noFigs}
}{}
}%
}

\makeatother

\makeatletter
\def\thischaptertitle{}\def\thischapternumber{}
\newtoggle{noTabs}

\apptocmd{\@chapter}%
{\gdef\thischaptertitle{#1}\gdef\thischapternumber{\thechapter}%
\global\toggletrue{noTabs}}{}{}

% the figure environment does the job: the first time it is used after a \chapter command,
% it writes the information of the chapter to the LoF
\AtBeginDocument{%
\AtBeginEnvironment{table}{%
\iftoggle{noTabs}{
{\protect\numberline {\thischapternumber} {\thischaptertitle}}{}{} }
\global\togglefalse{noTabs}
}{}
}%
}
\makeatother

\def\tablename{Tabla}
\def\listtablename{\'Indice de tablas}
}

\usepackage[margin=25mm,inner=30mm]{geometry}

urlcolor=blue,
citecolor=blue]{hyperref}

\usepackage{sectsty}

\usepackage[nottoc,notlof,notlot]{tocbibind}

\makeatletter
\def\tableofcontents{%
\newpage
\centerline{\Large\scshape Índice General}
\vspace*{0.3in}
\@mkboth{Contenidos}{}
\@starttoc{toc}
}
\makeatother

\makeatletter
\def\listoftables{%
\newpage
\centerline{\Large\scshape Índice de Tablas}
\vspace*{0.3in}
\@mkboth{Contenidos}{}
\@starttoc{lot}
}
\makeatother

\makeatletter
\def\listoffigures{%
\newpage
\centerline{\Large\scshape Índice de Figuras}
\vspace*{0.3in}
\@mkboth{Contenidos}{}
\@starttoc{lof}
}
\makeatother

\usepackage{appendix}
\usepackage{titlesec}
\usepackage[dotinlabels]{titletoc}

\usepackage{longtable}
\usepackage{tabularx}
\usepackage{bigstrut}
\usepackage{bigdelim}
\usepackage{ltxtable}
\usepackage{chngcntr}

\begin{document}
\selectlanguage{spanish}

%------------------------- TOC.

\cleardoublepage
\phantomsection
\tableofcontents

%------------------------- LOF.

\cleardoublepage
\phantomsection
\listoffigures

%------------------------- LOT.

\cleardoublepage
\phantomsection
\listoftables

\clearpage
\chapter{Capítulo 1}
% There are no tables here...

\clearpage

\begin{table}[h!]
\centering
\caption{Grupos de códigos de área.}\label{tab:1}
\begin{tabular}{cc}
\toprule
hola & chao\\
\midrule
bla & blabla\\
alb & albalb\\
\bottomrule
\end{tabular}
\end{table}
%and many other tables...
\clearpage
\chapter{Métodos y materiales}

\begin{table}[h!]
\centering
\begin{tabular}{lc}
\toprule
\multicolumn{2}{c}{\textbf{CARACTERÍSTICAS TÉCNICAS DEL ESPECTRÓMETRO STS-NIR }} \\
\midrule
Fabricante & OceanOptics \\
bla & blabla\\
\bottomrule
\end{tabular}%
\caption{Características del espectrómetro y de la fibra óptica.}\label{tab:car_espectrometro}%
\end{table}

% Here's much more... (bla bla... + bibliography...)
% And at the end (the appendix):

\clearpage
\renewcommand{\appendixname}{Anexo}
\renewcommand{\appendixtocname}{Anexo}
\renewcommand{\appendixpagename}{Anexo}
\renewcommand{\thesection}{\Alph{section}}

\appendix
\phantomsection
\addcontentsline{lot}{chapter}{Anexo} %This is the first approach.
\clearpage
\appendixpage

\counterwithin{table}{section}
\counterwithin{figure}{section}
\counterwithin{equation}{section}

\refstepcounter{section}%
\section*{\thesection. \quad Características generales de las agujas y conos de pino.}

\begin{table}[h!]
\centering
\begin{tabular}{lcc}
\toprule
& bla & blabla \\
\midrule
Moisture (wt.\%) & 12     & 8,9 \\
bla bla          & bla    & bla \\
\bottomrule
\end{tabular}%
\caption{Características generales de agujas y conos de pino.}
\end{table}%

\end{document}


It is very possible that I'm missing something (I'm trying to put just what I think It's necessary, because I've got hundreds of code lines in my preamble), therefore I'll be very alert for any question and/or answer. So, to conclude, the things that I'm asking to solve are:

1. That \appendix chapter ("Anexo" in LoT) has the same style as the other chapters (i.e Estado del Arte and Métodos y materiales).

2. To modify the chapters style in both LoT and LoF (to change the font size, color...with that it's perfect!).

I'd really appreciate some help!

• Welcome to TeX.SX! Please provide a Minimal Working Example (MWE). The code you provided is far too long to be minimal and has missing packages, so it's not working. A MWE should have only the necessary packages, be compilible and have enough code to show the issue. Providing a MWE will definetely increase your chances of getting help as it makes the helpers lives much easier! :D – Guilherme Zanotelli Nov 8 '16 at 11:59
• @GuilhermeZ.Santos, I already modified the code to run perfectly. Thank you. – Jorge V Nov 9 '16 at 15:43

You're missing the hyperref anchor line on your definition of \apptocmd{\@chapter}, done by:

\global\let\thischapterHref\@currentHref


\apptocmd{\@chapter}{%
\gdef\thischaptertitle{#1}%
\gdef\thischapternumber{\thechapter}%
\global\let\thischapterHref\@currentHref % hyperref
\global\toggletrue{noFigs}%
\global\toggletrue{noTabss}%
}{}{}


And you also have to call the anchor when making the list:

\AtBeginDocument{%
\AtBeginEnvironment{table}{%
\iftoggle{noTabs}{
{\protect\numberline {\thischapternumber} {\thischaptertitle}}%
{}%
}
\global\togglefalse{noTabs}
}{}
}%
}


Furthermore, to supress the page number on ToC entries added with \addtocontents instead of the \addcontentsline{lot}{chapter}{Anexo} you should use the below code, where the last argument chapter\thepage refers to hyperref's link anchor:

\addtocontents{lot}{\protect\contentsline{chapter}{Anexo}{}{chapter\thepage}}


The complete (M)WE:

\documentclass[11pt,a4paper,twoside,openright]{report}
\usepackage[spanish,es-lcroman]{babel}

\usepackage[utf8x]{inputenc}
\usepackage{microtype}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{booktabs}
\usepackage{caption}
\captionsetup{labelfont=bf}
\usepackage{amsmath}

\usepackage{etoolbox}

\makeatletter
% initial definitions of the chapter info (name and number)
\def\thischaptertitle{}\def\thischapternumber{}
\newtoggle{noFigs}
\newtoggle{noTabs}

\apptocmd{\@chapter}{%
\gdef\thischaptertitle{#1}%
\gdef\thischapternumber{\thechapter}%
\global\let\thischapterHref\@currentHref % hyperref
\global\toggletrue{noFigs}%
\global\toggletrue{noTabs}%
}{}{}

% the figure environment does the job: the first time it is used after a \chapter command,
% it writes the information of the chapter to the LoF
\AtBeginDocument{%
\AtBeginEnvironment{figure}{%
\iftoggle{noFigs}{
\protect\contentsline{chapter}%
{\protect\numberline {\thischapternumber} {\thischaptertitle}}{}{\thischapterHref} }
\global\togglefalse{noFigs}
}{}
}%
}

% the figure environment does the job: the first time it is used after a \chapter command,
% it writes the information of the chapter to the LoF
\AtBeginDocument{%
\AtBeginEnvironment{table}{%
\iftoggle{noTabs}{
{\protect\numberline {\thischapternumber} {\thischaptertitle}}{}{\thischapterHref} }
\global\togglefalse{noTabs}
}{}
}%
}
\makeatother

\def\tablename{Tabla}
\def\listtablename{\'Indice de tablas}
}

\usepackage[margin=25mm,inner=30mm]{geometry}

urlcolor=blue,
citecolor=blue]{hyperref}

\usepackage{sectsty}
\usepackage[nottoc,notlof,notlot]{tocbibind}

\makeatletter
\def\tableofcontents{%
\newpage
\centerline{\Large\scshape Índice General}
\vspace*{0.3in}
\@mkboth{Contenidos}{}
\@starttoc{toc}
}

\def\listoftables{%
\newpage
\centerline{\Large\scshape Índice de Tablas}
\vspace*{0.3in}
\@mkboth{Contenidos}{}
\@starttoc{lot}
}

\def\listoffigures{%
\newpage
\centerline{\Large\scshape Índice de Figuras}
\vspace*{0.3in}
\@mkboth{Contenidos}{}
\@starttoc{lof}
}
\makeatother

\usepackage{appendix}
\usepackage{titlesec}
\usepackage[dotinlabels]{titletoc}

\usepackage{longtable}
\usepackage{tabularx}
\usepackage{bigstrut}
\usepackage{bigdelim}
\usepackage{ltxtable}
\usepackage{chngcntr}

\begin{document}
\selectlanguage{spanish}

%------------------------- TOC.

\cleardoublepage
\phantomsection
\tableofcontents

%------------------------- LOF.

\cleardoublepage
\phantomsection
\listoffigures

%------------------------- LOT.

\cleardoublepage
\phantomsection
\listoftables

\clearpage
\chapter{Capítulo 1}
% There are no tables here...

\clearpage

\begin{table}[h!]
\centering
\caption{Grupos de códigos de área.}\label{tab:1}
\begin{tabular}{cc}
\toprule
hola & chao\\
\midrule
bla & blabla\\
alb & albalb\\
\bottomrule
\end{tabular}
\end{table}
%and many other tables...
\clearpage
\chapter{Métodos y materiales}

\begin{table}[h!]
\centering
\begin{tabular}{lc}
\toprule
\multicolumn{2}{c}{\textbf{CARACTERÍSTICAS TÉCNICAS DEL ESPECTRÓMETRO STS-NIR }} \\
\midrule
Fabricante & OceanOptics \\
bla & blabla\\
\bottomrule
\end{tabular}%
\caption{Características del espectrómetro y de la fibra óptica.}\label{tab:car_espectrometro}%
\end{table}

% Here's much more... (bla bla... + bibliography...)
% And at the end (the appendix):

\clearpage
\renewcommand{\appendixname}{Anexo}
\renewcommand{\appendixtocname}{Anexo}
\renewcommand{\appendixpagename}{Anexo}
\renewcommand{\thesection}{\Alph{section}}

\appendix
\phantomsection
\clearpage
\appendixpage

\counterwithin{table}{section}
\counterwithin{figure}{section}
\counterwithin{equation}{section}

\refstepcounter{section}%
\section*{\thesection. \quad Características generales de las agujas y conos de pino.}

\begin{table}[h!]
\centering
\begin{tabular}{lcc}
\toprule
& bla & blabla \\
\midrule
Moisture (wt.\%) & 12     & 8,9 \\
bla bla          & bla    & bla \\
\bottomrule
\end{tabular}%
\caption{Características generales de agujas y conos de pino.}
\end{table}%

\end{document}


• @JorgeV, you're welcome, don't forget to upvote helpful questions and answers as well as accepting correct answers. See edited answer above, I think everything is clear now! :D – Guilherme Zanotelli Nov 10 '16 at 6:48
• I'm sorry @JorgeV, but I don't understant the problem you're stating. You're supposed to be using \section not \chapter. Also, if you undo the changes I proposed and the problem persists, than it's unrelated to this question. Can you please check that? And if the problem is being caused by the proposed solution, add a new MWE showing it, if not, please ask a new question then! :) – Guilherme Zanotelli Dec 6 '16 at 19:57