scientific-thesis-template

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 the computer science departments listed below, each with example PDFs; other departments are untested. The template will be extended to support theses from more institutions.

The LaTeX snippets this template is assembled from can be inspected at https://latextemplates.github.io/latex-snippets/.

Supported institutions

University of Stuttgart, Computer Science

Universität Hamburg, Computer Science

Technische Hochschule Ulm (THU), Computer Science

Quick start

  1. Download

    1. 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.
    2. Extract scientific-thesis-template-main.zip to the directory you want to work. E.g., c:\users\user\documents\thesis.
  2. Start texing

    • University of Stuttgart:
      • English: main-english.tex
      • German: main-german.tex
      • Without Python (see below): main-basic-listings-english.tex, main-basic-listings-german.tex
    • The text is in chapters-en/ (English) and chapters-de/ (German), one file per chapter (e.g., chapters-en/10 - introduction.tex), which the main files include. The numbers go in steps of 10, so a new chapter fits in between (e.g., chapters-en/25 - my chapter.tex).
  3. Compile with “lualatex + biber” in your TeX editor or with latexmk main-english / make on the command line.

Usage at Overleaf

See docs/overleaf.

Advanced quick start

Instead of downloading the ZIP, let git fetch the template; later template updates then merge into your text (see the FAQ). In an empty folder:

git init -b main
git remote add template https://github.com/latextemplates/scientific-thesis-template.git
git fetch template
git merge template/main

Then edit and compile as above.

Writing your thesis

Benefits

Following features are enabled in this template:

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.

Contained directories and files

Directories

Files

Following additional files are included, which do not need to be adapted:

LaTeX compilation

Compile either in a Docker container (recommended) or with a LaTeX distribution installed on your machine.

The TeX Live docker image by the Island of TeX works the same on Windows, macOS, and Linux. It ships a complete TeX Live including latexmk, biber, latexindent, Python, and latexminted. Thus, minted works out of the box - also on Windows, without a separate Python setup.

  1. Install Docker (Docker Desktop on Windows and macOS).
  2. Open a terminal in the directory of this document and compile in the container. The first run downloads the image (approx. 3 GB); its tag selects the TeX Live version of this template.

    Windows (PowerShell):

    docker run --rm -v "${PWD}:/workdir" registry.gitlab.com/islandoftex/images/texlive:latest latexmk main-english
    

    Windows (Command Prompt):

    docker run --rm -v "%cd%:/workdir" registry.gitlab.com/islandoftex/images/texlive:latest latexmk main-english
    

    Linux and macOS:

    docker run --rm -v "$PWD:/workdir" registry.gitlab.com/islandoftex/images/texlive:latest latexmk main-english
    
  3. Optional: Let VS Code compile in the container, see “VS Code configuration”.

No Docker at hand? Open the repository in GitHub Codespaces and compile in the browser.

If you need additional tools in the image, extend the generated Dockerfile, build it with docker build -t ltg ., and use ltg instead of the image name.

Traditional

Install a LaTeX distribution on your machine:

See <docs/latex-setup.md> for refined installation instructions.

To have minted running with a traditional installation, you have to do following steps on Windows (the Docker image already contains all of this):

  1. Install python: choco install python - that uses chocolatey to install Python
  2. Install latexminted: pip install latexminted - that uses the Python package manager to install the minted library

latexmk hints

latexmk runs the LaTeX tools (e.g., lualatex and biber) as often as needed to get the final PDF (why latexmk is great). It reads its configuration from .latexmkrc in the directory of the document. Overleaf reads .latexmkrc, too, so the “Compiler” setting of the Overleaf project does not matter; select TeX Live 2026 there. To use the configuration for all your documents, put it at the right place.

Build the document:

latexmk main-english

In the Docker-based setup, put the docker run ... part from “Docker-based (recommended)” in front, or just run make. In the traditional setup, latexmk needs Perl (TeX Live ships it; with MiKTeX, install it, e.g., via choco install strawberryperl).

To recompile on every change and open the PDF, run:

latexmk -pvc main-english

On Windows, the configuration opens the PDF in Sumatra PDF, which reloads the PDF automatically.

Tool hints

Advanced usage

On the command line, there are additional features:

Without make (e.g., on Windows), run a target with make in the Docker image by DANTE e.V., which contains make and all tools, e.g., dictionaries:

docker run --rm -it -v "${PWD}:/workdir" -w /workdir danteev/texlive:2026-C make LOCAL=1 dictionaries
docker run --rm -it -u "$(id -u):$(id -g)" -e HOME=/tmp -v "$PWD:/workdir" -w /workdir danteev/texlive:2026-C make LOCAL=1 dictionaries

