0

I am trying to implement the attached solution to compile Appendices. However, I believe the solution causes the table and figure numbering to suppress the chapter number after the usage (subappendices).

I believe the phenomen is caused by the new environment "subappendices" and the way the figure and table counter are set. Can anyone help me? Below, you find a MWE and the source.

Best

Daniel

\documentclass[12pt]{book}
\renewcommand{\baselinestretch}{1.5}
\usepackage[toc,page]{appendix}
\usepackage{array}
\usepackage{amsmath,amsthm,verbatim,amssymb,amsfonts,amscd, graphicx}

%\usepackage[toc,page]{appendix}
\usepackage{booktabs}
%\usepackage{caption}
%\usepackage{cite}
\usepackage{eurosym}
\usepackage{float}
%\usepackage{graphics}
%\usepackage{hyperref}
\usepackage{lscape}
\usepackage{multirow}
\usepackage{natbib}
\usepackage{natbib}
%\bibliographystyle{rusnat}
%\usepackage[]{natbib}
%\usepackage[authordate]{biblatex-chicago}
%\usepackage[authordate]{biblatex-chicago}
\setcitestyle{sort&compress,authoryear,open={(},close={)}}
\usepackage{rotating}
\usepackage{setspace}
\usepackage{subcaption}
%\usepackage{subfig}
\usepackage{threeparttable}
\usepackage{xcolor}
\usepackage[tableposition=top]{caption}
\usepackage[section]{placeins}
\usepackage[multiple]{footmisc}
\usepackage[left=2.5cm, right=2.5cm, top=2.5cm, bottom=2.5cm]{geometry}
\usepackage{pifont}
\usepackage[acronym]{glossaries}
\makeglossaries
\usepackage{longtable} % for 'longtable' environment
\usepackage{pdflscape} % for 'landscape' environment
\usepackage[hyphens]{url}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=black,
    filecolor=black,      
    urlcolor=black,
    citecolor=blue,
}
\usepackage{fancyhdr}
\pagestyle{fancy}
%\usepackage{fancychap}

\usepackage{titlesec}
\usepackage{lipsum}
\usepackage{etoolbox}
\usepackage{dsfont}
\usepackage{makecell}






\titleformat{\chapter}[display]
{\normalfont\Large\sffamily}
{%\titlerule[1pt]%
%\vspace{1pt}%
%\titlerule
\vspace{1pc}%
\LARGE\MakeUppercase{\chaptertitlename} \thechapter}
{1pc}
{\titlerule
\vspace{1pc}%
\Huge}
%[\newpage] % creates the new page
\usepackage{tabularx}


