home | writing | TIL | now | about

Writing a thesis in latex.

This article is a guide to constructing a decent parent file for a thesis or dissertation compiled in Latex. The specific details implemented here, and included in the example files, are those set out by the guidelines for submission to the University of Nottingham, but can be easily amended to suit any sensible requirements.

Considerable attention has been paid to presenting the final document as a PDF file, which keeps the file size manageable (compared to postscript) and allows groovy add-ons such as hyperlinks and back-referencing. However, several hacks are required to attain good functionality from your PDF file and these can give the latex code a mysterious (and messy) appearance in places. While I highly recommend the inclusion of the PDF-related commands, they are not strictly necessary and can be ignored especially if you are new to Latex.

Note for Windows users

The code outlined below was designed and implemented on the unix system at Nottingham. For those of you unfortunate enough to be running a Windows box, a number of problems may arise when using the below code:

First off, not all the packages used will be present and will need to be installed. Probably the easiest way to do this is to google the package name with the extension .sty and save this file in the C:\VTEX\l2e\\ directory of your machine. Note that for the natbib package, you will also need to download the relevant .bst file, which in this case is unsrtnat.bst .

Also, many of the packages that are installed locally may need updating. For instance, the computers I have tested on both have old versions of the geometry and caption packages, which cause Latex to return errors. To resolve these problems, either download the latest versions, or remove the includefoot option from the geometry package and set the bottom margin to 1.4in.

Also, the code for compiling to PDF does not work so well in Windows, and so it is recommended that Windows users use the template without PDF code.

Requirements

The guidelines for theses to be submitted to the University of Nottingham specify that:

  • the document should be presented on single-sided a4 paper and typeset in a double-spaced size 10-12 font;
  • the left-hand margin should be at least 1.5 inches (4cm) to allow for binding;
  • the other three margins should be at least 1 inch (2.5cm).

Other settings such as the way chapter headings are formatted, and whether headers are included, are not specified and are up to the user. In this case, we’ll install headers and tinker with the chapter formatting.

Template files

Here are the template files which this page explains:

  • thesis_without_pdfcode.tex
  • thesis_with_pdfcode.tex

The appearance of both these files on the printed page will be identical; however after compilation into PDF (see the section below) and opening in Adobe Acrobat (or a similar PDF reader), the advantages that come with the PDF format will be apparent.

  • thesis_without_pdfcode.pdf
  • thesis_with_pdfcode.pdf

The rest of this page is devoted to explaining the code in these files.

Document structure

The document begins in a standard and entirely self-explanatory manner.

Preamble: essential packages

Next, the essential packages are loaded:

where the geometry package has been loaded to allow the margins to be set in a neat and consistent way. The non-obvious option includefoot ensures that the footer (which only contains the pagenumber) is included in the page and is thus 1 inch above the bottom of the page. Note that this option is only available in recent versions of the package: if you’re using an old version and can’t/won’t upgrade, then remove the offending option and extend the bottom margin to 1.4in. headheight=13.6pt is included due to to ensure compatibility with the fancyhdr package (and is not required if you don’t use the fancyhdr package). Also quite essential is the natbib package:

where the various options ensure that references appear in the document as:

…boiled dog can do maths claims experimenter [10,12,15-18].

Alternative referencing styles are easily implemented, see the natbib help file for more details. In fact, to use the natbib package, you’ll have to read at least a few lines of the help file so you understand the difference between \citet and \citep , and I insist you do that now.

Preamble: custom captions (optional)

We now set the figure captions to be elegant and dignified:

Note that early versions of this package don’t support the margin= and tableposition= options; in this case, these trimmings will have to be ignored.

Preamble: custom fonts (optional)

You can also choose an alternative font for both the text and the mathematical characters. This can be achieved by:

Aside from mathpazo , there are several other fonts available, such as chancery , palatino and times (all loaded in the same way).

Preamble: fancy headers (optional)

Feeling a little devil-may-care? If so, you’ll probably want to install some elegant headers along each page. This is easily achieved through the fancyhdr package:

The final complicated-looking three lines simply ensure that the headings for appendices are formatted correctly. (Without these lines, what should read “Appendix A” is set as “Chapter A”.)

Preamble: customised chapter/section headings (optional)

We now make use of several customisation options that are bundled with the sectsty package.

These alter the appearance of the first page of each chapter to have a centred title, with the word “chapter” set in small capitals immediately above. Feel free to employ your own individual and highly refined tastes here in choosing your own chapter/section settings.

Preamble: pdf options (optional)

If you want to publish your thesis on the internet, or even just to email it to someone, then you’ll want to store it in the ubiquitous PDF format. Doing so offers some neat facilities, such as hyperlinking, which are implemented by the hyperref package:

There are various other options you can pass to your favourite PDF reader via the \hypersetup command, such as pdftitle , pdfauthor and pdfsubject ; however, they’re not really essential. Note that the hyperlink colours have all been set to black for consistent printing. Should you want to distribute your thesis over the web, then it would be advisable to set these colours to red or something similarly vibrant and exciting.

Things get a little messy now as a hack is required to ensure the hyperlinks actually jump to the right place.

No need to worry about this code, let’s just move straight on.

Preamble: page layout

We now set various parameters to alter the general page layout:

The first two of these commands alter the paragraph formatting so that new paragraphs are not indented but separated from the previous one by a small amount of whitespace; the third sets the line spacing. The sharp-eyed among you will notice the discrepancy between our chosen line-spacing and that dictated by the university guidelines. However, no matter how poor your eyesight is, you’ll quickly appreciate that true double line-spacing (set with \renewcommand(\baselinestretch}{2} ) looks rubbish. In addition, Nottingham University are perfectly happy to accept theses set with the above line-spacing, which is more pleasing to the eye.

Some final settings:

Set which chapters to include when Latex is next run. The advantage of this method is that all your cross-references are remembered and Latex does not spit out loads of warnings.

Main matter

We now begin the document in earnest and define a suitable title:

followed by a dedication:

We now construct an abstract:

some acknowledgements:

and a contents page:

Now, we alter the pagenumbering to arabic and point to the relevant chapter files:

All your chapter files should be included here; to save time when editing, use the \includeonly command to specify which chapters to compile.

Finally, we make sure there is a link to the references section in the table of contents and reference the correct bibiography file (which in this case is called bibliography.bib ).

And there we have it: a complete thesis parent file that not only looks good on the printed page, but is fully functional and hyperlinked in PDF format.

Compiling to PDF

Whether you’ve included all the red PDF commands or not, you can convert your TEX file to PDF by running (in unix):

The additional argument to ps2pdf is required as the default paper size is US Letter. Note that you will probably need to bibtex your thesis file before running latex for the final time.

For Windows, first open a command window by going Start->Run and entering cmd . Provided MiKTeX and GhostScript are correctly installed then the necessary commands are:

The syntax for ps2pdf is slightly different in Windows compared to Unix - and note that the output pdf filename MUST be specified, else the ps file is overwritten and corrupted.

Something wrong? Suggest an improvement or add a comment (see article history ) Tagged with: latex Filed in: guides

Previous: Tutorial: the complex Ginzburg-Landau equation Next: Following log files with tail -f

Copyright © 2005-2024 David Winterbottom Content licensed under CC BY-NC-SA 4.0 .

A Basic LaTeX Preamble

The preamble is the place where one lays a document’s fundaments. It is used to include additional packages, set options, define new macros (commands), add PDF information and more. Even though one can define commands and set certain options within the document, it is preferred to set options globally. Otherwise we start smearing these definitions over the entire document, which makes finding things harder. This makes setting up the preamble a vital part of every document that is often overlooked.

In addition to adding more structure to the document, sometimes unexpected behaviour occurs when things are not done in the correct order. Writing a preamble is not very hard for simple documents, but for larger documents (i.e. package heavy documents), complications can occur.

Getting Started: Absolute Basics

Specifying the compiler.

Most (La)TeX documents have the .tex extension. This makes it hard to differentiate between different compilation engines because there is no such thing as a makefile for regular projects (TeX makefiles do exist, but they mainly serve the package writers, not document writers). Thus we will need some other way to define the compiler and encoding of the document. This is something that is editor dependent, but most editors will recognize the TeXShop way of doing this:

