TeXnik - Tips TeX and LaTeX

Welcome to the TeXnik website (under construction)

LaTeX lengths
 Main page Index UK FAQ Documentation Software CTAN Search CTAN: Statistics Google c.t.t. Google d.c.t.t.
Introduction |  Stripping Unit with Glue  |

A length register is in TeX defined by
```\dimen1=10pt
\dimen2=0.7\dimen1```
There 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=3cm```
In 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}
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` has the usual structure

`\ifdim ... \else ... \fi`
where 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 Glue

If 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:

local time: Sat Sep 26 07:58:19 CEST 2020 ; file is: 457.632638888889 days old
contact webmaster _at_ TeXnik.de