Scaling Rotating Mirroring Clipping

From Wiki
Jump to navigation Jump to search

You can use the commands for text, but also for graphics or other “building blocks”.


The \scale command is all-purpose, you can scale by factors or to a defined size.

As a special case, you can insert symbols at a reduced size in the text flow using \getscaledglyph.

\getscaledglyph{.5}{Serif}{a} a \getscaledglyph{2}{Serif}{a}


There is a \mirror{\sl mirorred} {\sl word} in this sentence.

\mirror makes a \hbox and mirrors the contents. If you want to have a longer paragraph mirrored, you have to make a \vbox manually.

\mirror{\vbox{Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: 
once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, \quote{and 
what is the use of a book,} thought Alice \quote{without pictures or conversation?}}}


You can \rotate something by an arbitrary angle like

\rotate[rotation=42]{the ultimate answer}

The rotation angle and the location (which determines around which point the content is rotated) are optional and can also be set by

\setuprotate[rotation=42,location=normal] % normal is the default
\rotate{the ultimate answer}

\ss Next generation L\rotate{m}\rotate{m}TSP\mirror{3}Al\rotate[rotation=270,location=high]{v}?

You can rotate a long paragraph as well.

Location parameter

The influence of location= at different angles:

       \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=depth] {\ruledhbox{\bfb  (depth)}}}}%
       \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=fit]   {\ruledhbox{\bfb    (fit)}}}}%
       \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=broad] {\ruledhbox{\bfb  (broad)}}}}%
       \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=normal]{\ruledhbox{\bfb (normal)}}}}%
       \hbox to .2\hsize{\hss\ruledhbox{\rotate[location=high]  {\ruledhbox{\bfb   (high)}}}}}

Rotating Figures

The following code shows how the location parameter influences rotation with a frame:

\setupbodyfont[sans, 30pt]

\ruledhbox{\rotate[rotation=\recurselevel, location=\recursestring]{%
   [width=\textheight, height=\textwidth, rulethickness=5pt,
    depth=0cm, foregroundstyle=\bfd]
  {\recursestring, \recurselevel°}

or, even nicer:

      \rotate[rotation=\recurselevel, location=\recursestring]{%

In a box

Depending on the usage you will sometimes probably want to include the content of what you wish to rotate into a box. Compare the following two examples:



Page dependent landscape figures

Sometimes, in a double-sided portrait document, you may wish to rotate a landscape figure so that the top is towards the spine of the book – no matter whether it’s on an odd or even page. In this case the \doifoddpageelse command can help:


This example is by Wolfgang, from the thread starting here. The thread contains other solutions to the problem.


You can adjust the size of an element by cropping/clipping its borders:


\definedfont[SansBold at 20mm]
\baselineskip 0pt % switch off the space between the stripes
\lineskip 0pt
\def\MyLogo{\vbox{\hbox{\CONTEXT}\null}} % null is necessary for the whole bounding box

And here’s how to cut out a piece by measures (see also \setupclipping and \clip):

\clip[width=3cm, height=1cm, hoffset=1cm, voffset=5mm]{\externalfigure[cow][width=5cm]}

Further reading

Graphic transformations are implemented in grph-trf.mkiv and grph-trf.lua.