Introduction to XeLaTeX: An alternative document preparation system.

40
Introduction to X E L A T E X An alternative document preparation system. Nikolaos Dimos June 17, 2012

description

This is a very basic introduction to XeLaTeX, a document preparation system.With it you can create really professional looking documents without worrying about how to format them. You just type what you want to appear in your document.

Transcript of Introduction to XeLaTeX: An alternative document preparation system.

Page 1: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEXAn alternative document preparation system.

Nikolaos Dimos

June 17, 2012

Page 2: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — I

Contents

1 Introduction 11.1 What is LATEX? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2 Parts of a document 2

3 Creating a document 33.1 Sections and paragraphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43.2 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.3 Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

3.3.1 Simple floating figure . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53.3.2 Floating figure with subfigures . . . . . . . . . . . . . . . . . . . . . . 8

3.4 Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.5 Table of contents, figures, listings, and tables. . . . . . . . . . . . . . . . . . . . 113.6 Choosing fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123.7 Bibliography, citation and cross-referencing . . . . . . . . . . . . . . . . . . . 13

3.7.1 Cross-referencing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133.7.2 Bibliography and citation . . . . . . . . . . . . . . . . . . . . . . . . . 13

4 Typesetting Mathematics 14

A RootyHelix 15

B Source code of this document 16

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 3: Introduction to XeLaTeX: An alternative document preparation system.

II — List of Tables

List of Figures

1 e smallest document! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 Output of the sectioning commands. . . . . . . . . . . . . . . . . . . . . . . . . 43 e available ways of creating lists in LATEX. . . . . . . . . . . . . . . . . . . . . 64 Enchanced description environment. . . . . . . . . . . . . . . . . . . . . . . . 75 A simple picture include. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 Subfigure output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 Root helix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Listings

1 Top Maer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Showcase of sectioning commands . . . . . . . . . . . . . . . . . . . . . . . . . 43 A simple picture include. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Code to generate subfigure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Code to generate Table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 Code to generate ”Table of Contents” and other lists . . . . . . . . . . . . . . . 127 Font seings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 Bibliography seings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13./latexLecture.tex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

List of Tables

1 A Sample table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 4: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 1

1 Introduction

1.1 What is LATEX?

LATEX is a document markup language1 and a document preparation system2. LATEX providessome macros3 in order to use the underlying TEX programming language. X ELATEX is a newerversion of this language which supports:

• Unicode encoding of text. is means that you can write:

– English: Hello world!,

– Greek: Καλημέρα κόσμε!,

– Arabic:

العالم! مرحبا

– and Polytonic Greek: Πάτερ ἡμῶν ὁ ἐν τοῖς οὐρανοῖς· ἁγιασθήτω τὸ ὄνομάσου·… in the same text without changing the encoding of the document itself.

• X ELATEX also supports PDF file creation on it’s own which means that you don’t have tocompile your text using other programs in addition to xelatex.

• X ELATEX also brought support of the usage of TrueType and OpenType fonts that areinstalled on your system. is means that you can choose any of the installed fonts touse them in your document. is works prey much like in every modern documentprocessing application.

1.2 Editors

Before moving forward to the document authoring part we should note that a TEX —andconsequently LATEX and X ELATEX— document can be wrien in any editor you like. From themost simple command line editor in UNIX systems with no graphical environment at all, tothe most complex editors available for every OS out there. Some examples of editors wouldbe:

• Simple ones: Although theymay offer some code highlighting and indentation, nothingmore is provided. No auto-complete of commands which means that you should knowthe commands to type them fully. No shortcuts for compiling, which means that youshould be able to compile your document from a command line.

1Other markup languages are HTML, XML, SGML,…2Other document preparation systems are the OpenOffice.org Writer, LibreOffice Writer, Microso Word,

IBM Lotus Word Pro3Macros are short, easy to remember commands that invoke some other commands in order to achieve a

result.

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 5: Introduction to XeLaTeX: An alternative document preparation system.

2 — 2 Parts of a document

– nano

– Notepad++

– gedit

• Middle-class ones: ey offer command auto complete, spell checking options, shortcutcreation, automation of the compilation process.

– Texmaker

– TeXstudio. If you look at TeXstudio you will see how much it looks alike theTexmaker. is is because TeXstudio is an extended version of Texmaker whichcan add words in the spelling dictionary. To some people this may be weird, andthey would say that this should be in Texmaker in the first place.

But this is exactly where open-source development comes in. e developers ofTexmaker for some reason they didn’t implement this function. Someone elsefound Texmaker interesting us a project and also had the background to programthis functionality in. So they took the code and added in their implementation andcreated a new piece of soware which is again free and open for anyone to modify.

– Kile

– TeXnicCenter

• WYSIWYG ones: ese offer a similar experience to using more mainstream documentprocessing applications such as Microso Word, LibreOffice Writer, OpenOffice Writer,AbiWord and iWork Pages.

– LyX

For a more comprehensive list of editor you can take a look at: Comparison of TEX edi-tors[1].

2 Parts of a document

Code:

1 \documentclass[11pt,oneside ]{ article }

3 \begin{document}Hello world!

5 \end{document}

Output:

Hello world!

Figure 1: e smallest document!

e code that is shown in Fig. 1 producesthe smallest and simplest document you cancreate. It’s the traditional ”Hello world!” ex-ample for X ELATEX. In the first line you seethe \documentclass[…]{…} where we putthe initial characteristics of the document.Inside the brackets ([…]) there is the text”11pt,oneside” which means that the de-fault size of the text in the document will be

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 6: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 3

11pt and that the document will be created asan oneside document. Other document classoptions may be draft which spaces the textwith bigger inter-line spaces and omits images by replacing them with a place-holder.

Aer the \documentclass[…]{…} a document must always have at least the followingbegin-end part: \begin{document}…\end{document}.Generally, a paern should be visible.ere are some word preceded by ”\” and followed by ”{…}” these are the commands that areused by LATEX in order to define different parts of the document.

e part of the code that is between the document class definition and the \begin{document}is the preamble. In that space you will include any packages that you may use when you cre-ate your documents. We will get back to that at a later point. Another part of the documentis the ”Top Maer” which is some commands that you would use to create the title page foryour document. e top maer of this document that you are reading is shown in Listing 1.

You can see that we begin a titlepage and then we add the authors, the title and the date.ere are also some aesthetic enhancements which will be covered later. ere are somecommands that deal with font sizes (\Huge, \LARGE) and some formaing commands like \\which inserts a new line, it is equivalent to pressing Enter . But other than that the commandsare prey self-explanatory.

1 \begin{ titlepage }

3 \author{Dimos, Nikolaos and Poupakis, Stavros }\ title {{\ Huge Introduction to \XeLaTeX {}}\\

5 {\ LARGE An alternative document preparation system .}}

7 \date {\ vfill \today}\ maketitle

9 \ thispagestyle {empty}

11 \end{ titlepage }

Listing 1: Top Maer

3 Creating a document

From the previous examples you should be able now to create a document that says Helloworld! and has a title page. is section will describe what else you need to do in order tocreate the rest of the document structure. is section will include instructions to generate:

1. Sections and paragraphs

2. Lists

3. Figures

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 7: Introduction to XeLaTeX: An alternative document preparation system.

4 — 3 Creating a document

4. Tables

5. Table of contents, Table of Figures

6. Seing the font to be used

7. Adding bibliography

3.1 Sections and paragraphs

e basic structure of the document and the guidance to the reader is given by assigning a”title” to bigger or smaller parts of a piece of text. In order to do this LATEX provides somecommands to create the basic sectioning headers.

1 \ part {What a nice part !}\ chapter {What a nice chapter !}

3 \ section {is is a section }\ subsection {A subsection then follows }

5 \ subsubsection {W00t! A Subsubsection !}\paragraph{A paragraph now:} No more subsubsubsub\ldots subsections

7 \subparagraph{But we have:} a Subparagraph!

Listing 2: Showcase of sectioning commands

Figure 2: Output of the sectioning commands.

e basic sectioning commands are shown in Listing 2. Not all of them can be used in anytype of document. For example, \chapter can only be used in books and reports. So in orderto be able to use \chapter, you should have defined in the document class the document aseither a book or a report like this: ”\documentclass[…]{book}”. Figure 2 shows the output

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 8: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 5

of the code quoted in Listing 2. Each sectioning command takes as input some text that isthen used appropriately to name the part/chapter/section/….

3.2 Lists

Another commonly used feature in texts, especially in academia, are the lists. Lists are usedin order to define some key aspects of a problem and make a clear approach on them whichcan be revisited at any time offering very good ‘user experience’4.

