1

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???

1 Answers1

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

Zarko
  • 296,517