I would like to do something like a code snippet on the left hand side and corresponding data on the right hand side. I use minipage currently but it looks not so nice, minipages are not centered.
Did anyone have some suggestions how can I improve the outcome ?
Here is latex file:
Code: Select all
\documentclass[a4paper,11pt]{article}
\usepackage{hyperref}
\hypersetup{linktocpage}
\usepackage{listings}
\usepackage{amsmath}
\usepackage{array}
\usepackage{tikz}
\usepackage{rotating}
\usepackage{graphicx}
\usepackage{booktabs} % for much better looking tables
\usetikzlibrary{arrows}
\begin{document}
%\begin{table}[ht]
\begin{minipage}[b]{0.5\linewidth}
\centering
\lstset{language=C,label=SliceExaple}
%\lstinputlisting{example_source.c}
\begin{lstlisting}[frame=single, numbers=left, mathescape, label=scopingExample, linewidth = 4cm]
x:=1;
if(x>0)
{
x:=5;
while(x>0)
{
x:=x-1;
}
x:=10;
}
else
{
write x;
}
x:=15;
\end{lstlisting}
\caption*{Example WHILE code snippet with nested scopes.}
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[b]{0.5\linewidth}
\centering
\begin{lstlisting}[frame=single, mathescape, label=scopesEnteredContents, linewidth = 4cm]
[0]
[0]
[1;0]
[1;0]
[2;1;0]
[1;0]
[3;0]
[0]
\end{lstlisting}
\caption{Contents of scopesEntered for each block.}
\end{minipage}
%\caption{Example of scope assigning using scopesEntered list.}
%\end{table}
\end{document}