Difference between revisions of "LaTeX:Layout"
(→Layout of the Page) |
(→Layout of the Page) |
||
Line 53: | Line 53: | ||
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): | 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): | ||
− | {| | + | {| border="1" |
|- | |- | ||
| Cell 2 || Cell 3 | | Cell 2 || Cell 3 |
Revision as of 19:47, 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.
Contents
[hide]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):
Cell 2 | Cell 3 |
Cell B | Cell C |