# Figure numbering after subappendix

Updated: 23/9/2019

I'm using a subappendix environment within my thesis, however figure numbers stop adding the chapter number, after using this environment. I thought I found the solution online but it doesn't seem to resolve my problem. The input and everything looks fine, it is just the numbering.

As requested this is the current MWE:

%document style
\documentclass[12pt]{book}

%main usepackages
\usepackage{titlesec}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{mathptmx}
\usepackage{upgreek}
\usepackage{textcomp}
\usepackage{pdflscape}
\usepackage{amsmath, amssymb}
\usepackage{appendix}
\usepackage{hyperref}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[comma, round,sort]{natbib}
\setlength{\bibsep}{0.0pt}
\usepackage[rootbib, sectionbib]{chapterbib}
\usepackage[a4paper, top=25mm, bottom=25mm, margin=25mm, bindingoffset=4mm]{geometry}
\usepackage{chngcntr}
\usepackage{etoolbox}
\usepackage{multirow}
\usepackage{textcomp}
\usepackage{gensymb}
\usepackage{rotating}
\usepackage{lscape}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage[table,xcdraw]{xcolor}
\usepackage[nottoc,numbib]{tocbibind}
\usepackage{hyperref}
\usepackage{wrapfig}
\usepackage[british]{babel}
\usepackage{verbatim}
\usepackage{pdfpages}
\usepackage{lineno}

% Start of subappendices environment
\AtBeginEnvironment{subappendices}{%
\chapter*{Appendices}
\counterwithin{figure}{section}
\counterwithin{table}{section}
}

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

\begin{document}
\frontmatter
\tableofcontents
\cleardoublepage
\listoffigures
\cleardoublepage
\listoftables
\cleardoublepage

\mainmatter
\chapter{Introduction}
\label{Int}
\graphicspath{{./5_Introduction/Figures/}}
\include{5_Introduction/Introduction}


Within the include file I have:

\begin{subappendices}
\pagestyle{empty}
\newpage
\begin{landscape}
\section{Analysis}
\begin{table}
\end{table}
\end{landscape}
\pagestyle{fancy}
\end{subappendices}


Followed by importing the next chapter in the main.tex file

%Chapter 2

\chapter{Analysis}
\label{Analysis}
\graphicspath{{./6_Analysis/Figures/}}
\include{./6_Analysis/Analysis}


It is in this next chapter where numbering fails me.

It would have been helpful if you had provided a complete MWE, from \documentclass... to \end{document}, that we could compile. What class are you using? What packages? As far as I can tell the following does what you want where the figure number in the subappendix is given as "Figure 1.2: Second figure".

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

\begin{document}
\frontmatter
\tableofcontents
\listoffigures
\mainmatter
\chapter{First}
\lipsum[1]
\begin{figure}
\centering
A FIGURE
\caption{First figure}
\end{figure}

\begin{subappendices}
\section{Sub appendix}
\lipsum[1]
\begin{figure}
\centering
A FIGURE
\caption{Second figure}
\end{figure}

\end{subappendices}

\end{document}

• Dear Peter, thank you for the reply. I'll add a more complete MWE below. To clarify, the problem is with the numbering of the appendices. It is the numbering of figures in subsequent chapters. – Rick Verberne Sep 22 at 0:49

Oké, I found the solution in another article: https://tex.stackexchange.com/a/340384/195439 set \counterwithout{section} but also \counterwithout{chapter}

\AtBeginEnvironment{subappendices}{%
%\chapter*{Appendix}
\counterwithin{figure}{section}
\counterwithin{table}{section}
}
\AtEndEnvironment{subappendices}{%
\counterwithout{figure}{section}
\counterwithin{figure}{chapter}
\counterwithout{table}{section}
\counterwithin{table}{chapter}
}
`