Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using the subfig package for subfigures and the float package for forced float placement (H). Using both these packages results in the subcaption not getting reset. The following example shows six figures from (a) to (f), whereas I'd expect them to be from (a) to (c), twice.

\documentclass[a4paper]{scrartcl}

\usepackage{graphicx} 
\usepackage{float}
\usepackage{subfig}

\begin{document}

\begin{figure}[H] \centering
    \subfloat[first subfig]{\includegraphics{img}}
    \subfloat[second subfig]{\includegraphics{img}}
    \subfloat[third subfig]{\includegraphics{img}}
\end{figure}

\begin{figure}[H] \centering
    \subfloat[first subfig]{\includegraphics{img}}
    \subfloat[second subfig]{\includegraphics{img}}
    \subfloat[third subfig]{\includegraphics{img}}
\end{figure}

\end{document}

What I'm trying to achieve is subfigures exactly where I want them to be. Is there a way to solve this interference, or is there a better solution?

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

It's the \caption command that resets the subfigure numbers and you don't provide one.

Actually, \caption performs \stepcounter{figure} and it's this command that does the business. So, if you really don't want to have a global caption, issue

\stepcounter{figure}\addtocounter{figure}{-1}

before \end{figure}. This will reset the subfloat counter but won't affect the figure counter, as the net change is 0.

share|improve this answer
add comment

The \subfloat command is designed to work with \caption only. If you don't want a \caption inside your figures, use \phantomcaption instead. This will both increase the figure counter and give proper hyperlinks when the hyperref package will be used. (\phantomcaption needs caption v3.2 or newer)

share|improve this answer
add comment

Put

\setcounter{subfigure}{0}

in between the two figures.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.