I am trying to create slides with sub-figures that will appear and disappear when the next slide will appear. So far everything looks perfect but my main problem is with sub-figure numbering. When the slides are initialized the numbering starts with (a) which is correct. On the second slide I would expect to see the subfigure as (b) but I see (a) again.
While I was looking online for people having the same problem, I found all this possible solutions:
Where I tried all solutions:
\setcounter{subfigure}{0}% Reset subfigure counter
\makeatletter
\@addtoreset{subfigure}{framenumber}% subfigure counter resets every frame
\makeatother
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\AtBeginEnvironment{figure}{\setcounter{subfigure}{0}}% Resets subfigure counter at start of figure environment
Unfortunately this did not work. I searched more and I found also:
Problem with subfigure numbering using ContinuedFloat
Where I tried:
\makeatletter
\newcommand\resetsubfigs{\setcounter{sub\@captype}{0}}
\makeatother
Which is similar to the previous solution, but unfortunately this did not work either.
Does anyone sees something that I am missing? Where I am going so wrong? Working sample of my code is provided under. In order to test the code just use an blank image.
\documentclass[xcolor=pdftex,dvipsnames,table]{beamer}
\usepackage[T1]{fontenc}
\makeatletter
\newcommand\resetsubfigs{\setcounter{sub\@captype}{1}}
\makeatother
%\makeatletter
%\newcommand\hyper@makecurrent[1]{}
%\makeatother
\usepackage{float}
\usepackage{caption} %caption for figures
%\usepackage{subfig}
\usepackage{subcaption} %subfigures
\usepackage{graphicx}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\mode<presentation>
\usetheme{Dresden} % so so
\setbeamertemplate{blocks}[rounded][shadow=true]
\setbeamertemplate{navigation symbols}{} %take out the navigation symbols
\captionsetup{labelformat=simple}
\usefonttheme[stillsansseriflarge]{structureitalicserif}
\expandafter\def\expandafter\insertshorttitle\expandafter{%
\insertshorttitle\hfill\insertframenumber\,/\,\inserttotalframenumber}%page numbering
%\makeatletter %reset the numbering on the subfigures (1)
%\@addtoreset{subfigure}{figure} %reset the numbering on the subfigures (2)
%\makeatother %reset the numbering on the subfigures (3)
\title[Title Description] % (optional, only for long titles)
{Main Title}
\subtitle{subtitle}
\vspace*{-2.2em}
\author[Author 1, Author 2]% (optional, for multiple authors)
{Number 1 \and Number 2}
\institute[Institution Here] % (optional)
{
\\
\medskip
{
\emph{author1@email.com}
\emph{author1@email.com}
}
}
\date[2014]{Presentation: 1, 2014}
\subject{Department \LaTeX}
\begin{document}
\begin{frame}[noframenumbering]
\begin{center}
% Upper part of the page
\vspace*{1.0em}
\includegraphics[width=0.15\textwidth]{image}\\ [0.3cm]
\emph{Supervisor:} \\
Dr.~First name \\
\textsc{Last name}
\end{center}
\titlepage
\end{frame}
\section{Section 1} \label{sec:one}
\subsection{Subsection 1}
\begin{frame}{Frame Text 1}
\setbeamercovered{dynamic}%Makes the text appear before it presents nice!!!!
\begin{columns}[t] % contents are top vertically aligned
\begin{column}[T]{5cm} % each column can also be its own environment
\begin{itemize}
\item<+-| alert@+> Text column subfigure 1:~\autoref{fig:colsub1}.
\item<+-| alert@+> Text column subfigure 2:~Figure:~1b.
\item<+-| alert@+> Text column subfigure 3:~Figure:~1c.
\item<+-| alert@+> Text column subfigure 4:~Figure:~1d.
\end{itemize}
\end{column}
\begin{column}[T]{5cm} % alternative top-align that's better for graphics
\begin{figure}
\resetsubfigs
\only<1>{%
\vspace*{-1.5cm}
\begin{subfigure}[b]{1.0\linewidth}
\caption{Column subcation 1} \label{fig:colsub1}
\hspace*{-1cm}
\includegraphics[width=7.0cm,height=5cm]{image}
%\includegraphics[width=\textwidth]{./pdf/core}
%\includegraphics[height=9.5cm]{./pdf/core}
\vspace*{-0.6cm}
\end{subfigure}\hfill
}
\only<2>{%
\vspace*{-1.5cm}
\begin{subfigure}[b]{1.0\linewidth}
\caption{Column subcation 2} \label{fig:receiver}
\hspace*{-0.5cm}
\includegraphics[width=5.5cm,height=5cm]{image}
\end{subfigure}
}
\only<3>{%
\vspace*{-1.5cm}
\begin{subfigure}[b]{1.0\linewidth}
\caption{Column subcation 3} \protect\label{fig:worst}
%\hspace*{1cm}
\vspace*{0.1cm}
\includegraphics[width=5.5cm,height=5cm]{image}
\end{subfigure}
}
\only<4>{%
\vspace*{-1.5cm}
\begin{subfigure}[b]{1.0\linewidth}
\caption{Column subcation 4} \protect\label{fig:best}
%\hspace*{0.5cm}
\vspace*{0.1cm}
\includegraphics[width=5.5cm,height=5cm]{image}
\end{subfigure}
}
\captionsetup{justification=centering} %Center a two line caption
\caption{Main Caption for Column subfigures} \protect\label{fig:5}%~\cite{wsn}
\end{figure}
\end{column}
\end{columns}
\end{frame}
\end{document}
Best Answer
Finally after all of experimentation I found the solution to my problem. I noticed that things get complicated when I use the final
\only<4>{}
. If I do not use the final\only<4>{}
the enumeration continues normally but not the expected output.So I searched for alternative solutions and I found the
\visible{}
, with reference to this question:Beamer: How to show images as step-by-step images
So my final solution is provided in case that someone else might have the same problem. For each picture you might need to play with
\vspace*{-1.0}
etc. in order to get the desired output.