In this example, the XeLaTeX compiler is used with a unicode encoding. This way, our editor will know it needs to use the XeLaTeX compiler, and not the default compiler ( pdflatex on most systems). If we compile using the command line, these two lines will just be ignored. More info about options that can be set this way can be found here .

Defining the Document Class and Adding Packages

After setting these compiler options, we need to define the type of document (typically book , report or article ) and some additional information about the document and language. It is important to set the language in the \documentclass command to make sure all packages use the correct language.

It is typically a good idea to try and make groups of packages (e.g. general, scientific, plotting). This will once again create more structure in this (plaintext) document. This is of course not required for the compiler to work properly, but makes finding things a lot easier. Now we can really start including packages, setting options, defining commands etc.

Setting big global options such as page margins is best done after loading the packages. However, sometimes we need to define some of these options before we can include subsequent packages. This is for instance needed when using \numberwithin . This needs to be set before loading the hyperref package. Otherwise, unexpected results might occur.

An extremely basic example is:

The more packages we include, the slower compilation will become. However, for most documents (especially those including TikZ figures), the time spent to process the preamble will remain less than the actual document, but it is good to keep the number of packages to a minimum, especially during production.

The Actual Document

After finishing the preamble, the actual document follows. Open the document environment, add everything and finally close the document. Commands that are present after finishing the document will not be executed, so they will not have any effect on the PDF that is produced.

For our example the final result is:

More Elaborate Example and Useful Packages

General and layout oriented packages.

I usually load a set of about 30 packages in all basic documents. These provide most of the basic functionality expected in modern LaTeX documents and some room for customisation of the layout.

A good set of general packages is the following:

I do need to mention that the inputenc package is a rather dirty hack that tries to add some unicode support. By including this package you can type the umlaut as you do in regular WYSIWYG editors (opposed to typing \"o for ö ). Do not expect that it will allow you to type Korean in your text.

By default, LaTeX’s column widths are calculated to make them just wide enough for the contents. However, sometimes we have multiline cells or want to have equal cell width. This is possible when using these extra column definitions:

More information can be found in my tables in LaTeX post .

Whitespace and Margins

The default margins and paragraph spacing is OK, but I find the text width to be rather small by default. The paragraph indent is also something that is not really needed. To fix this, we can use the geometry package. It provides several useful options that allow to change the margins (widths and other whitespace distances) quite easily:

Remember the a4paper option we set in \documentclass ? This is passed by this command to the geometry package to set appropriate parameters. Additionally, we centre the text, remove space reserved for header and footer and set all margins to 1 inch.

Paragraph whitespace cannot be set this way. We need to define the lengths ourselves (the two successive \setlength commands). We can also change the whitespace in the table of contents, as is illustrated above.

In place of using \setlength to redefine paragraphy whitespace, we can also just include the parskip package:

This will effectively remove all paragraph whitespace, and in addition also modify space between list items.

Two final remarks: avoid using the fullpage package (use the geometry package instead) and if we use (more) modern document classes (i.e. KOMA-Script classes or memoir ), we should set the paragraph indentetion and skip using their respective options.

Title Layout

The default layout for \maketitle is also fine, but I prefer the title, author and date to stand out a little more. One way to do this, is by changing the font and font size using the following set of commands:

Something strange happens here: sometimes we open an environment, but don’t close it and vice versa. This is intended because of the call order. Before typesetting the title, the commands in \pretitle are executed. Then, the title is inserted and finally the commands in \posttitle are executed. As a consequence we open and close the environments in the correct way.

Because TeX was designed before standard font encodings such as OpenType were invented, it has a rather special way of defining font sizes. What we do, is set the size we want with \fontsize and then make LaTeX search for the size in its mapping that is closest to the desired value with \selectfont . We can also specify text size using default LaTeX macros that do not require \selectfont because they use a value that is defined in the mapping. \large is one of them. A complete list is provided on Wikipedia .

The font encoding is also a bit different depending on our needs. If we only use plain English (i.e. no letters with accents) then the default OT1 encoding will suffice. It provides (approximately) all characters in the ASCII table. However, if additional characters are needed, switching to T1 might be useful (just replace OT1 with T1 in the above commands). If we need to typeset non-western characters (read: languages such as Greek, Chinese and Arabic), we should use XeTeX (with a font that supports the target language). A list of available fonts (for LaTeX users) that are installed by default can be found font list .

If we want an entire page for the title, author, date… We can of course use the titlepage environment in out document:

Using a Different Font

In the previous section, we changed the font of the title, author and date. Let’s go a bit further and change the font of the entire document. In LaTeX, using system fonts is not possible, but we can always load additional fonts by including packages. For example:

After loading the appropriate package, we need to redefine the font family. To use Latin Modern, we need to execute:

If we want to apply styling to the headings, this is done using:

Changing the math font in LaTeX is not very easy, and might need a lot of command redefinitions, so we will skip this. If we want to have more font control, we should really use Xe(La)TeX.

Xe(La)TeX users can use system fonts, providing users with a much bigger font library at their fingertips! Before loading these fonts, the fontspec package needs to be included:

After loading this package, we can use commands such as \setmainfont to load a specific system font. To redefine the main and mono spaced fonts for example, we can use:

If we want to redefine the math font, we should load the mathspec package in place of the fontspec package. However, most fonts do not have a complete math table (read: not all symbols are defined). If a symbol is not defined in the selected font, it will fall back to Computer Modern (LaTeX default).

If full font consistency is required, we can load the unicode-math package. This will only work with fonts that have a complete math table. An list can be found on tex.stackexchange .

Scientific Packages

LaTeX is very well suited for mathematics and science in general, having packages for advanced mathematics, chemical formulas and more. The list below is a must-have addition to the built-in possibilities:

Only the first two packages are really required for most users. However, if we need monospaced text (read: computer code), listings is a very good package. minted is a good alternative, but requires Python to be installed for syntax highlighting. SIunits provides the \unit command, which adds a thin space between the value and unit. Some examples:

Almost all units are predefined as LaTeX commands. The squaren option is the only required one for compatibility with amsmath .

One might expect an absolute value command to be defined by amsmath , but it is not. The list below tries to define several missing commands and make things easier to read. Usage of \left and \right is needed to make brackets scale according to their contents. The final command forces fractions and integrals within fractions to have a normal size. By default, LaTeX will scale them down, but this often leads to less beautiful math expressions in my opinion.

If the listings package is loaded, we need to activate these options to have monospaced code, avoid hbox overflows and more. The options are quite straightforward. More information can be found in the tips and tricks post .

Referencing, Annotating and Citing

One of the great powers of LaTeX is its referencing system. The default combination of \label and \ref works very well, but it could benefit from a few additions.

If we want to have numbering within each section for example, we need to use \numberwithin . We specify the numbered environment followed by the heading in which the counter will be reset. This can be useful for lengthy articles.

Let’s get to the actual packages. A good default list for annotating and referencing is the following:

More information about usage and what each individual package does, can be found in the references in LaTeX post .

We can also add some custom colours to hyperlinks with the following code:

Adding a bibliography is usually done with bibtex . There also is the default thebibliography environment, but it is not very flexible. More about adding a bibliography and bibtex in a future blog post.

Drawing and Plotting

LaTeX is not only good for mathematics, there are also very powerful drawing libraries available in LaTeX documents. My personal favourite is TikZ. Packages such as pgfplots build on TikZ to add even more functionality to the already huge TikZ framework. A possible list of packages:

More information on usage of these packages can be found in the creating Tikz figures and tables in LaTeX posts.

Misc: Todo Notes, EPS Support, Floats, Headers…

If we want to add things such as TODO notes, EPS support (there is none by default!), floats (images, tables…) and a header/footer, these are the go-to packages:

After these packages, it might be useful to add the definitions for new macros. Defining new macros is every useful if we need to repeat certian aspects of the document, without needing to copy and past everything. More on this in a future blog post.

More often than not, we need to include figures in our documents. These are usually located in a subdirectory of our LaTeX project. Specifying this directory every time when inserting a figure is cumbersome. We can predefine where LaTeX needs to look using this command:

If we have multiple directories, specify them like this: \graphicspath{{figures_ch1/}{figures_ch2/}} . Notice the use of {} . No spaces are allowed and values are not separated with commas.

To conclude this section, we will add a header and footer (we loaded the fancyhdr package, so let’s use it). LaTeX has a set of predefined header/footer styles: plain (only page number), empty , headings (depends on document style, usually includes additional info on where we are in the document) and myheadings (page number top left/right, the rest can be modified using \markright and \markboth ).

However, using the default options can be limiting, that’s why we loaded the fancyhdr package. It provides flexibility and is easy to use. First, set the page style to fancy . Then, we usually clear all header and footer fields (this is good practice). Now we can define what is contained in the header or footer of our page using \rhead , \chead , \lhead , \rfoot , \cfoot and \lfoot . The example below adds the page number in the centre of the footer, not very creative, but it is illustrative though. Notice we also redefined the \headrulewidth , which cases a horizontal line to be inserted after the header.

If we need to specify left and right pages for two-sided printing (default in the book document class), we should use the fancyhead and fancyfoot commands. More information is provided in the fancyhdr documentation .

Some Side Notes

Some packages need to be loaded in a specific order. A common example is the following set: hyperref , cleveref and autonum . These need to be loaded in that exact order, otherwise very ugly things can occur. We also need to set how references are created and stored before we can load these packages (hence the \numberwithin commands need to be executed before the above set can be loaded).

One package that deserves a special mention is nag . nag is only used to force the usage of newer commands and to output some warnings if we do not add a caption and label to a float. It is essential in contemporary texts to reference a float, otherwise it adds no meaning to the text and thus is useless.

If we are compiling a larger document, we may want to add the draft option to the \documentclass command. This speeds up compilation by not including external sources (such as images). And is very useful if we are looking for syntax errors or just compiling an unfinished document.

Writing a LaTeX preamble is not the easiest nor the hardest thing about LaTeX. Writing a good preamble for most documents takes some time. However, it is well worth it since we can avoid common mistakes and pitfalls.

because LaTeX matters

Writing a thesis in latex.

Writing a thesis is a time-intensive endeavor. Fortunately, using LaTeX, you can focus on the content rather than the formatting of your thesis. The following article summarizes the most important aspects of writing a thesis in LaTeX, providing you with a document skeleton (at the end) and lots of additional tips and tricks.

Document class

The first choice in most cases will be the report document class:

See here for a complete list of options. Personally, I use draft a lot. It replaces figures with a box of the size of the figure. It saves you time generating the document. Furthermore, it will highlight justification and hyphenation errors ( Overfull \hbox ).

Check with your college or university. They may have an official or unofficial template/class-file to be used for writing a thesis.

Again, follow the instructions of your institution if there are any. Otherwise, LaTeX provides a few basic command for the creation of a title page.

maketitle

Use \today as \date argument to automatically generate the current date. Leave it empty in case you don’t want the date to be printed. As shown in the example, the author command can be extended to print several lines.

For a more sophisticated title page, the titlespages package has a nice collection of pre-formatted front pages. For different affiliations use the authblk package, see here for some examples.

Contents (toc/lof/lot)

Nothing special here.

The tocloft package offers great flexibility in formatting contents. See here for a selection of possibilities.

Often, the page numbers are changed to roman for this introductory part of the document and only later, for the actual content, arabic page numbering is used. This can be done by placing the following commands before and after the contents commands respectively.

LaTeX provides the abstract environment which will print “Abstract” centered as a title.

abstract

The actual content

The most important and extensive part is the content. I strongly suggest to split up every chapter into an individual file and load them in the main tex-file.

In thesis.tex:

In chapter1.tex:

This way, you can typeset single chapters or parts of the whole thesis only, by commenting out what you want to exclude. Remember, the document can only be generated from the main file (thesis.tex), since the individual chapters are missing a proper LaTeX document structure.

See here for a discussion on whether to use \input or \include .

Bibliography

The most convenient way is to use a bib-tex file that contains all your references. You can download bibtex items for articles, books, etc. from Google scholar or often directly from the journal websites.

Two packages are commonly used to personalize bibliographies, the newer biblatex and the natbib package, which has been around for many years. These packages offer great flexibility in customizing the look of a bibliography, depending on the preference in the field or the author.

Other commonly used packages

  • graphicx : Indispensable when working with figures/graphs.
  • subfig : Controlling arrangement of several figures (e.g. 2×2 matrix)
  • minitoc : Adds mini table of contents to every chapter
  • nomencl : Generate and format a nomenclature
  • listings : Source code printer for LaTeX
  • babel : Multilingual package for standard document classes
  • fancyhdr : Controlling header and footer
  • hyperref : Hypertext links for LaTeX
  • And many more

Minimal example code

I’m aware that this short post on writing a thesis only covers the very basics of a vast topic. However, it will help you getting started and focussing on the content of your thesis rather than the formatting of the document.

Share this:

16 comments.

' src=

8. June 2012 at 7:09

I would rather recommend a documentclass like memoir or scrreprt (from KOMA-Script), since they are much more flexible than report.

' src=

8. June 2012 at 8:12

I agree, my experience with them is limited though. Thanks for the addendum. Here is the documentation: memoir , scrreprt (KOMA script)

' src=

8. June 2012 at 8:02

Nice post Tom. I’m actually writing a two-part (or three) on Writing the PhD thesis: the tools . Feel free to comment, I hope to update it as I write my thesis, so any suggestions are welcome.

8. June 2012 at 8:05

Thanks for the link. I just saw your post and thought I should really check out git sometimes :-). Best, Tom.

8. June 2012 at 8:10

Yes, git is awesome. It can be a bit overwhelming with all the options and commands, but if you’re just working alone, and probably on several machines, then you can do everything effortlessly with few commands.

11. June 2012 at 2:15

That’s what has kept me so far. But I’ll definitely give it a try. Thanks!

' src=

8. June 2012 at 8:08

What a great overview. Thank you, this will come handy… when I finally get myself to start writing that thesis 🙂

8. June 2012 at 14:12

Thanks and good luck with your thesis! Tom.

' src=

9. June 2012 at 4:08

Hi, I can recommend two important packages: lineno.sty to insert linenumbers (really helpful in the debugging phase) and todonotes (allows you to insert todo-notes for things you still have to do.)

11. June 2012 at 0:48

Thanks Uwe! I wrote an article on both, lineno and todonotes . Here is the documentation: lineno and todonotes for more details.

' src=

12. June 2012 at 15:51

Thanks for the post, i’m currently writing my master thesis 🙂

A small note: it seems that subfig is deprecated for the subcaption package: https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Subfloats

12. June 2012 at 16:05

Hey, thanks for the tip. Too bad they don’t say anything in the documentation apart from the fact that the packages are not compatible.

' src=

1. August 2012 at 21:11

good thesis template can be also found here (free): http://enjobs.org/index.php/downloads2

including living headers, empty pages, two-sided with front and main matter as well as a complete structure

2. August 2012 at 11:03

Thanks for the link to the thesis template!

' src=

15. November 2012 at 22:21

Hi Tom, I’m writing a report on spanish in LaTex, using emacs, auctex, aspell (~170pags. ~70 files included by now) and this blog is my savior every time because I’m quite new with all these.

The question: Is there anyway (other than \- in every occurrence) to define the correct hyphenation for accented words (non english characters like é)? I have three o four accented words, about the subject of my report, that occur near 100 times each, across several files, and the \hyphenation{} command can’t handle these.

20. November 2012 at 3:47

I was wondering what packages you load in your preamble. For a better hyphenation (and easier typing), you should use these packages:

See here for more details.

If this doesn’t help, please provide a minimal working example to illustrate the problem.

Thanks, Tom.

Leave a Reply Cancel reply

MSU Libraries

  • Need help? Ask a Librarian

Starting a LaTeX Document

Cross references.

  • Managing Citations in LaTeX
  • Creating Accessible LaTeX Documents
  • Additional Help
  • LaTeX Templates

Basic Commands

Recompile
Comment
Math mode
Superscript in math mode
Subscript in math mode

All LaTeX documents start with a preamble. If you open up a new document in Overleaf, it will auto-populate much of this information for you. The preamble allows you to define the type of document, author, date, language, and load in LaTex packages that you want to use in the document.

\documentclass[12pt, letter paper]{article} \usepackage[utf8]{inputenc}

