labeling underlined text over multiple lines
I've just released soulpos
, which allows this with a different approach based on savepos (pdftex or compatible required). Two passes are required:
\documentclass[two column]{article}
\usepackage{amsmath,soul}
\usepackage{soulpos}
\ulposdef{\ulnumaux}{%
$\underset{\saveulnum}{\rule[-.7ex]{\ulwidth}{.4pt}}$}
\newcommand{\ulnum}[2]{%
\def\saveulnum{#1}%
\ulnumaux{#2}}
\begin{document}
\ulnum{4}{This is short text}
\ulnum{6}{I want something to look like this text does, but I
don't want to manually break lines.} More. \ulnum{7}{And more text here.}
\end{document}
Far from perfect, but it's a start. This version doesn't work if start and end are on same line, and doesn't work if a page break happens between them. Both would be fixable.
I looked at this the other day but couldn't remember the trick to measure the position of a point along the line, then by coincidence @FrankMittelbach popped up and gave a full account of it here
How do you change indentation in the middle of a paragraph?
So here's that same code, re-arranged a bit to produce the image above (plain TeX in this version)
\hsize=.5\hsize
\newdimen\lastlinewidth
\baselineskip1.5\baselineskip
\def\ustart{%
\ustartend{%
\hbox to \hsize{\hskip\lastlinewidth
\leaders\hrule height 0pt depth 1pt\hskip 0pt plus 2fill
\kern-\hsize
\hskip\lastlinewidth\hfill\smash{\raise-7pt\hbox{\tempn}}\hfill
}}}
\def\uend{%
\ustartend{%
\count0=\prevgraf
\unskip\hbox to \hsize{%
\smash{\raise-\baselineskip\vbox{%
\loop
\ifnum\count0>2
\advance\count0 -1
\hbox to \hsize{%
\leaders\hrule height 0pt depth 1pt\hskip 0pt plus 2fill
\kern-\hsize
\hfill\smash{\raise-7pt\hbox{\tempn}}\hfill
}%
\repeat
\hbox to \lastlinewidth{%
\leaders\hrule height 0pt depth 1pt\hskip 0pt plus 2fill
\kern-\lastlinewidth
\hfill\smash{\raise-7pt\hbox{\tempn}}\hfill
}\hfill}}}}}
\def\ustartend#1#2{%
\def\tempn{#2}%
\leavevmode\hbox{}%
\begingroup
\predisplaypenalty=10000
\postdisplaypenalty=10000
\abovedisplayskip=-\baselineskip
\abovedisplayshortskip=-\baselineskip
\belowdisplayskip=0pt %-\baselineskip
\belowdisplayshortskip=0pt %-\baselineskip
$$
\global\lastlinewidth\predisplaysize
\global\advance\lastlinewidth by -2em
#1%
$$%
\endgroup
\vskip-\baselineskip
\vskip-\parskip
\noindent\kern\lastlinewidth
}
\def\n{One two thr\-ee four five six seven eight nine ten. }
\def\c{Red blue yellow green. }
\n\c\ustart{3}start underline \n\n
\n\n\n\n
\n\n end underline\uend{3} first text after end
\n\n
\n\n\n\n\c\ustart{4}start again\c\n\n\c\c\n
\n\n\n end underline\uend{4} first text after end
\n\c\c\n\n\c\c\n
\n\n\n\n\c\c\n\n\c\c\n
\bye