# tabular: vertical align minipage in table (top)

I have a poster consisting of two columns. In one of the columns I have placed two figures next to each other. To get a nice tikz-frame around each figure I had to put them into minipages each (I did not managed to get just the tikz-frame around a figure working without a minipage...)

My problem is now, that I would like to have both elements [tikz-framed-figure] to be vertically aligned at the top. I tried to align it with tabular{x} but so far without success.

\documentclass[englisch,a0]{KITposter}
\usepackage[latin1]{inputenc}
\usepackage[english,ngerman]{babel}
\usepackage{multicol}
\usepackage{xcolor}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{tabularx,booktabs}
\usepackage{tikz}
\usetikzlibrary{backgrounds}

\begin{document}

\begin{tabularx}{\textwidth}[t]{cc}
\begin{tikzpicture}
\node[framed,double,ultra thick,draw=red,rounded corners=25pt] {
\begin{minipage}[H]{.45\columnwidth}
\begin{figure}
\centering
\includegraphics[width=0.95\textwidth]{./setup_1.pdf}
\label{fig:setup_1}
\end{figure}
\end{minipage}
};
\end{tikzpicture}
&
\begin{tikzpicture}
\node[framed,double,ultra thick,draw=red,rounded corners=25pt] {
\begin{minipage}[H]{.45\columnwidth}
\begin{figure}
\centering
\includegraphics[width=0.95\textwidth]{./network_1.pdf}
\label{fig:network_1}
\end{figure}
\end{minipage}
};
\end{tikzpicture}
\end{tabularx}
\end{document}


edit

The solution suggested by Torbjørn (with a much more simplified structure without dead weight) works very well for me aligning the graphics within the tikz frames:

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{tikzpicture}[myframe/.style={double,ultra thick,draw=red,rounded corners=25pt,inner sep=10pt}]
\node [myframe] (imga) {\includegraphics[width=0.42\textwidth]{example-image}};
\node [right=of imga.north east,anchor=north west,myframe] {\includegraphics[width=0.42\textwidth]{example-image-10x16}};
\end{tikzpicture}


Cheers and thanks for the help!

• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – LaRiFaRi Mar 10 '15 at 12:55
• Welcome to TeX.SX! Note that you do not have to use the figure environment to use \includegraphics. In fact, as figure is a floating environment, it doesn't really make sense to put it inside a minipage in a node in a tikzpicture in a tabularx, all of which doesn't float. Remove the minipage and figure environments, and the \centering. – Torbjørn T. Mar 10 '15 at 12:55
• Hi Torbjørn, including the packages sounds reasonable ;) I have added them. The figure is mostly a remnant from playing around (with/without minipages etc.pp.) – THX Mar 10 '15 at 13:13
• (It wasn't me asking you to do that, but @LaRiFari.) Note also that it is best to avoid custom documentclasses unless they are required to demonstrate the problem. In this case I guess the standard article would be just as good? – Torbjørn T. Mar 10 '15 at 13:18
• ah, yes - sorry for the custom class (my universities corporate design requirements...) – THX Mar 10 '15 at 13:36

(My suggestion in the comment to LaRiFaRi's answer was a bit uncomplete, so here is a more complete answer.)

You can do this with a single tikzpicture, placing each image in a separate node. Instead of using the backgrounds library and modifying the style of the background rectangle, define a new style and apply this to each node. There is one addition of inner sep=10pt to keep the frame from covering the corners of the images.

The positioning is handled by the positioning library of TikZ. I set the second node to be right=of imga.north east, and then set anchor=north west. This means that the top of the two images are aligned.

The reason you got overlap is that you didn't use my code. You wrote right of= instead of right=of. See Difference between "right of=" and "right=of" in PGF/TikZ for an explanation of why that occurs

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[myframe/.style={double,ultra thick,draw=red,rounded corners=25pt,inner sep=10pt}]
\node [myframe] (imga) {\includegraphics[width=0.42\textwidth]{example-image}};
\node [right=of imga.north east,anchor=north west,myframe] {\includegraphics[width=0.42\textwidth]{example-image-10x16}};
\end{tikzpicture}
\end{document}


• Great! It is working like a charm, The graphics are aligned at the top. Good to know about the differences between "right=of" / "right of=" – THX Mar 11 '15 at 13:45

With tcolorbox

\documentclass{article}
\usepackage[many]{tcolorbox}
\begin{document}
\begin{tcbraster}[raster columns=2,
enhanced,
raster force size=false,
size=fbox,
raster column skip=4mm,
raster right skip= 0pt,
raster left skip=0pt,
raster valign=top,
boxrule=2pt,arc=2mm,
colframe=red,colback=blue!50!black,
\tcbincludegraphics[hbox,graphics options={width=0.42\linewidth}]{example-image-a}
\tcbincludegraphics[hbox,graphics options={width=0.42\linewidth}]{example-image-10x16}
\end{tcbraster}
\end{document}


Something like this?

% arara: pdflatex

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage{tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{document}
\begin{tabularx}{\textwidth}[t]{YY}
\begin{tikzpicture}[framed,background rectangle/.style={double,ultra thick,draw=red,rounded corners=25pt}] % change corner size to smaller values in order to prevent touching.
\node{\includegraphics[width=0.42\textwidth]{./setup_1.pdf}
%\label{fig:setup_1} % you do not need a label if there is no caption.
};
\end{tikzpicture}
&
\begin{tikzpicture}[framed,background rectangle/.style={double,ultra thick,draw=red,rounded corners=25pt}]
\node{\includegraphics[width=0.42\textwidth]{./network_1.pdf}
%\label{fig:network_1} % you do not need a label if there is no caption.
};
\end{tikzpicture}
\end{tabularx}
\end{document}


• Hi Torbjørn, the new defined column type did not improved the alignment with both graphics with different heights imgur.com/9Pfeezr – THX Mar 10 '15 at 13:24
• without table the horizontal alignment is not working (right of fails somewhat), also the vertical alignment is still centred \begin{tikzpicture}[myframe/.style={double,ultra thick,draw=red,rounded corners=25pt,inner sep=10pt}] \node[myframe](imga) { \includegraphics[width=0.45\columnwidth]{./overview_1.pdf} }; \node[right of=imga,myframe] { \includegraphics[width=0.45\columnwidth]{./network_1.pdf} }; \end{tikzpicture} imgur.com/f5wxGfP – THX Mar 10 '15 at 13:34