%Latex template based on my (Christoph Säckel, 2025) dissertation. Hope it helps, but no guarantees. Took initial advise on LaTeX structure from http://alexanderfabisch.github.io/latex-for-dissertations.html (2023-03-22)

\documentclass[
draft=false,
paper=a4,
paper=portrait,
pagesize=auto,
fontsize=11pt,
version=last,
headings=onelinechapter,%twolinechapter=chapter-number\\chapter-title
open=any,% start parts and chapters on both even and odd pages
listof=totoc,
listof=chapterentry]
{scrbook}
\usepackage{scrhack}%"fixes some common problems"
\usepackage[a-1b]{pdfx}%pdfa format because it is required. images in the pdf format may cause errors

\DeclareUnicodeCharacter{2009}{\,}%helps compile bibliography if some authors/journals use thin spaces in cited fields
\DeclareUnicodeCharacter{0398}{$\theta$}%helps compile bibliography if some authors/journals use the theta temperature in cited fields
\DeclareUnicodeCharacter{2212}{-}%glossary acronyms of chemicals (maybe caused by apostrophies?) throw error otherwise
%\DeclareUnicodeCharacter{030A}{°}%helps compile bibliography if some (scandinavian) authors/journals use 'combining ring above' in cited fields.

\input{Diss_OrdinaryPackages.tex}%collects normal packages, does not include packages which require a lot of extra attention e.g. the bibliography package

\input{Diss_ConvenienceCommands.tex}%defines commands I found useful: Shorthands, macros to keep options for future typesetting, global variables for figure size or to show/hide comments etc

\input{Diss_Hyphenation.tex}%latex did not do too well with hyphenation (babel, british english). When a weird hyphen was spotted on a linebreak, I specified hyphenation for that word here.

\input{Diss_Glossary.tex}%Handles that e.g. acronyms are spelled out and have their abbreviation introduced (by default) only on their first occurrence, even if you later rearrange sections of your document. Glossaries are a lot of work to set up, but in the end I think it was worth it. This tex file also defines some custom commands and structures I found useful, e.g. to manually treat an acronym as if it was its first occurrence, which I used in the conclusion in case a reader did not read anything else.

\input{Diss_Bibliography}%Handles references. Tex file shows which package options I used.

%Chapters you do not currently work on need not be re-compiled to see changes in the chapter you are currently editing. This can save a lot of compiling time, however, I did not get it to work. But I also didn't try too hard, so feel free to give it a try. Instead of \input{chapter.tex}, you should then use \include{chapter.tex}. Note that \include creates a pagebreak by default
%\includeonly{
%	Diss_OrdinaryPackages.tex,
%	Diss_ConvenienceCommands,
%	Diss_Glossary.tex,
%	Diss_Bibliography,
%	Diss_titlepages.tex,
%	Diss_Abstract,
%	Diss_Introduction.tex,
%	Diss_Theory.tex,
%	Diss_ExperimentalDetails.tex,
%	Diss_ResultsDiscussion.tex,
%	Diss_SideProjects.tex,
%	%Diss_Conclusion.tex,
%	%Diss_Appendix.tex,
%	Diss_Acknowledgements.tex
%}

%\listfiles%makes it easier to find package versions in the log file. See https://tex.stackexchange.com/questions/13304/which-package-version-am-i-using

\begin{document}
	\frontmatter
	\input{Diss_titlepages.tex}%fulfills formal requirements from the university/department
	\input{Diss_Abstract.tex}
	\renewcommand{\contentsname}{Table of Contents}%rename the table of contents (default name 'Contents')
	\setuptoc{toc}{totoc}%adds the table of contents to the table of contents and to the selectable sections in a pdf viewer.
	
	%reduce upper margin for table of contents, because otherwise it currently happens to create a new page for the single last entry
	%https://tex.stackexchange.com/questions/62125/how-to-remove-top-margin-above-tableofcontents
	\begingroup
	\makeatletter
	% Redefine the \chapter* header macro [on which table of contents is based in most cases] to remove vertical space
	\def\@makeschapterhead#1{%
		%\vspace*{50\p@}% Remove the vertical space
		{\parindent \z@ \raggedright
			\normalfont
			\interlinepenalty\@M
			\Huge \bfseries  #1\par\nobreak
			\vskip 40\p@
	}}
	\makeatother
	\tableofcontents
	\endgroup%reinstate normal chapter heading spacing
	\mainmatter
	%
	%Split dissertation in separate parts for a better overview, possibly also to keep compiling times reasonable if you get \includeonly to work. Assemble the separate .tex files with the commands \input{samplechapter.tex} (same as copy-pasting the contents) and/or \include{samplechapter.tex} (creates a pagebreak before including the file) %you can put \includeonly{mychapter, mychapter2} in the preamble to only compile a selected subset of all chapters. It does supposedly not mess up the references (e.g., table of contents, bibliography, and glossary) while keeping compiling times short.
	
	\input{Diss_Introduction.tex}
	\input{Diss_Theory.tex}
	\input{Diss_ExperimentalDetails.tex}
%	\input{Diss_ResultsDiscussion.tex}
	\input{Diss_Conclusion.tex}
	\appendix%signals some commonly reasonable changes, e.g. a change in chapter numbering from arabic to alphabetic
	\input{Diss_Appendix.tex}%information which is nice to have, but not essential to follow the arguments in the main text
	
	\backmatter%disables chapter numbering
	
	\clearpage
	\input{Diss_Acknowledgements}%say thank you
	
	\printglossary[type=acronym,title=Abbreviations,toctitle=Abbreviations]
	%\printglossaries \todo[color=red]{ensure that ignored glossary does not show up in appendix and TOC}

	%currently decided against lists of figures and tables. commands appear to work properly though, feel free to un-comment.
	%\listoffigures
	%\listoftables

	\clearpage%https://tex.stackexchange.com/questions/8458/making-the-bibliography-appear-in-the-table-of-contents
	\phantomsection%https://tex.stackexchange.com/questions/60556/link-to-bibliography-in-the-toc-fails
	\addcontentsline{toc}{chapter}{\bibname}%{Bibliography}%needs manual adjustment of Bibliography title and TOC entry
%	\begingroup%disable the clearpage command, to avoid a pagebreak between bibliography title and entries when switching to twocolumn layout
%	\renewcommand{\cleardoublepage}{}%only necessary if the openright option is used. Otherwise only acting on \clearpage is sufficient, but keeping \cleardoublepage does no harm.
%	\renewcommand{\clearpage}{}
	\printbibliography%[title=References]%\printbibliography[heading=none]
%	\endgroup
	
	\input{Diss_AcademicCV.tex}%formal requirement from the university/department to have this
\end{document}