LaTeX Thesis Template (Manuel Kuehner)

My PHD Thesis

My own thesis – which the template here is based on – can officially be found at the University Server (TUM)  or on my PHD project website (German).

General Information

I first published my PHD thesis on the Showcase of beautiful typography done in TeX & friends page. I was asked to publish the LaTeX code on the Stack Exchange TeX Blog here which made me very proud.

I then started to create a lean template that is suitable as a starting point for most thesis projects. Therefore I kept the number of packages to a reasonable minimum.


Here are some impressions of the template:

Used packages

The following packages are used in the template:

  • scrbook (Document Class from KOMA-Script, needed for the layout)
  • scrhack (KOMA-Script package, not needed for the layout, for preventing warnings in combination with the float package)
  • marginnote (KOMA-Script package, needed for the layout)
  • scrpage2 (KOMA-Script package, needed for the layout)
  • geometry  (needed for the layout)
  • inputenc (not needed for the layout)
  • fontenc (not needed for the layout)
  • babel (not needed for the layout)
  • calc (needed for the layout)
  • graphicx (not needed for the layout)
  • float (not needed for the layout)
  • xcolor (needed for the layout)
  • booktabs (just for demonstration – not needed for the layout)
  • ragged2e (needed for the layout)
  • pgfplots (just for demonstration – not needed for the layout)
  • caption (needed for the layout)
  • hyperref (not needed for the layout)
  • blindtext (just for demonstration – not needed for the layout)

Folder Structure

The template uses a recommended folder structure which looks like:
> 00_Backup
> 01_Preamble
> 02_Chapters
> 03_GraphicFiles
> 04_Tables
> 05_Bibliography
> 06_Listings
> 99_AppendixFiles
Batch_CleanUp.bat
Batch_CompileFile.bat
MainFile.pdf
MainFile.tex

Main File

The main file does not contain much code. It includes different tex files using the \input command which leads to a very tidy and readable structure.
%%% File encoding is ISO-8859-1 (also known as Latin-1)
%%% You can use special characters just liek ä,ü and ñ
%%% LaTeX template by Manuel Kuehner, 2015
%%% If you use this template then please give credit like this:
%%% —————————-
% LaTeX code inspired by the LaTeX Thesis Template by Manuel Kuehner
% www.bedienhaptik.de/latex-template/
%%% —————————-
% ##############################################
% Start: Template Preamble
% ##############################################
%
% Documentclass definition
\input{01_Preamble/documentclass.tex}
% Loading additional packages from the KOMA-Script family
\input{01_Preamble/KOMA-Script-Packages.tex}
% Page layout definition
\input{01_Preamble/PageLayout.tex}
% Standard packages
\input{01_Preamble/CommonPackages.tex}
% ####-Important-####
%
% Definition of the two main colors
% ———————–
% The corresponding xcolor package ist loaded in the file
% 01_Preamble/StandardPackages.tex
%
% ####-Important-####
\definecolor[named]{myColorMainA}{RGB}{0,26,153}
\definecolor[named]{myColorMainB}{RGB}{174,49,54}
% Customization of
% – Floating Objects (Caption)
% – Table of Contents (TOC)
% – List of Figures
% – List of Tables
% – Headings (like chapter, section, etc.)
\input{01_Preamble/Floating-AND-TOC-AND-ListOf-AND-Headings.tex}
% Customization of the header, footer and teh margin note
\input{01_Preamble/HeaderFooterMarginnote.tex}
% Optimize paragraphs (avoid overfull… warnings)
\input{01_Preamble/ParagraphOptimization.tex}
% PDF related packages
\input{01_Preamble/PDF-Related.tex}
% PDF related packages
\input{01_Preamble/RandomTextPackage.tex}
%
% #######################
% Ende: Template Preamble
% #######################
% ##############################################
% Start: Document
% ##############################################
%
% ——————————————————————
\begin{document}
% Title page
\input{02_Chapters/TitlePage.tex}
% Empty page after title page
\cleardoublepage
% Activate header and footer defined in the file:
% 01_Preamble/HeaderFooterMarginnote.tex
\pagestyle{scrheadings}
% Activate roman numbering (e. g. xii)
\pagenumbering{roman}
% Start with page 1 (I)
\setcounter{page}{1}
% Prologue
\input{02_Chapters/Prologue.tex}
% Abstract
\input{02_Chapters/Abstract.tex}
% Table of Contents and Lost of Figures/Tables
\input{02_Chapters/TOC-AND-ListOf.tex}
% Activate arabic numbering (e. g. 12)
\pagenumbering{arabic}
% Start with page 1
\setcounter{page}{1}
% Introduction
\input{02_Chapters/Introduction.tex}
% Main Part
\input{02_Chapters/MainPart.tex}
% Final Thoughts
\input{02_Chapters/FinalThoughts.tex}
% Start appendix
\appendix
% Appendix A
\input{02_Chapters/AppendixExampleChapterA.tex}
% Appendix B
\input{02_Chapters/AppendixExampleChapterB.tex}
\end{document}
% ——————————————————————
%
% #######################
% End: Document
% #######################

