12

I'd appreciate help top aligning the contents of \parboxes containing texts of different sizes as shown in the following graphic. Because one of the texts has a different size it appears to hover above the other: enter image description here

Source (MWE):

\documentclass[english]{article}
\begin{document}

\mbox{\Huge \textsc{Text}}
\hfill
\parbox[t]{4.25cm}{
I am a fish

I am a fish

I am a fish

I am a fish
}

\end{document}
1
  • You can also use a tabular environment. Commented Jun 2, 2012 at 18:46

1 Answer 1

18

Sometimes you need to adjust by hand with \raisebox etc but an automated solution to align at the top of the box rather than the first baseline produces:

enter image description here

\documentclass[english]{article}
\begin{document}

\parbox[t]{3cm}{\hrule height 0pt width 0pt\relax
\Huge \textsc{Text}
}
\hfill
\parbox[t]{4.25cm}{\hrule height 0pt width 0pt\relax
I am a fish

I am a fish

I am a fish

I am a fish
}

\end{document}

As noted in the comments, by placing rules in the first line the \parbox[t] code aligns on the rule (so effectively at the top of the first real line rather than its baseline).

4
  • \vspace{0pt} is the shorter version ...
    – user2478
    Commented Jun 2, 2012 at 18:56
  • 3
    @Herbert true, although I tend to use rules myself, partly I think as you can fiddle with visible rules to get special effects and then finally make them 0width (but odd height or depth) Commented Jun 2, 2012 at 19:02
  • small addition: add a \relax at the end of the \hrule line to make TeX stop scanning for more rule dimensions. If the following text starts with height, width, or depth (instead of I am a fish TeX will continue scanning for \hrule dimensions removing text to be formatting and probably raising an error. Commented Jan 15, 2023 at 11:07
  • @BerndRaichle er yes, fixed thanks Commented Jan 15, 2023 at 11:11

You must log in to answer this question.

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