TeXnik - Tips TeX and LaTeX


Welcome to the TeXnik website (under construction)

LaTeX lengths
TUG logo

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}
\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 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:

strip0.png

local time: Sat Dec 7 20:50:28 CET 2019 ; file is: 164.210520833333 days old
contact webmaster _at_ TeXnik.de