8

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{%
\strut\vadjust{\vbox to 0pt{
\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.

MunHo
  • 479
  • 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? – Steven B. Segletes Jan 04 '14 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! – MunHo Jan 04 '14 at 14:32

1 Answers1

8

enter image description here

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

\makebox(0,0)[tr]{$\star$}\par
\nointerlineskip
\rule{1cm}{5em}
\end{document}
David Carlisle
  • 757,742
  • 2
    +1 for not removing the charmingly cryptic ingen indentering av nya exempel comment from the code :-) – Mico Jan 03 '14 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! – MunHo Jan 03 '14 at 23:00
  • @MunHo change \par to \par\nobreak\vskip-\parskip – David Carlisle Jan 03 '14 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! – MunHo Jan 04 '14 at 09: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? – MunHo Jan 05 '14 at 10:25