Cropping text

From Wiki
Revision as of 17:58, 7 September 2005 by Sojus (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Cropping text

There are some rare cases in which it is useful to crop a given text line and loose part of its information.

Sometimes there is not enough room to show the complete (line of) text. In such a situation we can strip of some characters by using

\doboundtext {text} {width} {sentinel}

When the text is wider than the given width, it's split and the third argument (sentinel) is appended. As much text as possible is printed.

An example:

\framed{\doboundtext{My entire inheritance goes to my cat Pussy!}{62mm}{...}}

A bit more beautiful alternative for the previous command is \limitatetext. This command takes care of word boundaries, so that only complete words will appear in the final (cropped) text.

\limitatetext {text}  {width} {sentinel}
\limitatetext {text} {-width} {prelude}

When no width is given, the whole text becomes available. A negative value crops the beginning and the text starts with the prelude. Sentinel and prelude are optional.


\framed{\limitatetext {Pussy is the name of the cat!}{50mm}{...}}
\framed{\limitatetext {Pussy is the name of the cat!}{-50mm}{...}}

Both commands have their range of application. \limitatetext is more robust, \doboundtext works better on text that cannot be hyphenated.

TODO: \limitatefirstline