Changes

Jump to navigation Jump to search
587 bytes added ,  16:34, 14 September 2005
m
so it shares the problem with nonbreakable text.
But in contrast to <tt>\limitatetext</tt> it has a second mechanism, that is only used,
if the prior one failsor if the result of breaking is wasting too much space.
This fail safe mechanism "simply" clips (no breaking at all) the text to the desired
measures. This is done without any consideration to character boundaries.
<texcode>
\limitatefirstline {\underbar{Mr.~Drofnats was happiest when he was at work%
typesetting beautiful documents.}{110mm109mm}{\unknown}
</texcode>
 
<context>
\unprotect
 
\def\limitatefirstline#1#2#3%
{\hbox\bgroup\strut\dontcomplain \setbox\scratchbox\hbox{\begstrut#1\endstrut}% \ifdim\wd\scratchbox>#2\relax \setbox\scratchbox\hbox{#3}% \hsize#2\relax \advance\hsize-\wd\scratchbox \setbox\scratchbox\vbox{\forgetall\veryraggedright#1}% \setbox\scratchbox\vsplit\scratchbox to \lineheight \vbox {\unvbox\scratchbox \global\setbox\plusone\lastbox \global\setbox\plusone\hbox{\strut\unhbox\plusone}% \hbox % to #2 {\ifx\clip\undefined \box\plusone \else\ifdim\wd\plusone>\hsize \lower\strutdepth\hbox{\clip[\c!width=\hsize,\c!height=\lineheight]{\hbox{\raise\strutdepth\box\plusone}}}% \else\ifdim\wd\plusone<\dimexpr\hsize-6ex\relax% tolerance for "successful" breaking \lower\strutdepth\hbox{\clip[\c!width=\hsize,\c!voffsetheight=-4pt\lineheight]{\boxhbox{\raise\strutdepth\hbox{\begstrut#1\plusoneendstrut}}}}% \else \box\plusone \fi\fi\fi \removeunwantedspaces#3}}% \removeunwantedspaces\hss#3}}% \else #1% \fi \egroup}
\protect
 \limitatefirstline {\ss\x\underbar{Mr.~Drofnats was happiest when he was at work typesetting beautiful documents.}}{110mm107mm}{\unknown}
</context>
 
 
In this example breaking is successful (right after the word typesetting),
but the gap between the breaking point and the given width is too big.
So clipping is used here.
=== A direct comparison ===
37

edits

Navigation menu