Anda di halaman 1dari 6

FIVE MINUTE GUIDE

A TO L TEX
FIRST VERSION

Tim van der Horst Frits Wenneker

\howto

TEX {.com}

This document is copyrighted by howtoTeX.com. Feel free to distribute, but keep a reference to howtoTeX.com and its original authors.

Contents

A 1 L TEX Basics 1.1 Document structure 1.1.1 Preamble . . 1.1.2 Environments 1.1.3 Sectioning . . 1.2 Text formatting . . . 1.3 Cross references . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

1 1 1 1 1 1 1 2 2 2 2 3 3 4 4 4

2 Typesetting content 2.1 Equations . . . . . . 2.1.1 Working with 2.2 Figures . . . . . . . 2.3 Tables . . . . . . . . 2.4 Lists . . . . . . . . .

. . . units . . . . . . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

. . . . .

3 Bibliography with BibTEX 3.1 Using BibTEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3.2 Adding bibliography items . . . . . . . . . . . . . . . . . . . . . . . . . . . .

Preface
The title of this document says it all: this is a five minute guide to A L TEX, a way of typesetting documents that will save time and frustration. This guide is written to get you over the fairly steep learning curve. More A L TEX guides exist, but they all drown you in information. The content of this guide will teach you enough to write proper documents. A Before you can start, the L TEX system needs to be installed. A guide for Windows and Mac OS X is found here. To make life even easier, download A this folder structure to start L TEXing right away. May 27, 2012

CHAPTER 1
A L TEX Basics

A Together with this guide comes a pre-made folder structure for managing L TEX projects. The latest version is available here. Its advised to open and play with it when following this guide.

1.1 Document structure


Three subfolders are present in the provided folder structure: docs, gs and refs. The docs folder contains the main content and the preamble. Section 1.1.1 explains the preamble, while the rest of this guide teaches about the main content of documents. The gs folder is A the root where all gures are placed. Implementing gures in L TEX is shown in section 2.2. The refs folder contains a le for the bibliography, explained in chapter 3. In order to compile your document, run the master.tex le in the root of the folder structure. In most LaTeX editors, the master le can be specied such that the document can also be compiled from the .tex les in the docs folder.
docs folder gs folder refs folder

1.1.1 Preamble
A A L TEX document is congured in the preamble. The \documentclass[]{} command denes the documentclass , where [] contains optional arguments such as font size. The class is chosen between {}. Standard classes are article, book, report, slides, and letter.

documentclass

Example 1

Creating a report with 10pt font size


package

\documentclass[10pt]{report}
A The preamble also calls required packages : L TEX tools. In the provided preamble all necessary packages are called, together with a brief explanation.

1.1.2 Environments
Environments contain special content, such as math, gures, tables, etc. Environments start with \begin{} and end with \end{}, where the environment name is between {}. The document environment is most important: all content within this environment will be printed.

1.1.3 Sectioning
A distinct part or subdivision of a writing is created with: \section{}, \subsection{}, \subsubsection{}, \paragraph{}, where {} contains the title. The report and book classes require an additional \chapter{} command.

1.2 Text formatting


Text is formatted with: \textbf{} for bold, \textit{} for italic and \underline{} for A underlined text. As L TEX uses certain characters for its own purposes, a few special characters should be remembered: \& for &, \% for %, \$ for $, \{ \} for { } and \# for #. A line break is created by either a double return or \\. A whole page is cleared with the \clearpage command.
special characters

1.3 Cross references


A Cross referencing is one of the strong points of L TEX and can be done to all items that contain a counter. A label is added to the item with \label{}, where the label name is between {}. For example, this section is labeled with \label{sec:refs} and can be referred to with \cref{sec:refs}, which is printed as: section 1.3. The \cref{} command is introduced by the cleveref package, which automatically determines the type of reference.

label reference

A Five minute guide to L TEX ||| 1

CHAPTER 2
Typesetting content 2.1 Equations
Equations and other mathematical expressions are created within math environments. There are two types of math environments: inline and display. Inline equations are shown within the paragraph and are created by writing the equation between $ and $. Example 2 Creating an inline equation The derivative of x2 is 2x
display equation inline equation

The derivative of $x^2$ is $2x$

Display equations are used for larger equations, as they are shown in distinct paragraphs. The amsmath package introduces the align environment for display equations. Example 3 Creating a display equation y0 =