% *****************************************************************
% Custom subcaptions
% *****************************************************************
% Note/Source/Text after Tables
\newcommand{\figtext}[1]{
    \vspace{1ex}
    \captionsetup{justification={justified}, font={footnotesize,singlespacing}}
    \caption*{\hspace{6pt}\hangindent=1.5em #1}
    }
\newcommand{\fignote}[1]{\figtext{\emph{Note:~}~#1}}

\newcommand{\figsource}[1]{\figtext{\emph{Source:~}~#1}}

% Add significance note with \starnote
\newcommand{\starnote}{\figtext{* p $<$ 0.1, ** p $<$ 0.05, *** p $<$ 0.01.}}

\newcommand{\tablefont}{\fontsize{8pt}{10pt}\selectfont\centering}


% *****************************************************************
% Cnew column types
% *****************************************************************
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}


\defcitealias{BAMF2019}{BAMF, 2019}
\defcitealias{CDC2020}{CDC, 2020}
\defcitealias{RKI2020a}{RKI, 2020a}
\defcitealias{ba2020}{BA, 2020}
\defcitealias{Lancet2020}{The Lancet Global Health, 2020}
\defcitealias{UNHCR1951}{UNHCR, 1951}
\newcommand{\ie}{\textit{i}.\textit{e}., }
\newcommand{\eg}{\textit{e}.\textit{g}., }

\def\chapterthanks#1{\renewcommand{\thefootnote}{$\heartsuit$}%
\addtocounter{footnote}{-1}% 
\footnote{#1}}


\makeatletter
\patchcmd{\@maketitle}{\newpage}{}{}{} 
\renewcommand*\l@figure{\@dottedtocline{1}{1.5em}{3em}} % modified. 
\let\l@table\l@figure
\makeatother

\fancyfoot{}
\fancyhead[RO,LE]{\thepage}
\fancyhead[LO]{\leftmark}
\fancyhead[RE]{\rightmark}

\AtBeginEnvironment{subappendices}{%
\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendices}
\counterwithin{figure}{section}
\counterwithin{table}{section}
}

% End of subappendices environment
\AtEndEnvironment{subappendices}{%
\counterwithout{figure}{section}
\counterwithout{table}{section}
}


\begin{document} 

%\input{sections/Title.tex}

\begin{titlepage}
   \begin{center}
       \vspace*{1cm}

       {\LARGE Awesome stuff}

     
            
       \vspace{2cm}

       {\Large stuffy stuff}

       \vspace{2cm}
       
       {\Large More stuffy stuff
       \vfill
     
       %\includegraphics[width=0.4\textwidth]{university}
            
       Authored by me}
            
   \end{center}
\end{titlepage}

\tableofcontents
\listoffigures
\listoftables

\chapter[Initial stuff]{Initial stuff}
Interesting stuff.

\section{test}

\begin{table}[]
\caption{Test 1\label{tab:test1}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 &  \\
5 & 6 & 7 & 8 &  \\
  &   &   &   &  \\
  &   &   &   & 
\end{tabular}
\end{table}

\begin{subappendices}
\section{Additional tables}
\begin{table}[]
\caption{Test 2\label{tab:test2}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 &  \\
5 & 6 & 7 & 8 &  \\
  &   &   &   &  \\
  &   &   &   & 
\end{tabular}
\end{table}
\end{subappendices}

\chapter[Initial stuff 2]{Initial stuff}
Interesting stuff 2.

\section{test 2}

\begin{table}[]
\caption{Test 3\label{tab:test3}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 &  \\
5 & 6 & 7 & 8 &  \\
  &   &   &   &  \\
  &   &   &   & 
\end{tabular}
\end{table}

\begin{subappendices}
\section{Additional tables}

\begin{table}[]
\caption{Test 4\label{tab:test4}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 &  \\
5 & 6 & 7 & 8 &  \\
  &   &   &   &  \\
  &   &   &   & 
\end{tabular}
\end{table}
\end{subappendices}


\end{document}

Appendix after each chapter

EDIT: I have to add that I implemented the solution in the comments. I replicated the error directly in the MWE provided in the link. Please find the MWE 2 below.

\documentclass{book}
\usepackage{appendix}
\usepackage{chngcntr}
\usepackage{etoolbox}
\usepackage{lipsum}

\AtBeginEnvironment{subappendices}{%
\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendices}
\counterwithin{figure}{section}
\counterwithin{table}{section}
}

\AtEndEnvironment{subappendices}{%
\counterwithout{figure}{section}
\counterwithout{table}{section}
}

\begin{document}
\tableofcontents
\listoffigures
\listoftables

\chapter[Initial stuff]{Initial stuff}
Interesting stuff.

\section{test}

\begin{table}[]
\caption{Test 1\label{tab:test1}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 &  \\
5 & 6 & 7 & 8 &  \\
  &   &   &   &  \\
  &   &   &   & 
\end{tabular}
\end{table}

\begin{subappendices}
\section{Additional tables}
\begin{table}[]
\caption{Test 2\label{tab:test2}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 &  \\
5 & 6 & 7 & 8 &  \\
  &   &   &   &  \\
  &   &   &   & 
\end{tabular}
\end{table}
\end{subappendices}

\chapter[Initial stuff 2]{Initial stuff}
Interesting stuff 2.

\section{test 2}

\begin{table}[]
\caption{Test 3\label{tab:test3}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 &  \\
5 & 6 & 7 & 8 &  \\
  &   &   &   &  \\
  &   &   &   & 
\end{tabular}
\end{table}

\begin{subappendices}
\section{Additional tables}

\begin{table}[]
\caption{Test 4\label{tab:test4}}
\begin{tabular}{lllll}
1 & 2 & 3 & 4 &  \\
5 & 6 & 7 & 8 &  \\
  &   &   &   &  \\
  &   &   &   & 
\end{tabular}
\end{table}
\end{subappendices}

\end{document}

1 Answer 1

1

I found a solution. The source is here: Appendix after each chapter v2.0

The answer is to change the new environment as follows:

\AtBeginEnvironment{subappendices}{%
\chapter*{Appendix}
\addcontentsline{toc}{chapter}{Appendices}
\counterwithin{figure}{section}
\counterwithin{table}{section}
}

\AtEndEnvironment{subappendices}{%
\counterwithout{figure}{section}
\counterwithin{figure}{chapter}
\counterwithout{table}{section}
\counterwithin{table}{chapter}
}

That is it. That is the answer.

Daniel

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .