7

I have some text, and a corresponding tikzpicture, both of which are to be part of a test question, and which are thus included as part of an \item in an enumerate environment.

Like this:

\item 
\begin{minipage}[t]{0.55\linewidth}  
    description of question  
\end{minipage}  
\hspace*{1cm}  
\begin{minipage}[ht]{0.35\linewidth}  
   \begin{tikzpicture}[scale=0.3]  
    question diagram  
  \end{tikzpicture}  
\end{minipage}  

What I want is for the text to be vertically aligned as it would be without a minipage environment, and for the top of the tikzpicture to be aligned with the top of the text.

I can obtain this alignment with the option "baseline=4cm" in tikzpicture, but this has the result of putting in a large amount of vertical white space before the item, which then has to be countered with \vspace*{-2cm}.

Is there a better, automatic, way rather than fiddling with vertical space?

3
  • Hi Alasdair, you can use ` to format inline code and package/environment names. Code listings needs to be indented with 4 spaces to get syntax highlighted. You can use 101010 button on top of the edit window to do this automatically. Commented Feb 19, 2011 at 22:44
  • 3
    it would be great if you would post a small compilable example with a real TikZ diagram showing what you mean and which we could test.
    – Stefan Kottwitz
    Commented Feb 19, 2011 at 23:12
  • The answers to another question might be helpful. Commented Feb 20, 2011 at 14:26

1 Answer 1

7

It is a generic trick, to add a \vspace{0pt} at the beginning of the minipage environment. For example:

\begin{minipage}[t]{0.55\linewidth}  
\vspace{0pt}
    description of question  
\end{minipage}  
\hspace*{1cm}  
\begin{minipage}[t]{0.35\linewidth}  
\vspace{0pt}
   \begin{tikzpicture}
    \draw circle (1cm);
  \end{tikzpicture}  
\end{minipage}
2
  • Thanks! This helped me for some quite different problem with a badly aligned graphic in a minipage as well.
    – matheburg
    Commented Jul 15, 2013 at 13:36
  • 2
    Does anybody know why this trick is working?
    – Sebastien
    Commented Nov 4, 2014 at 21:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .