From Wikibooks, open books for an open world
< LaTeX
Jump to: navigation, search
LaTeX logo.svg


Getting Started
  1. Introduction
  2. Installation
  3. Installing Extra Packages
  4. Basics
  5. How to get help

Common Elements

  1. Document Structure
  2. Text Formatting
  3. Paragraph Formatting
  4. Colors
  5. Fonts
  6. List Structures
  7. Special Characters
  8. Internationalization
  9. Rotations
  10. Tables
  11. Title creation
  12. Page Layout
  13. Customizing Page Headers and Footers‎
  14. Importing Graphics
  15. Floats, Figures and Captions
  16. Footnotes and Margin Notes
  17. Hyperlinks
  18. Labels and Cross-referencing


  1. Errors and Warnings
  2. Lengths
  3. Counters
  4. Boxes
  5. Rules and Struts

Technical Texts

  1. Mathematics
  2. Advanced Mathematics
  3. Theorems
  4. Chemical Graphics
  5. Algorithms
  6. Source Code Listings
  7. Linguistics

Special Pages

  1. Indexing
  2. Glossary
  3. Bibliography Management
  4. More Bibliographies

Special Documents

  1. Scientific Reports (Bachelor Report, Master Thesis, Dissertation)
  2. Letters
  3. Presentations
  4. Teacher's Corner
  5. Curriculum Vitae

Creating Graphics

  1. Introducing Procedural Graphics
  2. MetaPost
  3. Picture
  4. PGF/TikZ
  5. PSTricks
  6. Xy-pic
  7. Creating 3D graphics


  1. Macros
  2. Plain TeX
  3. Creating Packages
  4. Themes


  1. Modular Documents
  2. Collaborative Writing of LaTeX Documents
  3. Export To Other Formats

Help and Recommendations

  1. FAQ
  2. Tips and Tricks


  1. Authors
  2. Links
  3. Package Reference
  4. Sample LaTeX documents
  5. Index
  6. Command Glossary

edit this boxedit the TOC

In TeX, a length is

  • a floating point number followed by a unit, optionally followed by a stretching value;
3.5pt plus 1pt minus 2pt
  • a floating point factor followed by a macro that expands to a length.


First, we introduce the LaTeX measurement units. All LaTeX units are two-letter abbreviations. You can choose from a variety of units. Here are the most common ones.[1]

Abbreviation Definition Value in points (pt) Value in micrometers (µm)
pt a point is 1/72.27 inch, that means about 0.0138 inch. 1 351.46
mm a millimeter 2.84 = 7227/2540 1000
cm a centimeter 28.4 = 7227/254 10000
in inch 72.27 25400
ex roughly the height of an 'x' in the current font undefined, depends on the font used
em roughly the width of an 'M' (uppercase) in the current font undefined, depends on the font used

The point is the default unit and 1pt is the default length. All other units are converted to the point by a fixed ratio.

Here are some less common units.[2]

Abbreviation Definition Value in points (pt) Value in micrometers (µm)
bp a big point is 1/72 inch, that means about 0.0139 inch. 1.00375 = 803/800 352 7/9
pc pica 12 4218
dd didôt 1.070 = 1238/1157 376
cc cîcero (12 didôt) 12.84 = 14856/1157 4512
nd new didot 1.067 = 685/642 375
nc new cicero (12 new didot) 12.80 = 1370/107 4500
sp scaled point 0.000015 = 1/65536 0.00536

Box lengths[edit]

A box in TeX is characterized by three lengths:

  • depth
  • height
  • width

See Boxes.

Length manipulation[edit]

You can change the values of the variables defining the page layout with two commands. With this one you can set a new value for an existing length variable:


with this other one, you can add a value to the existing one:


You can create your own length with the command, and you must create a new length before you attempt to set it:


You may also set a length from the size of a text with one of these commands:

\settowidth{\mylength}{some text}
\settoheight{\mylength}{some text}
\settodepth{\mylength}{some text}

The calc package provides also the function \settototalheight{\mylength}{some text}

