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 have a lot of files including images and I want them to be numbered continuously.

I use many images next to each other, which looks like

\begin{figure}[H]
    \begin{subfigure}[t]{0.45\textwidth}
            \includegraphics[bla]{bla1.jpg}
            \caption{bla}
            \label{fig:bla1}
    \end{subfigure}
    \begin{subfigure}[t]{0.45\textwidth}
        \includegraphics[bla]{bla2.jpg}
            \caption{bla}
            \label{fig:bla2}
    \end{subfigure}
\end{figure}

Their caption labels are (1) and (2).

Then I have single images like:

\begin{figure}[H]
\begin{subfigure}{0.62\textwidth}
    \includegraphics[bla]{bla3.jpg}
    \caption{bla}
    \label{fig:bla3}
\end{subfigure}
\end{figure}

Its label is (1) again, but I would like it to have (3).

My attempt was to use:

\usepackage{chngcntr}
\counterwithout{subfigure}{figure}

so that it ignores the figure-environment. It does not work.

The problem is that I am using memoir as documentclass, without using chapters. Originally, the pictures were numbered continuously like 0.1, 0.2, 0.3 etc., because they were in minipages instead of subfigures. But I wanted to remove the 0, so that I replaced the minipages with subfigures and

\renewcommand{\thesubfigure}{\arabic{subfigure}}

I hope this is understandable and I appreciate your help!

share|improve this question
    
What about DCs 'remreset'? –  Ruben Sep 21 '13 at 14:09
    
What about \ContinuedFloat? –  Axel Sommerfeldt Sep 22 '13 at 7:46

1 Answer 1

up vote 4 down vote accepted

Here is my solution using the etoolbox package and a new counter which will be increased by one each time the subfigure environment is called.

\documentclass{memoir}

\usepackage[draft]{graphicx}
\usepackage{subcaption}
\usepackage{caption}
\usepackage{etoolbox}
\newcounter{fignumber}
\setcounter{fignumber}{0}

\renewcommand{\thesubfigure}{\arabic{fignumber}}

\AtBeginEnvironment{subfigure}{\refstepcounter{fignumber}}

\begin{document}

\begin{figure}[H]
    \begin{subfigure}[t]{0.45\textwidth}
            \includegraphics{bla1.jpg}
            \caption{bla}
            \label{fig:bla1}
    \end{subfigure}
    \begin{subfigure}[t]{0.45\textwidth}
        \includegraphics{bla2.jpg}
            \caption{bla}
            \label{fig:bla2}
    \end{subfigure}
\end{figure}

\begin{figure}[H]
\begin{subfigure}{0.62\textwidth}
    \includegraphics{bla3.jpg}
    \caption{bla}
    \label{fig:bla3}
\end{subfigure}
\end{figure}

\end{document}

EDIT It turned out that the above solution is not entirely satisfying when calling \ref{} with one of the labels defined (see this question). In order to fix that, just add these lines to your preamble:

\makeatletter
\renewcommand{\p@subfigure}{}
\makeatother
share|improve this answer
    
Thank you, this solved the problem! Unluckily I have a follow-up problem concerning the referencing of the subfigures, if anybody is interested: tex.stackexchange.com/questions/134425/… –  Tommi Un Sep 21 '13 at 16:33

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.