In Fig. 3 you can see the code that is required (3a, 3c, 3e) in order to produce the respectivelist style (3b, 3d, 3f). e basic concept is that you only need to define if you want a bullet stylelist (itemize), a numbered list (enumerate), or a list with your defined descriptions (description).An aesthetic improvement to the description style list would be to indent the text that followsthe description. is could look like the example in Fig. 4.

3.3 Figures

Another very common thing in documents is the inclusion of figures. One way to put picturesin a document is as a wrapped object with the picture floating on one side of the text and thetext wrapped around it. is is good only for small pictures that will not take over more than50% of the page’s width in order to appear in a readable resolution.

3.3.1 Simple floating figure

Another way, and the most common one, is to include pictures as floating objects. Floatingobjects can be set to always float a the top or the boom of the page, or the can be explicitlyset to float at the current position that they are defined. Generally LATEX will try to positionfloats in a way that they don’t create large blank spaces in the text so that it won’t disrupt thereading. But floating seings can also be defined by other institutions. For example variousjournals will have their own template that the authors should follow. For example, if youwrite a paper for an IEEE conference, IEEE’s template will always put your floats on the topof the page regardless of where you include them in the text. is creates a concrete way ofdelivering papers for IEEE conferences and everyone aending them will expect them to bein that way. Using LATEX and a template of the journal you want your publication to look alikeyou just create the document as you would with any other template and this makes sure thatthe floats, among the other components of the document, will be placed appropriately.

In order to be able to include images and other graphics you have to include the graphicxpackage at the preamble of your document. is can be done using the following command:\usepackage{graphicx}.

4User experience in the terms of; a user who gets back to a list of itemswill seek to find condensed informationin a structured way which is easy to grasp.

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 9: Introduction to XeLaTeX: An alternative document preparation system.

6 — 3 Creating a document

\begin{itemize}\item 1st item\begin{itemize}

\item 1st nested item\end{itemize}\item 2nd item\begin{itemize}

\item 2nd nested item\end{itemize}\end{itemize}

(a) Input: e itemize environ-ment

• 1st item

– 1st nested item

• 2nd item

– 2nd nested item

(b) Output:e itemize envi-

ronment\begin{enumerate}\item 1st item

\begin{enumerate}\item 1st nested item

\end{enumerate}\item 2nd item

\begin{enumerate}\item 2nd nested item

\end{enumerate}\end{enumerate}

(c) Input: e enumerate envi-

ronment

1. 1st item

(a) 1st nested item

2. 2nd item

(a) 2nd nested item

(d) Output:e itemize envi-

ronment\begin{enumerate}\item 1st item

\begin{enumerate}\item 1st nested item

\end{enumerate}\item 2nd item

\begin{enumerate}\item 2nd nested item

\end{enumerate}\end{enumerate}

(e) Input: e description envi-

ronment

1. 1st item

(a) 1st nested item

2. 2nd item

(a) 2nd nested item

(f) Output:e itemize envi-

ronment

Figure 3: e available ways of creating lists in LATEX.

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 10: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 7

1 \begin{ description }\item[ First ] \ hfill \\

3 e first item\item[Second] \ hfill \\

5 e second item\item[ird] \ hfill \\

7 e third etc \ ldots\end{ description }

(a) Input

Firste first item

Seconde second item

irde third etc …

(b) Output

Figure 4: An aesthetic enchancement of the description environment.

Figure 5: A simple picture include.

\begin{ figure }[htbp]2 \centering

\ resizebox {0.5\ textwidth }{!}{4 \ includegraphics {./ images/020612−4.jpg}

}6 \caption {A simple picture include .}\ label { fig : simplePictureInclude }

\end{ figure }

Listing 3: A simple picture include.

In Listing 3 you can see the code that is required to insert an image in a document. eimage that is inserted using that code snippet is shown in 5. In the code we see the followingcommands:

• \begin{figure}…\end{figure}: With this you create a new floating figure environ-ment. Between those two lines the appropriate code to create the figure should beentered.

• e main parts of a figure are:

– e \includegraphics{…} command which is the command that actually bringsthe picture in the document.

– e \caption{…} commandwhich sets the caption to be shown under the picture.

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 11: Introduction to XeLaTeX: An alternative document preparation system.

8 — 3 Creating a document

– and the \label{…}, which always follows \caption{…}, which creates a label forthis picture in order to be cross-referenced later anywhere in the document.

• ere are also some other commands here that help with the placement of the pictureso that it won’t go out of limits.

– \centering is used tomakewhatever is inside the \begin{figure}…\end{figure}to be horizontally aligned to the center of the page.

– \resizebox{0.5\textwidth}{!}{\includegraphics{…}} is used to resize theimage to the a width equivalent to the 50% of the text’s width. e resizeboxcommand generallyworks like \resizebox{⟨width⟩}{⟨height⟩}{⟨image to beresized⟩}. You should notice that in the field where we should have put theheight we just have ”!” this is done so that resizebox will scale the picture only bywidth retaining the aspect ratio of the image.

3.3.2 Floating figure with subfigures

In order to create a group of figures like the one shown in Fig. 6 you would have to use thecode that is shown in Listing 4. But before writing the subfigure code you should includein the preamble of your document the package subfig. In order to include this package youshould use the command \usepackage{subfig}.

In order to create such a figure with one or more subfigures you have to create a figureenvironment likewe do in Listing 4, Line 1. e you have to create two subfigure environments(\begin{subfigure}…\end{subfigure}) inside which you will include the images like youwould normally do as if you were to include a single floating image. You are also able to assigncaptions and labels to the subfigures so you can refer directly to them from the document.

(a) e first picture (b) e second picture

Figure 6: A caption that is about all the pictures in the figure. Lorem ipsum dolor sit amet,consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et doloremagna aliqua.

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 12: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 9

1 \begin{ figure }[htbp]\centering

3 \begin{ subfigure }[ t ]{0.3\ textwidth}\centering

5 \ resizebox {1\ textwidth }{!}{\ includegraphics {./ images/020612−4.jpg}

7 }\caption {e first picture }

9 \ label { fig : firstPicInSubfig }\end{ subfigure }%

11 \quad %add desired spacing between images, e . g . ~, \quad, \qquad etc .%(or a blank line to force the subfigure onto a new line )

13 \begin{ subfigure }[ t ]{0.3\ textwidth}\centering

15 \ resizebox {\ textwidth }{!}{\ includegraphics {./ images/020612−4.jpg}

17 }\caption {e second picture }

19 \ label { fig : secondPicInSubfig }\end{ subfigure }

21 \caption[Subfigure output ]{A caption that is about all the pictures in thefigure . Lorem ipsum dolor sit amet, consectetur adipisicing elit , sed

23 do eiusmod tempor incididunt ut labore et dolore magna aliqua .}\ label { fig :subfigDemonstration}

25 \end{ figure }

Listing 4: e code to generate the subfigure shown in Fig. 6

3.4 Tables

Another way to present data except from importing figures is creating tables. In Listing 5 youcan see the code that generates Table 1. You can see that the table environment is similar tothe figure. We begin a table environment and then inside we insert the following commands5:

• We see again the \centering command which is used to center the table in the page.

• Aer that we see an environment in which we will define the table. e tabular en-vironment. You can see that we again \begin…\end the tabular environment as anyother environment.

• e tabular environment has some arguments though, {|r|l|}. ese arguments de-fine the number of columns and the looks of them.

– Having two leers inside the brackets {…} means that the table will be a two col-umn table.

5e commands in this example are only a small subset of those that can be used when creating a table.

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 13: Introduction to XeLaTeX: An alternative document preparation system.

10 — 3 Creating a document

– e vertical lines ‘|’ that you see inside the brackets denote where vertical bordersof the columns will show up. In this occasion we will have vertical borders drawnbefore and aer every column.

– e last observation has to do with the text alignment inside each cell. the leer rand l that are shown inside the brackets denote that the text in the cells of the firstcolumn will be aligned to the right side and the text in the second column will bealigned to the le side of the column. Another option is the leer c which wouldalign the text in the center.

• Aer the table definition we have the definitions of every line. At the first line we seethe command \hline which is the command that creates the horizontal borders of thecells in the table.

• en we have a normal line. e data in the first column will be 7C0 and in the secondhexadecimal the start of a new column is denoted using the & sign. At the end of eachline you have to put \\ in order to create a new line.

• In order to create more new lines you just repeat the above. In the case, that you wantthe horizontal border of a line to appear only under/over some cells and not the wholeline you can use \cline{…-…}. In the example that we present here \cline{2-2}means that the line will appear only in cell. Cline is used like this \cline{⟨startingcolumn⟩-⟨ending column⟩}.

Tables can get really complicated and have many multicolumn or multirow cells appearin their structure. Creating such tables gets out of the scope of this document. If youwant to find more details about designing more complicated tables you should start bylooking at [2] under the section ”Tables”.