The textlint job of the Check workflow reports weakening words (e.g., “clearly”, “just”) in the English .tex files as annotations. Run it locally with npx (needs Node.js; rules come from .textlintrc.json):

npx --yes --package textlint --package textlint-plugin-latex2e --package textlint-filter-rule-allowlist --package textlint-rule-terminology --package textlint-rule-write-good textlint main-english.tex chapters-en/*.tex chapters-en/*.md

The textidote job of the Check workflow checks spelling, grammar, and style of English documents with TeXtidote and reports its findings as annotations. Its options are in .textidote. Run it locally with make spellcheck-textidote: it writes the report textidote.html (for the chapters: chapters-*/*.textidote.html).

UML diagrams with PlantUML or Mermaid

The “LaTeX Hints” chapter shows UML diagrams drawn with MetaUML and pgf-umlsd, which need no further tools. PlantUML and Mermaid offer a more compact syntax and lay out the diagrams automatically, but need further tools: they are contained in the Docker image by DANTE e.V.. To use them, generate an own copy of this template with the latex template generator:

npx -p yo -p generator-latex-template -c 'yo latex-template --documentclass=scientific-thesis --latexcompiler=both --overleaf=true --texlive=2026 --enquotes=csquotes --tweakouterquote=babel --todo=pdfcomment --examples=true --howtotext=true --uml=plantuml --docker=dante'

Use --uml=mermaid for Mermaid. The generator asks for the remaining options (institution, language, and package for source code), which distinguish the main*.tex files of this template.

VS Code configuration

Currently, following extensions are recommended:

With the settings below, LaTeX Workshop compiles with the recipe “lualatex ➞ biber ➞ lualatex × 2”. To compile in the Docker container (see “Docker-based (recommended)”), add the following lines to VS Code’s settings.json (Shift+Ctrl+P, then “Preferences: Open Settings (JSON)”):

    "latex-workshop.docker.enabled": true,
    "latex-workshop.docker.image.latex": "registry.gitlab.com/islandoftex/images/texlive:latest",

The following settings are additionally recommended:

{
    "editor.wordWrap": "on",                                          // enable soft line breaks
    "latex-workshop.view.pdf.viewer": "tab",                          // display the generated PDF in a separate tab
    "latex-workshop.view.pdf.color.light.backgroundColor": "#cccccc", // light theme: use a darker background in the PDF viewer to lift the pages off it
    "latex-workshop.view.pdf.color.dark.backgroundColor": "#121314",  // dark theme: same, with a dark gray matching the editor
    "latex-workshop.latex.autoBuild.run": "never",                    // never automatically build; alternative: "onSave" (on saving .tex files)
    "editor.renderWhitespace": "all",                                 // display all whitespaces
}

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.

LTeX+ tips and tricks

LTeX+ is an offline grammar and spell checker with support for LaTeX and Markdown.

The main file starts with a magic comment that tells LTeX+ the language of the document, e.g., % LTeX: language=en-US. Add the same comment to further .tex files.

FAQs

Q: pdfLaTeX stops with “Invalid UTF-8 byte sequence (\lst@EC)” in a listing, or an umlaut is missing in it.

Under pdfLaTeX, the listings package reads a listing byte by byte, so a character outside ASCII has to be mapped to its LaTeX command. The template does this for accented Latin letters and common punctuation with literate= in \lstset (search for extendedchars in main-english.tex). A character that is not in the table triggers the error and is dropped. Add it with the same pattern, e.g., {Ĺ‘}}1 (the 1 is its width in characters). LuaLaTeX reads UTF-8 directly and needs no table, which is why the table is inside \ifpdftex. listingsutf8 helps with \lstinputlisting only, not with the lstlisting environment.

Q: How do I include an SVG file?

Convert it once to PDF with Inkscape (1.0 or later) and include the PDF with \includegraphics:

inkscape figure.svg --export-type=pdf --export-filename=figure.pdf

The svg package automates this (\includesvg{figure} converts at every build), but it needs Inkscape on the machine that compiles and --shell-escape, so the conversion fails on Overleaf and in CI; the one-time conversion has neither constraint. Text in the SVG stays as it is; the --export-latex option of Inkscape writes the text to a .pdf_tex file set by LaTeX in the document font instead (see the svg package manual for the \includeinkscape workflow).

Q: How do I find the cause of a LaTeX error?

Run the compiler so that it stops at the first error instead of continuing with a damaged document:

lualatex -halt-on-error --synctex=1 main-english

The line starting with ! in the output (and in main-english.log) names the error, the following l.<number> line the line of the source. make log shows only the relevant messages of the last run (using texlogsieve). For an interactive run, texfot wraps the compiler and prints only the lines that probably need a change in the source:

texfot lualatex main-english

