2

I'm trying to create a two column Beamer slide, with the first column displaying a short minted code listing, and the second column displaying a TikZ diagram.

Unfortunately the minted code listing is getting pushed to the bottom of the slide, despite the use of [t] placement specifiers both the \begin{columns} and \columns directives. Ideally I'd like the code aligned to the top of the diagram.

LaTeX code is as follows:

\documentclass{beamer}
\usepackage{minted}
\usepackage{hyperref}
\usepackage{tikz}
\usepackage{verbatim}

\usetheme{CambridgeUS}

\usetikzlibrary{calc,positioning,shapes,shadows,arrows}

\usemintedstyle{default}
\definecolor{mintedbg}{rgb}{0.8,0.8,0.8}
\newminted{cpp}{bgcolor=mintedbg}
\newminted{make}{bgcolor=mintedbg}

\begin{document}

\begin{frame}[fragile]
\frametitle{Pointers}
\begin{columns}[t]
\column[t]{0.25\paperwidth}
\begin{cppcode}
int a = 5;
int * ptr = &a; 
\end{cppcode}
\column[t]{0.7\paperwidth}
\begin{tikzpicture}
\tikzstyle{r}=[rectangle, outer sep=0pt, inner sep=0pt, minimum width=2.5cm, minimum height=0.5cm, draw=black!100, fill=blue!20]
\tikzstyle{textr}=[rectangle, outer sep=0pt, inner sep=0pt, minimum width=2.5cm, minimum height=0.5cm, draw=black!100]
\matrix[draw=black!100, row sep=1pt, column sep=1pt]
{
\node[textr] {Address}; \pgfmatrixnextcell \node[textr] {Data Value}; \pgfmatrixnextcell \node[textr] {Notes}; \\
\node[r, name=addr1] {0xFFFFFFA0}; \pgfmatrixnextcell \node[r, name=data1] {5}; \pgfmatrixnextcell \node {int a=5}; \\
\node[r, name=addr2] { }; \pgfmatrixnextcell \node[r, name=data2] { }; \pgfmatrixnextcell \node {}; \\
\node[r, name=addr3] { }; \pgfmatrixnextcell \node[r, name=data3] { }; \pgfmatrixnextcell \node {}; \\
\node[r, name=addr4] { }; \pgfmatrixnextcell \node[r, name=data4] { }; \pgfmatrixnextcell \node {}; \\
\node[r, name=addr5] {0xFFFFFFB0}; \pgfmatrixnextcell \node[r, name=data5] {0xFFFFFFA0}; \pgfmatrixnextcell \node {int * ptr=a;}; \\
\node[r, name=addr6] { }; \pgfmatrixnextcell \node[r, name=data6] { }; \pgfmatrixnextcell \node {}; \\
\node[r, name=addr7] { }; \pgfmatrixnextcell \node[r, name=data7] { }; \pgfmatrixnextcell \node {}; \\
\node[r, name=addr8] { }; \pgfmatrixnextcell \node[r, name=data8] { }; \pgfmatrixnextcell \node {}; \\
\node[r, name=addr9] { }; \pgfmatrixnextcell \node[r, name=data9] { }; \pgfmatrixnextcell \node {}; \\
};
\draw[line width=2pt, ->] (data5.north) .. controls (data3.north) and (addr3.south) .. (addr1.south);
\end{tikzpicture}
\end{columns}
\end{frame}

\end{document}
2

1 Answer 1

6

You have to set the baseline of your picture to the top of the picture:

\begin{tikzpicture}[baseline=(current bounding box.north)]

Normally a baseline of a tikz picture is set to the bottom, and it seems that minted sets its baseline to the top, resulting in the problem you experienced.

1
  • Thanks for the help! I can't upvote yet, so a text thanks will have to do :)
    – Simon
    Feb 23, 2012 at 13:49

You must log in to answer this question.

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