Another way to easily get tables into a LATEX document is to create the table in Excelor a similar program and use a specific extension for that program in order to generate‘copy-pasteable’ LATEX code. Such extension for Excel is the excel2latex which can befound here6.

ere are also other extensions for other popular products that are used to producetabular data like OpenOffice.org Calc, R, MATLAB. Links to them can be found here7.

6CTAN archive for excel2latex: http://www.ctan.org/tex-archive/support/excel2latex/7Wikibooks site: http://en.wikibooks.org/wiki/LaTeX/Tables

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 14: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 11

1 \begin{ table }[ htbp]\centering

3 \begin{ tabular }{| r | l |}\hline

5 7C0 & hexadecimal \\3700 & octal \\

7 \ cline {2−2}11111000000 & binary \\

9 \hline \hline1984 & decimal \\

11 \hline$\ frac {\ sqrt [3]{8* x +2}}{3* x+5}$ & math\\

13 \hline\end{ tabular }

15 \caption {A Sample table }\ label { tab :sampleTable}

17 \end{ table }

Listing 5: e code to generate Table 1

7C0 hexadecimal3700 octal

11111000000 binary

1984 decimal3√8∗x+23∗x+5

math

Table 1: A Sample table

3.5 Table of contents, figures, listings, and tables.

If you have followed the previous examples to create Sections, subsections, figures, tablescreating a ”Table of Contents” or a ”List of figures” is the easiest thing that you can do. Listing6 contains the code that is used to create the ”Table of contents” and the rest of the Lists ofthis document that are shown on pages and .

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 15: Introduction to XeLaTeX: An alternative document preparation system.

12 — 3 Creating a document

1 \setcounter {page }{1}\pagenumbering{Roman}

3

\ tableofcontents5

\newpage7 \ listoffigures

\vspace {1.5cm}9 \ lstlistoflistings

\vspace {1.5cm}11 \ listoables

13 \newpage\setcounter {page }{1}

15 \pagenumbering{arabic}

Listing 6: Code to generate ”Table of Contents”, List of Figures, and other lists.

In the code quoted in Listing 6 you can see the commands \tableofcontents, \listoffigures,\lstlistoflistings, and \listoftables. ese are the only commands necessary to cre-ate the respective lists. e rest of the code that you see in Listing 6 are there only for for-maing reasons.

• efirst two lineswith the commands \setcounter{page}{1} and \setcounter{Roman}are used in order to format the page numbering style and set the starting page number.For these pages we have choosen the page numbering style to be in Roman numbers (I,II, III, …) and the numbering to start from I.

• we have also used the \newpage command in order to create a new page aer the Tableof Contents where we would put the rest of the lists.

• e \{vspace}{1.5cm} command is used to create some black vertical space. In thisoccasion we are creating some blank vertical space between the lists of 1.5cm.

• e listing finishes with the same commands that it started which are now used to resetthe page number to 1 and the style to Arabic (1, 2, 3, …)

3.6 Choosing fonts

In order to choose the font which your document will use you have to put some commandsin the preamble8.

8e segment of the .tex file that is between the \documentclass and the \begin{document}

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 16: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 13

1 \usepaage{fontspec}\ setmainfont {Linux Libertine O}

3 \ defaultfontfeatures { Ligatures=TeX}

Listing 7: Code to set the font to be used.

In Listing 7 you can see the code that is used to set the default font for the text. In order todo this you have to insert the three lines that are shown on Listing 7 in the preamble of yourdocument.

• You first declare that you will be using the fontspec package.

• en you have to select the main font using the \setmainfont{…} command. In thatcommand you will put in the place of the ”…” the name of the font that you want to use.For this document you can see that we are using a font named ”Linux Libertine O”.

• e last command is issued in order to create ligatures for common groups of leers.Some of those are: , fi, ffi, , , Qea, Qea, f, fi, p.

3.7 Bibliography, citation and cross-referencing

3.7.1 Cross-referencing

You have seen throughout this text that we have been referring to Figures, Tables, and List-ings. is is done by using the labels that we set up when we insert those elements. Whenwe insert an image we create a label using \label{…}. In the place of ”…” we put the la-bel that we will use to refer to this element later. For a figure the label would look like\label{fig:aDiscriptiveLabel}. You can see that we prepend the label with fig:. Youcan also prepend labels for tables with tab:. is is so that you can distinguish the labels ata later point. Because at some point your document may have many labels set up. In orderto refer to a figure you will have to use the \ref{…} command by replacing the ”…” with thelabel that you want to refer to. Be careful though, this only gets the number of the elementyou are referring. So, if you want to refer to a figure you should type the word Figure andthen \label{fig:myFigure}.

3.7.2 Bibliography and citation

1 \usepaage[round,authoryear,merge,sort ]{ natbib }\ bibliographystyle {agsm}

3

\bibliography {name_of_the_bibliography_file }

Listing 8: Seings for bibliography.

Listing 8 shows the required commands to create the bibliography and be able to createcitations in the text. e first line is loading the package natbib which is used to format the

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 17: Introduction to XeLaTeX: An alternative document preparation system.

14 — 4 Typesetting Mathematics

citations that you put in the text. Here for example the options used will format the citationsaccording to the harvard style. So it will use:

• round brackets = parentheses

• authoryear form

• it will merge continuous citations and separate them with ”;”

• it will sort the citations alphabetically.

On the second line the bibliography style is declared. In this occasion we are using agsmwhich is a harvard style. is command should also be in the preamble. It is beer to groupthose two commands and keep them together in the preamble.

e last command is going to actually load the file that you have the bibliography in. youshould save the bibliography file in the same folder as you save the .tex file of your document.A good way to creating and managing your bibliography file is JabRef9. [3]

4 Typesetting Mathematics

ere are three ways to insert an equation in a document:

• e first way is to create an inline equation like this3√8∗x+23∗x+5

using the following code:$\frac{\sqrt[3]{8*x+2}}{3*x+5}$

• e second way is to create an unnumbered equation like the following one

3√8 ∗ x+ 2

3 ∗ x+ 5

using the following code:\[\frac{\sqrt[3]{8*x+2}}{3*x+5}\]

• And as a numbered equation like the one below, which can also be referenced in thedocument as Equation (1).

3√8 ∗ x+ 2

3 ∗ x+ 5(1)

e code that produces the Equation (1) is:

\begin{equation }\ label {eq: test }2 \ frac {\ sqrt [3]{8* x +2}}{3* x+5}

\end{equation}

In order to use the equation environment you should load the package amsmath in thepreamble of your document. is can be donewith the following command: \usepackage{amsmath}

9JabRef: http://jabref.sourceforge.net/

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 18: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 15

A RootyHelix

Figure 7 demonstrates the power of TEX in generating more than text! e image shown inthis figure is created using only LATEX commands and when you zoom in and out you get moredetails contrary to what would happen if you just included a .jpg file.

..

√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

.

√29

.

√30

.

√31

.

√32

.

√33

.

√34

.

√35

.

√36

.

√37

.

√38

.

√39

.

√40

.

√41

.

√42

.

√43

.

√44

.

√45

.

√46

.

√47

.

√48

.

√49

.

√50

.

√51

.

√52

.

√53

. √54.

√55

.

√56

.

√57

.

√58

.

√59

.

√60

.

√61

.

√62

.

√63

.

√64

.

√65

.

√66

.

√67

.

√68

.

√69

.

√70

.

√71

.

√72

.

√73

.

√74

.

√75

.

√76

.

√77

.

√78

.

√79

.√80

.

√81

.

√82

.

√83

.

√84

.

√85

.

√86

.

√87

.

√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

.

√29

.

√30

.

√31

.

√32

.

√33

.

√34

.

√35

.

√36

.

√37

.

√38

.

√39

.

√2

.

√3

.

√4

.

√5

.

√6

.√7

.

√8

.

√9

.

√10

.

√11

.

√12

.

√13

.

√14

.

√15

.

√16

. √1

Figure 7: Root helix

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 19: Introduction to XeLaTeX: An alternative document preparation system.

16 — B Source code of this document

B Source code of this document

1 %%is work is licensed under the Creative Commons Aribution−NonCommercial−ShareAlike%%3.0 Unported License . To view a copy of this license , visit

3 %%hp :// creativecommons. org / licenses /by−nc−sa/3.0/ or send a leer to :%%

5 %%Creative Commons%%444 Castro Street

7 %%Suite 900%%Mountain View

9 %%California , 94041%%USA

11

13 \documentclass[a4paper,12pt,twoside , final ]{ article }

15 %Font seings\usepaage{ xltxtra }

17 \usepaage{xunicode}\usepaage{fontspec}

19 \ defaultfontfeatures { Ligatures=TeX}\ setmainfont {Linux Libertine O}