Changing the Two Main Layout Colors

The template uses two colors as eye candy. In my opinion this leads to a more modern look of the document. The colors are defined in the main file:
% ####-Important-####
\definecolor[named]{myColorMainA}{RGB}{0,26,153}
\definecolor[named]{myColorMainB}{RGB}{174,49,54}
myColor_MainA is a dark blue and myColor_MainB is a dark red. You can reuse the colors like this:
\definecolor{myColor_Example}{named}{myColor_MainA}
I also used the named colors in my TikZ/PGF drawings as you can see in the example output of the template: Example Document (PDF)

Document Class

I use the KOMA-Script class scrbook as the document class. This has the advantage that there is a very extensive German documentation and the document class covers a wide range of features. Therefore I do not need less packages. The memoir document class offers similar advantages (but no German documentation).
% KOMA-Script class ‘scrbook’
% Link to the documentation:
% German: http://mirrors.ctan.org/macros/latex/contrib/koma-script/doc/scrguide.pdf
% English: http://mirrors.ctan.org/macros/latex/contrib/koma-script/doc/scrguien.pdf
% CTAN: http://www.ctan.org/pkg/koma-script
% Author of the KOMA-Script family is Markus Kohm
\documentclass%
[%
paper=a4
,fontsize=11pt % common are 10, 11 or 12
,headings=big
,parskip
,numbers=noendperiod % 2.3.1 vs 2.3.1. (no dot after the last chapter number)
,twoside=true
,toc=bibliography % Bibliography appears in Table of Contents (without a number)
,toc=listof % List of Figures and List of Tables appear in Table of Contents
,version=last % Use latest version of the KOMA-Script
]%
{scrbook}

Stuff That is Missing

In order to keep the template small and compatible with other packages there are features that are not implemented, such as extended math support, many symbols, bibliography, complicated tables, indexes, typesetting units correctly and fancy fonts. Here are some suggestions:

  • amsmathmathtools and/or fixmath (math)
  • textcompbbdingpifont and/or wasysym (symbols)
  • biblatex/biber (bibliography)
  • array and tabu (tables)
  • xindy (indexes)
  • units and siunitx (units)
  • mathpazohelvet and/or inconsolata (fonts)

Regarding fonts make sure you visit the following discussions on tex.stackexchange.com:

I also like to use the hypercap package which solves the problem that hyperlinks to figures (floats in gereral) normally aim to the caption rather then to the start of the figure/picture.

Download the Template

The template can be downloaded on my PHD project website (scroll to the bottom of the page, I couldn’t upload a ZIP file here). Here you can download an example document (PDF) which was generated with the template files.

My System Setup

I used LaTeX (pdfTeX) on a Windows 7 system (MiKTeX distribution) and chose Texmaker as my LaTeX text editor. There is a video tutorial that shows how to setup up such a system:

YouTube: Installing LaTeX/MiKTeX and Texmaker on a Windows 7 System (Version 2014)

Batch Files

I added two batch files to the template which work under Windows in combination with MiKTeX.

  1. The first batch file is named Batch_CleanUp.bat and deletes all auxiliary files like .aux, .log and so on.
  2. The second batch file is named Batch_CompileFile.bat and calls Batch_CleanUp.bat, pdflatex and biberpdflatex is executed with some additional options which are useful when you have a large document and use the external option of TikZ/PGF.

