Hi all, Hans Hagen wrote:
Peter Rolf wrote:
another one
\def\limitatefirstline#1#2#3% {\hbox\bgroup\strut \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 \box\plusone \fi\fi \removeunwantedspaces#3}}% \removeunwantedspaces\hss#3}}% \else #1% \fi \egroup}
Hans
Seems to work now :) There is only one thing left. The clip mechanism is only called, if breaking fails (which is not enought). An example: My name is ThisPartIsVisiblexxxxxxxxxxxxxxxxxx. ^^ ^^ break cut here Breaking is successful, so \limitatefirstline acts nearly like \limitatetext and you get My name is... instead of My name is ThisPartIsVisible... There must be another test, which checks the quality (width) of the breaking. If there is too much wasted space, clipping should be used instead. \else\ifdim\wd\plusone<\dimexpr\hsize-2ex\relax% breaking tolerance \lower\strutdepth\hbox{\clip[\c!width=\hsize,\c!height=\lineheight]{\hbox{\raise\strutdepth\hbox{\begstrut#1\endstrut}}}}% I don't know, if boxing #1 is enought (more than one line problem)... and we have to add \dontcomplain somewhere. The tolerance of 2ex acts very greedy, so in most cases, clipping is used (not usefull in common , but that's the way I need it). Maybe 6-8ex are a better value for the final (no need to force 2ex to others). Thanks Hans. This was a hard birth, but the baby is looking nice :) Peter