# Align image next to text

The problem is to align an image right to a variable length of text at the top. Here is a minimal example:

\documentclass{minimal}
\usepackage{lipsum}
\begin{document}
\parbox{0.8\textwidth}{\lipsum[1]}%
\parbox{0.1\textwidth}{\rule{1cm}{1cm}}
\end{document}


I need the image to be in one line with the first sentence. I know I can individually raise the box. However, I'm searching for a general approach because I have quite a few of these cases in my document.

• \parbox[t]{0.8\textwidth}{\lipsum[1]}% ?
– user11232
Sep 19, 2013 at 11:56

Not only does the lipsum \parbox need to be top anchored, as Harish pointed out, but the rule box needs to be pushed downward. One could use a \raisebox with an explicit negative value of pushdown, but that will vary with the height of what is being pushed down. Here, instead, I set the top of the item (regardless of vertical size) to a position corresponding with the top of the \strut, meaning that the top of the rule box will split the gap between the two paragraphs shown in my MWE.

\documentclass{minimal}
\usepackage{lipsum}
\usepackage{stackengine}
\begin{document}
\lipsum[1]

\parbox[t]{0.8\textwidth}{\lipsum[1]}%