Sie sind auf Seite 1von 10

Introduction to Latex through Kile

Kim Andersen 16th of April, 2011


Abstract This document is a beginners document and aims at providing the user with an easy entrance to Latex. Latex (pronounced Latec) is a document processing program used to create scientic and / or academic documents. Normally Latex has been associated with primarily mathmatical academic disciplines. However, as I will argue in the following introduction, Latex can be used by everyone that wants to make a document independent of platform (read Linux, Macintosh or Windows) as well as a document free of the instability of WYSIWYG (What you see is What You Get) editors. Please notice that I have added extra commands in the commands list (see section 5).

Contents
1 The document outline 2 Formatting 2.1 Sections and labels . . . 2.2 Italic and bold . . . . . 2.3 Alignment and fontsize . 2.4 Type of font . . . . . . . 2.5 Numbering . . . . . . . 2.6 Footnotes and endnotes 3 Pictures 4 Tables 5 Useful commands The following should be placed above begin document This is the used classes and packages of this document. \documentclass[a4paper,10pt]{article} %\documentclass[a4paper,10pt]{scrartcl} \usepackage[utf8x]{inputenc} \usepackage{endnotes} \usepackage[pdftex]{graphicx} \usepackage{multirow} \usepackage{enumerate} 3 4 4 4 4 4 5 5 6 6 9

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

. . . . . .

While Latex is a language similar to markup languages such as HTML, the technical aspects will not be addressed further. On top of Latex, Kile works as a graphical frontend similar to other graphical frontends. However, while WYSIWYG frontends provide the user with a lavish set of options, Kile is much poorer. In other words, the user has to know at least a basic set of commands and tags. This is the scope of this introduction.

The document outline

The heading of any Latex document requires the author to ll in name, creater etc. as well as title which will be shown as in this document which is an article and pdf document. The heading is also used to dene languages which is rather important if Kile and Latex must operate correctly. They provide you with a document, which has justied margins. While Word and its open equivalents such as OpenOce and LibreOce provide you with the same option, Latex splits words in order to minimise the white spaces between the words. The standard dictionary is English, but other languages can be installed. To do so, one has to add another usepackage in the heading of the document, which is basically anything above begin document. The Danish usepackage looks like this: \usepackage[danish]{babel} Begin document is as it says they beginning of your document. In other words, this is where you text goes. If you want a neat little abstract, you enter the following command: \begin{abstract} Add you abstract here. \end{abstract} Once again Latex will provide you with a pre-formatted abstract, which can be seen in the top of this document. Before continuing you might have noticed that within the Latex editor, F10 will lock the right margin so that you will not have very long lines. As you might have noticed, I have a table of contents. While most academic texts do not have such, it might be a useful thing if you are producing a larger text. In other words, you might enjoy the following command: \tableofcontents This provide you with all (sub)sections of the document, which can be produced with the following commands: \section{Section title} \subsection{Subsection title} One last thing to be mentioned, is that the ongoing right margin. This is quite annoying. Thus press F10 to limit the margin.

2
2.1

Formatting
Sections and labels

Formatting is important to all texts. It makes them easier to read. In section 1 I briey touched upon how to make sections. When you read academic texts, you will often notice that the author refers to forthcomming as well as past sections. In Latex this is done by giving a section a label and hereafter refer to that label as show below: \label{Label of the section} \ref{Reference to the "Label of the section"} My teacher in European and American lobbyism said that numbering is a wonderful thing, because it makes it easier for the reader to navigate the text, and hence it empowers the author to control the understanding of the reader.

2.2

Italic and bold

Sections and subsection are not the only way for author to format. It is possible to italicise texts. This is done by using the emph and bf tags: \emph{} {\bf } Notice that the bold tag has to be placed within the brackets unline the emph tag.

2.3

Alignment and fontsize

You might be interested in aligning your text. This can be done by using raggedleft, right or center as below: \raggedleft Just as text can be italicised as well as bold, it can also be bigger or smaller. This is done by using one of the following tags: \tiny \scriptsize \footnotesize \small \normalsize \large \Large \LARGE \huge \Huge

2.4

Type of font

Just as the size of the font can be adjusted, so can the type. To do so one can use the following command above the begin document section. \renewcommand{\familydefault}{\sfdefault} This command will select a font from the serif family. An alternative would be the ttdefault as a substitute to the serif command or the sfdefault. Notice that there are many options and that this is a science. I have only briey touched upon fonts in Latex.

2.5

Numbering

Numbering is wonderful because it can provide a basic overview of the arguments posed in a text. However, while before we have used only tags, numbering requires a bit more than that. \begin{enumerate} or itemize for bullets and \end{enumerate} where a numbering is made with an \item. This makes it possible for us to make a numbering such as the one below: 1. Latex is a HTML language which makes editing of texts more stable. 2. It is a bit more complicated than WYSIWYG editors. 3. It empowers the author in a dierent way than WYSIWYG editors. To create a subsection of items, itemize tag is needed: \begin{enumerate} \item This is the supersection. \begin{itemize} - use enumerate to get letters in brackets. \item This is the subsection.\label{subsection-numbering} \end{itemize} \item This is another supersection. \end{enumerate} . It produces a result like this: 1. This is the supersection. (a) This is the subsection. 2. This is another supersection. As I describe in section 2.1 labels can be used to make a reference to a forthcomming and past reference. This is also possible with numbering. Add the label tag to the numbering and use the ref tag and you will get this: 1a.

