I needed to create an animated code sample presentation, so I decided to use beamer
+ minted
. That's what I could finally come up with:
\documentclass{beamer}
\usepackage{ifthen}
\usepackage{minted}
\newcommand<>{\iterdemo}[3]{%
\begin{onlyenv}#4
\begin{columns}
\begin{column}{0.4\textwidth}
\ifthenelse{#3 = 1}
{\inputminted[highlightlines=#1,highlightcolor=structure!50!white]{Delphi}{iterdemo1.pas}}
{\inputminted[highlightlines=#1,highlightcolor=structure!20!white]{Delphi}{iterdemo1.pas}}
\end{column}
\begin{column}{0.4\textwidth}
\begin{onlyenv}<4-44>
\ifthenelse{#3 = 2}
{\inputminted[highlightlines=#2,highlightcolor=structure!50!white]{Delphi}{iterdemo2.pas}}
{\inputminted[highlightlines=#2,highlightcolor=structure!20!white]{Delphi}{iterdemo2.pas}}
\end{onlyenv}
\end{column}
\end{columns}
\end{onlyenv}
}
\begin{document}
\begin{frame}
\iterdemo<1>{0}{0}{1}
\iterdemo<2>{5}{0}{1}
\iterdemo<3>{6}{0}{1}
\iterdemo<4>{6}{0}{1}
\iterdemo<5>{8}{0}{1}
\iterdemo<6>{8}{2}{2}
\iterdemo<7>{8}{3}{2}
\iterdemo<8>{8}{3}{1}
\iterdemo<9>{9}{3}{1}
\iterdemo<10>{10}{3}{1}
\iterdemo<11>{10}{3}{2}
\iterdemo<12>{10}{4}{2}
\iterdemo<13>{10}{4}{1}
\iterdemo<14>{11}{4}{1}
\iterdemo<15>{12}{4}{1}
\iterdemo<16>{12}{4}{2}
\iterdemo<17>{12}{5}{2}
\iterdemo<18>{12}{5}{1}
\iterdemo<19>{13}{5}{1}
\iterdemo<20>{14}{5}{1}
\iterdemo<21>{14}{5}{2}
\iterdemo<22>{14}{6}{2}
\iterdemo<23>{14}{6}{1}
\iterdemo<24>{15}{6}{1}
\iterdemo<25>{16}{6}{1}
\iterdemo<26>{16}{6}{2}
\iterdemo<27>{16}{7}{2}
\iterdemo<28>{16}{7}{1}
\iterdemo<29>{17}{7}{1}
\iterdemo<30>{18}{7}{1}
\iterdemo<31>{18}{7}{2}
\iterdemo<32>{18}{8}{2}
\iterdemo<33>{18}{8}{1}
\iterdemo<34>{19}{8}{1}
\iterdemo<35>{20}{8}{1}
\iterdemo<36>{20}{8}{2}
\iterdemo<37>{20}{9}{2}
\iterdemo<38>{20}{9}{1}
\iterdemo<39>{21}{9}{1}
\iterdemo<40>{22}{9}{1}
\iterdemo<41>{22}{9}{2}
\iterdemo<42>{22}{10}{2}
\iterdemo<43>{22}{0}{1}
\iterdemo<44>{24}{0}{1}
\iterdemo<45>{24}{0}{1}
\iterdemo<46>{26}{0}{1}
\end{frame}
\end{document}
The code is obviously suboptimal due to heavy duplication (and it was pain to create it!). However, the following approaches to fight the hand-work didn't play for me:
Using
<+->
overlay specification instead of hard-coded numbers doesn't have effect: the content appears on every page.It seemed that
\foreach
loop would easily remove a lot of duplication in the central part of code, but I couldn't find a way to pass expanded value as aminted
option highlightlines. This is probably due topgfkeys
nature ofminted
options.
Is it possible to simplify the above code, e.g. by using a loop?
iterdemo1.pas
thus cannot test your code. What is the intended result of your code?