Changes

Jump to navigation Jump to search
858 bytes added ,  13:48, 9 September 2005
m
< [[Visuals]] |
 
== Cropping text ==
There are some rare cases in which it is useful to crop a given
text line and loose part of its information.
=== <tt>\doboundtext</tt> ===
Sometimes there is not enough room to show the complete
(line of) text. In such a situation we can strip of some
=== <tt>\limitatetext</tt> ===
A bit more beautiful alternative for the previous command is <tt>\limitatetext</tt>.
This command takes care of '''word''' boundaries, so that only complete words will
on text that cannot be hyphenated.
 
=== <tt>\limitatefirstline</tt> ===
In ConTeXt versions newer than 07.09.2005 there is also a command
called <tt>\limitatefirstline</tt>, which acts nearly like <tt>\doboundtext</tt>,but at a more robust level. This macro first tries to break the given textat character level. It uses nearly the same breaking mechanism as <tt>\limitatetext</tt>,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 fails.This fail safe mechanism "simply" clips (no breaking at all) the text to the disiredmeasures. This is done without any consideration to character boundaries.So you must live with the fact, that the last character can be cut off at any possibleplace.
<texcode>
<texcode>
\limitatefirstline {\underbar{The garden's version of \CONTEXT is too oldMr.~Drofnats was happiest when he was at work% typesetting beautiful documents.}{65mm110mm}{\unknown}
</texcode>
\def\limitatefirstline#1#2#3%
{\hbox\bgroup\strut \setbox\scratchbox\hbox{#1}% \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{\unhbox\plusone}% \hbox to #2 {\ifx\clip\undefined \box\plusone\removeunwantedspaces#3% \else\ifdim\wd\plusone>\hsize \hbox{ \clip[\c!width=\hsize,\c!height=\lineheight,\c!voffset=-4pt]{\box\plusone}#3}% \else \box\plusone\removeunwantedspaces#3% \fi\fi \removeunwantedspaces\hss#3}}% \else #1% \fi \egroup}
\protect
\limitatefirstline {\underbar{The garden's version of \CONTEXT is too oldMr.~Drofnats was happiest when he was at work typesetting beautiful documents.}}{65mm110mm}{\unknown}
</context>
 
 
=== A comparison (TODO) ===
comparison table with examples of all commands
37

edits

Navigation menu