Subfigures in beamer documents

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?

-
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 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

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

\makeatletter
\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.

-
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
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

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

-
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

You shouldn't be using the obsolete subfigure package in modern LaTeX documents; you could use the subfig package instead (since you are using beamer the subcaption package is not an option since it's incompatible with beamer):

The code:

\documentclass{beamer}
\usepackage{subfig}

\begin{document}

\begin{frame}
\begin{figure}
\centering
\subfloat[Second subfigure\label{fig:b}]{\includegraphics[height=2cm,width=3cm]{example-image-a}}
\caption{A figure}
\label{fig:1}
\end{figure}

\begin{figure}
\centering
\subfloat[Fourth subfigure\label{fig:d}]{\includegraphics[height=2cm,width=3cm]{example-image-c}}
\caption{Another figure}
\label{fig:2}
\end{figure}
\end{frame}

\end{document}


When I first wrote this answer subcaption and beamer were not explicitly incompatible; since this has changed, now I updated my answer with subfig. Thanks to kww who noticed this in his/her comment.

-
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
@Gonzalo Medina I receive the "! Package caption Error: The 'subcaption' package does not work correctly" by loading \usepackage{caption} and \usepackage{subcaption}. –  kww Jul 20 at 19:21
@kww Yes, This was an old answer and 4 years ago there was no incompatibility between (sub)caption and beamer. Since that time, the packages became incompatible with beamer. However, subfig can still be used. Give me some minutes to update the answer. Thanks for pointing me out to this problem. –  Gonzalo Medina Jul 20 at 19:38