# Vertically align the top of a box to the top of the tallest box of a line

This is a follow-up question on this thread.

I want to mark a line by putting a star to the left of it. If the line contains a box that is tall, the marker should be aligned with the top of this box, not the bottom. How to align something to the top of the tallest box of a line?

MWE (edited):

\documentclass{article}

\def\marker{%
\kern-\dp\strutbox\smash{\llap{$\star$}}\vss}}%
\ignorespaces}

\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 1pt minus 3pt}

\begin{document}
Some text \marker\rule{1cm}{5em} some more text, all \newline in the same paragraph.  A paragraph, where\newline \rule{1cm}{2em} \marker some lines are marked with a star\newline that should be aligned with the tallest box of the line.
\end{document}


Compile this to see the problem: the stars should be aligned with the top of the black rectangles.

Edit: I changed the MWE to describe the problem in a more accurate way. A \par break and skipping back up to the old line does, unfortunately, not solve the problem.

• Will the tall box always be the first or only thing on the line, or could there be text prior to/following the tall box? Jan 4, 2014 at 14:20
• Actually, now that I think of it, if there is a tall box in the line, it will most often be right behind the star. Ideally, I would like the solution to work whereever the tall box is on the line. But a solution that handles the case of a box right behind the star would help a lot at the moment! Jan 4, 2014 at 14:32

\documentclass{article}
\begin{document}
\setlength{\parindent}{0pt}% ingen indentering av nya exempel

\makebox(0,0)[tr]{$\star$}\par
\nointerlineskip
\rule{1cm}{5em}
\end{document}

• +1 for not removing the charmingly cryptic ingen indentering av nya exempel comment from the code :-)
– Mico
Jan 3, 2014 at 22:27
• It looks promising, but I also have \setlength{\parskip}{6pt plus 1pt minus 3pt} in the code, so \nointerlineskip does not work. Sorry, missed to erase the comment! Jan 3, 2014 at 23:00
• @MunHo change \par to \par\nobreak\vskip-\parskip Jan 3, 2014 at 23:55
• It certainly works in the MWE, but in my document I get a Dimension too large error every new page when I add \nobreak\vskip-\parskip (and, contrary to the MWE, a vertical space is inserted between the star and the ensuing text). Without posting the whole of my code, I don't know how to exemplify this problem. Is there any other way to raise the star to the top of the tallest box of the line, without a issuing a new paragraph? Very grateful for your help, indeed! Jan 4, 2014 at 9:20
• I realised that a par break is not possible in my setting, see edited question. Is it not possible to access the height of the tallest box of the present line somehow? Jan 5, 2014 at 10:25