This website is no longer maintained. Its content may be obsolete. Please visit http://home.cern/ for current CERN information.
Lengths can be defined, set and changed by the following commands.
\newlength{cmd} & \setlength{cmd}{len} \addtolength{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.
fill
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!
\stretch{dec_num}
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.
\newcommand{\HS}[1][1.]{\hspace{\stretch{#1}}} \begin{center} 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 \end{center}[1.]
left right
left .5] right
left iddle right
left middle right
left right
left .5] right
left dotfill right
left 2.] right
\documentclass{article} \usepackage{times} \thispagestyle{empty} \newcommand{\HRule}{\rule{\linewidth}{1mm}} \setlength{\parindent}{0mm} \setlength{\parskip}{0mm} \begin{document} \vspace*{\stretch{1}} \HRule \begin{flushright} \Huge Geoffrey Chaucer\\ [5mm] The Canterbury Tales \end{flushright} \HRule \vspace*{\stretch{2}} \begin{center} \Large\textsc{London 1400} \end{center} \end{document}