Graphics, Figures & Tablessubfigure + caption + appendix = bug

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
squall83
Posts: 5
Joined: Thu Nov 26, 2009 10:38 am

subfigure + caption + appendix = bug

Post by squall83 »

Hello everyone,

I have the following problem:
I want to have multiple figures in the same row. So I used the subfigure command. The subfigures are indexed (a), (b), (c). Now I have the same in the appendix, but there the indexing continues with (d), (e), (f).

This problem only occurs when I switch from my last chapter to the appendix. If I have multiple figures with subfigures within a chapter or within the appendix instead, then the indexing is fine. Also if I have multiple subfigures in the appendix and the indexing of the first one is wrong due to this bug, all later subfigures are fine.

The same happens if you take minipage and subcaption instead of subfigure and caption.

Example code:

Code: Select all

\documentclass{scrreprt}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{subfig}
\begin{document}

\begin{figure}
	\begin{minipage}{2cm}
		\includegraphics{Test}
		\subcaption{}
	\end{minipage}
\end{figure}

%\begin{figure}
%	\includegraphics{Test}
%	\caption{}
%\end{figure}
\appendix


\begin{figure}
	\begin{minipage}{2cm}
		\includegraphics{Test}
		\subcaption{}
	\end{minipage}
\end{figure}


\end{document}
The indexing of the second minipage should be (a), but it's (b). If you remove the comments from the 4 lines I commented out, you will see that the indexing is fine, i.e. both graphics are indexed with (a).

I don't want to use minipage + caption because the caption "Figure 1.1" is too big and it feels redundant if you have "Figure 1.x" written 5 times. Does anyone know the official rules on how to caption multiple graphics in a formally correct way with LaTeX?

Kind regards,
Alex

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
TikZ book
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

subfigure + caption + appendix = bug

Post by gmedina »

Hi,

yes, I remember some post concerning this very same issue. Using the "Advanced Search" function of this board, and looking for sommerfee (the nickname used in this forum by the author of the caption package), will surely guide you to the thread and to the solution of your problem.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
squall83
Posts: 5
Joined: Thu Nov 26, 2009 10:38 am

subfigure + caption + appendix = bug

Post by squall83 »

I searched this sub-forum for sommerfee and read all threads (diagonally) that seemed to be remotely similar to what my problem is, but I couldn't find anything.

I think that the easiest workaround would be if I could reset the counter which is being used by the subcaption-command manually because this seems to be what the author might have forgotten to do.

So, does anyone know the name of that counter? I searched through the subcaption-documentation, but I didn't find it.
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

subfigure + caption + appendix = bug

Post by sommerfee »

This bug was fixed in version 3.1k of the caption-Package, so updating the caption package should help. If this is not possible or desired one must reset the counter manually.
So, does anyone know the name of that counter?
It's named "subfigure", so \setcounter{subfigure}{0} right after \appendix should help here when updating the caption package is not an option.

HTH,
Axel

P.S.: Please don't load both, subcaption and subfig package.
squall83
Posts: 5
Joined: Thu Nov 26, 2009 10:38 am

Re: subfigure + caption + appendix = bug

Post by squall83 »

Thank you, now it's working. ^^ But I'll try to update the caption-package anyway.

I downloaded Miktex roughly 2,5 months ago with all packages included but since I didn't want any beta I downloaded the newest stable version, so that's probably why I didn't get Version 3.1k of the caption-package.

Also thanks for the hint to not load both packages.
Post Reply