Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
Hi Simon, Welcome to TeX.sx! I've removed the thanks. It's just the style here, and thanks is best expressed as upvotes for those answers you find helpful. –  qubyte Feb 23 '12 at 12:39
    
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Jubobs Jan 17 at 17:37

1 Answer 1

up vote 5 down vote accepted

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.

share|improve this answer
    
Thanks for the help! I can't upvote yet, so a text thanks will have to do :) –  Simon Feb 23 '12 at 13:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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