# \captionof{figure} starts with number 2 [duplicate]

Why does the caption start with number 2 and how to fix it?

\documentclass{article}

\usepackage{mwe}
\usepackage{subcaption}

\begin{document}

\begin{center}
\captionsetup{type=figure}
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image-a.pdf}
\end{subfigure}
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image-b.pdf}
\end{subfigure}
\captionof{figure}{Description}
\end{center}
\end{document}


Output:

Maybe also see here

• hy are you posting the same question twice? It is pretty much very very lickely that solving one mystery will automatically get rid of the other one. – Johannes_B Sep 4 '16 at 13:02
• Argh, now i voted on the wrong one to close. – Johannes_B Sep 4 '16 at 13:02
• I actually don't know if it's related. But I can produce both "errors" without the other – Ben Sep 4 '16 at 13:14
• Unfortunately this question was already closed so I cannot answer. So I will do so within this comment: Just change \captionof{figure}{...} to \caption{...} and the counting will be fine. Background: With \captionsetup{type=figure} you say "Hey, here starts some kind of figure, so increase the figure counter etc.". And with \captionof{figure}{...} you say "Hey, this isn't a figure but typeset the caption like a figure caption and btw please increase the figure counter". So it gets incremented twice. – 0-------0 Sep 4 '16 at 14:14
• @cfr Yes. When using the caption package \captionof{figure}{...} is only a abbreviation of \captionsetup{type=figure}\caption{...}. – 0-------0 Jun 15 '18 at 8:29

Use the H placement of a figure environment, or add this as a workaround: \addtocounter{figure}{-1}:

\documentclass{article}

\usepackage{mwe}
\usepackage{subcaption,float}

\begin{document}

\begin{figure}[H]
\centering
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image-a.pdf}
\end{subfigure}
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image-b.pdf}
\end{subfigure}
\caption{Description}
\end{figure}

\begin{center}
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{example-image-a.pdf}
\end{subfigure}

• I heard, that H actually doesn't mean here to 100%, so I'm still avoiding it. I got a solution here which uses minipages, which solves this problem too – Ben Sep 4 '16 at 14:20
• It really means here (as far as I know), but this implies a drawback: you may have unwanted whitespace if the image has to go to next page. In my opinion, it is wiser to let LaTeX decide first, and in a second time use the H joker if you think it's not the right choice. – Bernard Sep 4 '16 at 15:05