4

Here is a slide from a presentation I'm preparing:

\documentclass{beamer}
\usepackage{listings}
\begin{document}
\begin{frame}[fragile]{Example}
\begin{tabular}{ l r }
\begin{lstlisting}[mathescape=true]
harness void main(int x){
int y = x * ??$_0$;
assert y == x + x;
}
\end{lstlisting} & 
\begin{minipage}{.8\textwidth}
    $\phi:\{(??_0,\tau_{\emptyset}) \} \to \mathbb{Z}$. \newline
    $y \equiv \lambda \phi. x * \phi(??_0,\tau_{\emptyset})$ 
\end{minipage}%
 \\ \hline
\begin{lstlisting}[mathescape=true]
generator int linexp(int t){
 return t * ??$_0$ + ??$_1$ ;
}

generator int 
 linexp2(int t1, int t2){
 return linexp$_{g1}$(t1) + 
        linexp$_{g2}$(t2);
}

void main(int x, int z){
 int y = linexp2$_{g0}$(x, z);
 assert y == x + x + z;
}   
\end{lstlisting} &  
\begin{minipage}{.9\textwidth}
    $\tau_1 = g_0 \cdot g_1, \tau_2 = g_0 \cdot g_2$ \\
    $\phi:\{(??_0,\tau_1),(??_0,\tau_2), 
            (??_1,\tau_1),(??_1,\tau_2) \} \to \mathbb{Z}$ \\
    $y \equiv \lambda \phi. x * \phi(??_0,\tau_1) + \phi(??_1,\tau_1) 
       + z * \phi(??_0,\tau_2) + \phi(??_1,\tau_2)$ 
\end{minipage}%
\end{tabular}
\end{frame}
\end{document}

enter image description here

How can I get the text to the right to be aligned properly. Something like:

enter image description here

  • I also appreciate any comments on the style – Javier Jun 10 at 20:26
5

I would use aligned environments for the math material, and I'd use a lot more line breaks in the second math group. I would also use \colon instead of :, as the latter is treated by default as a relational operator, which doesn't seem to be the case here.

enter image description here

\documentclass{beamer}
\usepackage{listings}
\begin{document}
\begin{frame}[fragile]{Example}
\begin{tabular}{@{} ll @{}}
\begin{lstlisting}[mathescape=true]
harness void main(int x){
int y = x * ??$_0$;
assert y == x + x;
}
\end{lstlisting} & 
$\begin{aligned}
&\phi\colon\{(??_0,\tau_{\emptyset}) \} \to \mathbb{Z} \\
&y \equiv \lambda \phi\cdot x * \phi(??_0,\tau_{\emptyset})
\end{aligned}$ \\ 
\hline
\begin{lstlisting}[mathescape=true]
generator int linexp(int t){
 return t * ??$_0$ + ??$_1$ ;
}

generator int 
 linexp2(int t1, int t2){
 return linexp$_{g1}$(t1) + 
        linexp$_{g2}$(t2);
}

void main(int x, int z){
 int y = linexp2$_{g0}$(x, z);
 assert y == x + x + z;
}   
\end{lstlisting} &  
$\begin{aligned}
&\tau_1 = g_0 \cdot g_1,\\
&\tau_2 = g_0 \cdot g_2, \\
&\phi\colon\{(??_0,\tau_1),(??_0,\tau_2), \\
&\qquad(??_1,\tau_1),(??_1,\tau_2) \} \to \mathbb{Z} \\
&y \equiv \lambda \phi\cdot x * \phi(??_0,\tau_1) \\
&\qquad+ \phi(??_1,\tau_1) \\
&\qquad+ z * \phi(??_0,\tau_2) \\
&\qquad+ \phi(??_1,\tau_2)
\end{aligned}$
\end{tabular}
\end{frame}

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.