\title{Practice} \author{Erika Weir} \date{November 2019}

After we have included a preamble, we can go ahead and start the main text of our document. We can add things like a title, abstract, and table of contents.

\begin{abstract}     This is an introduction to using LaTex. It will show how to format a paper, insert equations, figures, and tables. LaTex can also be used to create lab reports, CV's, bibliographies, and other documents. \end{abstract}

\tableofcontents

We can then add sections that will automatically be added to the Table of Contents:

\section{Introduction}

We can also create lists: \begin{itemize}     \item llamas     \item donkeys     \item goats \end{itemize} And numbered lists: \begin{enumerate}     \item oranges     \item bananas     \item apples \end{enumerate}

First, add this package to your preamble to complete this section:

\usepackage{amsmath}

One of the most useful features of LaTex is the ability to easily write mathematical equations. We can do this inline ($E=mc^2$) or in display mode: \begin{equation}     E=\frac{mc^2}{\surd(1-v^2/c^2)} \end{equation}

You can also display equations without numbering. \[E^2=p^2c^2+m^2c^4\]

You can reference the following list to lookup many mathematical symbols and operators:

  • Overleaf's List of Greek letters and math symbols

Add the following packages to your preamble to add images and tables:

\usepackage{graphicx}

\usepackage[table,xcdraw]{xcolor}

To add images, you will need to first upload the images in Overleaf to your document:

Screenshot of the upload button in Overleaf

If you add your images in a folder, you must first add the file path.

\graphicspath{{images/}}

We can then add the image.

\includegraphics{hubble.jpg}

However, depending on the size of the image, it might not fully display on the page. We can edit the image to define the size.

\includegraphics[width=4cm]{hubble.jpg}

When writing academic papers, we may also want to label our figures so that we can refer back to them.

\begin{figure}[h]     \centering     \includegraphics[width=4cm]{aminoacids.jpg}     \caption{an amino acid info-graphic}     \label{fig:amino} \end{figure}

More information on formatting images can be found here:

  • Including images on Overleaf

Formatting and stylistic changes to LaTex tables can be extremely complicated. The following web resource allows you to create a table and then creates the corresponding LaTeX code.

  • LaTex Table Generator

LaTeX allows you to easily cross-reference anything that has been labeled in your document. This can include figures, tables, equations, or sections.

To create a label, use the label command: \label{ marker } . LaTeX users also typically include a short (3 letter) descriptor for the type of object they are labeling. For example, the following label command is for an amino acids figure:

\label{fig:amino}

To refer back to any labeled object, we can use the reference command: \pageref{ marker } . We can also use the page reference ( \pageref{ marker } ) command to print the page number the object originally appears on. For example, the following LaTeX code references our original figure:

See Figure \ref{fig:amino} on page \pageref{fig:amino}.

  • << Previous: Home
  • Next: Managing Citations in LaTeX >>
  • Last Updated: Oct 14, 2022 7:57 PM
  • URL: https://libguides.lib.msu.edu/latex

Writing a thesis in LaTeX - part 2

November 5, 2022

2022   ·   LaTeX     ·   research  

In the first part of this blog series, a minimal working example (MWE) of a LaTeX thesis project was derived. This MWE is rather basic and, therefore, this blog post will introduce additional commands and packages that enhance the quality of the document and make writing a thesis in LaTeX even more convenient. This blog post is about the following topics:

  • \includeonly{<path/to/file.tex>} for only compiling parts of the thesis which can significantly accelerate compilation.
  • automatically filter reference information
  • avoiding so-called widows and orphans for nicer typesetting
  • csquotes for citing text
  • siunitx for nice and flexible display of numbers with and without SI units
  • cleveref for better referencing to chapters, sections, figures and tables
  • enumitem for nicer enumerations and description lists

The final zipped LaTeX project can be downloaded here .

Below, a few commands (and hacks) that make life easier in LaTeX and produce nicer documents will be presented.

Compile only parts of a document

When working on a thesis document, one usually does not write all chapters in parallel but rather one after another. Therefore, compiling the single chapter, that is currently being drafted, is often sufficient. This can be achieved by integrating the \includeonly{<path/to/file.tex>} command in the preable. For example, adding

to the preamble of the main.tex file from the MWE derived in part 1 of this blog series, leads to only compiling the introduction and the following pdf:

It can be seen that only Chapter 1 Introduction is compiled and the other chapters are ignored. In large LaTeX documents this can save a lot of compile time and accelerate the process of writing significantly.

Automatically filter reference information

In the MWE from part 1 , two references were integrated, that end up being listed in the bibliography (see the pdf viewer above). It can be seen that the reference entry for the Nature paper by Rumelhart et al. has an ISSN and DOI. The first is the international serial number of the nature journal and the latter is the digital object identifier of the article. In order to find the reference, the DOI is sufficient in this case. The ISSN of the journal is not a necessary information and can be deleted.

In contrast, the other reference entry, which is a book by Bishop, has an ISBN, which is a necessary information for finding and matching the reference.

Usually, we do not want redundant or unnecessary information in the bibliography. There are two ways of handling this: first, the ISSN of the paper by Rumelhart et al. can be deleted from the bib file manually:

Since the information is missing, bibtex cannot print it in the bibliography. With a long list of references, deleting unnecessary information can be cumbersome and a source of mistakes, however.

A second and automatic way of handling the issue is to define filters for the entire bibliography in the preamble of the main.tex file:

Note, that the bibliography has to be re-compiled first (in TeXstudio: Tools > Bibliography (F8)). This will lead to the ISSN not being printed for the paper by Rumelhart et al. in the bibliography, any more.

Additionally, the command above will remove the fields abstract , pagetotal and month for all types of references, the fields url and urldate for references which are usually printed, such as standards and manuals, and remove the field doi for books, that should have an ISBN.

Avoiding widows and orphans

Sometimes, LaTeX produces a document with so-called widows and orphans. According to this Wikipedia article , a widow is “a paragraph-ending line that falls at the beginning of the following page […]” and an orphan is “a paragraph-opening line that appears by itself at the bottom of a page […]”. Such widows and orphans are considered unaesthetic and should be avoided.

On pages 2 and 5 of the MWE, there are indeed widows, which can be avoided by adding the following penalties to the preamble of main.tex (more information about LaTeX penalties can be found here ).

Now, the widows on pages 2 and 5 do not appear anymore. This is rather a hack than a command, but this worked nicely for avoiding widows and orphans in my thesis document and at, the same time, did not cause problems elsewhere.

Having introduced some handy commands, the remainder of this blog post will introduce additional packages that come with useful features and can enhance a LaTeX thesis document.

This package provides advanced functionalities for displaying quotes. After adding it to the preamble (i.e., \usepackage{csquotes} ), the command

can be used to produce a simple inline quote. In contrast, the command

produces a larger block quote which is clearly separated from the rest of the text. See section 1.3 of the pdf displayed above for examples.

This is one of my favorite packages as it standardizes the quantities and units in the entire document. After integrating it in the preamble (i.e., \usepackage{siunitx} ), all quantities can be defined using \qty{<number>}{<unit>} . For example,

will result in \(12.5\hskip .25em \text{m}\hskip .25em\text{s}^{-2}\). If you look closely, this is different from standard \(12.5\enspace\text{ms}^{-2}\). Using siunitx , a middle space is added between th number and the unit, instead of an en quad space.

If the units should be displayed differently (e.g., \(\text{m/s}^2\) instead of \(\text{m}\hskip .25em\text{s}^{-2}\)), this is easily adjustable in the options of siunitx . Just change the code to

If this should be changed in the entire document for all quantities, the preamble can be adjusted to

Note, how handy this can be. When writing the thesis, one can ignore the format of the unis and decide in the end, which format all units should have.

Further features include ranges of quantities and list of quantities. See section 1.4. of the pdf displayed above for examples. I recommend to check out the documentation for the SI unit names and prefixes in tables 1-6.

In a thesis, we usually want to cross-reference to chapters, sections, figures, tables and maybe even single pages. This can be automated with the cleveref package. After including it in the preamble (i.e., \usepackage{cleveref} ), the cref{<label>} command is available. For example,

is compiled to

“The introduction to this thesis is given in chapter 1.”

in the compiled document. The only prerequisite is that the cross-referenced object needs a label. In this case chapter 1 has a label defined directly after its declaration in introduction.tex :

See more examples in section 1.5 of the pdf displayed above and check out the documentation for further details.

The last package I recommend using is the enumitem package which provides control over the layout of the three basic list environments: enumerate, itemize and description. Hence, it enables also custom labels.

For example, the following code defines a list of items with custom labels “L” followed by an arabic number starting at 1:

See the outcome in section 1.6 of the pdf displayed above and also check out the documentation for further details.

In the second series of my lessons learned the main takeaways are

  • Compiling only parts of the document with \includeonly{<path/to/file.tex>} saves a lot of time.
  • Filter reference information automatically is more convenient than manually deleting information in the bib file
  • Widows and orphans can be avoided easily by introducing custom penalties
  • The packages csquotes , siunitx , cleveref , enumitem should be called in every preamble

In the next part we will look at an automated way of integrating a nomenclature into a LaTeX thesis document.

Imperial College London Imperial College London

Latest news.

latex preamble thesis

£150,000 study will explore links between breast cancer and breastfeeding  

latex preamble thesis

Bezos Centre for Sustainable Protein launches at Imperial with $30m funding

latex preamble thesis

Public Engagement team celebrate six years of sector-leading Academy

  • Graduate School
  • Imperial students
  • Professional Development
  • Courses for Doctoral Students
  • Research Computing & Data Science
  • Research Computing & Data Science Skills Courses

Writing Theses in LaTeX

Key information.

Tutor:  Dr Christopher Cooling  Course Level:  Level 2 Course Credit:   1 credit Prerequisites:  You should be comfortable with the basics of LaTeX, such as the content of the Introduction to LaTeX course  Course Duration:  3 hour session  Format:  Live online or live face to face with hands on practice 

Course Resources

  • Course Materials
  • Pre-course Setup

Your thesis is likely to be the longest technical document you have ever compiled and can seem a daunting task. But if done well, you will leave behind a lasting record of your achievements. This workshop explores how LaTeX can be used to typeset a thesis in a professional and aesthetic way, which conforms to the Imperial College guidelines. You will practise using a variety of LaTeX packages, will receive personalised feedback on your typesetting, and will leave with your thesis template.

  • Thesis requirements
  • Page numbering
  • Line spacing
  • Title pages
  • Thesis preamble
  • Tables of contents
  • Splitting your document
  • Graphicspath
  • Custom commands
  • Bibliography Management

The course will be delivered through a combination of slides, and hands-on practicals.

Learning Outcomes:

On completion of this workshop you will be able to:

  • Identify an array of useful LaTeX packages 
  • Recognise when and how to split large documents into manageable subdocuments 
  • Employ custom formatting and referencing 
  • Develop a full thesis template

Dates & Booking Information

  • Thursday 20 June 2024, 10:00-13:00, Microsoft Teams
  • Friday 28 June 2024, 10:00-13:00, South Kensington (In-Person Teaching)

To book your place, please follow the booking process advertised on the  main programme page

University of Rhode Island

  • Future Students
  • Parents and Families

College of Engineering

  • Research and Facilities
  • Departments

Guide to Writing Your Thesis in LaTeX

Frequently asked questions, 1. general use, 1.1 how can i use single-spacing, 2. bibliography and references.

2.1 My bibliography or list of references is missing. 2.2 How do I refer to a web page in a bibliographic reference? 2.3 How do I include a source in the bibliography, but not specifically reference it in the thesis?

3. Submitting to the Graduate School

3.1 How do I add my name to the short abstract for the dissertation? 3.2 How do I add typed signatures to the electronic copy?

4. Package information

4.1 What packages are not compatible with this class? 4.2 What does the hyperref package do? 4.3 What options should be used with the hyperref package?

You can use single-spacing with the \singlespace command. There is also a \doublespace command if needed to restore the default spacing. Note that single-spacing is only allowed in a few contexts. See the Graduate School documentation for details.

2.1 My bibliography or list of references is missing.

Run the script genbib.bat

2.2 How do I refer to a web page in a bibliographic reference?

Use the Electronic type in your references.bib file.

2.3 How do I include a source in the bibliography, but not specifically reference it in the thesis?

Use the \nocite{} command. This works the same as the \cite{} command, but will only include the reference in the bibliography, not in the list of references.

3.1 How do I add my name to the short abstract for the dissertation?

Use the command

at the top of your abstract.tex file.

3.2 How do I add typed signatures to the electronic copy?

Add the options electronic to the documentclass command, as in

then make sure the \signature{} and \deansignature{} statements are correct in the file thesis.tex .

4.1 What packages are not compatible with this class?

The only known incompatible package is chapterbib by Donald Arseneau. The reason for this incompatibility is that the support for references at the end of each chapter comes from inserting code from this package into appropriate places in the urithesis class file.

4.2 What does the hyperref package do?

When using pdflatex to create a pdf version of the thesis, the hyperref package will do the following:

  • create a pdf table of contents in the pdf document
  • all citations and references in the thesis will be hyperlinks that will go to the referenced equation, figure, bibliographic citation, etc…
  • the table of contents in the thesis will be hyperlinks to the corresponding section in the thesis

4.3 What options should be used with the hyperref package?

  • pdfborder={0 0 0} – this option makes the boxes that would appear around hyperlinks in the pdf document white, therefore they will be invisible
  • plainpages=false – this option says to use the page numbers as they appear on the pages, instead of the Arabic equivalent. This will make the roman page numbers in the preliminary material have different numbers from the chapters of the thesis.
  • pdfpagelabels – this option puts the page number as it appears on the page in the pdf file, therefore the first page of the first chapter will be page 1.

Masters/Doctoral Thesis

This template provides a full framework for writing a graduate level thesis. It is carefully structured and separated into multiple parts for easy editing. Included are the following pages/sections: a cover page, declaration of authorship, quotation, abstract, acknowledgements, contents page(s), list of figures, list of tables, abbreviations, physical constants, symbols, dedication, example chapter, example appendix and bibliography.

Description

This template provides a full framework for writing a graduate level thesis. It is carefully structured and separated into multiple parts for easy editing. Included are the following pages/sections: a cover page, declaration of authorship, quotation, abstract, acknowledgements, contents page(s), list of figures, list of tables, abbreviations, physical constants, symbols, dedication, example chapter, example appendix and bibliography. An example chapter is included which explains the basics of LaTeX and this template. It contains everything you need to know to begin writing your academic thesis using this template. Important note: this template comes as a zip file with multiple files and folders within it. It is worth reading the Chapter 1 introduction to the thesis to get an idea of what they do.

latex preamble thesis

This second major version of this template was made by Vel . The thesis style was originally created by Steve R. Gunn and modified into a template by Sunil Patel .

Current Version

v2.5 (August 27, 2017)

This template is licensed under a CC BY-NC-SA 3.0 license. Click here to see what this license means for your use of the template.

Open Template for Free Editing Online

Download template, have a question.

  • Ask a Question at LaTeX.org
  • Report via Email

This page last updated on: August 27, 2017

latex preamble thesis

LaTeX Templates Information

General enquiries [email protected]

Most templates licensed under CC BY-NC-SA 4.0

LaTeX Templates is developed in New Zealand

© Creodocs Limited. All Rights Reserved.

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Splitting a document per chapter with preample for Latexian live preview

Currently, I have my main LaTeX document set up as follows:

While my chapters themselves contain no preamble, no begin/end document etc, just the contents of the chapter itself.

I use Latexian and really enjoy the live preview function in a split screen. I would like to write each individual chapter and use the live preview feature, however, I cannot compile/preview each chapter on its own without its own preamble, begin/end document etc.

Is there a way around this? It feels very clunky to have to switch back and forth between a window containing just my chapter and one containing the entire thesis. Similarly, it feels very clunky to have each chapter contain everything necessary to compile and then manually comment out the extra lines from every single chapter when I wish to compile them all together.

