# Numbering chapters, sections and subsections continuous after figure label, not the document

I have problem with numbering subsection after figure label. I put appendix, caption and label, and put counter of figure to 0 so graph label says Picture 1. Then, when i want to start new chapter, section or subsection, it is numbered .0.1. instead of example, 2.2.1. How do i end figure labeling and let document continue section numbering normally? Here is the code:

\section{text}
\pgfplotsset{compat=1.12}
\begin{figure}[h]
\centering
\appendix

\begin{tikzpicture}
\begin{axis}[xlabel=x,ylabel=y,grid=both,xmax=10,ymax=10,axis lines=middle,restrict y to domain=-7:10,enlargelimits]
\addplot[blue]  {pow(2,x)} node[above]{$y=2^x$};
\addplot[red]  {pow(10,x)} node[above]{$y=10^x$};
\end{axis}
\end{tikzpicture}

\setcounter{figure}{0}
\caption{text}
\label{fig:text}
\end{figure}

\subsection{text}

• What is your over all goal doing this? Why is there an \appendix-Tag in the middle of your figure? – nhck Aug 2 '17 at 9:30
• @nhck I have a section 2.2. In there i need to put a graph of an exponential function. This is my first picture in document so i need to label it: "Picture 1: Exponential graph". If i just use caption and label, it's label isn't "1." but "2.1" for some reason. If i put \appendix and set counter to 0, it shows correct number of caption but messes up section numbering. It may be a minor problem, i just started working in tex yesterday, so I only put appendix in because it worked that way, I cant really understand what it does. – Mactadilis Aug 2 '17 at 10:12

The numbering depends on your documentclass. I'm assuming book in this example. You can use the package chngcntr to adjust the figure numbering to include or exclude certain numbers. The example below excludes section and subsection number for the figure number.

The \appendixtag you use is just for resetting the counter to start the appendix numbering.

These two posts are also a good read for you: How to number figures continuously in documentclass{article} and Why does an environment's label have to appear after the caption?

\documentclass{book}
\usepackage{lipsum} %Just for the sampletext

\usepackage[demo]{graphicx} %Package for the Figures

\usepackage{chngcntr} %Package to set the counter
\counterwithout{figure}{section}
\counterwithout{figure}{subsection}

\begin{document}
\chapter{This is Chapter}
\section{Section One}
\begin{figure}
\centering
\includegraphics[width=0.3\linewidth]{img}
\caption{trest}
\end{figure}
\lipsum[1-3]
\section{Section Two}
\lipsum[1]
\begin{figure}
\centering

\includegraphics[width=0.3\linewidth]{img}
\caption{trest2}