LaTeX Template for a Scientific Thesis
This template is a general template for scientific theses. Currently, it is the unofficial LaTeX template for Master, Bachelor, Diploma, and Student Theses at following institutions:
University of Stuttgart, Computer Science
The template will be extended to support theses from different institutions.
For architectural decision records see docs/adr.
Quick start
Download
Go to the development version at https://github.com/latextemplates/scientific-thesis-template/archive/main.zip. Reason: LaTeX packages change so fast over time and we cannot do a release on each change.
Extract
scientific-thesis-template-main.zipto the directory you want to work. E.g.,c:\users\user\documents\thesis.
Start texing
University of Stuttgart:
English:
main-english.texGerman:
main-german.texGerman advanced usage:
main-minted-german.tex(see below)
Usage at overleaf
See docs/overleaf.
Usage
main-english.texis the main documentUse "lualatex + biblatex" in your TeX editor or
latexmk main-english/makein the command line
Using latexmk
latexmk is a very smart tool for latex compilation. It executes the latex tools as often as needed to get the final PDF. (More information about why latexmk is great can be found at https://tex.stackexchange.com/a/249243/9075.)
To build the whole document, execute following command. Note that this requires a working perl installation.
To enable latexmk, please move _latexmkrc to latexmkrc.
If you want automatic compilation use following command:
This will also open a Sumatra PDF and only works with the supplied configuration.
latexmk configuration
This repository ships a .latexmkrc which is read by latexmk. In case there is a _latexmkrc file, you need to rename it to .latexmkrc. It is configured for Windows and especially sets Sumatra PDF as default PDF viewer. You can make this local configuration a global configuration, when you put it at the right place.
If you want to add more packages, configure it there. For instance, for support of makeglossaries see http://tex.stackexchange.com/questions/1226/how-to-make-latexmk-use-makeglossaries.
Debugging LaTeX errors
In case something goes wrong, you can instruct the LaTeX compiler to stop at the first error:
Run biber main-english to get the bibliography rendered (execute lualatex afterwards).
Advanced usage
On the command line, there are additional features:
latexmk -Cormake cleanfor cleaning upmake formatto reformat the.texfiles (one sentence per line and indent)make aspellfor interactive spell checkingmake stand: Creates a new PDF with the current status of the thesis.make view: Opens the configured viewermake mrproper: Cleans up and removes also editor backup files.
Benefits
Following features are enabled in this template:
(Optional) Typesetting of listings using advanced highlighting powered by the minted package.
mintedprovides better output than listings, but requires latexminted to be installed.Generated PDF allows for copy and paste of text without getting words with ligatures such as "workflow" destroyed. This is enabled by
glyphtounicode, which encodes ligatures (such as fl) using unicode characters.Ligatures are removed if they are typeset at the wrong place. This is enabled by the selnolig package.
Support of hyperlinked references without extra color thanx to hyperref.
Better breaking of long URLs.
Support for
\powersetcommand.Support todos as pdf annotations. This is enabled by the pdfcomment package.
microtypographic extensions for a better look of the paper.
Modern packages such as microtype, cleveref, csquotes, paralist, hyperref, hypcap, upquote, booktabs.
LaTeX compilation using the modern lualatex compiler. For older systems, pdflatex is still supported.
biblatex+biber instead of plain bibtex to have a more intuitive
.bibfile: Unicode (UTF-8) is fully supported and commands such as\citeauthor{...}work out of the box. See also https://tex.stackexchange.com/q/8411/9075.latexmk for easy compilation of the LaTeX document.
Ready-to-go configuration for latexindent.
Proper hyphenation and microtype for English texts.
Hints on writing an abstract and thesis by Dirk Fahland.
Disabled features
Following features were not activated for this template. You can run the latex template generator to enable the features.
Congratulations. You chose to use all available features.
Tool hints
Prerequisites
Windows: Recent MiKTeX. MiKTeX installation hints are given at http://latextemplates.github.io/scientific-thesis-template/#installation-hints-for-windows.
Mac OS X: Recent TeX Live (e.g. through MacTeX) - Try
sudo tlmgr update --allif you encounter issues with biblatexLinux: Recent TeX Live distribution
See <docs/latex-setup.md> for refined installation instructions.
Usage of minted
To have minted running properly, you have to do following steps on Windows:
Install python:
choco install python- that uses chocolatey to install PythonInstall latexminted:
pip instal latexminted- that uses the Python package manager to install the minted libraryWhen latexing, use
-shell-escape:pdflatex -shell-escape main-english. You can also just executelatexmk main-english.
VS Code configuration
Currently, following extensions are recommended:
LaTeX Workshop to support LaTeX in VS Code and
LaTeX Utilities to enhance LaTeX Workshop
LTeX+ to have a nice spell checker that also identifies grammar issues
Then, change the setting of LaTeX Workshop to use biber:
Press Shift+Ctrl+P to open the command palette. Then type "JSON" and select "Preferences: Open Settings (JSON)" to open settings.json.
Update the following lines in VS Code's settings.json to contain:
The following settings are additionally recommended:
Alternatively, just copy and paste the contents of the vscode.settings.json file to your VS Code settings file.
You can manually trigger compilation by hitting the green button in the extension or using other methods provided by LaTeX Workshop.
Please remove the magic comments (% !TeX program ...) at the top of the main-....tex file. Although LaTeX-Workshop supports magic comments, it currently does not work reliably. Without the magic comments, compilation works.
LTeX+ tips and tricks
LTeX+ is an offline grammar and spell checker with support for LaTeX and Markdown.
Add a magic comment to your files to tell LTeX+ which language to use:
If you want to use different languages in the text, use the \foreignlanguage{language}{text} command. LTeX+ will detect these elements and automatically switch the spell checker's language. For example:
Usage with docker
The generated Dockerfile is based on the Dockerfile by the Island of TeX.
Following one-time setup is required:
Contained Directories and Files
Directories
figures Directory containing the figures. By using LuaLaTex/PDFLaTeX it is possible to use PDFs, JPGs, PNGs, ... We recommend to use PDFs to enable smooth scaling.
Files
main-english.tex- The main.texfile loading all LaTeX packages and their configurations.Add text here
Adjust title etc. here
bibliography.bib - Bibliography. biblatex format. Manage it with JabRef.
abbreviations.tex - Acronyms and abbreviations.
commands.tex - Example LaTeX macros.
Following additional files are included, which do not need to be adapted:
localSettings.yaml - Settings for latexindent
Makefile - The Makefile. Builds on latexmk.
Texlivefile - List of packages required for a minimal TeXLive installation.
FAQs
Q: How can I synchronize updates from the template to my repository?
Initialize your git repository as usual
Add this repository as git remote:
git remote add template https://github.com/latextemplates/{template}.gitMerge the branch
template/maininto yourmainbranch:git merge template/main.
After that you can use and push the main branch as usual. Notes on syncing with the upstream repository are available from GitHub.
Q: I get the error ! pdfTeX error (font expansion): auto expansion is only possible with scalable fonts.
Install the cm-super package using the MiKTeX package manager. Then, run initexmf --mkmaps on the command line. (Long description: https://tex.stackexchange.com/a/324972/9075)
Q: I get Package csquotes Error: Unbalanced groups or invalid nesting. What can I do?
A: You have activated \MakeOuterQuote{"} and used some special babel command to allow hyphenation at other places as a dash. One example is writing application"=specific. Now, you have to decide whether you want keep using plain quotes to enquote a word or use the special hyphenation command. In other words: Do you want "quote" and app\-lication\-specific or \enquote{quote} and application"=specific?
Note that this should not happen when the template is generated as the setting tweakouterquote ensures that these two options are mutually exclusive.
Q: I need more space. What can I do?
The most simple solution to get more space is to exchange the font.
Q: How can I reformat my .tex files?
Execute latexindent -l -s -sl -w main-english.tex
Alternatively, execute make format.
Q: How I want to obey the one-sentence-per-line rule. How to do?
See "How can I reformat my .tex files?"
Q: I want to use minted, because I think its syntax highlighting seems to be better.
You can re-generate the template and choose minted as listings environment. Moreover, ensure that python and latexminted are installed properly:
choco install pythonpip install latexminted
Q: I have troubles with minted on Windows.
For instance, on gets following output:
Try out following command to update latexminted. See minted#425 for details.
Q: Can I also write in German?
Yes. You can regenerate the template and choose "German" as language.
Q: I was recommended the Harvard style
This template uses the alphabetic style. That style is explained at the biblatex documentation on page 60:
The alphabetic labels resemble a compact author-year style to some extent, but the way they are employed is similar to a numeric citation scheme. For example, instead of “Jones 1995” this style would use the label “[Jon95]”. “Jones and Williams 1986” would be rendered as “[JW86]”.
We are aware that the University of Stuttgart recommends to use the Hardvard style. However, this style is not common in natural sciences and information science.
Q: ngerman-x-latest is reported missing
Install the package dehyph-exptl.
Q: I get ! I can't find file `clmr28t10+20'.
You seem to use latexmk locally. Please move _latexmkrc to latexmkrc to get latexmk working. If you don't do this, latexmk tries to execute latex, which tries to produce a DVI file (and not a PDF file).
Q: I get Font "LatinModernMath-Regular" not found.. What can I do?
Error message:
Install the package lm-math manually.
Q: I get File `ushyphex.tex' not found.
Install package tugboat.
Q: I get ! Package fontspec Error: The font "LinuxLibertineO" cannot be found.. What can I do?
Install the package libertine manually.
Q: I get ! Package fontspec Error: The font "TeXGyreTermes" cannot be found.. What can I do?
Install the package tex-gyre and tex-gyre-math manually.
Q: I get ! error: (type 1): cannot find encoding file 'ntx-ot1-tlf.enc' for reading. What can I do?
See https://tex.stackexchange.com/a/240850/9075: Install the packages newpx and newtxsf manually.
Q: I get ! TeX capacity exceeded, sorry [main memory size=3000000].. What can I do?
Follow the steps at https://tex.stackexchange.com/a/548335/9075
Try with following command
See https://tex.stackexchange.com/a/124206/9075 for details.
Q: There is an output that biber/biblatex too old
See installation hints of how to update them at different systems.
Q: MiKTeX complains about missing .sty files.
Use the MiKTeX console to refresh the package index. Then, automatic installation should work again.
Q: I cannot get minted to run. There is this -shell-escape warning.
Please ensure that your compilation command includes -shell-escape. E.g., lualatex -shell-escape -synctex=1 main-minted-german.tex. When compiling main-minted-german.tex with TeXStudio, you will see a dialog warning about overriding the compilation command. Just answer "(a) allow for this document" and it will work.
Q: How to include Excel charts properly?
Select the Excel chart you want to use.
Print to PDF with the option "Print Selected Chart".
Remove empty space of the created PDF page with
pdfcrop chart.pdf chart_cropped.pdf(install via MikTeX first, if not available; check viapdfcrop --version).Use pdfscissors to crop the borders and title (maybe you have to allow https://sites.google.com in the Java security center in the control panel).
Include the PDF in LaTeX via
\includegraphics{chart_cropped.pdf}.
Q: How do I change the appearance of chapter headings?
Look for % Code for my fancy chapters. in your main .tex file and play around with parameters.
Q: Aren't there other templates?
Sure. The Hagenberg Thesis Document Collection seems to be the most promising. However, they currently do not support microtype and not the cover of the University of Stuttgart.
We are collecting alternatives at the issue #25 and plan to add a comparison to each other template.
Q: Do I have to do something special for the final version?
If you included some version control statements, please remove them. Currently, the template does not support any, but it used to support SVN.
By using
\largepageand\shortpage, single lines at the bottom or at the top of the page can be manually fixed.Search the PDF for "TODO" or similar things. Remove
\usepackage{todonotes}in your main.texfile.Ensure that you run
lualatexat least three times and that there are no "undefined references".The margins are intended for good screen reading. Do not change them (or do exactly know what you are doing).
Q: main-minted-german.tex does not compile: File `main-minted-german-plantuml.latex' not found. \end{plantuml}. What can I do?
You did not setup the plantuml package correctly. Please head to https://koppor.github.io/plantuml/ for installation instructions.
Further information
Other templates: https://latextemplates.github.io/
For German users, go to https://texfragen.de/.
Frank Mittelbach with Ulrike Fischer: The LaTeX Companion is the ultimate guide for LaTeX: The authors went through all packages offered by CTAN, selected the most promising ones, described them, and provide minimal working example for each of it.
Lutz Hering, Heike Hering: How to Write Technial Reports, Springer, 2010; also available in German Technische Berichte - verständlich gliedern, gut gestalten, überzeugend vortragen. - Highly recommended, because it guides through all aspects of a report (such as a Master Thesis).
Marcus Deininger et al.: Studienarbeiten - Ein Leitfaden zur Erstellung, Durchführung und Präsentation wissenschaftlicher Abschlussarbeiten am Beispiel Informatik, vdf. - Recommended as guideline for planning and working on the whole thesis.
Charles Lipson, Cite Right, Second Edition: A Quick Guide to Citation Styles--MLA, APA, Chicago, the Sciences, Professions, and More, Chicago Guides to Writing, Editing, and Publishing, 2011. - Recommended in case you are unsure about how to correctly cite something.
License
The license of this work is 0BSD which corresponds to "public domain". Any derived work can freely be relicensed and can omit original copyright and license information.