3

My goal is to show different source code versions. For readability, I prefer to have those versions on different frames, but for the organization of the presentation, it should seem like one frame. Changing the page counter can be done by \addtocounter{framenumber}{-1}.

This would be an example:

\documentclass{beamer}
\usepackage{listings}
\usepackage[english]{babel}

\usetheme{Berlin}
\setbeamertemplate{footline}[frame number]

\begin{document}

\section{Test}
\subsection{Test}

\begin{frame}[fragile]{My Code}

\begin{lstlisting}[mathescape=true]
class ClassA {
 public void methodA() {
  new ClassB().methodB1();
 }
}
 \end{lstlisting}
\end{frame}

\begin{frame}[fragile]{My Code}
\addtocounter{framenumber}{-1}

\begin{lstlisting}[mathescape=true]
class ClassA {
 public void methodA() {
  new ClassB().methodC1();
 }
}
 \end{lstlisting}
\end{frame}

\begin{frame}[fragile]{Final Remarks}
...
\end{frame}

\end{document}

But I could not find a solution for changing the navigation. Setting the counter with \setcounter{subsection}{1} did not set the correct counter, since this seems to set the subsection, not the frame number in the subsection. Is there any way of finding a counter, e.g. in a list of all defined counters?

Hide some slides from the miniframes navigation in beamer is very similar to the solution, but if I use this, the current navigation circle is not highlighted. Is there a solution where the circle for the current (last) frame stays highlighted, but there is no circle added in the navigation?

1 Answer 1

5

Messing with the miniframe navigation is tricky, I would not do it unless it is really necessary.

Instead simply use only a single frame and split it in several overlays:

\documentclass{beamer}
\usepackage{listings}
\usepackage[english]{babel}

\usetheme{Berlin}
\setbeamertemplate{footline}[frame number]

\begin{document}

\section{Test}
\subsection{Test}

\begin{frame}[fragile]{My Code}

\begin{onlyenv}<1>
\begin{lstlisting}[mathescape=true]
class ClassA {
 public void methodA() {
  new ClassB().methodB1();
 }
}
 \end{lstlisting}
\end{onlyenv}

\begin{onlyenv}<2>
\begin{lstlisting}[mathescape=true]
class ClassA {
 public void methodA() {
  new ClassB().methodC1();
 }
}
 \end{lstlisting}
\end{onlyenv}
\end{frame}

\begin{frame}[fragile]{Final Remarks}
...
\end{frame}

\end{document}
3
  • 1
    This is the best answer here. I had very hard ties with the \minifrimesoff function described here: tex.stackexchange.com/questions/37127/…
    – Miloš
    Oct 19, 2022 at 13:11
  • Great answer. \begin{onlyenv}<1> ... \end{onlyenv} \begin{onlyenv}<2> ... \eng{onlyenv} is the trick, and it is applicable for rmarkdown beamer users as well. Is there a way to change the slide title for the \begin{onlyenv}<2> part, by the way? Oct 29, 2022 at 20:02
  • 1
    @MatthewSon Sure, you can have different titles with \frametitle<1>{foo} \frametitle<2>{bar} Oct 29, 2022 at 20:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .