LaTeX documents begin with a preamble. This is where you control the style and layout of the entire document. It is also where you load any packages that you may use later
in the content of your document. More on these later.
The first line of a document always declares the document class. This tells LaTeX what type of document that you are creating and allows you to declare some options that apply to every page. The syntax is:
The most used class is 'article' which is suitable for journals, short reports and any standard document. Be aware that most journals have their own LaTeX template where they have declared their own document class. For example, 'IEEEtran' which is a class used for IEEE articles.
The next page shows some of the possible options.
|proc||Used for proceedings|
|report||Used for long reports, small books and theses|
|book||Used for longer books|
|letter||Used for writing letters|
|beamer||Used for creating presentations|
There are more classes and options than those in the tables, but these are the most common. For your thesis we want a report on A4 paper with a font size of 11pt.
The first line of your LaTeX document will therefore become:
|10pt, 11pt, 12pt||Controls the size of the standard text.|
|a4paper||Sets the paper size.|
|fleqn||Formulae are left-aligned instead of centred.|
|leqno||Formulae numbers appear on the left-hand side of the page instead of the right.|
|twocolumn||Puts the document content into two columns like a newspaper or journal article.|
|landscape||Only use this document class if you want the entire document to be landscape. We will cover how to insert single landscape pages in the packages section.|
To include pictures, formulae, a bibliography and more advanced features we use packages that are declared in the preamble. The syntax is:
Several packages can be declared at the same time by seperating their names with a comma e.g.
Several options can also be declared in the same way e.g.
There is no limit to the number of packages that you can declare in the preamble.
There are many other packages and many options. The template we will use will start you off with all the packages you need in the beginning. If you need a new package remember to copy it into the preamble before using its functions in the text.
|Package Name||Package Function|
|amsmath, amsfonts, amssymb||You must include these three packages if you want to use formulae in your document.|
|geometry||The options of this package allow you to control the margins of the pages.|
|graphicx||This is needed for inserting pictures as JPEGs, PNGs and PDFs.|
|hyperref||This hyperlinks sections of your PDF. Click on Chapter 1 in the contents and the PDF viewer will jump to the first page of Chapter 1 in the body of the document.|
|fancyhdr||Used to customise headers and footers.|
|epstopdf||Allows you to use EPS files as figures. It converts the EPS file to a PDF file.|
|natbib||Creates author-year and numbered references in the bibliography. The bibliography style is controlled separately.|
|pdflandscape||Rotates chosen pages to landscape on the screen. Replace with lscape when printing the document.|
The code on the right hand side of this page can be used to build a long report(or thesis). It has margins of 2.5cm at the top and bottom, 4cm at the left side of the page and
2cm at the right. In the header is today's date on the left-hand side and the page number in the centre. Finally the document is also set up to handle mathematical formulae.
If you come across a package or option that you have not met before, Google is your friend. Many of the answers to your initial questions can be found either in this course or in the LaTeX Wikibook.