Which tool fits which situation is compared in the decision record on log filtering. Run biber main-english to get the bibliography rendered (execute lualatex afterwards).

If there is no PDF although the log shows only warnings, the compiler stopped on a missing file without an ! line: search the end of the log for not found, cannot find, or Fatal error. A missing font or encoding file is the usual cause (see the questions on .enc files and LatinModernMath below); warnings such as “THIS IS AN ALPHA VERSION” of a package are harmless. The Check workflow builds this template on every change, so a build that fails locally comes from the local TeX installation; compare with the PDF at https://latextemplates.github.io/scientific-thesis-template/ or build in the Docker image (see the Makefile).

Q: I get ! Package minted Error: minted v3+ executable is not installed

The complete output reads:

! Package minted Error: minted v3+ executable is not installed, is not added to
 PATH, or is not permitted with restricted shell escape; or MiKTeX is being use
d with -aux-directory or -output-directory without setting a TEXMF_OUTPUT_DIREC
TORY environment variable.

The minted package needs Python and the Python package latexminted. The Docker image and Overleaf contain both. For a local installation:

  1. Install Python, e.g., choco install python on Windows.
  2. Install or repair latexminted: python -m pip install --force-reinstall latexminted (see minted#425).

Without Python, use the *-basic-listings*.tex variant: it typesets source code with the listings package.

Q: How do I spell check a passage in another language?

Use the \foreignlanguage{language}{text} command. LTeX+ will detect these elements and automatically switch the spell checker’s language. For example:

\foreignlanguage{english}{Therefore, our proposed approach will change the world.}

Q: How do I add a word (e.g., the name of a tool) to the spell checkers?

Each spell checker reads its own word list; add the word as a new line:

Spell checker Word list
aspell (CI job spell-check, make spellcheck-aspell) .aspell.en.pws (English), .aspell.de.pws (German); below the first line, no hyphenated words
LTeX+ (VS Code) .vscode/ltex.dictionary.en-US.txt, .vscode/ltex.dictionary.de-DE.txt; “Add to dictionary” in VS Code writes there
TeXtidote (CI job textidote, make spellcheck-textidote) .textidote.dict
typos (CI job typos) .typos.toml, section [default.extend-words], e.g., Heros = "Heros"; only needed if typos reports the word

The word lists of aspell, LTeX+, and TeXtidote contain the same words. Instead of editing each of them, add the word to the aspell or the LTeX+ word list and run make dictionaries: it merges both and writes the word into all of them (hyphenated words not into aspell’s). On GitHub, the workflow Dictionaries does this after each push that changes one of these word lists and commits the result. To remove a word, delete it from the aspell and the LTeX+ word list and run make dictionaries.

Q: How do I compile a single chapter?

In chapters-en/, run latexmk "10 - introduction"; the result is 10-introduction.pdf. Each chapter file starts with \documentclass[../<main file>]{subfiles}, and the subfiles package loads the preamble of that main file. The .latexmkrc in the chapter directory takes the settings of the main directory and lets LaTeX find the packages, figures and the bibliography there. References to other chapters show as ?? and the bibliography is not printed; the full document has them.

Q: How can I synchronize updates from the template to my repository?

Set up the repository as described in the advanced quick start: this template is the git remote template. To get the latest template version, fetch and merge it:

git fetch template
git merge template/main

If you already have a repository, add the remote first: git remote add template https://github.com/latextemplates/scientific-thesis-template.git. 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: Can I also write in German?

Yes. You can regenerate the template and choose “German” as language.

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'.

latexmk runs latex, which produces a DVI file (and not a PDF file), because it does not find its configuration. Make sure that .latexmkrc is in the directory of the document.

Q: I get Font "LatinModernMath-Regular" not found.. What can I do?

Error message:

luaotfload | db : Reload initiated (formats: otf,ttf,ttc); reason: Font "LatinModernMath-Regular" not found.
luaotfload | resolve : sequence of 3 lookups yielded nothing appropriate.

! Package fontspec Error: The font "LatinModernMath-Regular" cannot be found.

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

lualatex -shell-escape --extra-mem-top=10000000 --synctex=1 main-english.tex

See https://tex.stackexchange.com/a/124206/9075 for details.

Q: \glsunset{...} or \glsreset{...} seem to do nothing. Why?

They only change the “already used” flag of an abbreviation; nothing is printed where they stand. The effect shows at the next \gls{...} of that abbreviation: after \glsunset{nlp}, \gls{nlp} prints the short form; after \glsreset{nlp}, the long form. Put them before that \gls{...} in the text, use the key from abbreviations.tex (\newabbreviation{nlp}{NLP}{natural language processing}), and compile twice (latexmk does), because the first-use information comes from the previous run. \glsresetall after the abstract lets every abbreviation appear in its long form again in the main text.

Q: The thesis is in English, but the title page says “Masterarbeit” (or “Bachelorarbeit”). Why?

On the cover of the University of Stuttgart, the thesis type is the official German term of the examination regulations, also in an English thesis; see the discussion at the cover package. If your university wants it in English, set the type as free text in the options of scientific-thesis-cover in the main file: type={Master Thesis} instead of type=master.

Q: I write my thesis at ISTE (University of Stuttgart). What do I set?

Q: Why are the pages numbered continuously, without roman numerals for the front matter?

ISO 7144 (“Presentation of theses and similar documents”) numbers the pages consecutively with arabic numerals from the title page on, and the doctoral regulations of the University of Stuttgart require that. Furthermore, the page number in the PDF viewer then equals the printed one, and a page reference is unambiguous. See the decision record. If your institution wants roman numerals for the front matter, put \frontmatter before the title page and \mainmatter before the first chapter of the main file, or generate an own copy of the template with the latex template generator:

npx -p yo -p generator-latex-template -c 'yo latex-template --documentclass=scientific-thesis --latexcompiler=both --overleaf=true --texlive=2026 --enquotes=csquotes --tweakouterquote=babel --todo=pdfcomment --examples=true --howtotext=true --pagenumbering=roman'

Q: How do I change the font of the table of contents?

With KOMA-Script commands in the preamble of the main file (next to \setkomafont{disposition}); the tocloft package is not needed and does not go well with KOMA-Script. The chapter entries use the font element chapterentry, the lower levels are set by \DeclareTOCStyleEntries:

\setkomafont{chapterentry}{\sffamily\bfseries\large}
\DeclareTOCStyleEntries[entryformat=\sffamily\large]{tocline}{section}
\DeclareTOCStyleEntries[entryformat=\sffamily]{tocline}{subsection,subsubsection}

The template sets all entries in the sans-serif font of the headings; see the KOMA-Script manual (texdoc scrguide, section on tocbasic) for numwidth, indent, pagenumberformat, and the other keys.

Q: How do I speed up compilation with a precompiled preamble?

With pdfLaTeX, the preamble of main-english.tex can be dumped into a format file once (mylatex, part of TeX Live); later runs load the format instead of reading all packages, which saved 26 % per run for the example thesis.

pdflatex -ini "&pdflatex" mylatex.ltx main-english
pdflatex "&mylatex" main-english

Caveats: a run with the format skips the preamble of the .tex file, so after every change to the preamble, and after a TeX Live update, the first command has to be repeated; otherwise the change is silently ignored. Additions placed after a line containing only % mylatex (put it right before \begin{document}) are read anyway, so new packages and macros can go there while writing. latexmk does not rebuild the format, so this is for runs by hand while writing; latexmk builds the final version as usual. The file mylatex.fmt (about 14 MB) is a build product and in .gitignore. LuaLaTeX (the default of this template) cannot dump its preamble: Lua states and the loaded fonts are not part of a format. The other ways to shorten the edit-compile loop, with measurements, are in the decision record How to speed up compilation.

Q: How do I change the citation style (APA, Chicago, IEEE, …)?

The bibliography is typeset by biblatex with its built-in styles: alphabetic here (--authoryear at generation time switches to authoryear). These styles are generic and complete; they follow no published style guide, which is fine unless a department or a journal prescribes one. To switch to a prescribed style, replace the bibstyle and citestyle options in the \usepackage[...]{biblatex} block of main-english.tex by the style’s option, e.g., style=apa (biblatex-apa) or style=ieee (biblatex-ieee); Chicago comes as its own package (biblatex-chicago), which is loaded instead of biblatex. The options minalphanames and maxalphanames belong to the alphabetic style and have to go. Rendered examples of each style and the trade-offs are in the decision record How to cite in a given citation style.

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: How to include Excel charts properly?

  1. Select the Excel chart you want to use.
  2. Print to PDF with the option “Print Selected Chart”.
  3. Remove empty space of the created PDF page with pdfcrop chart.pdf chart_cropped.pdf (install via MikTeX first, if not available; check via pdfcrop --version).
  4. 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).
  5. 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: How do I let section headings stick out into the left margin?

Add \RedeclareSectionCommand[indent=-1cm]{section} to the preamble; indent is the KOMA-Script option for that, the same works for subsection, paragraph, etc. A negative \hspace* in \addtokomafont{section} achieves a similar effect, but belongs to the font setting and is not applied to all headings consistently.

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?

Further information

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.

Exceptions

The logos are trademarks of the universities: use them only on the title page of a thesis submitted there, so that the thesis is not mistaken for a publication of the university.