LaTeX_Tutorial.pdf

(413 KB) Pobierz
A
L TEX Tutorial
William Hicklin
Abstract
This tutorial will go through the steps required to start writing scientific
A
reports with L TEX and get you on your way to a life free of typesetting hassles.
A
L TEX is a scripting language specifically designed for mathematicians and
scientists to write scientific articles and reports. This tutorial will illustrate
A
A
what is needed to start writing with L TEX, gives an overview of how L TEX
works and some useful commands to get you stated.
1
Contents
1 Introduction
A
2 Installing a L TEX editor
3
3
3
5
5
6
7
8
10
10
10
A
3 Writing your first L TEX document
4 Useful Commands
4.1
4.2
4.3
Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Referencing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
5 Further Reading
A Page layout
B Sub-equations
C Sub-figures
2
1
Introduction
TEX was developed by Donald Knuth in 1978 [1] to help scientists publish papers
in a standard format without having to worry about formatting, typesetting, align-
A
ments, references, etc. L TEX is a scripting language, this means that you will write
in a script and then execute it to generate a .pdf file. This has several advantages
including; low computation requirements, platform independent, horizontal and ver-
tical alignment, smart automatic float (image, table, equation, etc.) placements,
automatic numbering, easy cross-referencing and more.
A
Being a scripting language one will have to inform L TEX about any formatting by
writing commands such as
\section{name}.
This might seem to be more com-
plicated but it is easier than using a user interface. By writing such commands
all typesetting formats will be implied according to initial settings. More of these
commands will be explained in section 4.
2
A
Installing a LTEX editor
A
Before writing in L TEX one has to install the required libraries for the computer
to understand the scripts. If you are running on a Mac or windows system this
is accomplished by installing MiKTEX
1
, if you’re running a Linux system this is
probably already installed. After installing MiKTEX you will now need to install
A
A
a suitable L TEX editor (a shell program) to write the L TEX scripts. The shell
program I will be using for this tutorial is
TeXMaker,
this is an open-source cross-
platform editor. Other TEX editors like TeXmacs and TeXshop, for macintosh, exist.
TeXMaker can be freely downloaded
2
and installed for any operating system.
3
A
Writing your first LTEX document
A
A L TEX document is written in a
.tex
file, which is similar to a
.txt
file.
In TeXMaker a new
.tex
file can be created using
ctrl+n
or from tab File
>
New.
A
At the beginning of a L TEX document one has to set certain document pa-
rameters like font size, document class, paper size, page layout, etc. This is
called the preamble.
In TeXMaker this list of initial commands can be easily created using the
Wizard
tab. Figure 1 shows the wizard window where you can specify the
1
2
http://miktex.org/2.8/setup
http://www.xm1math.net/texmaker/download.html
3
document class, font size, author, title, etc. This will generate the preamble
and the commands
\begin{document}
&
\end{document}.
Anything between a
\begin{}
&
\end{}
is called an environment and within
the document environment you can start writing your document.
Writing a new document will normally start by the title page which is easily
created by writing
\maketitle
in the document environment. To view the
effect of this command we have to execute the script and generate a pdf file.
To do this, click on the drop down menu after the first blue arrow (Figure 2(a))
and choose
PDFLaTeX,
clicking on the blue arrow will now execute the script
and generate the pdf. To view the pdf document click on the drop down menu
after the second blue arrow (Figure 2(b)) and choose
View PDF,
clicking on
the second blue arrow will open the generated pdf with the default pdf viewer.
If you continue to write in your
.tex
file you can view the changes in the
pdf by clicking on the first arrow (or pressing F6) and viewing the pdf again.
Running PDFLaTeX will overwrite the last pdf.
Figure 1:
This figure shows the window generated when clicking the wizard tab
(a) First blue arrow
(b) Second arrow
Figure 2:
Settings for the blue arrows
While writing your document you will need to create sections and subsections
which have a different type setting then the rest of the text. This is done by
4
simply writing
\section{SectionName}.
This command will automatically
number and write the section title in the appropriate format according to the
document class and font size specified in the preamble.
Similarly one can also create subsections (\subsection{}) and subsubsections
(\subsubsection{}).
When writing a document, paragraphs may be either separated by a line, and
no indentation, or just by indentation. To specify the preferred method, one
must add the commands
\parindent 0pt
&
\parskip 2ex
in the preamble,
therefore before the
\begin{document}.
These particular settings will create
a line separated document.
The commands discussed until now will help you create a neatly structured docu-
ment. The next section will show some other useful command for inserting equations,
figures, tables, references and cross-references.
4
Useful Commands
A
L TEX has been around for quite some time and a lot of people have realised its
potential to make report writing much easier. Since the language is open-source, a
lot of people have written different packages to solve different problems. Most of
these packages where installed during the MikTEX installation. To avoid conflicts
one has to specify which packages are going to be used in the document. This is
done by adding the command
\usepackage{Name}
with the package name in the
preamble.
4.1
Equations
To write equations and use Greek letters no packages are required since this is the
A
main purpose of L TEX. However, Greek letters must be written inside an equation
A
environment. Below are examples of the different equation environments in L TEX.
1. New line + numbered [2]
\begin{equation}
\int_0^{\infty} e^{-\rho} \rho^{2l}\left[ L_{n+l}^{2l+1} \left(\rho
\right) \right]^2 \rho^2 d\rho = \frac{2n \left[\left(n+l\right)!
\right]^3}{(n-l-1)!}
\end{equation}
e ρ
0
−ρ
2l
L
2l+1
n+l
2n [(n +
l)!]
3
(ρ)
ρ dρ
=
(n
l
1)!
2
2
(1)
5
Zgłoś jeśli naruszono regulamin