3

How to align the top of the figure produced by tikz with the top of a text positioned next to it. Both the figure and the text are encapsulated by a minipage each. I just got an approximate but totally manual effect using \vspace at the end of theminipage that contains the figure.

Align top of the text and figure

\documentclass{article}
\usepackage{tikz, lipsum}
\begin{document}
\begin{minipage}{1\textwidth}
\fbox{
\begin{minipage}{0.8\textwidth}
%\hspace{.002in}
%\noindent
\textsf{\vspace{.3in}\\}
\setlength\parindent{5pt}
    \begin{minipage}{.5\textwidth}
    \textsf{\fontsize{10}{6}\selectfont \lipsum[1]}
            \end{minipage}
\setlength\parindent{9pt}
    \begin{minipage}{.5\textwidth}
        \begin{tikzpicture}[scale=0.5]
    \draw [help lines] (0,0) grid (8,17);
    \end{tikzpicture}
        \vspace{1.17in}
\end{minipage}
\end{minipage}
}
\end{minipage}
\end{document}
7

You can use a combination of adjustbox with the valign option and the TikZ baseline option. Also I think you're using too many minipages. I have stripped some of them off.

\documentclass{article}
\usepackage{adjustbox, tikz, lipsum}
\begin{document}

\fbox{%
  \begin{adjustbox}{valign=T,minipage=.5\textwidth}
    \textsf{\fontsize{10}{6}\selectfont \lipsum[1]}
  \end{adjustbox}%
  \hspace{1em}%
  \begin{tikzpicture}[scale=0.5,baseline={(current bounding box.north)}]
    \draw [help lines] (0,0) grid (8,17);
  \end{tikzpicture}%
}

\end{document}

enter image description here

  • Hi @HenriMenke, thank you for your solution. – Diego Bnei Noah Feb 25 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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