# Vertically Align Content of Minipage

With latex beamer I would like to top align the content in minipages or a similar environment to the same height as if there was no minipage present.

Minimal Example:

\documentclass[t]{beamer}
\usepackage{tikz}

\begin{document}
\setlength\pdfpageheight{1.60cm}%
\setlength\pdfpagewidth{6cm}%

\begin{frame}{A\strut}
\begin{itemize}
\item X
\end{itemize}
\end{frame}

\begin{frame}{B\strut}
\begin{minipage}[t]{2cm}
\vskip 0pt%
\begin{itemize}
\item X
\end{itemize}
\end{minipage}%
\nolinebreak%
\begin{minipage}[t]{2cm}
\vskip 0pt%
\begin{tikzpicture}
\node[fill=gray,minimum width=2cm,minimum height=1cm] {};
\end{tikzpicture}
\end{minipage}%
\end{frame}

\begin{frame}{C\strut}
\begin{tikzpicture}
\node[fill=gray,minimum width=4cm,minimum height=1cm] {};
\end{tikzpicture}
\end{frame}

\end{document}


As can bee seen, the \item X is differently top aligned in frame A and B, the tikzpicture is different top aligend in frame B and C, and most confusingly the difference in alignment also differs between the \item X and the tikzpicture.

• What is causing this different alignments?
• How can the alignment in frame B be changed to be the same as in frame A and C?
• Nov 29 '19 at 11:58

Is this what you look for

\documentclass[t]{beamer}
\usepackage{tikz}
\begin{document}

\begin{frame}
\begin{minipage}[t]{.1\textwidth}
A
\end{minipage}
\begin{minipage}[t]{.2\textwidth}
\begin{itemize}
\item X
\item Y
\item Z
\end{itemize}
\end{minipage}
\begin{minipage}[t]{.3\textwidth}
\begin{tikzpicture}
\node[fill=gray,minimum width=2cm,minimum height=1cm] {tikz};
\end{tikzpicture}
\end{minipage}

\end{frame}
\end{document}


Also please see--https://tex.stackexchange.com/a/272260/197451 for problem with the \itemize

If you feel the answer is as per your requirements please upvote the answer by clicking on the red triangle at the left and the tick mark below it

• The hint to the itemize problem was helpful. Dec 3 '19 at 10:32

## Top align not baseline aline

\begin{minipage}[t] aligns minipages to the baseline of the first content line. As already used in the question, starting the minipage with a \vskip 0pt% causes the baseline to be at the top of the minipage, therefore producing true top alignment.

## Put the minipage into horizontal mode

To get the same behaviour in the minipage as outside, the minipage must be put into horizontal mode with \leavemode%, followed by \vskip -\baselineskip% to correct the vertical offset.

## Putting it all together

The desired effect can be created by starting every minipage as follows:

\begin{minipage}[t]{2cm}
\leavevmode%
\vskip 0pt%
\vskip -\baselineskip%


Full minimal example:

\documentclass[t]{beamer}

\usepackage{tikz}

\begin{document}

\setlength\pdfpageheight{1.6cm}%
\setlength\pdfpagewidth{6cm}%

\begin{frame}{A\strut}
\begin{itemize}
\item X
\end{itemize}
\end{frame}

\begin{frame}{B\strut}
\begin{minipage}[t]{2cm}%
\leavevmode%
\vskip 0pt%
\vskip -\baselineskip%
\begin{itemize}
\item X
\end{itemize}
\end{minipage}%
\nolinebreak%
\begin{minipage}[t]{2cm}%
\leavevmode%
\vskip 0pt%
\vskip -\baselineskip%
\begin{tikzpicture}
\node[fill=gray,minimum width=2cm,minimum height=0.55cm] {};
\end{tikzpicture}
\end{minipage}%
\end{frame}

\begin{frame}{C\strut}
\begin{tikzpicture}
\node[fill=gray,minimum width=4cm,minimum height=0.55cm] {};
\end{tikzpicture}
\end{frame}

-\end{document}