Batch_CleanUp.bat

:: Delete all auxiliary files
del *.aux
del *.log
del *.gz
del *.blg
del *.bbl
del *.lof
del *.lot
del *.out
del *.ptc
del *.toc
del *blx.bib
del *run.xml
del *.bcf

Batch_CompileFile.bat

:: Delete all auxiliary files
rem — ‘rem’ or ‘::’ is the key word for comments in batch files like this

rem — Call cleanup script in order to delete all auxiliary files —
rem — Sometimes after error messages there are still errors in the auxiliary files even if the root of the error was corrected in the tex file
:: —
call my_Batch_CleanUp.bat
:: —

rem — First LaTeX run (pdflatex) with special options (more memory) for large LaTeX projects and tikz stuff (-shell-escape) —
rem — I use MiKTeX — maybe you need another syntax if you use TeX Live for example —
:: —
pdflatex –extra-mem-top=60000000 -synctex=1 -shell-escape -interaction=batchmode MainFile.tex

rem — Execute biber if used —
:: —
biber MainFile
:: —

rem — Compile three times to make sure everything is correct —
:: —
pdflatex –extra-mem-top=60000000 -synctex=1 -shell-escape -interaction=batchmode MainFile.tex
pdflatex –extra-mem-top=60000000 -synctex=1 -shell-escape -interaction=batchmode MainFile.tex
pdflatex –extra-mem-top=60000000 -synctex=1 -shell-escape -interaction=batchmode MainFile.tex
:: —

Other Templates

Other thesis templates can be found in the discussion here. Here I especially like the thesis template project from Siarhei Khirevich.

Suggestions From the Comments

Update 1st August 2015: Error “! Missing $ inserted. <inserted text>$ \chapter{Introduction}”

Some users saw the error message like in this screenshot:

ErrorMissingDollar
Error “! Missing $ inserted. $ \chapter{Introduction}”

It seems like it is caused by the underscores in the color names myColor_MainA and myColor_MainB. I therefore removed the underscore (myColorMainA and myColorMainB) and updated the template.

10 thoughts

    1. Hello John. Actually I don’t know – I guess I used this code part for several years in different thesises and it just worked. Is the result the same if you exchange the code?

  1. I’m curious: what do you need the

    float

    package for? AFAIK KOMA-Script offers everything which is needed for customizing floats or defining new ones?!

    BTW: you have a typo on your webpage the German forum is spelled mrunix. If you like you can also link texwelt.de, a German site which has quite some similarities to TeX.sx.

    1. Hello cgnieder. Thanks for the hints (typo and TeXwelt) – I updated the website accordingly. In my experience people have problems to differ between ‘normal LaTeX’ and ‘KOMA LaTeX’. If they are looking for help internationally (Google) then KOMA-Script is not very well known.

      In addition it seems that one huge documentation (KOMA or memoir) is more complicated to handle than several small package documentations.

      Including figures and tables is a very common request – therefore I decided to leave is with an ‘international solution’. But you are right!

      In a nutshell: You are right. It was more a gut feeling from my side. I should correct that in the future

  2. Actually I get the correct page number for the List of Tables (roman) only if I use

    frontmatter

    instead of ´\pagenumbering{roman}

    and

    \mainmatter

    instead of ´pagenumbering{arabic}

    . These are KOMA script commands afaik. I also would suggest to use the scrlayer-scrpage package instead of the scrpage2 packages, as it succeeded it, as far as I know.

    1. Hello John. Thanks for the advice. I will look into it – but not today or tomorrow.

      It took me almost all day yesterday to create the ‘clean’ template and so on.

      No PC time for me this weekend :).

      PS: There should be a user friendly formatting possibility in comments. I never remember the syntax.

  3. I really like the design, but I don’t get the template to work for me. It always comes up with the errors “Missing $” / “Missing }”.
    I thought it would be because of the underscores used everywhere in the code, but I couldn’t make it work. Any advice? Thanks so much !

Leave a Reply

Your email address will not be published. Required fields are marked *