2.6

Footnotes and endnotes

Familiarity with academic texts also produces familiarity with footnotes and endnotes. I personally prefer footnotes because I do not want to turn to the end to nd the notes. Aarhus University Department of Political Sciences journal, Politica, uses endnotes. However, footnotes are just as familiar. A footnote is created by the following tag: \footnote{Here is my footnote.} This tag will create a footnote which can be seen below1 . Additional references to the same footnote can be created like this1 :
1 Additional

information should be placed here.

\footnote[1] which is a reference to footnote 1. The endnote is a bit dierent from its cousin described above. To be able to make endnotes, the package endnotes has to be activated. This is shown below as. It is also important to indicate where to put the endnotes. Typically in academic texts, they come before the literature list. Thus breaking a page and inserting the footnotes before the last section is very useful. \usepackage{endnotes} \endnote{This is an endnote}. \pagebreak \theendnotes

Pictures

In section 2 document formatting was addressed. In this section I will address how to add a picture to the document. This is a bit more complicated than what I have shown until now. To add a picture the following is needed: 1. A picture and its precise location on your harddrive. 2. The following code. Before elaborating on the code, use the following package: \usepackage[pdftex]{graphicx} The code: \begin{figure}[htb] \begin{center} \caption{Name of the picture of figure} \leavevmode \includegraphics[width=1\textwidth]{image.png} \small This is where you determine the size of the picture. Numbers are given like this: x.y. \end{center} \end{figure} The code above will produce the following:

Tables

Like gures and the like, tables are also a bit more challenging than in an ordinary WYSIWYG editor. I have chosen a complicated tabel because it looks like those we use at Department of Political Science in Aarhus. The code goes like this: \begin{table}[htp] \begin{center} \caption{The title of the table.} 6

Figure 1: Picture of my Latex code

The dierent colours make it easier for the author to code his document.

\begin{tabular}{ l c r } - Alignment or left, centre, right. \hline - Adding a horisontal line. & Column 1 & Column 2 \\ \hline First cell & 2 & 3 \\ Second row & 8 & 9 \\ \hline \small Remarks in the bottom of the table \end{tabular} \end{center} \end{table} It creates a table like this: Table 1: The title of the table. Column 1 First cell 2 Second row 4
Remarks in the bottom of the table

Column 2 3 5

It is important to notice that tables in Latex are without lines. Lines are added by the hline tag. However, tables can be even more complicated, which requires the use of a special package. It is called multirow : \usepackage{multirow} The code goes like this: \begin{table}[htp] \begin{center} \caption{A more complicated table.} \begin{tabular}{ l l c r } \hline \hline & & \multicolumn{2}{c}{Two columns}\\ - Two collumns merged. \cline{3-4} - Indicates the line below Two columns 7

& & CIA & PNA \\ \hline \multirow{2}{*}{Agents} & Operative 1 & 5 & 6 \\ & Operative 2 & 8 & 9 \\ \hline \end{tabular} \end{center} \end{table}

Table 2: A more complicated table. Two columns CIA PNA Operative 1 5 6 Agents Operative 2 8 9

Notice the dierence from before. First of all we have two horisontal lines in the top. The two columns are merged with the multicolumn command in the text and the two and-signs stress a two cell move. The table has four rows which is indicated by the LLCR. The cline tag indicates that a line needs to be placed in cell three and four. The multirow tag signies that two rows are collapsed into one. Agents are there placed in the centre of what has become a cell created out of two cells.

Useful commands

Please notice that this list is neither exhaustive nor has I include the commands for gures / pictures and tables. \begin{abstract} \end{abstract} - Signifies when the abstract begins and ends. \begin{enumerate} \item \end{enumerate} - Produces numbering where item is x. {\bf bold text} - Creates bold text. \emph{Your text} - Italicised text. \footnote{Here is my footnote} - Footnotes are placed next any given word. \footnote[x] - Reference to footnote x. \indent - Creates an indent. \input{your latex file} - can be used to include i.e. literature lists that must not be counted together with the rest of the document. Notice that the latex file must be in the same directory as your main file. \hspace{length} - is like vspace but horisontal. \label{Name of the section} - Here you put the name of your section. \linespread{1.3} - indenting. \newline - Creates a blank new line but can only be used in paragraph mode. That is within a paragraph. \noindent - No indent. \pagebreak - Breaks a page which means that all content after this page will begin on a clean page. \raggedleft - Aligns the text to the RIGHT. \ref{Reference to a section} - In this code you add the name of the section, you want to refer to. \section \subsection - Sections of Latex. \tableofcontents - Displays all sections and subsections.

\vspace{12pt} - Creates an empty line outside a paragraph. Centimetres can be used instead of points (pt).

10