Document Types
The following document types can be created using mark-up code. Predefined templates for each type ship with
and more can be found in open-source archives. For example, publishers provide templates to facilitate content delivery and typesetting, or to better align document structure and content:
Type | Description |
---|---|
article | Commonly used for short documents and journal articles. |
IEEEtran | For articles with the IEEE Transactions format. |
proc | A class for proceedings based on the article class. |
report | For longer reports containing several chapters, and small books, such as a thesis |
book | Useful to write books |
memoir | It is based on the book class, but you can create any kind of document with it |
letter | Appropriate for memos and letters |
beamer | Presentation slides in the Beamer class format |
Document types are defined in the first line of mark-up code using the command \documentclass[…]{…}. The basic skeleton of a document has the following elements:
1 2 3 4 5 6 |
\documentclass[option1, option2, option3]{type} \usepackage[option1, option2, option3]{named-package} \begin{document} ... \end{document} |
The most common options for the standard document classes are listed in the following table:
Option | Description |
---|---|
10pt, 11pt, 12pt | Sets the size of the main font in the document. If no option is specified, 10pt is assumed. |
a4paper, letterpaper,... | Defines the paper size. The default size is letter paper. However, many European distributions of TeX now come pre-set for A4, not Letter, and this is also true of all distributions of pdfLaTeX. Besides that, a5paper, b5paper, executivepaper, and legalpaper can be specified. |
fleqn | Typesets displayed formulas left-aligned instead of centered. |
leqno | Places the numbering of formulas on the left hand side instead of the right. |
titlepage, notitlepage | Specifies whether a new page should be started after the document title or not. The article class does not start a new page by default, while report and book do. |
twocolumn | Instructs LaTeX to typeset the document in two columns instead of one. |
twoside, oneside | Specifies whether double or single sided output should be generated. The article and report classes are single sided and the book class is double sided by default. Note that this option concerns the style of the document only. The option twoside does not tell the printer you use that it should actually make a two-sided printout. |
landscape | Changes the layout of the document to print in landscape mode. |
openright, openany | Makes chapters begin either only on right hand pages or on the next page available. This does not work with the article class, as it does not know about chapters. The report class by default starts chapters on the next page available and the book class starts them on right hand pages. |
draft | Makes LaTeX indicate hyphenation and justification problems with a small square in the right-hand margin of the problem line so they can be located quickly. It also suppresses the inclusion of images and shows only a frame where they would normally occur. |
Preamble
The area between \documentclass[…]{…} and \begin{document} is called the preamble. It normally contains commands and default setting that affect the entire document. For instance, a normal document preamble might look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
% Define document type \documentclass[12pt, a4paper]{article} % Set title fields \title{{\LaTeX} Typesetting} \author{Bradley Horn} \date{\today} % Load and configure packages \usepackage{Sweave} \usepackage[top=0.5in, bottom=0.75in, left=1.0in, right=0.5in]{geometry} \usepackage[usenames,dvipsnames,svgnames,table]{xcolor} \usepackage[parfill]{parskip} \usepackage{graphicx} \usepackage[section]{placeins} \usepackage{afterpage} \usepackage{amssymb, amsmath} \usepackage{dcolumn} \usepackage{mdframed} \usepackage{hyperref} \usepackage{fancyhdr} % Set document format parameters \setcounter{totalnumber}{5} |
If 12pt is omitted from the \documentclass[…]{} command, then the document will be set in 10pt size.
The preamble also relies heavily on packages, which expand document flexibility with TEX macros or custom code. The last line above defines a document default (e.g. max number of figures per page), and is one of many that could be defined.
Finally, if there are two authors separate them with the \and command:
Title Page
To display the title and document meta-data, it is necessary to include additional code after \begin{document}:
1 2 3 4 5 6 7 8 9 |
\begin{document} \begin{titlepage} \maketitle \end{titlepage} In this document ... \end{document} |
The commands \begin{titlepage} and \end{titlepage} declare an environment (e.g. a chunk of code with specific behavior). The outcome will depend on document class. For articles, the title page is the first page and separated from any text.
The command \maketitle then launches the environment and prints the title, author and date. If the titlepage environment is not used, the title will appear at the beginning of the document on the same page as the intro text.
Abstract
Many scientific documents or business briefs include an overview of the main subject of the paper. In , there’s the abstract environment for this. The abstract environment will places the intro text in a special format at the top of your document.
1 2 3 4 5 6 7 8 9 10 |
\begin{document} \begin{abstract} The abstract is a simple paragraph at the beginning of the document, which provides a brief introduction to the main subject. \end{abstract} In this document ... \end{document} |
By default, will use the word “Abstract” as a title for your abstract. If you want to change it into anything else, e.g. “Executive Summary”, add the following line before you begin the abstract environment:
1 |
\renewcommand{\abstractname}{Executive Summary} |
Paragraphs and New Lines
If you need to start a new paragraph you must hit the “Enter” key twice (to insert a double blank line). Notice that paragraphs have a white space before the first line.
To start a new line without actually starting a new paragraph insert a break line point, this can be done by \\ (a double backslash as in the example) or the \newline command. For example, to create a more complex title page:
1 2 3 4 5 6 7 8 |
\title{Expanded Title Structure in {\LaTeX}} \author{Bradley Horn\\ New Energy Department,\\ Directorate of Strategy and Planning,\\ Qatar Petroleum\\ \texttt{bxhorn@gmail.com}} \date{\today} \maketitle |