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 beamer package to produce slides. I put many figures on a slide by using the subfigure package. The problem is that for captions, the subfigure are labeled "a", "b".. "m", "n" and so on, for subfigures appearing on different slides. How could I reset the subfigure numbering when passing to a new slide?

share|improve this question
3  
Using figure and subfigure in beamer seems like a conflict of interest. Figure is for floating material, which you don't want for beamer. Why not just use the columns environment? –  Matthew Leingang Oct 25 '10 at 13:19
    
I did not know about this environment. Thank you. –  lmsasu Oct 30 '10 at 9:20
    
I have 4 graphs and I want to put them on one beamer slide with a note at the top of each. How do I do this in beamer? –  user5242 May 2 '11 at 2:50
    
Adding the reset counter in every frame can be tedious when you have too many and you must add them at different times. The answer that gave Stefan didn't work with me, but I found this solution in another question, so I post it here: what you should add is, instead of figure, framenumber: \makeatletter \@addtoreset{subfigure}{framenumber} \makeatother always in the preamble. I've just tried it and it works. Regards! –  oxio Jan 31 '13 at 14:46
add comment

3 Answers 3

up vote 7 down vote accepted

Instead of doing this for every figure, you could define it once in the preamble:

\makeatletter
\@addtoreset{subfigure}{figure}
\makeatother

Alternatively, using the chngcntr package:

\usepackage{chngcntr}
\counterwithin{subfigure}{figure}

Though I would expect such a reset per figure as default subfigure behavior, but you did not post your code.

share|improve this answer
    
I guess this is a conflict between beamer and subfigure; beamer has its own definitions of figure environments (which are non-floating in beamer). –  Jukka Suomela Oct 25 '10 at 14:09
1  
Neither of these solutions works for me under MikTeX 2.9. The first one just doesn't work, and the second one gives me an error to the effect that subfigure is not a counter. –  SSilk Sep 27 '11 at 2:08
    
@SSilk: perhaps you didn't load the subfigure package. –  Stefan Kottwitz Sep 27 '11 at 6:49
add comment

Solved: added \setcounter{subfigure}{0} before each \begin{figure}.

share|improve this answer
    
Adding \setcounter{subfigure}{0} before each \begin{figure} worked perfectly for me. It is especially usefull when you want to reset it inside a frame (e.g. when you are making a poster using beamer you only have one frame). –  user27314 Mar 13 '13 at 14:03
add comment

@Jim Silverton: You could use the subcaption package (a companion to the caption package):

\documentclass{beamer}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{frame}
\begin{figure}
  \begin{subfigure}[b]{.45\linewidth}
    \centering
    \caption{First subfigure}
    \label{fig:a}
    \includegraphics[height=3cm]{figure1}
  \end{subfigure}\hfill
  \begin{subfigure}[b]{.45\linewidth}
    \centering
    \caption{Second subfigure}
    \label{fig:b}
    \includegraphics[height=3cm]{figure2}
  \end{subfigure}\\
  \begin{subfigure}[b]{.45\linewidth}
    \centering
    \caption{Third subfigure}
    \label{fig:c}
    \includegraphics[height=3cm]{figure3}
  \end{subfigure}\hfill
  \begin{subfigure}[b]{.45\linewidth}
    \centering
    \caption{Fourth subfigure}
    \label{fig:d}
    \includegraphics[height=3cm]{figure4}
  \end{subfigure}%
\caption{A figure}\label{fig:1}
\end{figure}
\end{frame}

\end{document}

share|improve this answer
    
The answer can't be moved to another question. You need to copy it manually and delete this one. Just click on edit and copy&paste the whole text should work including the images. –  Martin Scharrer May 2 '11 at 10:10
    
Note that the @usename notification doesn't work in answers or questions. –  Martin Scharrer May 2 '11 at 10:13
    
@Martin Scharrer: I'll then wait and see if Jim Silverton moves his answer to a new question and then I'll move my answer accordingly. Thank you. –  Gonzalo Medina May 2 '11 at 14:14
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.