1

How can I use \pause command in beamer to pause displaying my code now putted in a minted environment? I have searched on TSE and I found two solutions for quite similar problems but not exactly mine, so I still decided to ask again.

In the first solution, the answer suggested to use to environments, which doesn't help in my case.

In the second solution, the answer suggested to use the option [escapeinside=||] which seemed useful with white minted default environment, however, mine is not default and for the default white environment I can use multi environment and usual pause to get the same effects.

\begin{minted}[escapeinside=||]{lua}
|\pause|print("foo")
|\pause|print("bar")
|\pause|print("baz")
\end{minted}

And also, [escapeinside=||] doesn't work with my custom mintedbox environment.

Here is my MWE:

\documentclass{beamer}
\usepackage{minted}
\usepackage{tcolorbox}
%\usepackage{parskip}
\usepackage{tabularx}
\tcbuselibrary{minted,breakable,xparse,skins}
%\renewcommand{\FancyVerbFormatLine}[1]{>\/>\/> #1}
\usepackage{xcolor}
%\definecolor{bg}{gray}{0.98}
%\definecolor{bl}{rgb}{0.1,0.5,1}
\DeclareTCBListing{mintedbox}{O{}m!O{}}{breakable=true, listing engine=minted, listing only, minted language=#2, 
minted style=default, minted options={gobble=0, breaklines=true, breakafter=,, fontsize=\small, numbersep=8pt,
#1},
boxsep=0pt, left skip=0pt, right skip=0pt, left=0pt, right=0pt, top=0pt, bottom=0pt, arc=0pt, leftrule=0pt, 
rightrule=0pt, bottomrule=0pt, toprule=0pt, enhanced}
\begin{document}

\begin{frame}[fragile]

\frametitle{Foo}

\begin{minted}[escapeinside=||]{lua} |\pause|print("foo") |\pause|print("bar") |\pause|print("baz") \end{minted}

Here is mintedbox environment

\begin{mintedbox}[escapeinside=||]{lua} |\pause|print("foo") |\pause|print("bar") |\pause|print("baz") \end{mintedbox} \end{frame}

\end{document}

I do want to custom something like

begin{custompy}
command 1 \pausecommand 
command 2 \pausecommand
\end{custompy} 

which has the same effect as the normal \pause command in beamer and doesn't affect this \pause in the whole frame or document.

Please help me.

Thanks.

trequartista
  • 1,891

1 Answers1

2

Instead of worrying about the tcblisting, you could add a background colour to the minted code:

% !TeX program = txs:///arara
% arara: pdflatex: {synctex: on, interaction: nonstopmode, shell: yes}
\documentclass{beamer}
\usepackage{minted}
\newminted{lua}{escapeinside=||,bgcolor=gray!15}

\begin{document}

\begin{frame}[fragile]

\frametitle{Foo}

\begin{luacode} |\pause|print("foo") |\pause|print("bar") |\pause|print("baz") \end{luacode}

\end{frame}

\end{document}

enter image description here


Instead of uncovering the lines, you could completely exclude them from the previous overlays:

% !TeX program = txs:///arara
% arara: pdflatex: {synctex: on, interaction: nonstopmode, shell: yes}
\documentclass{beamer}
\usepackage{minted}
\newcounter{foo}

\makeatletter \newcommand*{\slideinframe}{\number\beamer@slideinframe} \makeatother

\begin{document}

\begin{frame}[fragile,t] \frametitle{Foo}

This is some text \pause test \pause

\setcounter{foo}{\slideinframe} \addtocounter{foo}{1} \addtocounter{foo}{-\thebeamerpauses} \begin{minted}[lastline=\thefoo,bgcolor=gray!15]{lua} print("foo") print("bar") print("baz") \end{minted} \pause[5] \end{frame}

\end{document}

enter image description here