CERN Accelerating science

This website is no longer maintained. Its content may be obsolete. Please visit for current CERN information.

next up previous
Next: Page Markup---Several Kinds Up: LaTeXeAn Overview Previous: Defining New Environments

Playing with lengths

Lengths can be defined, set and changed by the following commands.

\newlength{cmd} &  \setlength{cmd}{len}  
\settowidth{cmd}{text} & \width  
\settoheight{cmd}{text}& \height  
\settodepth{cmd}{text} & \depth   
                               & \totalheight

The new \settoheight and \settodepth commands, in analogy with the \settowidth command, already present in LaTeX 2.09, allow one to ``measure'' the height and depth of some TeX material. The lengths \width, \height, \depth, and \totalheight are also new in LaTeXe, and can be used inside the box commands described in the next section.

The following lines show how length commands are created, defined, changed, and used. They work, most of the time, both for rigid and rubber lengths.

\newlength{\Mylen} Mylen = \the\Mylen

\setlength{\Mylen}{10mm} Mylen = \the\Mylen       
\setlength{\Mylen}{5mm plus 1mm minus .5mm}
\par Mylen = \the\Mylen  % Use a rubber length

\setlength{\Mylen}{1em} One em is \the\Mylen;
\addtolength{\Mylen}{1pc} add one pica \the\Mylen.

\settowidth{\Mylen}{May} The width is \the\Mylen
\settowidth{\Mylen}{\Large May} and now \the\Mylen.

\settoheight{\Mylen}{May} The height is \the\Mylen
\settoheight{\Mylen}{\Large May} and now \the\Mylen.

\settodepth{\Mylen}{May} The depth is \the\Mylen
\settodepth{\Mylen}{\Large May} and now \the\Mylen.

``Rubber'' (variable) lengths are very useful for placing information on the page.


This is a rubber length with a natural length of zero. It can stretch to any positive value and its value should not be changed!


This is a more useful rubber length, since fill is equivalent to \Lmcs{stretch}. More generally, \Lmcs{stretch{dec_num has a stretchability of dec_num times fill. It can be used to fine-tune the positioning of text horizontally or vertically.

Examples of the use of these stretchable lengths for controlling the horizontal and vertical page layout are given below.

left \hfill                            right\\ 
left \HS[.5]\fbox{$\frac{1}{3}$}\hfill right\\ 
left \HS         middle \hfill         right\\ 
left \hrulefill\ middle \hrulefill\    right\\ 
left \dotfill\                         right\\ 
left \dotfill\ \HS[.5] \dotfill\       right\\ 
left \dotfill\ \HS     \dotfill\       right\\ 
left \dotfill\ \HS[2.] \dotfill\       right

left right left .5] right left iddle right left middle right left right left .5] right left dotfill right left 2.] right

    \Huge Geoffrey Chaucer\\ [5mm]
          The Canterbury Tales
    \Large\textsc{London 1400}

Janne Saarela
Wed May 17 14:38:58 METDST 1995