5

In Re-using the title of the previous Beamer slide, Andrew Stacey gave a solution for repeating frametitle and framesubtitle to the next frame.

However it does not work for framesubtitle. How should I modify the commands in order to make it work?

Example.

\documentclass{beamer}

\usepackage[utf8]{inputenc}

%\url{https://tex.stackexchange.com/q/66274/86}
\makeatletter
\def\beamer@checkframetitle{%
\begingroup
  \edef\temp{%
    \endgroup
    \noexpand\frametitle
    [\unexpanded\expandafter{\beamer@savedshortframetitle}]%
    {\unexpanded\expandafter{\beamer@savedframetitle}}%
  }
\temp
\@ifnextchar\bgroup\beamer@inlineframetitle{}}

\long\def\beamer@@frametitle[#1]#2{%
  \beamer@ifempty{#2}{}{%
    \gdef\insertframetitle{{#2\ifnum\beamer@autobreakcount>0\relax{}\space\usebeamertemplate*{frametitle
continuation}\fi}}%
  \gdef\beamer@frametitle{#2}%
  \gdef\beamer@shortframetitle{#1}%
  \global\let\beamer@savedshortframetitle\beamer@shortframetitle
    \global\let\beamer@savedframetitle\beamer@frametitle
}%
}
  \global\let\beamer@savedshortframetitle\@empty
    \global\let\beamer@savedframetitle\@empty

\makeatother
% \end{add previous title and subtitle}

\title{Test Title}
\author{Pablo}
\date{September 23, 2013}
\institute{Teste Institute}

\begin{document}

\frame{\titlepage}

\frame{
  \frametitle{Title}
  \framesubtitle{Subtitle}
  \begin{itemize}
    \item{Testing}
  \end{itemize}
}

\frame{
  \begin{itemize}
    \item{New item}
  \end{itemize}
}

\end{document}
  • 3
    Can you clarify "does not work"? I just tested it (albeit the code from tex.stackexchange.com/q/65975/86 rather than in the question you linked to) and the framesubtitle seems to carry over from the last frame where a title was given. Perhaps you could post an example where you aren't getting the behaviour that you expect, and say what you expected to see. – Andrew Stacey Sep 20 '13 at 18:57
  • Hi Andrew, thanks for the response. * sorry for the poor post, it is my first time in this forum. 1) I just edited the question adding an example code. 2) My problem is that in both examples from the links there is no \framsubtitle being used. I added a subtitle to the example you posted and it is not carried to the next slide. 3) In my example, I expect the "Subtitle" to be in both slides, however it just appear in the first one. What am I doing wrong? Thanks Again!! – Pablo Musa Sep 21 '13 at 18:29
  • No problem about the post. It's just hard to figure something out without code to experiment with. As you see from my answer, I didn't even know about \framesubtitle, and my initial assumption was that it was the short title (ie the optional argument to \frametitle), hence my confusion. – Andrew Stacey Sep 21 '13 at 19:43
  • I was very confused about what is the frame short title. I did some google and found some links. Please, correct me if I am wrong - it is a shortened version of the title for footers and should be used as: \frametitle[short title]{title}. – Pablo Musa Sep 21 '13 at 20:25
  • That's absolutely correct about the short title. – Andrew Stacey Sep 21 '13 at 21:22
7

When I wrote the original code then I was completely unaware of the \framesubtitle command. The original code can deal with a frame title and a short frame title, but not - as you say - the frame subtitle. In actual fact, the subtitle is easier because there is a hook in the code that is called after the subtitle is set so we can hook into that and use it to save the subtitle into a global register. Then it's just a few extra lines to the rest to ensure that the saved subtitle is restored at the start of the frame.

\documentclass{beamer}
%\url{http://tex.stackexchange.com/q/134308/86}
\usepackage[utf8]{inputenc}

%\url{http://tex.stackexchange.com/q/66274/86}
\makeatletter
\def\beamer@checkframetitle{%
\begingroup
  \edef\temp{%
    \endgroup
    \noexpand\frametitle
    [\unexpanded\expandafter{\beamer@savedshortframetitle}]%
    {\unexpanded\expandafter{\beamer@savedframetitle}}%
    \noexpand\framesubtitle
    {\unexpanded\expandafter{\beamer@savedframesubtitle}}%
  }
\temp
\@ifnextchar\bgroup\beamer@inlineframetitle{}}

\long\def\beamer@@frametitle[#1]#2{%
  \beamer@ifempty{#2}{}{%
    \gdef\insertframetitle{{#2\ifnum\beamer@autobreakcount>0\relax{}\space\usebeamertemplate*{frametitle
continuation}\fi}}%
  \gdef\beamer@frametitle{#2}%
  \gdef\beamer@shortframetitle{#1}%
  \global\let\beamer@savedshortframetitle\beamer@shortframetitle
    \global\let\beamer@savedframetitle\beamer@frametitle
  }%
}
  \global\let\beamer@savedshortframetitle\@empty
    \global\let\beamer@savedframetitle\@empty
    \global\let\beamer@savedframesubtitle\@empty

\def\beamer@aftersubtitle{%
  \global\let\beamer@savedframesubtitle\insertframesubtitle
}



\makeatother
% \end{add previous title and subtitle}

\title{Test Title}
\author{Pablo}
\date{September 23, 2013}
\institute{Teste Institute}

\begin{document}

\frame{\titlepage}

\frame{
  \frametitle[Subtitle]{Title}
  \framesubtitle{Subtitle}
  \begin{itemize}
    \item{Testing}
  \end{itemize}
}

\frame{
  \begin{itemize}
    \item{New item}
  \end{itemize}
}

\end{document}
| improve this answer | |
  • Working like a charm!! Thank you very much!! – Pablo Musa Sep 21 '13 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.