\begin{align} \label{eq:example} y_{0} &= \frac{\sqrt{256}}{2} \\ &= 2^{3} = 8 \nonumber \end{align}

256 2 = 23 = 8

(2.1)

Subscripts can be made with _{} and superscripts with ^{}. Use & to vertically align the equations and add \\ to break a line. A label is added to the environment, such that a cross reference to equation (2.1) can be made with \cref{eq:example}. In order to suppress the automatic equation numbering, use the align* environment or add \nonumber to the desired line.

sub- and superscript

suppress numbering

2.1.1 Working with units


The siunitx package provides an easy way to work with (SI) units . This is done with \SI{}{}, where the rst {} contains the value and the second {} the unit. The SI command can be used both within and outside math environments. Example 4 Working with units 1 Hz is equal to 2 rad s1
SI units

\SI{1}{\hertz} is equal to \SI{2\pi}{\radian\per\second}

2.2 Figures
Place gures in the provided gs folder. A gure is dened with a figure environment and its placement is determined by an optional argument between []: [h] stands for here, [b] for bottom, [t] for top and [p] for separate page. To insert a gure, use \includegraphics[]{}, where [] contains the size and {} the lename. Center a gure with \centering. Also, a label and caption should be assigned. Example 5 Inserting a gure named logo.pdf
gs folder gure placement

\begin{figure}[h] \centering \includegraphics[width=30mm]{figs/logo} \caption{Caption example} \label{fig:logo} \end{figure}

\howto

TEX {.com}

Figure 2.1: Caption example

A Five minute guide to L TEX ||| 2

2.3 Tables
For nice looking tables, the booktabs package is recommended. A table is placed within a table environment: rst a caption and label are dened, whereafter a tabular environment follows. In the latter, the content of the table can be placed. Table rules are created with \toprule, \midrule and \bottomrule. Example 6 Creating a table
table rule

\begin{table}[h] \centering \caption{Table caption} \label{tb:table} \begin{tabular}{crl} \toprule Name & Grade & Year \midrule John & 7.5 & 2012\\ Richard & 2 & 2010\\ \bottomrule \end{tabular} \end{table}

Table 2.1: Table caption Name


\\

Grade 7.5 2

Year 2012 2010

John Richard

Similar to gures, table placement can be specied by [h], [t], [b] or [p]. The argument {crl} behind \begin{tabular} determines the column alignment : the rst is centered with c, the second is right aligned with r and the last is left aligned with l.

table placement column alignment

2.4 Lists
In order to make lists, a listing environment must be created. The enumerate environment creates numbered lists . Example 7 Creating a numbered list 1. First entry 2. Second entry
bulleted list descriptive list numbered list

\begin{enumerate} \item First entry \item Second entry \end{enumerate}

Similar, bulleted lists () are created with the itemize environment. It is possible to create nested lists by placing one listing environment into another. Descriptive lists are created using the description environment. Example 8 Creating a descriptive list First entry Second entry

\begin{description} \item[First] entry \item[Second] entry \end{description}

A Five minute guide to L TEX ||| 3

CHAPTER 3
Bibliography with BibTEX 3.1 Using BibTEX
BibTEX provides a convenient way to create a consistent list of references. The provided refs folder contains a le references.bib, in which the bibliography items are listed. The bibliography style is determined by \bibliographystyle{plain}, where plain is the default style. The bibliography is printed by the command \bibliography{refs/references}. A A To compile or update the bibliography: run L TEX, then BibTEX and then L TEX twice more.
bibliography

compilation

3.2 Adding bibliography items


Dierent entries exist for dierent sources, such as @book, @article and @misc. The following example creates a book reference with @book. In the same manner, the entries for @article and @misc (to cite websites) are created in the references.bib le. Example 9 Creating a book reference

@book{Last2012, author = {Last, First von}, title = {Book}, publisher = {Publisher}, year = {2012}, }

[1] First von Last. Book. Publisher, 2012.

In the rst line, the reference name is assigned: Last2012. Use \cite{Last2012} to cite A the reference in the L TEX document, resulting in: [1]. If no citation is made to the entry, it will not be added to the bibliography. Making BibTEX entries can often be simplied with the help of internet: most article/book databases, such as Google Books and ScienceDirect, provide BibTEX les.

citation

A Five minute guide to L TEX ||| 4

Anda mungkin juga menyukai