3.3 TEX/LATEX attributes

TEX/LATEX attributes are instances to be passed to a texrunners text() method. They stand for TEX/LATEX expression fragments and handle dependencies by proper ordering.

class halign( boxhalign, flushhalign)
Instances of this class set the horizontal alignment of a text box and the contents of a text box to be left, center and right for boxhalign and flushhalign being 0, 0.5, and 1. Other values are allowed as well, although such an alignment seems quite unusual.

Note that there are two separate classes boxhalign and flushhalign to set the alignment of the box and its contents independently, but those helper classes can't be cleared independently from each other. Some handy instances available as class members:

boxleft
Left alignment of the text box, i.e. sets boxhalign to 0 and doesn't set flushhalign.

boxcenter
Center alignment of the text box, i.e. sets boxhalign to 0.5 and doesn't set flushhalign.

boxright
Right alignment of the text box, i.e. sets boxhalign to 1 and doesn't set flushhalign.

flushleft
Left alignment of the content of the text box in a multiline box, i.e. sets flushhalign to 0 and doesn't set boxhalign.

raggedright
Identical to flushleft.

flushcenter
Center alignment of the content of the text box in a multiline box, i.e. sets flushhalign to 0.5 and doesn't set boxhalign.

raggedcenter
Identical to flushcenter.

flushright
Right alignment of the content of the text box in a multiline box, i.e. sets flushhalign to 1 and doesn't set boxhalign.

raggedleft
Identical to flushright.

left
Combines boxleft and flushleft, i.e. halign(0, 0).

center
Combines boxcenter and flushcenter, i.e. halign(0.5, 0.5).

right
Combines boxright and flushright, i.e. halign(1, 1).

Figure 3.1: valign example
\includegraphics{textvalign}

class valign( valign)
Instances of this class set the vertical alignment of a text box to be top, center and bottom for valign being 0, 0.5, and 1. Other values are allowed as well, although such an alignment seems quite unusual. See the left side of figure 3.1 for an example.

Some handy instances available as class members:

top
valign(0)

middle
valign(0.5)

bottom
valign(1)

baseline
Identical to clearing the vertical alignment by clear to emphasise that a baseline alignment is not a box-related alignment. Baseline alignment is the default, i.e. no valign is set by default.

class parbox( width, baseline=top)
Instances of this class create a box with a finite width, where the typesetter creates multiple lines in. Note, that you can't create multiple lines in TEX/LATEX without specifying a box width. Since PyX doesn't know a box width, it uses TEXs LR-mode by default, which will always put everything into a single line. Since in a vertical box there are several baselines, you can specify the baseline to be used by the optional baseline argument. You can set it to the symbolic names top, parbox.middle, and parbox.bottom only, which are members of valign. See the right side of figure 3.1 for an example.

Since you need to specify a box width no predefined instances are available as class members.

class vshift( lowerratio, heightstr="0")
Instances of this class lower the output by lowerratio of the height of the string heigthstring. Note, that you can apply several shifts to sum up the shift result. However, there is still a clear class member to remove all vertical shifts.

Some handy instances available as class members:

bottomzero
vshift(0) (this doesn't shift at all)

middlezero
vshift(0.5)

topzero
vshift(1)

mathaxis
This is a special vertical shift to lower the output by the height of the mathematical axis. The mathematical axis is used by TEX for the vertical alignment in mathematical expressions and is often usefull for vertical alignment. The corresponding vertical shift is less than middlezero and usually fits the height of the minus sign. (It is the height of the minus sign in mathematical mode, since that's that the mathematical axis is all about.)

There is a TEX/LATEX attribute to switch to TEXs math mode. The appropriate instances mathmode and clearmathmode (to clear the math mode attribute) are available at module level.

mathmode
Enables TEXs mathematical mode in display style.

The size class creates TEX/LATEX attributes for changing the font size.

class size( sizeindex=None, sizename=None, sizelist=defaultsizelist)
LATEX knows several commands to change the font size. The command names are stored in the sizelist, which defaults to ["normalsize", "large", "Large", "LARGE", "huge", "Huge", None, "tiny", "scriptsize", "footnotesize", "small"].

You can either provide an index sizeindex to access an item in sizelist or set the command name by sizename.

Instances for the LATEXs default size change commands are available as class members:

tiny
size(-4)

scriptsize
size(-3)

footnotesize
size(-2)

small
size(-1)

normalsize
size(0)

large
size(1)

Large
size(2)

LARGE
size(3)

huge
size(4)

Huge
size(5)

There is a TEX/LATEX attribute to create empty text boxes with the size of the material passed in. The appropriate instances phantom and clearphantom (to clear the phantom attribute) are available at module level.

phantom
Skip the text in the box, but keep its size.