21

%%Include various packages23

%A package that you need in order provide more extensive25 %math functionality in your document e .g . add numbered equations

\usepaage{amsmath}27

%A package that shrinks the margins of the page.29 \usepaage{ fullpage }

31 %A package to create fancy headers and footers\usepaage{fancyhdr}

33 \ setlength {\ headheight}{20pt }

35 %Set the pagestyle to fancy\pagestyle {fancy}

37

%Clear the header style39 \fancyhead{}

41 %Set the new header style\fancyhead[LE] {\ textbf {\ thepage} −−− \textbf{\nouppercase\lemark }\vspace{1cm}}

43 \fancyhead[RO] {\ textbf { Introduction to \XeLaTeX{}} −−− \textbf{\thepage}\vspace{1cm}}\renewcommand{\headrulewidth}{0pt} % remove lines as well }

45

%Set the footer style

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 20: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 17

47 \ fancyfoot [C]{\ includegraphics [ scale =.8]{./ images/by−nc−sa.pdf}\\\begin{ scriptsize }

49 Introduction to \XeLaTeX{}: An alternative document preparation system. by \ href { hp :// www.scribd.com/doc/97184558/Introduction−to−XeLaTeX−An−alternative−document−preparation−system}{Nikolaos Dimos} \\

is licensed under a \ href { hp :// creativecommons.org/ licenses /by−nc−sa/3.0/}{Creative CommonsAribution−NonCommercial−ShareAlike 3.0 Unported License}.\\

51 \end{ scriptsize }}

53 %A package to create wrapped figures in the text .\usepaage{wrapfig}

55

%A package required in order to include graphics in the text .57 \usepaage{graphicx}

59 %A package that provides some more logos like \XeLaTeX{}\usepaage{metalogo}

61

%A package that provides small images that represent keyboard buons63 \usepaage{keystroke}

65 %A package that is used to creat hyperlinks for all the citations , cross− references and URLs in thetext

\usepaage{hyperxmp}67 \usepaage{hyperref}

\hypersetup{69 colorlinks =true , % false : boxed links ; true : colored links

linkcolor =black , % color of internal links71 citecolor =black , % color of links to bibliography

urlcolor =blue % color of external links73 }

75 \hypersetup{pditle ={%

77 Introduction to XeLaTeX: An alternative document preparation system .},pdfauthor={Nikolaos Dimos},

79 pdfcopyright={is work is licensed under a Creative Commons Aribution−NonCommercial−ShareAlike 3.0 Unported License.},

pdflicenseurl ={hp :// creativecommons.org/ licenses /by−nc−sa/3.0/},81 pdfsubject ={ introduction to XeLaTeX},

pdeywords={introduction , Document, typeseing , bibliography , typography, beginners , latex , tex ,How to, xelatex , word alternative },

83 pdflang={en}}

85

87 %A package which in conjunction with the \ capstart command points at the top of an%image when you click its refernce instead of pointing at its caption

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 21: Introduction to XeLaTeX: An alternative document preparation system.

18 — B Source code of this document

89 \usepaage[all ]{ hypcap}

91 %A package that formats what the captions will look like .\usepaage[format=hang, labelfont =bf ]{ caption }

93

%A package that provides captions for the subfigures .95 \usepaage{subcaption}

97 %A package that gives you the ability to define colors .\usepaage{color }

99

\ definecolor {gray }{ rgb }{0.5,0.5,0.5}101

%A package to provide code listings103 \usepaage{ listings }

105 %Set the default options for the code listings in this document.\ lstset {language=[LaTeX]TeX,

107 basicstyle =\ footnotesize ,numbers=le,

109 numberstyle=\tiny\ color {gray },stepnumber=2,

111 numbersep=15pt,stringstyle =\ ttfamily ,

113 columns=flexible ,captionpos=b,

115 tabsize =3}

117 %%A package that gets XMP metadata to the pdf file that is generated%\usepackage{xmpincl}

119 %\includexmp {./ includes /metadata}

121 %A package that provides the ability to write in multiple languages in a text .\usepaage{ polyglossia }

123 \setmainlanguage{english }\ setotherlanguage {greek}

125 \ setotherlanguage { arabic }

127 %Set the fonts for the other languages .\newfontfamily\greekfont {Old Standard TT}

129 \newfontfamily\ arabicfont {Scheherazade Graphite Alpha}

131

%Sets the bibliography style .133 \ bibliographystyle { ieeetr }

135 %Set the line spacing .\ linespread {1.15}

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 22: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 19

137

\begin{document}139

\begin{ titlepage }141

\author {\vspace{1cm} Nikolaos Dimos}143 \ title {{\ Huge Introduction to \XeLaTeX {}}\\

{\ LARGE An alternative document preparation system .}}145

\date {\ vfill \today}147 \ maketitle

\ thispagestyle {empty}149

\end{ titlepage }151 \setcounter {page }{1}

\pagenumbering{Roman}153 \ label { toc }

\ tableofcontents155 \newpage

\ label { lists }157 \ listoffigures

\vspace {1.5cm}159 \ lstlistoflistings

\vspace {1.5cm}161 \ listoables

\newpage163

165 \setcounter {page }{1}\pagenumbering{arabic}

167 \ section { Introduction }\ subsection {What is \LaTeX{}?}

169

171 \LaTeX{} is a document markup language\footnote{Other markup languages are HTML, XML, SGML,\ldots}and a document preparation system\footnote{Other document preparation systems are the OpenOffice.org Writer , LibreOffice Writer , Microso Word,

IBM Lotus Word Pro}. \LaTeX{} provides some macros\footnote{Macros are short , easy to remembercommands that invoke some other commands in order to achieve a result .} in order to use theunderlying \TeX{} programming language. \XeLaTeX{} is a newer version of this language whichsupports :

173 \begin{ itemize }\item Unicode encoding of text . is means that you can write :

175 \begin{ itemize }\item \ textbf { English :} Hello world !,

177 \item \ textbf {Greek:} \ textgreekΚαλημέρα{ κόσμε !},\item \ textbf {Arabic :} \begin{ flushright }\ textarabic [ locale =mashriq ]{ !}

179 \end{ flushright }

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 23: Introduction to XeLaTeX: An alternative document preparation system.

20 — B Source code of this document

\item and \ textbf { Polytonic Greek:} \ textgreek [ variant=polyΠάτερ]{ ἡμῶνὁἐντοῖςοὐρανοῖς ·ἁγιασθήτωτὸὄνομάσου · \ ldots }

181 in the same text without changing the encoding of the document itself .\end{itemize }

183

\item \XeLaTeX{} also supports PDF file creation on it ’ s own which means that you don’t have tocompile your text using other programs in addition to \emph{xelatex }.

185 \item \XeLaTeX{} also brought support of the usage of TrueType and OpenType fonts that are installedon your system. is means that you can choose any of the installed fonts to use them in your

document. is works prey much like in every modern document processing application .\end{itemize }

187

\ subsection { Editors }189 Before moving forward to the document authoring part we should note that a \TeX{} −−−and

consequently \LaTeX{} and \XeLaTeX{}−−− document can be wrien in any editor you like . From themost simple command line editor in UNIX systems with no graphical environment at all , to themost complex editors available for every OS out there . Some examples of editors would be:

\begin{ itemize }191 \item \ textbf {Simple ones :} Although they may offer some code highlighting and indentation , nothing

more is provided . No auto−complete of commands which means that you should know the commandsto type them fully. No shortcuts for compiling, which means that you should be able to compileyour document from a command line.

\begin{ itemize }193 \item \ href { hp :// www.nano−editor.org/}{nano}

\item \ href { hp :// notepad−plus−plus.org/}{Notepad++}195 \item \ href { hp :// projects .gnome.org/gedit /}{ gedit }

\end{itemize }197 \item \ textbf {Middle−class ones :} ey offer command auto complete, spell checking options , shortcut

creation , automation of the compilation process .\begin{ itemize }

199 \item \ href { hp :// www.xm1math.net/texmaker/}{Texmaker}\item \ href { hp :// texstudio . sourceforge . net /}{ TeXstudio }. If you look at TeXstudio you will

see how much it looks alike the Texmaker. is is because TeXstudio is an extended versionof Texmaker which can add words in the spelling dictionary . To some people this may be

weird, and they would say that this should be in Texmaker in the first place .201

But this is exactly where open−source development comes in. e developers of Texmaker forsome reason they didn’ t implement this function . Someone else found Texmaker interestingus a project and also had the background to program this functionality in . So they tookthe code and added in their implementation and created a new piece of soware which isagain free and open for anyone to modify.

203 \item \ href { hp :// kile . sourceforge . net /}{ Kile }\item \ href { hp :// www.texniccenter.org /}{ TeXnicCenter}

205 \end{itemize }\item \ textbf {WYSIWYG ones:} ese offer a similar experience to using more mainstream document

processing applications such as Microso Word, LibreOffice Writer , OpenOffice Writer , AbiWordand iWork Pages.

207 \begin{ itemize }

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 24: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 21

\item \ href { hp :// www.lyx.org/}{LyX}209 \end{itemize }

\end{itemize }211

For a more comprehensive list of editor you can take a look at : \ href { hp :// en.wikipedia .org/wiki/Comparison_of_TeX_editors}{Comparison of \TeX{} editors }\ cite {Wikipedia2012CoTe−WTFE}.

213

\ section { Parts of a document}215

217

219 \begin{wrapfigure }{ r }{0.5\ textwidth}\ capstart

221 \centering\vspace{−5pt}

223 \ textbf {Code:}\ lstset {numbersep=3pt}

225 \begin{ lstlisting }\documentclass[11pt,oneside ]{ article }

227

\begin{document}229 Hello world!

\end{document}231 \end{ lstlisting }

\ textbf {Output:}233 \begin{quote}

Hello world!235 \end{quote}

\vspace{−5pt}237 \caption {e smallest document!}\ label { fig :smallDocument}

\end{wrapfigure}239

e code that is shown in Fig . \ ref { fig :smallDocument} produces the smallest and simplest documentyou can create . It ’ s the traditional ”Hello world!” example for \XeLaTeX{}. In the first lineyou see the \ texttt {\ textbaslash {} documentclass[\ ldots ]\{\ ldots \}} where we put the initialcharacteristics of the document. Inside the brackets ([\ ldots ]) there is the text ”\ texttt {11pt ,oneside }” which means that the default size of the text in the document will be \emph{11pt} andthat the document will be created as an \emph{oneside document}. Other document class optionsmay be \ texttt { dra } which spaces the text with bigger inter−line spaces and omits images byreplacing them with a place−holder.

241

Aer the \ texttt {\ textbaslash {} documentclass[\ ldots ]\{\ ldots \}} a document must always have atleast the following \emph{begin−end} part: \ texttt {\ textbaslash {} begin \{ document\}\ ldots \textbaslash {} end\{document \}}. Generally , a paern should be visible . ere are some wordpreceded by ”\ textbaslash ” and followed by ”\{\ ldots \}” these are the commands that are usedby \LaTeX{} in order to define different parts of the document.

243

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 25: Introduction to XeLaTeX: An alternative document preparation system.

22 — B Source code of this document

e part of the code that is between the \emph{document class} definition and the \ texttt {\textbaslash {} begin \{ document\}} is the \emph{preamble}. In that space you will include anypackages that you may use when you create your documents. We will get back to that at a laterpoint . Another part of the document is the ”\emph{Top Maer}” which is some commands that youwould use to create the title page for your document. e top maer of this document that youare reading is shown in Listing \ ref { lst : topMaer }.

245

You can see that we begin a \emph{titlepage } and then we add the authors , the title and the date .ere are also some aesthetic enhancements which will be covered later . ere are somecommands that deal with font sizes (\ textbaslash {} Huge, \ textbaslash {} LARGE) and someformaing commands like \textbaslash {}\ textbaslash {} which inserts a new line , it isequivalent to pressing \Enter . But other than that the commands are prey self−explanatory.

247

\ lstset { caption={Top Maer }, label = lst : topMaer}249 \begin{minipage }{\ textwidth}

\begin{ lstlisting }251 \begin{ titlepage }

253 \author{Dimos, Nikolaos and Poupakis, Stavros }\ title {{\ Huge Introduction to \XeLaTeX {}}\\

255 {\ LARGE An alternative document preparation system .}}

257 \date {\ vfill \today}\ maketitle

259 \ thispagestyle {empty}

261 \end{ titlepage }\end{ lstlisting }

263 \end{minipage}

265 \ section {Creating a document}

267 From the previous examples you should be able now to create a document that says \emph{Hello world!}and has a title page. is section will describe what else you need to do in order to createthe rest of the document structure . is section will include instructions to generate :

\begin{enumerate}269 \item Sections and paragraphs

\item Lists271 \item Figures

\item Tables273 \item Table of contents , Table of Figures

\item Seing the font to be used275 \item Adding bibliography

\end{enumerate}277

\ subsection { Sections and paragraphs}279

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 26: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 23

e basic structure of the document and the guidance to the reader is given by assigning a ” title ”to bigger or smaller parts of a piece of text . In order to do this \LaTeX{} provides somecommands to create the basic sectioning headers .

281

\begin{minipage }{\ textwidth}283 \ lstset { caption={Showcase of sectioning commands}, label={ lst : sectioningCommandsInput}}

\begin{ lstlisting }285 \ part {What a nice part !}

\ chapter {What a nice chapter !}287 \ section {is is a section }

\ subsection {A subsection then follows }289 \ subsubsection {W00t! A Subsubsection !}

\paragraph{A paragraph now:} No more subsubsubsub\ldots subsections291 \subparagraph{But we have:} a Subparagraph!

\end{ lstlisting }293 \end{minipage}

295

\begin{ figure }[htbp]297 \ capstart

\centering299 \ includegraphics [ scale =.5]{./ images/ sectioning .pdf}

\caption {Output of the sectioning commands.}\label{ fig :sectioningCommandsOutput}301 \end{ figure }

303 e basic sectioning commands are shown in Listing \ ref { lst : sectioningCommandsInput}. Not all ofthem can be used in any type of document. For example, \ texttt {\ textbaslash {} chapter } can onlybe used in books and reports . So in order to be able to use \ texttt {\ textbaslash {} chapter },you should have defined in the \emph{document class} the document as either a \emph{book} or a \emph{report} like this : ”\ texttt {\ textbaslash {} documentclass[\ ldots ]\{ book \}}”. Figure \ ref {fig :sectioningCommandsOutput} shows the output of the code quoted in Listing \ ref { lst :sectioningCommandsInput}. Each sectioning command takes as input some text that is then usedappropriately to name the part /chapter/ section /\ ldots .

\ subsection { Lists }305

Another commonly used feature in texts , especially in academia, are the lists . Lists are used inorder to define some key aspects of a problem and make a clear approach on them which can berevisited at any time offering very good ‘user experience ’\ footnote {User experience in the termsof ; a user who gets back to a list of items will seek to find condensed information in astructured way which is easy to grasp .}.

307

\begin{ figure }[htbp]309 \centering

\begin{ subfigure }[ b ]{0.3\ textwidth}311 \centering

\begin{verbatim}313 \begin{ itemize }

\item 1st item

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 27: Introduction to XeLaTeX: An alternative document preparation system.

24 — B Source code of this document

315 \begin{ itemize }\item 1st nested item

317 \end{itemize }\item 2nd item

319 \begin{ itemize }\item 2nd nested item

321 \end{itemize }\end{itemize }

323 \end{verbatim}\caption {\ textbf { Input :} e \emph{itemize} environment}

325 \ label { fig : itemizeEnvInput}\end{ subfigure }%

327 \quad %add desired spacing between images, e . g . ~, \quad, \qquad etc .%(or a blank line to force the subfigure onto a new line )

329 \begin{ subfigure }[ b ]{0.3\ textwidth}\centering

331 \begin{ itemize }\item 1st item

333 \begin{ itemize }\item 1st nested item

335 \end{itemize }\item 2nd item

337 \begin{ itemize }\item 2nd nested item

339 \end{itemize }\end{itemize }

341 \caption {\ textbf {Output:}e \emph{itemize} environment}\ label { fig : itemizeEnvOutput}

343 \end{ subfigure }\\ \hrule%add desired spacing between images, e . g . ~, \quad, \qquad etc .

345 %(or a blank line to force the subfigure onto a new line )\begin{ subfigure }[ b ]{0.3\ textwidth}

347 \centering\begin{verbatim}

349 \begin{enumerate}\item 1st item

351 \begin{enumerate}\item 1st nested item

353 \end{enumerate}\item 2nd item

355 \begin{enumerate}\item 2nd nested item

357 \end{enumerate}\end{enumerate}

359 \end{verbatim}\caption {\ textbf { Input :} e \emph{enumerate} environment}

361 \ label { fig :enumEnvInput}\end{ subfigure }

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 28: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 25

363 \qquad\qquad\begin{ subfigure }[ b ]{0.3\ textwidth}

365 \centering\begin{enumerate}

367 \item 1st item\begin{enumerate}

369 \item 1st nested item\end{enumerate}

371 \item 2nd item\begin{enumerate}

373 \item 2nd nested item\end{enumerate}

375 \end{enumerate}\caption {\ textbf {Output:}e \emph{itemize} environment}

377 \ label { fig :enumeEnvOutput}\end{ subfigure }

379 \\ \hrule%add desired spacing between images, e . g . ~, \quad, \qquad etc .%(or a blank line to force the subfigure onto a new line )

381 \begin{ subfigure }[ b ]{0.3\ textwidth}\centering

383 \begin{verbatim}\begin{enumerate}

385 \item 1st item\begin{enumerate}

387 \item 1st nested item\end{enumerate}

389 \item 2nd item\begin{enumerate}

391 \item 2nd nested item\end{enumerate}

393 \end{enumerate}\end{verbatim}

395 \caption {\ textbf { Input :} e \emph{description} environment}\ label { fig :descEnvInput}

397 \end{ subfigure }\qquad\qquad

399 \begin{ subfigure }[ b ]{0.3\ textwidth}\centering

401 \begin{enumerate}\item 1st item

403 \begin{enumerate}\item 1st nested item

405 \end{enumerate}\item 2nd item

407 \begin{enumerate}\item 2nd nested item

409 \end{enumerate}\end{enumerate}

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 29: Introduction to XeLaTeX: An alternative document preparation system.

26 — B Source code of this document

411 \caption {\ textbf {Output:}e \emph{itemize} environment}\ label { fig :descEnvOutput}

413 \end{ subfigure }\caption {e available ways of creating lists in \LaTeX {}.}\ label { fig : listEnv }

415 \end{ figure }

417 In Fig . \ ref { fig : listEnv } you can see the code that is required (\ ref { fig : itemizeEnvInput }, \ ref { fig:enumEnvInput}, \ref { fig :descEnvInput}) in order to produce the respective list style (\ ref { fig :itemizeEnvOutput}, \ ref { fig :enumeEnvOutput}, \ref{ fig :descEnvOutput}). e basic concept is thatyou only need to define if you want a bullet style list (\ emph{itemize}) , a numbered list (\

emph{enumerate}), or a list with your defined descriptions (\ emph{description }) . An aestheticimprovement to the \emph{description} style list would be to indent the text that follows thedescription . is could look like the example in Fig . \ ref { fig :aesthEnchDesc}.

\begin{ figure }419 \centering

\begin{ subfigure }[ b ]{0.4\ linewidth}421 \centering

\ lstset { caption ={}, label ={}}423 \begin{ lstlisting }

\begin{ description }425 \item[ First ] \ hfill \\

e first item427 \item[Second] \ hfill \\

e second item429 \item[ird] \ hfill \\

e third etc \ ldots431 \end{ description }

\end{ lstlisting }433 \caption {\ textbf { Input }}

\ label { fig :enchancedDescInput}435 \end{ subfigure }%

\qquad %add desired spacing between images, e . g . ~, \quad, \qquad etc .437 %(or a blank line to force the subfigure onto a new line )

\begin{ subfigure }[ b ]{0.4\ linewidth}439 \centering

\begin{ description }441 \item[ First ] \ hfill \\

e first item443 \item[Second] \ hfill \\

e second item445 \item[ird] \ hfill \\

e third etc \ ldots447 \end{ description }

\caption {\ textbf {Output}}449 \ label { fig :enchancedDescOutput}

\end{ subfigure }451 \caption[Enchanced description environment.]{An aesthetic enchancement of the \emph{description}

environment .}\ label { fig :aesthEnchDesc}

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 30: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 27

\end{ figure }453

\ subsection { Figures }455

Another very common thing in documents is the inclusion of figures . One way to put pictures in adocument is as a wrapped object with the picture floating on one side of the text and the textwrapped around it . is is good only for small pictures that will not take over more than 50\%of the page’ s width in order to appear in a readable resolution .

457

\ subsubsection {Simple floating figure }459 Another way, and the most common one, is to include pictures as floating objects . Floating objects

can be set to always float a the top or the boom of the page, or the can be explicitly set tofloat at the current position that they are defined . Generally \LaTeX{} will try to positionfloats in a way that they don’t create large blank spaces in the text so that it won’t disruptthe reading . But floating seings can also be defined by other institutions . For examplevarious journals will have their own template that the authors should follow . For example, ifyou write a paper for an IEEE conference , IEEE’s template will always put your floats on the topof the page regardless of where you include them in the text . is creates a concrete way ofdelivering papers for IEEE conferences and everyone aending them will expect them to be inthat way. Using \LaTeX{} and a template of the journal you want your publication to look alikeyou just create the document as you would with any other template and this makes sure that thefloats , among the other components of the document, will be placed appropriately .

461 In order to be able to include images and other graphics you have to include the \emph{graphicx}package at the preamble of your document. is can be done using the following command: \texttt{\ textbaslash {} usepackage\{graphicx \}}.

463 \begin{ figure }[htbp]\ capstart

465 \centering\ resizebox {0.3\ textwidth }{!}{

467 \ includegraphics {./ images/020612−4.jpg}}

469 \caption {A simple picture include .}\ label { fig : simplePictureInclude }\end{ figure }

471

\begin{minipage }{\ textwidth}473 \ lstset { caption={A simple picture include .}, label ={ lst : simplePictureIncludeCode }}

\begin{ lstlisting }475 \begin{ figure }[htbp]

\centering477 \ resizebox {0.5\ textwidth }{!}{

\ includegraphics {./ images/020612−4.jpg}479 }

\caption {A simple picture include .}\ label { fig : simplePictureInclude }481 \end{ figure }

\end{ lstlisting }483 \end{minipage}

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 31: Introduction to XeLaTeX: An alternative document preparation system.

28 — B Source code of this document

485

In Listing \ ref { lst : simplePictureIncludeCode } you can see the code that is required to insert animage in a document. e image that is inserted using that code snippet is shown in \ ref { fig :simplePictureInclude }. In the code we see the following commands:

487 \begin{ itemize }\item \ texttt {\ textbaslash {} begin \{ figure \}\ ldots \ textbaslash {} end\{ figure \}}: With this you

create a new floating figure environment. Between those two lines the appropriate code to createthe figure should be entered .

489 \item e main parts of a figure are :\begin{ itemize }

491 \item e \ texttt {\ textbaslash {} includegraphics \{\ ldots \}} command which is the commandthat actually brings the picture in the document.

\item e \ texttt {\ textbaslash {} caption \{\ ldots \}} command which sets the caption to beshown under the picture .

493 \item and the \ texttt {\ textbaslash {} label \{\ ldots \}}, which always follows \ texttt {\textbaslash {} caption \{\ ldots \}}, which creates a label for this picture in order to becross−referenced later anywhere in the document.

\end{itemize }495 \item ere are also some other commands here that help with the placement of the picture so that it

won’t go out of limits .\begin{ itemize }

497 \item \ texttt {\ textbaslash {} centering } is used to make whatever is inside the \ texttt {\textbaslash {} begin \{ figure \}\ ldots \ textbaslash {} end\{ figure \}} to be horizontallyaligned to the center of the page.

\item \ texttt {%499 \ textbaslash {} resizebox%

\{0.5 %501 \ textbaslash {} textwidth%

\}%503 \{!\}\{\ textbaslash {} includegraphics \{\ ldots \}\}} is used to resize the image to the a

width equivalent to the 50\% of the text ’ s width . e resizebox command generally workslike \ text {\ textbackslash {} resizebox \{$\ langle $width$\ rangle $\}\{$\ langle $height $\ rangle$\}\{$\ langle $image to be resized $\ rangle $\}}. You should notice that in the field wherewe should have put the height we just have ”!” this is done so that resizebox will scalethe picture only by width retaining the aspect ratio of the image.

\end{itemize }505 \end{itemize }

507

\ subsubsection { Floating figure with subfigures }509

In order to create a group of figures like the one shown in Fig . \ ref { fig :subfigDemonstration} youwould have to use the code that is shown in Listing \ ref { lst : subfigDemonstrationCode}. Butbefore writing the subfigure code you should include in the preamble of your document thepackage \emph{subfig }. In order to include this package you should use the command \texttt {\textbaslash {} usepackage\{ subfig \}}.

511

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 32: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 29

513 In order to create such a figure with one or more subfigures you have to create a \emph{figure}environment like we do in Listing \ ref { lst : subfigDemonstrationCode}, Line 1. e you have tocreate two \emph{subfigure} environments (\ texttt {\ textbaslash {} begin \{ subfigure \}\ ldots \textbaslash {} end\{ subfigure \}}) inside which you will include the images like you wouldnormally do as if you were to include a single floating image. You are also able to assign \emph{captions} and \emph{labels} to the subfigures so you can refer directly to them from thedocument.

515

\begin{ figure }[htbp]517 \centering

\begin{ subfigure }[ t ]{0.3\ textwidth}519 \centering

\ resizebox {1\ textwidth }{!}{521 \ includegraphics {./ images/020612−4.jpg}

}523 \caption {e first picture }

\ label { fig : firstPicInSubfig }525 \end{ subfigure }%

\quad %add desired spacing between images, e . g . ~, \quad, \qquad etc .527 %(or a blank line to force the subfigure onto a new line )

\begin{ subfigure }[ t ]{0.3\ textwidth}529 \centering

\ resizebox {\ textwidth }{!}{531 \ includegraphics {./ images/020612−4.jpg}

}533 \caption {e second picture }

\ label { fig : secondPicInSubfig }535 \end{ subfigure }

\caption[Subfigure output ]{A caption that is about all the pictures in the figure . Lorem ipsum dolorsit amet, consectetur adipisicing elit , sed do eiusmod tempor incididunt ut labore et dolore

magna aliqua .}\ label { fig :subfigDemonstration}537 \end{ figure }

539 \begin{minipage }{\ textwidth}\ lstset { caption={[Code to generate subfigure .]e code to generate the subfigure shown in Fig . \ ref {

fig :subfigDemonstration }}, label ={ lst : subfigDemonstrationCode}}541 \begin{ lstlisting }

\begin{ figure }[htbp]543 \centering

\begin{ subfigure }[ t ]{0.3\ textwidth}545 \centering

\ resizebox {1\ textwidth }{!}{547 \ includegraphics {./ images/020612−4.jpg}

}549 \caption {e first picture }

\ label { fig : firstPicInSubfig }

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 33: Introduction to XeLaTeX: An alternative document preparation system.

30 — B Source code of this document

551 \end{ subfigure }%\quad %add desired spacing between images, e . g . ~, \quad, \qquad etc .

553 %(or a blank line to force the subfigure onto a new line )\begin{ subfigure }[ t ]{0.3\ textwidth}

555 \centering\ resizebox {\ textwidth }{!}{

557 \ includegraphics {./ images/020612−4.jpg}}

559 \caption {e second picture }\ label { fig : secondPicInSubfig }

561 \end{ subfigure }\caption[Subfigure output ]{A caption that is about all the pictures in the

563 figure . Lorem ipsum dolor sit amet, consectetur adipisicing elit , seddo eiusmod tempor incididunt ut labore et dolore magna aliqua .}

565 \ label { fig :subfigDemonstration}\end{ figure }

567 \end{ lstlisting }\end{minipage}

569

\ subsection {Tables }571

Another way to present data except from importing figures is creating tables . In Listing \ ref { lst :sampleTableCode} you can see the code that generates Table \ ref { tab :sampleTable }. You can seethat the \emph{table} environment is similar to the \emph{figure }. We begin a \emph{table}environment and then inside we insert the following commands\footnote{e commands in thisexample are only a small subset of those that can be used when creating a table .}:

573

\begin{ itemize } %\itemsep1pt \ parskip0pt \ parsep0pt575 \item We see again the \ texttt {\ textbaslash {} centering } command which is used to center the table

in the page.\item Aer that we see an environment in which we will define the table . e \emph{tabular}

environment. You can see that we again \ texttt {\ textbaslash {} begin\ ldots \ textbaslash {} end}the \emph{tabular} environment as any other environment.

577 \item e tabular environment has some arguments though, \ texttt {\{| r | l |\}}. ese arguments definethe number of columns and the looks of them.

\begin{ itemize } %\itemsep1pt \ parskip1pt \ parsep1pt579 \item Having two leers inside the brackets \ texttt {\{\ ldots \}} means that the table will be a two

column table .\item e vertical lines ‘|’ that you see inside the brackets denote where vertical borders of the

columns will show up. In this occasion we will have vertical borders drawn before and aerevery column.

581 \item e last observation has to do with the text alignment inside each cell . the leer \ texttt { r }and \ texttt { l } that are shown inside the brackets denote that the text in the cells of thefirst column will be aligned to the right side and the text in the second column will be alignedto the le side of the column. Another option is the leer \ texttt {c } which would align thetext in the center .

\end{itemize }

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 34: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 31

583 \item Aer the table definition we have the definitions of every line . At the first line we see thecommand \texttt {\ textbaslash {} hline } which is the command that creates the horizontal bordersof the cells in the table .

\item en we have a normal line . e data in the first column will be \ texttt {7C0} and in thesecond \ texttt {hexadecimal} the start of a new column is denoted using the \ texttt {\&} sign . Atthe end of each line you have to put \ texttt {\ textbaslash {}\ textbaslash {}} in order tocreate a new line .

585 \item In order to create more new lines you just repeat the above. In the case , that you want thehorizontal border of a line to appear only under/over some cells and not the whole line you canuse \ texttt {\ textbaslash {} cline \{\ ldots−\ldots \}}. In the example that we present here \ texttt{\ textbaslash {} cline \{2−2\}} means that the line will appear only in cell . Cline is used likethis \ texttt {\ textbaslash {} cline \{$\ langle$ starting column$\rangle$−$\langle$ending column$\rangle $\}}.

587 Tables can get really complicated and have many multicolumn or multirow cells appear in theirstructure . Creating such tables gets out of the scope of this document. If you want to findmore details about designing more complicated tables you should start by looking at \ cite {Wikibooks2012L−WTFTP} under the section ”Tables”.

589 Another way to easily get tables into a \LaTeX{} document is to create the table in Excel or asimilar program and use a specific extension for that program in order to generate ‘copy−pasteable’ \LaTeX{} code. Such extension for Excel is the \emph{excel2latex } which can be found \href { hp :// www.ctan.org/tex−archive/support/excel2 latex /}{ here }\ footnote {CTAN archive for \emph{excel2latex }: \ url { hp :// www.ctan.org/tex−archive/support/excel2 latex /}}.

591 ere are also other extensions for other popular products that are used to produce tabular datalike OpenOffice.org Calc , R, MATLAB. Links to them can be found \href { hp :// en.wikibooks.org/wiki/LaTeX/Tables}{here }\ footnote {Wikibooks site : \ url { hp :// en.wikibooks.org/wiki/LaTeX/Tables }}.

\end{itemize }593 \begin{minipage }{\ textwidth}

595 \ lstset { caption={[Code to generate Table .]e code to generate Table \ ref { tab :sampleTable }}, label ={lst : sampleTableCode}}

\begin{ lstlisting }597 \begin{ table }[ htbp]

\centering599 \begin{ tabular }{| r | l |}

\hline601 7C0 & hexadecimal \\

3700 & octal \\603 \ cline {2−2}

11111000000 & binary \\605 \hline \hline

1984 & decimal \\607 \hline

$\ frac {\ sqrt [3]{8* x +2}}{3* x+5}$ & math\\609 \hline

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 35: Introduction to XeLaTeX: An alternative document preparation system.

32 — B Source code of this document

\end{ tabular }611 \caption {A Sample table }

\ label { tab :sampleTable}613 \end{ table }

\end{ lstlisting }615 \end{minipage}

617 \begin{ table }[ htbp]\centering

619 \begin{ tabular }{| r | l |}\ hline7C0 & hexadecimal \\

621 3700 & octal \\ \ cline {2−2}11111000000 & binary \\

623 \hline \hline1984 & decimal \\

625 \hline$\ frac {\ sqrt [3]{8* x +2}}{3* x+5}$ & math\\

627 \hline\end{ tabular }

629 \caption {A Sample table }\ label { tab :sampleTable}

631 \end{ table }

633

635 \ subsection {Table of contents , figures , listings , and tables .}

637 If you have followed the previous examples to create Sections , subsections , figures , tables creatinga ”Table of Contents” or a ” List of figures ” is the easiest thing that you can do. Listing \ ref{ lst : tocLists } contains the code that is used to create the ”Table of contents” and the rest ofthe Lists of this document that are shown on pages \ ref { toc } and \ ref { lists }.

639 \begin{minipage }{\ textwidth}\ lstset { caption={[Code to generate ”Table of Contents” and other lists ]Code to generate ”Table of

Contents”, List of Figures , and other lists .}, label ={ lst : tocLists }}641 \begin{ lstlisting }

\setcounter {page }{1}643 \pagenumbering{Roman}

645 \ tableofcontents

647 \newpage\ listoffigures

649 \vspace {1.5cm}\ lstlistoflistings

651 \vspace {1.5cm}\ listoables

653

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 36: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 33

\newpage655 \setcounter {page }{1}

\pagenumbering{arabic}657 \end{ lstlisting }

\end{minipage}659

In the code quoted in Listing \ ref { lst : tocLists } you can see the commands \texttt {\ textbaslash {tableofcontents }}, \ texttt {\ textbaslash { listoffigures }}, \ texttt {\ textbaslash {lstlistoflistings }}, and \ texttt {\ textbaslash { listoables }}. ese are the only commands

necessary to create the respective lists . e rest of the code that you see in Listing \ ref { lst :tocLists } are there only for formaing reasons .

661 \begin{ itemize }\item e first two lines with the commands \texttt {\ textbaslash {} setcounter \{ page \}\{1\}} and \

texttt {\ textbaslash {} setcounter \{ Roman\}} are used in order to format the page numbering styleand set the starting page number. For these pages we have choosen the page numbering style to

be in Roman numbers (I, II , III , \ ldots ) and the numbering to start from I .663 \item we have also used the \ texttt {\ textbaslash {newpage}} command in order to create a new page

aer the Table of Contents where we would put the rest of the lists .\item e \ texttt {\ textbaslash {}\{ vspace \}\{1.5 cm\}} command is used to create some black \emph{

vertical space }. In this occasion we are creating some blank vertical space between the lists of1.5cm.

665 \item e listing finishes with the same commands that it started which are now used to reset thepage number to 1 and the style to Arabic (1, 2, 3, \ ldots )

\end{itemize }667

\ subsection {Choosing fonts }669

In order to choose the font which your document will use you have to put some commands in thepreamble\footnote{e segment of the . tex file that is between the \ texttt {\ textbaslash {}documentclass} and the \ texttt {\ textbaslash {} begin \{ document \}}}.

671

\begin{minipage }{\ textwidth}673 \ lstset { caption={[Font seings ]Code to set the font to be used .}, label ={ lst : fontSeings }}

\begin{ lstlisting }675 \usepaage{fontspec}

\ setmainfont {Linux Libertine O}677 \ defaultfontfeatures { Ligatures=TeX}

\end{ lstlisting }679 \end{minipage}

681 In Listing \ ref { lst : fontSeings } you can see the code that is used to set the default font for thetext . In order to do this you have to insert the three lines that are shown on Listing \ ref { lst :fontSeings } in the preamble of your document.

683 \begin{ itemize }\item You first declare that you will be using the \emph{fontspec} package.

685 \item en you have to select the main font using the \ texttt {\ textbaslash {} setmainfont \{\ ldots \}}command. In that command you will put in the place of the ”\ ldots ” the name of the font that

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 37: Introduction to XeLaTeX: An alternative document preparation system.

34 — B Source code of this document

you want to use . For this document you can see that we are using a font named ”Linux LibertineO”.

\item e last command is issued in order to create ligatures for common groups of leers . Some ofthose are : , fi , ffi , , , Qea, \emph{Qea}, \emph{f }, \emph{fi }, \emph{p}.

687 \end{itemize }

689 \ subsection {Bibliography , citation and cross−referencing}

691 \ subsubsection {Cross−referencing}You have seen throughout this text that we have been referring to Figures , Tables , and Listings .

is is done by using the labels that we set up when we insert those elements. When we insertan image we create a label using \ texttt {\ textbaslash {} label \{\ ldots \}}. In the place of ”\ldots ” we put the label that we will use to refer to this element later . For a figure the labelwould look like \ texttt {\ textbaslash {} label \{ fig : aDiscriptiveLabel \}}. You can see that weprepend the label with \ texttt { fig :}. You can also prepend labels for tables with \ texttt { tab :}.is is so that you can distinguish the labels at a later point . Because at some point your

document may have many labels set up. In order to refer to a figure you will have to use the \texttt {\ textbaslash {} ref \{\ ldots \}} command by replacing the ”\ ldots ” with the label that youwant to refer to . Be careful though, this only gets the number of the element you are referring .So, if you want to refer to a figure you should type the word \emph{Figure} and then \ texttt {\textbaslash {} label \{ fig :myFigure \}}.

693

\ subsubsection {Bibliography and citation }695 \begin{minipage }{\ textwidth}

\ lstset { caption={[Bibliography seings ] Seings for bibliography .}, label ={ lst : bibSeings }}697 \begin{ lstlisting }

\usepaage[round,authoryear,merge,sort ]{ natbib }699 \ bibliographystyle {agsm}

701 \bibliography {name_of_the_bibliography_file }\end{ lstlisting }

703 \end{minipage}

705 Listing \ ref { lst : bibSeings } shows the required commands to create the bibliography and be able tocreate citations in the text . e first line is loading the package \ texttt { natbib } which isused to format the citations that you put in the text . Here for example the options used willformat the citations according to the \ texttt {harvard} style . So it will use:

\begin{ itemize }707 \item \ texttt {round} brackets = parentheses

\item \ texttt {authoryear} form709 \item it will \ texttt {merge} continuous citations and separate them with ”;”

\item it will \ texttt { sort } the citations alphabetically .711 \end{itemize }

713 On the second line the bibliography style is declared . In this occasion we are using \ texttt {agsm}which is a \ texttt {harvard} style . is command should also be in the preamble. It is beer togroup those two commands and keep them together in the preamble.

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 38: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 35

715 e last command is going to actually load the file that you have the bibliography in . you shouldsave the bibliography file in the same folder as you save the . tex file of your document. Agood way to creating and managing your bibliography file is \ href { hp :// jabref . sourceforge . net/}{ JabRef }\ footnote { JabRef : \ url { hp :// jabref . sourceforge . net /}}. \ cite {smith2005 virtual }

717 \ section { Typeseing Mathematics}ere are three ways to insert an equation in a document:

719 \begin{ itemize }\item e first way is to create an inline equation like this $\ frac {\ sqrt [3]{8* x +2}}{3* x+5}$ using

the following code:721 \ texttt {\$\ textbaslash {} frac \{\ textbaslash {} sqrt [3]\{8* x +2\}\}\{3* x +5\}\$}

\item e second way is to create an unnumbered equation like the following one723 \[

\ frac {\ sqrt [3]{8* x +2}}{3* x+5}725 \]

using the following code :\ texttt {\ textbaslash {}[\ textbaslash {} frac \{\ textbaslash {} sqrt [3]\{8* x+2\}\}\{3* x +5\}\ textbaslash {}]}

727

\item And as a numbered equation like the one below, which can also be referenced in the document asEquation \ eqref {eq: test }.

729

\begin{equation }\ label {eq: test }731 \ frac {\ sqrt [3]{8* x +2}}{3* x+5}

\end{equation}733 e code that produces the Equation \ eqref {eq: test } is :

\ lstset { caption ={}, label ={}}735 \begin{ lstlisting }

\begin{equation }\ label {eq: test }737 \ frac {\ sqrt [3]{8* x +2}}{3* x+5}

\end{equation}739 \end{ lstlisting }

\end{itemize }741

In order to use the \emph{equation} environment you should load the package \emph{amsmath} in thepreamble of your document. is can be done with the following command: \texttt {\ textbaslash {}usepackage\{amsmath\}}

743 \appendix

745 \ section {RootyHelix}Figure \ ref { fig : rootyHelix } demonstrates the power of \TeX{} in generating more than text ! e image

shown in this figure is created using only \LaTeX{} commands and when you zoom in and out youget more details contrary to what would happen if you just included a . jpg file .

747 \begin{ figure }[h!]\ capstart

749 \centering\ resizebox {0.8\ textwidth }{!}{

751 \ includegraphics {./ includes /rootyHelix .pdf}}

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 39: Introduction to XeLaTeX: An alternative document preparation system.

36 — B Source code of this document

753 \caption {Root helix }\ label { fig : rootyHelix }\end{ figure }

755

\newpage757 \ section {Source code of this document}

759 \ lstset { breaklines =true , columns=flexible , caption ={}, label ={}}\ lstinputlisting {./ latexLecture . tex }

761

\newpage763

\nocite {Lamport1986−Adps}765 \nocite {Kew2011Tts}

\nocite {Wikipedia2012CoTe−WTFE}767 \nocite {Wikibooks2012L−WTFTP}

\bibliography { latexLecture }769 \end{document}

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.

Page 40: Introduction to XeLaTeX: An alternative document preparation system.

Introduction to X ELATEX — 37

References

[1] Wikipedia, “Comparison of TeX editors — Wikipedia, e Free Encyclopedia.” http://en.wikipedia.org/w/index.php?title=Comparison_of_TeX_editors, 2012.

[2] Wikibooks, “LaTeX — Wikibooks, e Free Textbook Project.” http://en.wikibooks.org/w/index.php?title=LaTeX, 2012.

[3] J. Smith and R. Nair, Virtualmachines: versatile platforms for systems and processes. MorganKaufmann, 2005.

[4] L. Lamport, “Latex – A document preparation system.” http://www.latex-project.org/, 1986.

[5] J. Kew, “e xetex typeseing system.” http://scripts.sil.org/xetex, April 2011.

Introduction to X ELATEX: An alternative document preparation system. by Nikolaos Dimosis licensed under a Creative Commons Aribution-NonCommercial-ShareAlike 3.0 Unported License.