[Tex/LaTex] Change frame subtitle after a framebreak

beamerframe-title

Consider the following MWE

\documentclass{beamer}

\setbeamertemplate{frametitle continuation}[from second][
  \insertcontinuationcountroman]
\usepackage{lipsum}

\begin{document}

\begin{frame}[allowframebreaks]
  \frametitle{Foo}
  \framesubtitle{Bar}
  \lipsum[1]
  \framebreak
  \framesubtitle{Baz}
  \lipsum[2]
\end{frame}
\end{document}

As it can be seen in the image, the first frame has the proper title, Foo, but the wrong subtitle (it should be Bar instead of Baz). How I can fix this? I know that for the second frame I can just create a new frame like this:

\begin{frame}[allowframebreaks]
  \frametitle{Foo II}
  \framesubtitle{Baz}
  \lipsum[2]
\end{frame}

and avoid my current problem. However I was wondering if it is possible to place an explicit frame break with a new subtitle for the continuation frame without resetting the subtitle for the first frame.

enter image description here

Edit After @Mark showed me this question I can do this:

\documentclass{beamer}
\begin{document}
\begin{frame}
  \frametitle{Foo}
  \only<+>{
    \framesubtitle{Bar}
  }
  \only<+>{
    \framesubtitle{Baz}
  }
\end{frame}
\end{document} 

to get the correct subtitles in each frame. The problem with this approach, as seen in the image, is that I want the title on the second frame to be Foo II instead of Foo (I like the allowframebreaks behavior of showing a roman numeral appended to the title of a continuation frame).

enter image description here

So my question is, can I use the overlay approach to fix the subtitle reset problem but also somehow append roman numerals to the titles of the continuation frames as allow allowframebreaks does?

Best Answer

Based on your edited question and Beamer - How can I add sub-frame numbers? you could do something like this:

\documentclass{beamer}

\makeatletter
\def\c@slideinframe{\beamer@slideinframe}
\def\beamerslideinframe{\beamer@slideinframe}
\makeatother

\begin{document}
    \begin{frame}
        \frametitle{Foo}
        \only<+>{
            \framesubtitle{Bar}
        }
        \only<+>{
            \frametitle{Foo \Roman{slideinframe}}
            \framesubtitle{Baz}
        }
    \end{frame}
\end{document} 

enter image description here


EDIT:

To make this automatically

\documentclass{beamer}

\makeatletter

\def\c@slideinframe{\beamer@slideinframe}
\def\beamerslideinframe{\beamer@slideinframe}

\newcommand*{\augmentframetitle}[1]{%
    \expandafter\frametitle\expandafter
    {\beamer@frametitle #1 \expandafter\ifnum\beamer@slideinframe>1\relax\Roman{slideinframe}\fi}%
}

\makeatother

\begin{document}

    \begin{frame}
        \augmentframetitle{bar}
        \only<+>{
            \framesubtitle{Bar}
        }
        \only<+>{
            \framesubtitle{Baz}
        }
    \end{frame}

\end{document}