Jonas Stein's user avatar

  • Doesn't Latexian allow you to set a master document or main file or similar? Many editors have a concept of a project so that compiling any file in that project can be configured to compile the main/master file. If you use \include rather than \input , you can use \includeonly{} as mentioned below. Alternatively, look at standalone or import for other possibilities. –  cfr Commented Jan 17, 2017 at 3:04
  • @cfr I have never heard of this feature before, but it looks like what I am after. I will have to see whether or not Latexian can do this, thank you. –  Echan Commented Jan 17, 2017 at 5:10
  • @cfr The feature was fairly well hidden, but that completely solved my issue. –  Echan Commented Jan 17, 2017 at 5:37
  • You should put te \chapter{<title>} command within te chapter file. –  Johannes_B Commented Jan 17, 2017 at 7:24
  • look into the subfiles package. –  samcarter_is_at_topanswers.xyz Commented Jan 17, 2017 at 9:35

3 Answers 3

Convert your chapters in complete documents (with the same preample that the main document) and then go to CTAN to known about the topic subdoc: in­clude com­plete doc­u­ments in other doc­u­ments . In particular, docmute or standalone packages is what your are looking for. It is a simple as add one of these packages to the preamble of the main document (there are many examples of use of both packages in this site, for example this answer .

I suggest also move rest of the preamble to a preamble.tex file and left in the main document only \input{preamble} and use only this command in the preambles of the child fles, because if you need change some change in the preambles, you only have to do once, avoiding mistakes.

Alternatively, as suggested in the other answer, you can also preview the main document with only a chapter, using \includeonly{...} in the preamble of the main document, but note that this command affect to \include commands, not to \input (see When should I use \input vs. \include? ), so in your example, you should change \chapter{...}\input{...} by only \include{...} with \chapter{...} included in the child document.

Community's user avatar

Another approach is to have a compile01.tex file which contains:

You'd then have compile02.tex etc. as well. I didn't use this approach for chapters (I wanted to test the bibliography and TOC often enough that it wasn't worth it, instead I preferred to use \includeonly or comment out the \include / \input lines in my thesis_master.tex ). But I did set up something similar for TikZ pictures to avoid compiling the whole thesis while fine-tuning a figure.

Chris H's user avatar

  • Although your suggestion will not produce the same result that \includeonly in main.tex and simplify check partial results, basically translate the hassle of having to compile main.tex to the hassle of of compile through a third file for each chapter, but the main point of the question is see a live preview while editing chapter01.tex , that is not really solved in this way –  Fran Commented Jan 17, 2017 at 14:11
  • @Fran I don't use Latexian so it wasn't obvious to me that this wouldn't generate a live preview until you said so. My thesis files were big enough that for all but the introduction, compilation of a single chapter took a few tens of seconds on a fast machine. With frequent saving it would be almost constantly updating. So I compiled on my own schedule –  Chris H Commented Jan 17, 2017 at 14:26

Plenty of other questions on this same topic. I think the easiest way to do it is to put a line like this in your preamble:

Typeset single chapter from book

Edit: And use \include instead of \input

Tom Anderson's user avatar

  • 2 This really doesn't address the question and adding this to the preamble in the question will just produce an error. –  cfr Commented Jan 17, 2017 at 3:02
  • @cfr not sure I understand your comment. Because you also posted above: "If you use \include rather than \input, you can use \includeonly{}as mentioned below." Why post the same advice as me and downvote my brief response plus link to information? Is it because you thought I should copy more of their answer? –  Tom Anderson Commented Jan 21, 2017 at 4:36
  • @TomAnderson I think the problem is that the code in the question doesn't have any chapters, so more is needed than just adding \includeonly : the source also needs to be set up correctly. –  Joseph Wright ♦ Commented Jan 21, 2017 at 8:14
  • 1 The source in the question doesn't use \include{} . You can't use \includeonly{} with \input{} . –  cfr Commented Jan 21, 2017 at 19:10
  • 1 By the way, it was not me who down-voted your answer. @JosephWright ?? –  cfr Commented Jan 21, 2017 at 19:11

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged chapters preamble latexian ..

  • Featured on Meta
  • Upcoming sign-up experiments related to tags

Hot Network Questions

  • WORD REQUEST: A class for students who want to get better at a subject, aside from their public education
  • RAW, do transparent obstacles generally grant Total Cover?
  • How does a vehicle's brake affect the friction between the vehicle and ground?
  • How to turn a desert into a fertile farmland with engineering?
  • If a reference is no longer publicly available, should you include the proofs of the results you cite from it?
  • Determinacy and Woodin cardinals
  • How to create a flow that checks the overlaping dates on records?
  • Looking for a caveman discovers fire short story that is a pun on "nuclear" power
  • Why am I unable to distribute rotated text evenly in Adobe Illustrator 2024?
  • What is a "general" relation algebra?
  • Isn't it problematic to look at the data to decide to use a parametric vs. non-parametric test?
  • What is a curate in English scone culture?
  • What is the explicit list of the situations that require RAII?
  • Where did the pronunciation of the word "kilometer/kilometre" as "kl OM iter" rather than "KILL o meeter" originate?
  • What's the necessary and sufficient condition for a real sequence to be written as the self-convolution of another real sequence?
  • Numerical approximation of the integral by using data
  • Do wererats take falling damage?
  • Freewheeling diode in a capacitor
  • Voronoi mesh of a circular image
  • proper way to write C code that injects message into /var/log/messages
  • Proving for n+1 and n-1 at the same time using induction.
  • What happened to Slic3r?
  • Sink vs Basin distinction
  • Binary Slashes Display

latex preamble thesis

Some Quarto PDF formatting tips, with particular reference to thesis writing

Cameron Patrick

17 July, 2023

I’ve just spent most of a day faffing around trying to get Quarto to produce a nice PDF file that I like the look of and which meets my university’s formatting requirements for a PhD thesis. Maybe my pain and suffering can help reduce yours.

I decided to write my PhD thesis in Quarto . Between my idiosyncratic standards for the PDF output and the university’s rigid requirements for what a PhD thesis ought to look like, I knew that some degree of tweaking the formatting settings would be required. I’ve never really used Quarto for PDF output before, but since I’m fairly confident using LaTeX, I figured “how hard could it possibly be”.

This post is a slightly elaborated version of the notes I made for myself during the process, shared in the hope that it may be useful for others who want to use Quarto to write reports or theses with idiosyncratic styling.

The one piece of this post that I haven’t seen spelled out anywhere else on the web is the section on additional front matter before and after the table of contents , which took a bit of LaTeX trickery to achieve. The solution I found is better than the other alternatives I’ve seen (for my purposes, anyway), because it allows you to write the front matter in Markdown instead of LaTeX and have it present in the HTML output as well as PDF.

Basic principles

  • Start by creating a “Quarto book project” using your favourite IDE (RStudio)
  • It’s probably a good idea to use git and periodically commit as you mess with stuff, but I just YOLO’ed it until I had something I was happy with
  • You should probably set up renv so your package versions are tracked and reproducible. renv::init()
  • Most of the configuration begins in editing the YAML file, _quarto.yml
  • The most basic but also most important options are documented in the Quarto PDF Options section of the Quarto manual
  • Achieving more complex goals requires writing chunks of LaTeX code which you reference in the YAML (or sometimes include inline in your chapter .qmd files)
  • Some of what I’m explaining here wasn’t documented and required reading the Quarto source code. I am not to be held responsible for any voided warranty or code that stops working with the next release of Quarto
  • I’m assuming you have some familiarity with YAML, Markdown, and LaTeX; but not necessarily with Quarto. In other words, I’m writing for me-last-week. Good luck

Bibliography workflow

Thanks to Brenton Wiernik and Matthijs Hollanders on Twitter for pointing me in the right direction here.

  • Use Zotero and the Better BibTeX for Zotero plugin
  • (Aside: the ZotFile plugin may also be useful if/when I exceed my free Zotero PDF storage limit, although I like Zotero enough I may well just give them cash for cloud storage.)
  • Set a sensible schema for naming your reference keys in the Better BibTeX settings. I’m using auth.lower + year + shorttitle.lower which generates keys like @rubin1974estimatingcausaleffects
  • Set Zotero “quick copy” format to Better BibTeX Citation Key and set it to use Markdown, so you can hit Command-Shift-C to copy the citation in Markdown format
  • Export using the Better CSL YAML plugin (you can also set it to automatically update when your Zotero library changes), or use the R Better BibTeX package to get an automatically updated bibliography export every time you knit your document (I haven’t tried this yet)
  • Grab a CSL file for your preferred bibliography and citation format and copy it into your Quarto project
  • Add bibliography and csl top-level keys to your YAML:

I’ve also edited my references.qmd Markdown file which generates the bibliography so it has a ragged right margin (i.e. left justified, not full justified):

Yeeting the RStudio visual editor

If you’re like me, and can’t stand the RStudio visual Markdown editor but accidentally clicked the “Visual editor” check box when creating the project, change your YAML to say:

Instead of editor: visual . Or vice versa, if you prefer the visual editor.

Easy PDF tweaks (only YAML needed)

All of these go inside the format: → pdf: chunk of the YAML. They’re documented in the Quarto manual but that’s very long and sometimes unclear (partly because Quarto can produce PDF output both via LaTeX and via HTML, and different options apply to each). Here’s what I cared about enough to mess with:

  • LaTeX document class: Quarto’s default templates will take advantage of the KOMA Script classes if you use those, and they seem to make some customisation nicer than the LaTeX packages I’ve used previously. So documentclass: scrbook for two-sided or documentclass: scrreprt for single-sided (note the lack of “o” in “scrreprt”)
  • You can change the name of the PDF file produced, e.g.  output-file: "FirstnameLastname_thesis.pdf" (this one goes under the book: top-level YAML section, not under format: pdf: )
  • Set keep-tex: true so you can take a squiz at the generated TeX file. I found this helped when figuring out what I needed to change to bend the output to my whims
  • Enable Table of Contents, List of Figures, List of Tables; toc-depth of three means that the Table of Contents will show up to \subsection (or ### headings in Markdown):
  • Section numbering: number-depth appears to count differently from toc-depth , so the below will have numbered \subsection ( ### ) but not \subsubsection ( #### ):
  • Paper size: papersize: a4 or you’ll get US Letter
  • Margins: you can either use the KOMA Script options (see below) which use some kind of fancy formula to derive margins, or you can specify options to the LaTeX geometry package in your YAML. Below is what I’m currently using, copied from my MSc thesis LaTeX preamble. I can’t remember what the header and footer bits do exactly. heightrounded helps prevent “underfull vbox” warnings by making sure the text height is a multiple of the line height
  • Indented paragraphs vs space between paragraphs: indent: true or indent: false . You can use KOMA Script options for greater control over the indent or skip distances but the defaults look fine to me
  • Spacing between lines: you can use e.g.  linestretch: 1.25 or linestretch: 1.5 to get increased line spacing
  • As far as I can tell, you can’t choose between full justified and ragged right (left justified) in the YAML, you’ll need to add LaTeX commands to the preamble (see below)
  • Font size: set the base font size used for body text, e.g.  fontsize: 11pt
  • I prefer the XeLaTeX engine: pdfengine: xelatex because…
  • If you’re using the XeLaTeX engine, you can specify any (Unicode, TrueType/OpenType) system font if you don’t like the standard Computer Modern Roman look that screams “my document was made with TeX”. The TeX Gyre Math font families provide OpenType math fonts compatible with XeLaTeX that fit well with Times and Palatino, amongst others. Here’s an example of using Times New Roman and other common Microsoft fonts, alongside TeX Gyre Termes Math which provides mathematical symbols which blend in nicely with these fonts:

KOMA Script options: fonts, headings, headers, and footers

The KOMA Script manual is comprehensive but inscrutable, and it takes a bit of messing around to find out where to put the options anyway.

To set these options, you’ll need to add them to what Quarto calls the LaTeX header (which I’ve always known as the LaTeX preamble). That means you need to add a line like include-in-header: include-in-header.tex to the PDF format options in your YAML, and then add the code here to a file called include-in-header.tex .

Here are a few things I did here:

  • Make the headings the same font as the rest of the document, instead of sans serif: \addtokomafont{disposition}{\rmfamily}
  • Restore the classic LaTeX chapter headings that are two lines, the first saying e.g. “Chapter 2” on a line before the chapter title: \KOMAoptions{chapterprefix=true,appendixprefix=true}
  • Smaller fonts for headings: \KOMAoptions{headings=small}
  • If you’re fussy about the size of the indent or spacing between paragraphs, you would do that here too
  • If you prefer left-justified (ragged right margin) instead of full-justified, you can do that here: \raggedright
  • Header and footer fonts: normal upright font (instead of slanted, the KOMA Script default) and a smaller size. See this handy web site for more info on LaTeX relative font size commands like \footnotesize .
  • Headers and footers! For this we’ll need the scrlayer-scrpage package, and commands like \lefoot[]{} where “l” starts for left (there’s also “c” and “r”), “e” starts for even page (there’s also “o”), “foot” for footer (there’s also “head”). Inside the square brackets you put what you want on “plain” pages (start of chapter) and inside the curly braces you put what want on pages with a running-head (inside chapters). Here’s an example that gives output similar to many technical books: (1) centred page numbers ( \pagemark ) in the footer on the first page of a chapter; (2) page numbers on the outside edge of the header inside chapters; (3) chapter and section titles (“running heads”, \leftmark and \rightmark ) on the inside margins:
  • Headers and footers! If you’re using single-sided output, beware: all of your pages will be considered “odd”, for some odd reason.

My university has a specific requirement for the formatting of title pages, and even if it didn’t I’d still want to change the default Quarto title page because it’s kind of ugly.

To do this, we will once again need to write some LaTeX code. This time, rather than just adding extra code to the preamble, we’ll be replacing some of the built-in Quarto Pandoc templates . You can see what templates are available and what they contain by looking at the Quarto source code (!). Ignore the seductively-named title.tex because to edit the title page you will need to replace before-body.tex . Start by adding before-body.tex to the template-partials list under format: pdf: in your YAML (yeesh).

Then, in before-body.tex , we’ll add the code to create the title page. You’ll notice that this isn’t quite normal LaTeX, there’s some kind of crazy templating language going on, with directives inside pairs of $ signs. I’m not aware of any documentation on this, I just pieced it together from reading other Quarto templates.

The first few lines (copied from the standard Quarto template ) enable front matter mode in LaTeX, which causes pages to be numbered in roman numerals instead of normal (arabic) digits. Later on, \mainmatter will cause the page numbering to restart from 1. The remainder of the code is LaTeX code to generate the title page, with a bit of cleverness to pull the title and author information out of the YAML. Instead of just using \maketitle built into LaTeX, we’ll make our own title page from scratch.

To go along with this, you’ll also need to provide appropriate information in the book: section of the YAML:

latex preamble thesis

Additional front matter before and after the table of contents

According to my university, a PhD thesis needs to contain the following items, in this order: title page, abstract, authorship declaration, preface, acknowledgements, table of contents, list of tables, list of figures, abbreviations; the body of the thesis; references; and finally appendices.

Unfortunately, the default Quarto template places the table of contents immediately after the title page. To change this, we’ll need to edit another “template partial”, this time toc.tex . In the YAML:

Then in toc.tex :

If you compare the above to the standard Quarto toc.tex template you’ll see that I’ve removed a heap of code. Some of that code was for presentations but most importantly I removed the \tableofcontents , \listoffigures and \listoftables commands which actually produce the table of contents and lists of figures and tables. (I’ve also added some bonus code to make the “List of figures” and “List of tables” headings in sentence case instead of title case, all modern-like.)

We’ll also need to stop Quarto from switching from \frontmatter to \mainmatter at around this point. I couldn’t find the partial template that was responsible for this, so instead I added these two lines of LaTeX to the end of before-body.tex :

The above code effectively neuters the \mainmatter command, until we’re ready to bring it back to life.

Now we can write the ‘chapters’ that make our extra front matter. These can be written just like normal Quarto chapters, though I added {.unnumbered .unlisted} to the end of the chapter headings so they don’t get chapter numbers and aren’t included in the table of contents.

At the end of the last section before the table of contents should appear — acknowledgements.qmd in my case — add the following LaTeX code to generate table of contents (and list of tables and list of figures, if desired):

Finally, at the end of the last front matter section — abbreviations.qmd in my case — add this code to return the \mainmatter command to life and run it, causing the main section of the document to have ordinary page numbers, starting from 1 again:

HTML output

One nice thing about Quarto is that it can produce multiple output formats from the same input. I find the HTML output particularly convenient for on-screen previewing. I haven’t messed with the appearance of the HTML output much, but here’s the YAML chunk I’m using at the moment:

I will probably end up writing a CSS stylesheet at some point as a form of procrastination.

Setting the output directory

You can change the directory that the HTML and other outputs are saved to. This may be useful if, for example, you want to use GitHub Pages to publish your document as a web site. GitHub Pages expects the HTML to either be in the repository root or a “docs” subdirectory:

Easy thesis template

Easy LaTeX thesis template prepared by Simon Ternsja, based on Graduate Thesis template written by Sunil Patel.

This template was originally published on ShareLaTeX and subsequently moved to Overleaf in November 2019.

Easy thesis template

Get in touch

Have you checked our knowledge base ?

Message sent! Our team will review it and reply by email.

Email: 

COMMENTS

  1. How to Write a Thesis in LaTeX (Part 1): Basic Structure

    The preamble. In this example, the main.tex file is the root document and is the .tex file that will draw the whole document together. The first thing we need to choose is a document class. The article class isn't designed for writing long documents (such as a thesis) so we'll choose the report class, but we could also choose the book class.. We can also change the font size by adding square ...

  2. Good LaTeX preambles for math thesis

    12. The best preamble is the preamble, that does contain only these packages and definitions you are using. BTW: You should read l2tabu to avoid obsolete packages like t1enc (use \usepackage[T1]{fontenc} instead). And it would be better to use packages like geometry or typearea to setup text area and margins.

  3. Standard preamble for theses

    "An example thesis design", pp. 357-375) to explain how to design a thesis style. There might be a few clues about additional features one might want to incorporate into the own preamble. However, it should also be said that this manual focuses on the thesis style from a package/class designer point of view.

  4. Writing a Thesis in LaTeX

    Preamble: customised chapter/section headings (optional) We now make use of several customisation options that are bundled with the sectsty package. ... > latex thesis_with_pdfcode.tex > dvips thesis_with_pdfcode.dvi > ps2pdf.bat -sPAPERSIZE#a4 thesis_with_pdfcode.ps thesis_with_pdfcode.pdf

  5. PDF LATEX Thesis Class for University of Colorado

    package in the preamble, so that bitmap images (PNG, JPG) and vector images (PDF) can be inserted using the \includegraphics macro. (Convert EPS files to PDF using ps2pdf.) ... thesis can use all LaTeX macros just as described in the references (2, 3). The εfigure on page 2 shows the contents of a fictitious thesis file, mythesis.tex, that ...

  6. A Basic LaTeX Preamble

    A Basic LaTeX Preamble. The preamble is the place where one lays a document's fundaments. It is used to include additional packages, set options, define new macros (commands), add PDF information and more. Even though one can define commands and set certain options within the document, it is preferred to set options globally.

  7. Writing a thesis in LaTeX

    Writing a thesis is a time-intensive endeavor. Fortunately, using LaTeX, you can focus on the content rather than the formatting of your thesis. The following article summarizes the most important aspects of writing a thesis in LaTeX, providing you with a document skeleton (at the end) and lots of additional tips and tricks. Document class.

  8. Writing in LaTeX

    All LaTeX documents start with a preamble. If you open up a new document in Overleaf, it will auto-populate much of this information for you. The preamble allows you to define the type of document, author, date, language, and load in LaTex packages that you want to use in the document. \documentclass[12pt, letter paper]{article}

  9. How to get started writing your thesis in LaTeX

    Here we provide a guide to getting started on writing your thesis in LaTeX, using a standard template which is pre-loaded into Overleaf. We have a large number of thesis templates in our online library, and you can upload your own if your university provides a set of LaTeX template files. We'll assume you've used LaTeX before and so are ...

  10. Guide to Writing Your Thesis in LaTeX

    Now we will explain how to set things like the title, the author name, and whether it is a masters thesis or a doctoral dissertation. Start by opening the file thesis.tex in your editor. Setting the Class Options. The first line of the file will be: \documentclass{urithesis} This tells LaTeX to use the urithesis document class with all default ...

  11. Writing a thesis in LaTeX

    Writing a thesis in LaTeX - part 2. November 5, 2022. 2022 · LaTeX · research . In the first part of this blog series, a minimal working example (MWE) of a LaTeX thesis project was derived. This MWE is rather basic and, therefore, this blog post will introduce additional commands and packages that enhance the quality of the document and make writing a thesis in LaTeX even more convenient.

  12. PDF Writing a thesis with LATEX

    typical problems that arise while writing a thesis with LaTeX and suggests improved solutions by handling easy packages. Many suggestions can be ... is necessary to define the abstract in the preamble (the code that follows is the definition used by the reportclass).6 6. Instructions on how to use the fancyhdrpackage can be found in sec.6.3.1.

  13. How to Write a Thesis in LaTeX (Part 5): Customising Your ...

    In the previous post we looked at adding a bibliography to our thesis using the biblatex package.In this, the final post of the series, we're going to look at customising some of the opening pages. In the first video we made a rather makeshift title page using the \maketitle command and by using an \includegraphics command in the \title command. Although this works, it doesn't give us as much ...

  14. How to write a clean and organized preamble in LaTeX?

    My solution: Make a .sty file, where you put the preamble. Then you just have to import that .sty to your Code. When you start a new project you just have to copy and paste that .sty. I made a folder with different .sty, each .sty has a different style.

  15. Guide to Writing Your Thesis in LaTeX

    Step 1: Install LaTeX and a LaTeX Aware Editor. LaTeX is not a word processor, it is a document preparation system for high-quality typesetting. It is most often used for medium-to-large technical or scientific documents, but it can be used for almost any form of publishing. LaTeX encourages authors not to worry too much about the appearance of ...

  16. Writing Theses in LaTeX

    This workshop explores how LaTeX can be used to typeset a thesis in a professional and aesthetic way, which conforms to the Imperial College guidelines. You will practise using a variety of LaTeX packages, will receive personalised feedback on your typesetting, and will leave with your thesis template. Syllabus: Thesis requirements; Page numbering

  17. Guide to Writing Your Thesis in LaTeX: FAQ

    When using pdflatex to create a pdf version of the thesis, the hyperref package will do the following: create a pdf table of contents in the pdf document. all citations and references in the thesis will be hyperlinks that will go to the referenced equation, figure, bibliographic citation, etc…. the table of contents in the thesis will be ...

  18. Basic thesis template

    This LaTeX template includes a title page, a declaration, an abstract, acknowledgements, table of contents, list of figures/tables, a dedication, and example chapters and sections. This template was originally published on ShareLaTeX and subsequently moved to Overleaf in November 2019. This Thesis LaTeX template is an ideal starting point for ...

  19. LaTeX Templates

    Masters/Doctoral Thesis. This template provides a full framework for writing a graduate level thesis. It is carefully structured and separated into multiple parts for easy editing. Included are the following pages/sections: a cover page, declaration of authorship, quotation, abstract, acknowledgements, contents page (s), list of figures, list ...

  20. How to Write a Thesis in LaTeX (Part 4): Bibliographies with ...

    All of the information about the recognised source types and all the keywords you can use can be found in the biblatex documentation.. Now let's return to the main .tex file. To set it up for a bibliography we need to load up the biblatex package using the \usepackage command. Also in the preamble we need to specify which .bib files we want to use by calling the \addbibresource command and ...

  21. preamble

    Convert your chapters in complete documents (with the same preample that the main document) and then go to CTAN to known about the topic subdoc: in­clude com­plete doc­u­ments in other doc­u­ments.In particular, docmute or standalone packages is what your are looking for. It is a simple as add one of these packages to the preamble of the main document (there are many examples of use of ...

  22. Some Quarto PDF formatting tips, with particular reference to thesis

    To set these options, you'll need to add them to what Quarto calls the LaTeX header (which I've always known as the LaTeX preamble). That means you need to add a line like include-in-header: include-in-header.tex to the PDF format options in your YAML, and then add the code here to a file called include-in-header.tex.

  23. Easy thesis template

    License. Other (as stated in the work) Abstract. Easy LaTeX thesis template prepared by Simon Ternsja, based on Graduate Thesis template written by Sunil Patel. This template was originally published on ShareLaTeX and subsequently moved to Overleaf in November 2019.