LaTeX/Useful Measurement Macros

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

A list of macros and their values

Contents

[edit] Units

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)
pt a point is 1/72.27 inch, that means about 0.0138 inch or 0.3515 mm. 1
mm a millimeter 2.84
cm a centimeter 28.4
in inch 72.27
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

And here are some less common units.[2]

Abbreviation Definition Value in points (pt)
bp a big point is 1/72 inch, that means about 0.0139 inch or 0.3527 mm. 1.00375
pc pica 12
dd didôt (1157 didôt = 1238 points) 1.07
cc cîcero (12 didôt) 12.84
sp scaled point (65536sp per point) 0.000015

[edit] Length 'macros'

Some length commands are;

\baselineskip 
The normal vertical distance between lines in a paragraph
\baselinestretch 
Multiplies \baselineskip
\columnsep 
The distance between columns
\columnwidth 
The width of the column
\evensidemargin 
The margin for 'even' pages (think of a printed booklet)
\linewidth 
The width of a line in the local environment
\oddsidemargin 
The margin for 'odd' pages (think of a printed booklet)
\paperwidth 
The width of the page
\paperheight 
The height of the page
\parindent 
The normal paragraph indentation
\parskip 
The extra vertical space between paragraphs
\tabcolsep 
The default separation between columns in a tabular environment
\textheight 
The height of text on the page
\textwidth 
The width of the text on the page
\topmargin 
The size of the top margin
\unitlength 
Units of length in Picture Environment

[edit] Length manipulation macros

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

\setlength{parameter}{length}

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

\addtolength{parameter}{length}

You can create your own length with the command:

\newlength{parameter}

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

\settowidth{parameter}{some text}
\settoheight{parameter}{some text}
\settodepth{parameter}{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 a set of commands to avoid this duplication:

\newsavebox{boxname}
\savebox{boxname}{some text}
\usebox{boxname}

You may wish to look at the example below to see how you can use these. The command \newsavebox creates a placeholder for storing a text; the command \savebox stores the specified text in this placeholder, and does not display anything in the document; and \usebox recalls the content of the placeholder into the document.


See LaTeX/Page_Layout for samples using these.

[edit] Samples

Resize an image to take exactly half the text width :

\includegraphics[width=0.5\textwidth]{mygraphic}

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

\addtolength{\itemsep}{0.5\baselineskip}

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

% Create the holders we will need for our work
\newlength{\mytitleheight}
\newsavebox{\mytitletext}
% Create the reference text for measures
\savebox{\mytitletext}{%
  \Large\bfseries This is our title%
}
\settoheight{\mytitleheight}{\usebox{\mytitletext}}
% Now creates the actual object in our document
\framebox[\textwidth][l]{%
  \includegraphics[height=\mytitleheight]{my_image}%
  \hspace{2mm}%
  \usebox{\mytitletext}%
}

[edit] References

  1. http://www.uz.ac.zw/science/maths/latex/ltx-86.html
  2. http://www.uz.ac.zw/science/maths/latex/ltx-86.html


Previous: Accents Index Next: Index
Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox
Sister projects
Print/export