2

I am confronted to a long-proof problem like in this question, which entails breaking a block between two frames, and also to the problem that I am creating an article and I do not want the proof environment to be broken there, like in that closed question.

How can I combine both ideas ?

3 Answers 3

1

After fumbling with the different versions of \mode, I managed to get it to work.

I do not really understand why I have to use one version at some place and the other at another place, and I am open to explanations, better ways of doing it or even automating it (ie. defining a shorter macro to do that).

\documentclass{beamer}
\makeatletter
\@ifclassloaded{beamer}{\usecolortheme{orchid}}{\usepackage{beamerarticle}}
\makeatother

\NewDocumentEnvironment{preuve}{O{Preuve}}{\begin{block}{#1}}{\end{block}}

\begin{document}
\begin{frame}
\begin{alertblock}{Berge, 1957}
Un couplage $C$ est de cardinal maximal si et seulement s'il n'admet pas de chemin augmentant.
\end{alertblock}
\pause
\begin{preuve}[Preuve du sens non couvert par le lemme]
some already long text

\mode
<presentation>
% article mode does not see this
\hfill …/…
\end{preuve}
\end{frame}

\begin{frame}
\begin{block}{}

\mode
<all>
Soit $p$ un chemin maximal dans $K$ : \uncover<2->{sa première et sa dernière arêtes sont dans $C_2$.}
\mode
<presentation>
\end{block}\pause[3]\vfill

\mode
<all>

\mode<article>{\end{preuve}}

Remarque : ce lemme et ce théorème n'utilisent pas le fait que le graphe est biparti.\\
Cette propriété va cependant permettre de faciliter la recherche d'un chemin augmentant.
\end{frame}
\end{document}
0

Here is a more elegant solution, using lua to hide the frame-splitting code from LaTeX in article mode.

\RequirePackage{luacode}

\begin{luacode*}
envname = ""
current = ""

function startGobble(cur, fut)
  envname = fut
  current = cur
  luatexbase.add_to_callback("process_input_buffer", gobble, "gobbler")
end

function gobble(line)
  if line:find("\\begin{"..envname.."}") ~= nil then
    luatexbase.remove_from_callback("process_input_buffer", "gobbler")
    luatexbase.add_to_callback("process_input_buffer", replace, "replacer")
    return "\\refstepcounter{framenumber}"
  else
    return ""
  end
end

function replace(line)
  if line:find("\\end{"..envname.."}") ~= nil then
    luatexbase.remove_from_callback("process_input_buffer", "replacer")
    return line:gsub("\\end{"..envname.."}", "\\end{"..current.."}")
  else
    return line
  end
end    
\end{luacode*}


\mode
<presentation>
\NewDocumentCommand{\mergeFrame}{mm}{}

\mode
<article>
\NewDocumentCommand{\mergeFrame}{mm}{\luadirect{startGobble("#1", "#2");}}

\mode
<all>

We can then say

\NewDocumentEnvironment{preuve}{O{Preuve}}{\begin{block}{#1}}{\end{block}}

\begin{document}
\begin{frame}
\begin{alertblock}{Berge, 1957}
Un couplage $C$ est de cardinal maximal si et seulement s'il n'admet pas de chemin augmentant.
\end{alertblock}
\pause
\begin{preuve}[Preuve du sens non couvert par le lemme]
some already long text
\mergeFrame{preuve}{block}
\end{preuve}
\end{frame}

\begin{frame}
\begin{block}{}

Soit $p$ un chemin maximal dans $K$ : \uncover<2->{sa première et sa dernière arêtes sont dans $C_2$.}
\end{block}

Remarque : ce lemme et ce théorème n'utilisent pas le fait que le graphe est biparti.\\
Cette propriété va cependant permettre de faciliter la recherche d'un chemin augmentant.
\end{frame}
\end{document}

In presentation mode, the \mergeFrame does nothing. In article mode, it sets up a line-gobbler until it sees \begin{block} (included). It then lets the content show up, until it sees \end{block}, which it replaces with \end{preuve}. Therefore, in article mode, LaTeX saw a single preuve environment. We \refstepcounter{framenumber} when going out from gobbling mode, although this should not be very relevant in article mode.

0

Beamer blocks are -- by default -- not breakable. However you can replace them by breakable tcolorboxes and use \framebreak to break your block as you like.

The \framebreak macro is defined to only act in presentation mode, thus it won't interfere with your article.

\documentclass{article}

\makeatletter
\@ifclassloaded{beamer}{\usecolortheme{orchid}}{\usepackage{beamerarticle}}
\makeatother
\usepackage{lipsum}
\usepackage[most]{tcolorbox}
\useinnertheme{tcolorbox}
\tcbset{breakable,title after break=\insertblocktitle}

\begin{document}

\begin{frame}[allowframebreaks]
\begin{proof}
\lipsum[1]
\framebreak
\lipsum[1]
\end{proof}
\end{frame}

\end{document}
1
  • Yes, but you cannot have \pause in a tcolorbox, afaik.
    – ysalmon
    Aug 2, 2023 at 18:17

You must log in to answer this question.

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