# Aligning image and text on top, with minipages

I have an image (on the left) and a block of text (on the right), and I would like both to be aligned on their top. I am trying to use minipages for that:

\documentclass{article}
\begin{document}
\begin{minipage}[t]{0.2\linewidth}
%\includegraphics[width=\textwidth]{Boltzmann}
\rule{\textwidth}{3cm}
\end{minipage}\hfill
\begin{minipage}[t]{0.7\linewidth}
\paragraph{Ludwig Boltzmann (1844~V1906)}\par
He was an Austrian physicist famous for his founding contributions in the
fields of statistical mechanics and statistical thermodynamics. He was
one of the most important advocates for atomic theory at a time when that
scientific model was still highly controversial.
\end{minipage}
\end{document}


(actual image replaced with black rectangle). That doesn't work, because it aligns the baseline of the image (which is its bottom) with the baseline of the text, which is the baseline of the first line. I then tried to change put the image in a raisebox, like so:

\raisebox{-\height}{\includegraphics[width=\textwidth]{Boltzmann}}


but that aligns the top of the image with the baseline of the text, which is still not what I want. I could add another raisebox, like so:

\raisebox{\baselineskip}{%
\raisebox{-\height}{\includegraphics[width=\textwidth]{Boltzmann}}}


but (a) that code is plain ugly, and (b) it still doesn't align exactly, so I don't know why.

So, yes, this is nitpicking on my part, but how can I get clean code that does exactly what I described in the beginning?

-
Welcome to tex.sx, good question! It's usually best to have compilable code (it's only a few more lines after all, and it makes it easier to start fixing the code). To achieve this, I replaced your \includegraphics with a \rule, hope that's OK. –  Hendrik Vogt Feb 21 '11 at 13:19
Beamer's blocks can do this sort of alignment, so there might be a solution lurking in doing something similar here... –  Seamus Feb 21 '11 at 13:27

Here's a nifty way to do it:

\documentclass{article}

\usepackage[demo]{graphics}

\begin{document}

\begin{tabular}{p{5cm} p{7cm}}
\vspace{0pt}
\includegraphics{test}
&
\vspace{0pt}
He was an Austrian physicist famous for his founding contributions in the fields of
statistical mechanics and statistical thermodynamics. He was one of the most
important advocates for atomic theory at a time when that scientific model was
still highly controversial.\\
\end{tabular}

\end{document}


What happens here is that you change the reference point of the image with the \vspace{0pt}, which allows top aligning the the text and the image.

When you want to use \paragraph to style the name, the vertical spacing is still broken. Hopefully somebody will shed some extra light how to fix that (I found that using \vspace{-3ex} before the text seems to do the job).

Disclaimer: I used the idea of Stefan Kottwitz from this blog post, and rephrased his explanation. That's why this is a CW answer.

-

The only solution I've seen is to add \vspace{0pt} at the top of each minipage.

From what i can see, it unfortunately adds a small spacing on top of both minipages, but the both columns are aligned exactly. This is how the genmpage package does it for the T and B options.

The multicol enviroment can also align from the top of the contents instead of the first baseline.

It would be interesting to see if there is a simpler solution, some way to tell minipage to align at the top, completely ignoring baselines.

-