3

I want to show my text using the overlay function of Beamer.

Example

Following this sequence:

  • Intro phrase 0 --> Item 1 --> Item 2 --> Code 4 and so on

Moreover, I would like to know how to align vertically the text content on the left column with the code on the right column (for example Code 3 in between Item 1 and Item 2, code 6 aligned with Item 5 ...). Up to now, I am using only spaces of the Verbatim environment.

In order to work with overlay and verbatim environment, it should be used the onlyenv environment. While the overlay in the columns environment is set with <1-> etc.

Nonetheless, I am not able to show as I want my content.

Note: Once displayed I want the item/code to be shown for the rest of the slide, not on the contrary, to disappear.

MWE:

\documentclass[11pt, xcolor=dvipsnames]{beamer}

\usetheme[titleformat=regular, numbering=fraction,
progressbar=frametitle, sectionpage=none]{metropolis}

\usepackage{verbatim}
\usepackage{fancyvrb}
\usepackage{listings}

% ----

\begin{document}

\begin{frame}[fragile]
\frametitle{Overlay Example}
\vspace{0.8em}
\begin{columns}
\begin{column}[t]{0.70\textwidth}
Intro phrase 0
\begin{enumerate}
\item Item 1
\item Item 2 \medskip
\end{enumerate}

Intro phrase 4
\begin{itemize}
\item Item 5
\item Item 7
\item Item 9
\end{itemize}
\end{column}
\vrule{}
\begin{column}[t]{0.30\textwidth}
\begin{Verbatim}[fontsize=\small]
  Code 3


\end{Verbatim}
\begin{Verbatim}[fontsize=\small]


  Code 6


  Code 8    


  Code 10

\end{Verbatim}
\end{column}
\end{columns}   
\end{frame}

\end{document}
2
  • 1
    Can you divide your questions into separate ones for the alignment and the uncovering? May 10, 2017 at 10:08
  • Yes I can, but the main issue is related to the overlay. As I wrote, I can workaround the vertical alignment by using extra spaces in the Verbatim environment. May 10, 2017 at 12:06

1 Answer 1

3

This answer addresses only the alignment issues, not the overlay.

It uses the verbatimbox package to put the code content in LaTeX boxes. Then I introduce the macro \setverbbox[<extra -rule-depth>] to set the most recently created verbbox on the right-hand side of the item.

The format for the item input will be

\item <Item text>
\begin{verbbox}[\footnotesize]
<Code>
\end{verbbox}
\setverbbox[<extra-rule-depth>]

This format assumes the item text is one line, less than the width up to the rule. If not, one could place the item text into a top-aligned\parbox, as shown in the MWE for item 1.

\documentclass[11pt, xcolor=dvipsnames]{beamer}

\usetheme[titleformat=regular, numbering=fraction,
progressbar=frametitle, sectionpage=none]{metropolis}

\usepackage{verbatim}
\usepackage{fancyvrb}
\usepackage{listings}
\usepackage{verbatimbox,stackengine}
% ----
\newcommand\codewidth{3cm}
\newcommand\setverbbox[1][12pt]{\hfill\belowbaseline[-.7\ht\strutbox]{%
  \smash{\rule[-#1]{1pt}{\dimexpr#1+\ht\savedverbbox+3pt}}%
  \dp\savedverbbox=10pt\relax%
  \makebox[\codewidth][l]{\theverbbox}}\qquad\mbox{}}
\begin{document}
\begin{frame}[fragile]
\frametitle{Overlay Example}
Intro Phrase 0
\setverbbox[25pt]\\
\begin{enumerate}
\item \parbox[t]{5cm}{Item 1 is a bit longer than a single line\strut}
\begin{verbbox}[\footnotesize]
Code 3
\end{verbbox}
\setverbbox[18ex]

\item Item 2 
\end{enumerate}

Intro phrase 4\\
\begin{itemize}
\item Item 5
\begin{verbbox}[\footnotesize]
Code 6
Code 6 cont.
line 3 of code 6
\end{verbbox}
\setverbbox

\item Item 7
\begin{verbbox}[\footnotesize]
Code 8
\end{verbbox}
\setverbbox
\item Item 9
\begin{verbbox}[\footnotesize]
Code 10
2nd line code 10
\end{verbbox}
\setverbbox
\end{itemize}
\end{frame}
\end{document}

enter image description here

You must log in to answer this question.

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