2

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]}%
    \qquad%
    \parbox{0.1\textwidth}{\rule{1cm}{1cm}}
\end{document}

Image next to text

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.

1
  • 2
    \parbox[t]{0.8\textwidth}{\lipsum[1]}% ? – user11232 Sep 19 '13 at 11:56
3

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]}%
    \qquad%
    \belowbaseline[-\ht\strutbox]{\parbox{0.1\textwidth}{\rule{1cm}{1cm}}}
\end{document}

enter image description here

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.