1

This question already has an answer here:

I'm trying to align this 2 minipage on the top, but it doesn't work.....Any body help?

\documentclass{article}
\usepackage{tikz}
\usepackage{graphicx}

\begin{document}
\begin{minipage}[t]{0.3\textwidth}
$2+2=4$
\end{minipage}
\begin{minipage}[t]{0.3\textwidth}
\begin{tikzpicture}
\draw (0,0) circle (3cm);
\end{tikzpicture}
\end{minipage}
\end{document}

It gives me this: enter image description here

I want this: enter image description here

How can I get this???

marked as duplicate by marmot, Kurt, Stefan Pinnow, TeXnician, Bobyandbob Mar 25 '18 at 8:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Please have a look here. – marmot Mar 25 '18 at 1:57
0

problem is position of tikzpicture baseline (which is in the middle of the circle). you should move it accordingly. the simplest way seems to be enclose image in adjustbox. a bit shorter code you obtain if instead two minipages use tabular environment. however use of adjustbox work in combination with minipage:

\documentclass{article}
\usepackage{tikz}
\usepackage{adjustbox}

\begin{document}
\centering
   \begin{tabular}{|p{0.25\linewidth}|p{0.5\linewidth}|}
$2+2=4$
&
\adjustbox{valign=t}{\begin{tikzpicture}% adjustbox move tikzpicture baseline to the top of tabular cell
\draw (0,0) circle (3cm);
\end{tikzpicture}}
    \end{tabular}
\end{document}

or

\documentclass{article}
\usepackage{tikz}
\usepackage{adjustbox}

\begin{document}
\centering
   \begin{minipage}[t]{0.25\linewidth}
$2+2=4$
    \end{minipage}
\adjustbox{valign=t}{\begin{tikzpicture}% adjustbox move tikzpicture baseline to the line in in minipage
\draw (0,0) circle (3cm);
\end{tikzpicture}}
 \end{document}

enter image description here

  • Better to use \vspace*{0pt} and top-align both minipages (\begin{minipage}[t]) – Arzigoglu Mar 25 '18 at 8:00

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