|
|
Welcome to the TeXnik web site LaTeX lengths |
![]() |
||||||||||
|
Introduction |
Stripping Unit with Glue |
A length register is in TeX defined by \dimen1=10pt \dimen2=0.7\dimen1There are 256 possible registers \dimen0 ... \dimen255. For more information have a look at the TeXBook
or http://www.tug.org/utilities/plain/cseq.html#dimen-rp.
It is possible to define symbolic names for length registers:
\dimendef\myLength=2 \newdimen\myDimen \myDimen=3cmIn the first case \myLength is a synonym for dimen2. In the second case we do not know which register TeX chooses, it takes the fisrt free one.
In LaTeX we call dimension registers still a length and define it by
\newlength{\myLength}
\setlength{\myLength}{3cm}
\addtolength{\myLength}{-1.3cm}
It is possible to compare two lengthts with the TeX command \ifdim.
In the following example file the length \lThree depends to two other lenghts.
The \ifdim ... \else ... \fiwhere the \else part is optional. \the shows the value of a length.
It is also possible to define a macro which returns the greatest width of two lengths: \newcommand\greaterof[2]{\ifdim#1>#2#1\else#2\fi}
[...]
\parbox{\greaterof{\linewidth}{3in}}{
This shows you can use \greaterof anywhere you can use a length
}
Stripping the Unit and GlueIf you need only the number of a length without its unit then you can use one of the LaTeX macros. But none of these can handle lengthes with glue:
|
|||||||||||