\limitatefirstline (or slave to the wiki)
Hi all,
I've tested the latest version of \limitatefirstline and it still
doesn't work as expected. This is really a complex story (problem).
- the clip mechanism cuts off the lowest part of some special chars
(clipping graphics is easy, but I don't understand what happens here)
- text is sometimes cropped at word boundaries (example 110pt),
instead of beeing clipped
The example file is appended and I use the latest beta. There is no
timeline, so fixing is not that urgent.
And yes, I've cancelled my hollidays and will live for the wiki only
from now on :)
wiki, wiki, wiki,....
Greetings,
Peter
% interface=en output=pdftex
% Time-stamp:
Peter Rolf wrote:
Hi all,
I've tested the latest version of \limitatefirstline and it still doesn't work as expected. This is really a complex story (problem).
- the clip mechanism cuts off the lowest part of some special chars (clipping graphics is easy, but I don't understand what happens here) This one is unsolved. I added height to the clipping (\struttotal; maybe not enought for \underbar). Now I get complete characters, but the cropped text and the sentinel are not on the same baseline anymore.
- text is sometimes cropped at word boundaries (example 110pt), instead of beeing clipped I have fixed this one. There must be another check in case of a successful break (else it acts like \limitatetext). Haven't thought about this :)
So just ignore the prior mail (example) and look at the attached code
instead.
Greetings,
Peter
% interface=en output=pdftex
% Time-stamp:
Peter Rolf wrote:
Hi all,
I've tested the latest version of \limitatefirstline and it still doesn't work as expected. This is really a complex story (problem).
- the clip mechanism cuts off the lowest part of some special chars (clipping graphics is easy, but I don't understand what happens here) - text is sometimes cropped at word boundaries (example 110pt), instead of beeing clipped
The example file is appended and I use the latest beta. There is no timeline, so fixing is not that urgent.
add some struts: \setbox\scratchbox\hbox{\begstrut#1\endstrut}% \ifdim\wd\scratchbox>#2\relax \setbox\scratchbox\hbox{\begstrut#3\endstrut}% and remove your funny voffset Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Hans Hagen wrote:
Peter Rolf wrote:
Hi all,
I've tested the latest version of \limitatefirstline and it still doesn't work as expected. This is really a complex story (problem).
- the clip mechanism cuts off the lowest part of some special chars (clipping graphics is easy, but I don't understand what happens here) - text is sometimes cropped at word boundaries (example 110pt), instead of beeing clipped
The example file is appended and I use the latest beta. There is no timeline, so fixing is not that urgent.
add some struts:
\setbox\scratchbox\hbox{\begstrut#1\endstrut}% \ifdim\wd\scratchbox>#2\relax \setbox\scratchbox\hbox{\begstrut#3\endstrut}%
and remove your funny voffset
oeps, a relict from testing.
Hans
Yep, it (later example) works with the struts. Thank you Hans!
But the clipping still needs the height parameter, else you get no
drawings below the baseline. I use \struttotal in my example, which can
be too small in case of underbar/underline.
working example is attached.
Greetings,
Peter
% interface=en output=pdftex
% Time-stamp:
Peter Rolf wrote:
Yep, it (later example) works with the struts. Thank you Hans!
I must clean my glasses. The sentinel is now at the bottom of the text box (ruledhbox) and not on height on the baseline. So it's still not working...
But the clipping still needs the height parameter, else you get no drawings below the baseline. I use \struttotal in my example, which can be too small in case of underbar/underline.
working example is attached.
Greetings,
Peter
Sorry for the noise, Peter
Peter Rolf wrote:
\ifdim\wd\plusone<\dimexpr\hsize-2ex\relax% tolerance for "successful" breaking
\clip[\c!width=\hsize,\c!height=\struttotal]{\ruledhbox{\begstrut#1\endstrut}}% must be #1 here
This may fail, since it #1 may have more than one line, and this whole branch is entered when there are more lines Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
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 ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
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
participants (2)
-
Hans Hagen
-
Peter Rolf