Difference between revisions of "LaTeX:Layout"

(Layout of the Page)
(Layout of the Page)
Line 54: Line 54:
  
 
{| class="wikitable" border="1" cellpadding="2"
 
{| class="wikitable" border="1" cellpadding="2"
|-
+
|-valign="top"
 
| \pdfpageheight, \pdfpagewidth ||Height and width of the PDF page to create (i.e. size of paper you'd print on).
 
| \pdfpageheight, \pdfpagewidth ||Height and width of the PDF page to create (i.e. size of paper you'd print on).
|-
+
|-valign="top"
 
|\topmargin ||Margin at top of page above all printing. Add 1 inch (so that, for example, setting \topmargin to 0.25in would produce a top margin of 1.25 inches).
 
|\topmargin ||Margin at top of page above all printing. Add 1 inch (so that, for example, setting \topmargin to 0.25in would produce a top margin of 1.25 inches).
|-
+
|-valign="top"
 
|\evensidemargin ||Left margin on even numbered pages. Add 1 inch (as with \topmargin).
 
|\evensidemargin ||Left margin on even numbered pages. Add 1 inch (as with \topmargin).
|-
+
|-valign="top"
 
|\oddsidemargin || Left margin on odd numbered pages. Add 1 inch (as with \topmargin).
 
|\oddsidemargin || Left margin on odd numbered pages. Add 1 inch (as with \topmargin).
|-
+
|-valign="top"
 
|\headheight || Height of the header (the header is text that appears atop all pages).
 
|\headheight || Height of the header (the header is text that appears atop all pages).
|-
+
|-valign="top"
 
|\headsep ||Distance from bottom of header to the body of text on a page.
 
|\headsep ||Distance from bottom of header to the body of text on a page.
|-
+
|-valign="top"
 
|\topskip || Distance from top of main text box to the baseline of the first line of text in the main text box.
 
|\topskip || Distance from top of main text box to the baseline of the first line of text in the main text box.
|-
+
|-valign="top"
 
|\textheight, \textwidth ||Height and width of main text box.
 
|\textheight, \textwidth ||Height and width of main text box.
|-
+
|-valign="top"
 
|\footskip ||Distance from bottom of body to the bottom of the footer (the footer is the text at the bottom of each page).
 
|\footskip ||Distance from bottom of body to the bottom of the footer (the footer is the text at the bottom of each page).
|-
+
|-valign="top"
 
|\parskip || Distance between paragraphs.
 
|\parskip || Distance between paragraphs.
|-
+
|-valign="top"
 
|\parindent || Amount of indentation at the first line of a paragraph.
 
|\parindent || Amount of indentation at the first line of a paragraph.
 
|}
 
|}

Revision as of 20:54, 10 July 2007

LaTeX
About - Getting Started - Diagrams - Symbols - Downloads - Basics - Math - Examples - Pictures - Layout - Commands - Packages - Help

This article outlines some of the basics of layout in LaTeX.

Note: Rather than typing up all the examples, you can copy-paste the examples into your TeXnicCenter files. We highly recommend opening up your TeXnicCenter and trying out each of the examples as you go. It takes almost no time at all to just copy-paste, compile, and view the results.

Source File Format

The source file of a LaTeX broadly consists of two parts, the preamble and the document itself. The preamble consists of everything before the \begin{document} command. Things like margin settings, document style definitions, paragraph spacing settings, custom function definition and page numeration style are items that are set in the preamble. Often, much of the preamble is placed in a separate file and included using the \usepackage statement. This allows you to use the same code in many source files by just including a single line in each source file.

Our next three sections deal primarily with preamble items, while the rest cover tools you might use within your document.

Preamble Formatting

Document Class

The first line of your source code sets the document class with the cleverly named command \documentclass. While LaTeX supports several classes, such as book, report, and letter, we will be focusing on the document class article in these webpages. Using \documentclass, we can also set the general font size for the document (which we can reset for parts of the document as required). Thus, the first line of your source code will almost always look like this:

\documentclass[11pt]{article}

If you want a slightly larger font, try 12pt. If smaller, go for 10pt.

Should you decide to use one of the other classes, for example if you chose to write a book with LaTeX, we suggest getting a book on LaTeX.

Including Packages You'll Need

Immediately following the \documentclass statement we usually include all the packages we'll need using \usepackage. The two most common packages to include are the amsmath package, which defines many new mathematical symbols, and the graphicx package, which allows you to include images in your document. So, for instance, many of your documents may begin:

\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage[pdftex]{graphicx}

The pdftex in brackets is an optional argument to the graphicx package. In general, for many commands, we can add optional arguments in brackets; we'll be describing some of these as we go along.

After you have become more comfortable with LaTeX, read about how to create your own packages to simplify your source files and to allow you to easily use the same style and commands in multiple source files without having to copy over all the commands from one source file to the next.

Layout of the Page

In the preamble we define all the relevant settings for our page, such as margins, width of text, page sizes, etc. Here's an example of what might follow your \documentclass declaration to set page parameters:

\documentclass[11pt]{article}
\usepackage{amsmath}

\pdfpagewidth 8.5in
\pdfpageheight 11in

\setlength\topmargin{0in}
\setlength\headheight{0in}
\setlength\headsep{0in}
\setlength\textheight{7.7in}
\setlength\textwidth{6.5in}
\setlength\oddsidemargin{0in}
\setlength\evensidemargin{0in}
\setlength\parindent{0.25in}
\setlength\parskip{0.25in}

That may look pretty intimidating. For starters, you really only need to worry about the first two lines if you are creating PDF documents. You can easily get away with ignoring the rest; LaTeX will simply use reasonable defaults for the other values. The two \pdf commands tell LaTeX what size PDF document to create. You can see that our settings above are for a standard 8.5 x 11 page.

Here are some parameters you might set (note you can use any of several different units of length, such as in for inches, cm for centimeters, or pt for points):

\pdfpageheight, \pdfpagewidth Height and width of the PDF page to create (i.e. size of paper you'd print on).
\topmargin Margin at top of page above all printing. Add 1 inch (so that, for example, setting \topmargin to 0.25in would produce a top margin of 1.25 inches).
\evensidemargin Left margin on even numbered pages. Add 1 inch (as with \topmargin).
\oddsidemargin Left margin on odd numbered pages. Add 1 inch (as with \topmargin).
\headheight Height of the header (the header is text that appears atop all pages).
\headsep Distance from bottom of header to the body of text on a page.
\topskip Distance from top of main text box to the baseline of the first line of text in the main text box.
\textheight, \textwidth Height and width of main text box.
\footskip Distance from bottom of body to the bottom of the footer (the footer is the text at the bottom of each page).
\parskip Distance between paragraphs.
\parindent Amount of indentation at the first line of a paragraph.

Many of these parameters (if not all) can be set to negative numbers. Note also that there's no explicit way to set the right margin on a page: you can control the left margin (with \oddsidemargin and \evensidemargin) and the width of the text (with \textwidth), which implicity controls the right margin.

There are many other parameters that you can set in the preamble, such as the title of the document, the header style, the footer style, page numbering, etc. You can consult books or Google for more information on these areas.

Starting Your Document

Document Formatting

Paragraphs

Sections

Font Sizes and Styles

Spacing

Justification (Centering, etc).

Tables

Boxes

Lists

Referencing

Comments

See Also