# Using \parbox in \resizebox

I tried resizing a \parbox-d text into a 5cm x 5cm square box (without keeping the aspect ratio). The output is absolutely strange to me, even if I don't specify the height. Couldn't find the cause/culprit. Why does the output happen to be this? Is there a way to do this somehow?

\documentclass{article}

\usepackage{lipsum}
\usepackage{lmodern}
\usepackage[demo]{graphicx}

\begin{document}

\resizebox{5cm}{!}{\parbox{20cm}{\lipsum{1}}}
\includegraphics[width=5cm, height=5cm]{}

\newpage

\resizebox{5cm}{5cm}{\parbox{20cm}{\lipsum{1}}}
\includegraphics[width=5cm, height=5cm]{}

\end{document}


I've some tried some possibilities like \parbox[t][][t]... but the output was even worse that way.

• The \parbox is, by default, centered on the baseline, whereas the \includegraphics sits on the baseline. Try \parbox[b] Nov 12 '13 at 16:17
• @StevenB.Segletes: Thank you, this is the answer. I've tried several settings, but I didn't really knew what I was doing.
– masu
Nov 12 '13 at 16:21
• @StevenB.Segletes You should turn that in to a real answer. Nov 12 '13 at 19:11

As I mentioned in my comment, the default vertical alignment is different for \parbox and \includegraphics. By default, the \parbox is centered vertically about the baseline. The \includegraphics always sits atop the baseline.

In the first graphic below, I show the problem that you were trying to fix, with the baseline given for reference. In the second image, I show that by using a [b] option on the \parbox, you can achieve bottom alignment, as you desired.

In the third image, I show that, for those times where you need to achieve top alignment on a graphic, you can use the \belowbaseline feature of the stackengine package to achieve it.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{stackengine}
\def\baseline{\rule{2cm}{.1ex}}
\parskip 1cm
\begin{document}
BASELINE:
\baseline
\parbox{2cm}{This should be a centered parbox, by default}
\baseline
\includegraphics[width=2cm, height=2cm]{}
\baseline

BASELINE:
\baseline
\parbox[b]{2cm}{This should be a bottom-justified parbox}
\baseline
\includegraphics[width=2cm, height=2cm]{}
\baseline

BASELINE:
\baseline
\parbox[t]{2cm}{This should be a top-justified parbox}
\baseline
\belowbaseline[-\ht\strutbox]{\includegraphics[width=2cm, height=2cm]{}}
\baseline
\end{document}