When using these commands, you may duplicate the text that you want to use as reference if you plan to also display it. But LaTeX also provides \savebox to avoid this duplication. You may wish to look at the example below to see how you can use these. See Boxes for more details.

You can also define stretched values. A stretching value is a length preceded by plus or minus to specify to what extent tex is authorized to change the length. Example:

\setlength{\parskip}{10pt plus 5pt minus 3pt}

It means that tex will try to use a length of 10pt; if it is underfull, it will raise the length up to a maximum of 15pt; if it is overfull, it will lower the length up to a minimum of 7pt.

Note that it is not mandatory to specify both the plus and the minus values, but if you do, plus must be placed before minus.

To print a length, you can use the \the command:


Plain TeX[edit]

To create a new length:


To set a length:


To view, it is the same as with LaTeX, using the command \the.

LaTeX default lengths[edit]

Common length macros are:

The normal vertical distance between lines in a paragraph.
Multiplies \baselineskip.
The distance between columns.
The width of the column.
The margin for 'even' pages (think of a printed booklet).
The width of a line in the local environment.
The margin for 'odd' pages (think of a printed booklet).
The width of the page.
The height of the page.
The normal paragraph indentation.
The extra vertical space between paragraphs.
The default separation between columns in a tabular environment.
The height of text on the page.
The width of the text on the page.
The size of the top margin.
Units of length in picture environment.

Fixed-length spaces[edit]

To insert a fixed-length space, use:


\hspace stands for horizontal space, \vspace for vertical space.

If such a space should be kept even if it falls at the end or the start of a line, use \hspace* instead.

If the space should be preserved at the top or at the bottom of a page, use the starred version of the command, \vspace*, instead of \vspace. If you want to add space at the beginning of the document, without anything else written before, then you may use

{ \vspace*{length} }

It's important you use the \vspace* command instead of \vspace, otherwise LaTeX can silently ignore the extra space.

TeX features some macros for fixed-length spacing.

Inserts a small space in vertical mode (between two paragraphs).
Inserts a medium space in vertical mode (between two paragraphs).
Inserts a big space in vertical mode (between two paragraphs).

The vertical mode is during the process of assembling boxes "vertically", like paragraphs to build a page. The horizontal mode is during the process of assembling boxes "horizontally", like letters to build a word or words to build a paragraph.

The fact they are vertical mode commands mean they will be ignored (or fail) in horizontal mode such as in the middle of a paragraph. The first token next the a double linebreak is still in vertical mode if it does not expand to characters.

Some words.
Let's continue.

Some words.

Let's continue.

Rubber/Stretching lengths[edit]

The command:


generates a special rubber space where factor is a number, possibly a float. It stretches until all the remaining space on a line is filled up. If two \hspace{\stretch{factor}} commands are issued on the same line, they grow according to the stretch factor.

x \hspace{ \stretch{1} } x \hspace{ \stretch{3} } x
x      x                  x

The same way, you can stretch vertically:

\vspace{ \stretch{1} }
Some comments.
\vspace{ \stretch{1} }

You can also use \fill instead of \stretch{1}.

The \stretch command, in connection with \pagebreak, can be used to typeset text on the last line of a page, or to center text vertically on a page.

There are 'shortcut commands' for stretching with factor 1 (i.e. with \stretch{1} or \fill): \hfill and \vfill.


Some comments.

Fill the rest of the line[edit]

Several macros allow filling the rest of the line -- or stretching parts of the line -- in different manners.

  • \hfill will produce empty space.
  • \dotfill will produce dots.
  • \hrulefill will produce a rule.


Resize an image to take exactly half the text width :


Make distance between items larger (inside an itemize environment) :


Use of \savebox to resize an image to the height of the text:

% Create the holders we will need for our work
% Create the reference text for measures
  \Large\bfseries This is our title%
\settoheight{\mytitleheight}{ \usebox{\mytitletext} }
% Now creates the actual object in our document



See also[edit]

Previous: Errors and Warnings Index Next: Counters