\chapter{Styleguide and \LaTeX manual}
The original template was written with \LaTeX. 
At first, it seems difficult and complex, but it makes writing large documents very easy.
You can also write your thesis with Word or similar open access programs, but you have to insert many things manually. 
Therefore, we provide this template with detailed explanations on how to use \LaTeX ~and insert many examples you can directly use with slight modifications.
It is still advisable to get familiar with the basics of \LaTeX.
Fast help and many easy tutorials can be found on the world wide web.

In the following sections, we will apply many methods that \LaTeX offers for you to see in the output \texttt{00Thesis.pdf} file to directly compare with the commands used in the \texttt{\%.tex} files.
If any problems occur, there is numerous literature in the library.
Due to fast changes and current development of usepackages it is recommended to ask the internet.

{\color{Word} For Word users: The following sections are also an useful example, how to nicely organise your document. 
	Sadly, you will have to do most of the formatting manually and as many of you might already experienced, that can be a very laborious business, if you try to apply some fast changes. 
	Please use a serif font with 12\,pt font size like Times New Roman.
	The spacing should be set to one and a half for easy reading.}

\section{Installation}
First you need to install a TeX distribution on your system. 
You can install either MikTeX (\url{https://miktex.org/download}) or TeX~live (\url{https://tug.org/texlive/acquire-netinstall.html}).
MikTeX has the advantage, that instead of installing the whole available package of TeX programs as TeX~live does, it installs a basic setting and updates needed programs on the fly.
However, you need a working internet connection when using new usepackages.

In the second step, you install a TeX editor.
There are many editors available like TeXmaker, TeXStudio, TeXworks, TeXlipse \dots
Choose one and install. 
For an easy start, TeXStudio, which automatically recognises your MikTeX installation, or TeXmaker are recommended.

\section{Start writing}
\LaTeX ~offers many advantages like automatic numbering, positioning of tables and figures, easily referencing chapters, sections, tables and figures and automated citation.
First of all, it is hardly possible to make any spacing typos. 
It does not matter, how many   spaces you have between your words, \LaTeX takes only you text input.
Furthermore, you can easily reread your written words, because you can put each sentence in a new line, which means if you insert your corrections, you can easily find the sentences by their first words.

New paragraphs are formed by skipping one line and the first sentence is automatically intended.
How it looks like in the source file? Like this:
\begin{verbatim}
First of all, it is hardly possible to make any spacing typos. 
It does not matter, how many   spaces you have between your words, \LaTeX takes only you text input.
Furthermore, you can easily reread your written words, because you can put each sentence in a new line, which means if you insert your corrections, you can easily find the sentences by their first words.

New paragraphs are formed by skipping one line and the first sentence is automatically intended.
How it looks like in the source file? Like this!
\end{verbatim}

\LaTeX sets the spacing in justifications automatically as Word does, but it also executes the hyphenation on its own.
However, this automation has some disadvantages. 
For example it will insert the larger spacing after a \enquote{.} also after dots for other purposes like abbreviations.
Here you have to insert the forced spacing ``\verb|~|'' like in Prof.~Dr.~X or f.~e.
This forced spacing can also be used to avoid line break in those wordgroups, that have to be printed in one block like nameprefixes or referenced objects like Figure~Y.

To avoid line breaks in units, use either ``\verb|\,|'' or utilise the \texttt{siunitx} package to set a smaller protected spacing between the value and the unit: 10\,g or \SI{10}{\gram}.
This package has more to offer, if you are having more complex units like the  gravitational force \SI{9.81}{\metre\per\square\second}.
To find out, what this package offers and which units are provided, you should read its package documentation (this goes for other \LaTeX packages, too).
You can also define your own units to add missing ones like Darcy with \verb|\DeclareSIUnit\Darcy{D}| in the preamble.

\LaTeX offers many formatting tools like \textbf{bold}, \textit{italic}, \underline{underline}, \emph{emphasing}, various {\color{violet} colours} (A list of \LaTeX colours can be found by a simple internet research).
Here we already defined some additional colours with \verb|\definecolor{text}{model}{color-spec}| like the TUC {\color{TUCgreen} green}, {\color{TUCred} red}, {\color{TUCdarkgrey} dark grey}, {\color{TUClightgrey}light grey} or the {\color{Word} Word blue}.
Also you can write text in \textsuperscript{superscript} or \textsubscript{subscript}.
With some easy commands you can also vary the {\Huge T}{\huge e}{\LARGE x}{\Large t}{\large s}{\normalsize i}{\small z}{\footnotesize e} {\scriptsize if} {\tiny needed} in special occasions.
The standard font size should remain \verb|\normalsize| with 12\,pt.

\section{Structuring your thesis}
In bachelor and master theses it is not recommended to have more than three structure layers (you are not writing a book!).
If you need more layers in one chapter, you should rethink your structure.
Obviously, one of your sections is significant enough to get its own chapter.

The document class in \LaTeX is \verb|scrreprt|, which offers chapters as the highest structuring element, then sections, subsections, subsubsections and paragraphs.
However, you should not go lower than subsubsections, which are already excluded from the table of content, do not have a numbering (in this template, usually everything is numbered until paragraph) and are might used to give a large subsection a tidier order.

Each chapter starts with a new page and in case of \LaTeX users with a new \verb|.tex| file.
This chapter page does not have a heading, all following pages have the heading with the number and title of the current chapter ({\color{Word}sorry, no idea how to do that in word manually or if it is even possible}).
In \LaTeX you can write as many single files as you want and simply insert them with either \verb|\include{}| (for whole chapters, because it starts a new page) or \verb|\input{}|, which inserts the written text without interruption (if you want to insert larger texts or very big tables separately).
This is another advantage of \LaTeX: you can write your thesis in small bits and put them together instead having one endless document which makes you scroll through forever. 

You should always refer to you tables and figures in your texts and number them according to their appearance.
It is recommended, to use the number of the chapter and then start counting figures and tables separately for each chapter.
This comes in handy, if you have many tables and figures included in you thesis, for smaller reports it is not necessary.
In \LaTeX, the numbering is done automatically and you can refer to figures and tables (as well as equations, chapters, sections,\dots ) by giving them a label \verb|\label{key}| and use this as a reference with \verb|\ref{label}|.
In subsection~\ref{subsec:Ready} we already used this to refer to section~\ref{sec:Submission}.
You should use reasonable label keys with prefixes for what you label. 
This makes the search for your labels much easier, because many \LaTeX editors like TeXstudio are suggesting already used keys while writing so you only have to chose from the list by clicking on one suggestion.
In this template, we used \verb|\label{tab:}| for tables, \verb|\label{fig:}| for figures, \verb|\label{ch:}| for chapters, \verb|\label{sec:}| for sections and \verb|\label{subsec:}| for subsections.
If you have any other questions, have a look at Table~\ref{tab:Help}.

\section{Tables}
For a tidy table layout, avoid vertical and double lines.
Vertical lines often interrupt reading a row and lead easily to skip lines or columns when searching for data. 
Writing table in \LaTeX is often a laborious business an one of its disadvantages, but the results are simple and well-arranged as you can see in Table~\ref{tab:Data}. 
The font is slightly reduced with \verb|\footnotesize| or {\color{Word} 10\,pt for Word users}.
The captions of figures and tables are 10\,pt, too.
{\color{TUCred}How tables and other float objects like figures are positioned in \LaTeX, is explained in section~\ref{sec:Figures}!}
\begin{table}[htbp] 
	\renewcommand{\arraystretch}{1.25} %Changing line height, because space to upper line is to small
	\taburulecolor{gray}
	\vspace{.5em}
	\caption{Laboratory data}
	\label{tab:Data}
	\centering
	\footnotesize
	\begin{tabular}{l@{\hspace{3em}}ccc}
		\toprule
		Chemical	&	$T$ [°C]	&	$p$ [bar]  & $k$ [mD]]\\
		\hline									
		\ce{H2O}		&	70	&	1.5	&	256	\\
		\ce{NH3}		&	60	&	3.0	&	512	\\
		Brine          	&	80	&	1.6	&	1024	\\
		2-Propanol	    &	50	&	1.8	&	2048	\\
		\bottomrule
	\end{tabular}			
\end{table}

After \verb| \begin{tabular}| you define the alignment of your columns in the bracket \verb|{}|. 
\texttt{c} for center, \texttt{l} for left, \texttt{r} for right and \texttt{p{width}} for a column of fixed width, but without alignment. 
In this document we defined three extra alignments: \texttt{C{}}, \texttt{L{}} and \texttt{R{}} that align like before, but you can fix the width of the colums. 
You use this, if you have long texts in your tables as we had in Table~\ref{tab:req_CPs}. 
Fixing the length causes automatical line breaks. Otherwise the table will just expand to the length of the text. 
You can use cm, em, pt or ex as a unit for lenghts or fractions of pageparameters like \verb|0.5\textwidth| or \verb|0.1\textheight|. 
With \verb|@{\hspace{width}| between the column alignment paramters you can insert a space for optical optimisation, f.e.~if the automated space appears to be to narrow.

If you have very long tables with relevant lab data, \LaTeX offers the \texttt{longtable} environment, that generates tables over more than one page and gives automated subcaptions.
With \texttt{threeparttable} you can even use footnotes limited only to your table as used in the very helpful Table~\ref{tab:Help}.
\begin{table}[htbp]
	\renewcommand{\arraystretch}{1.25} %Changing line height, because space to upper line is to small
	\taburulecolor{gray}
	\vspace{.5em}
	\caption{Helpful table}
	\label{tab:Help}
	\centering
	\footnotesize
	\begin{threeparttable}[b]
		\begin{tabular}{lccL{5cm}}
			\toprule
			Number  & Value & Data & Description \\
			\midrule
			1 & Answer & 42 & Asked the question\tnote{1}\\
			2 & None & --\tnote{2} & Help!\\
			\bottomrule
		\end{tabular}
		\begin{tablenotes}
			\item [1] What was the question?
			\item [2] No data available. Sorry\dots
		\end{tablenotes}
	\end{threeparttable}
\end{table}

To make things a little bit easier, you can utilise online tools. 
They come in very handy if you have multirows or multicolumns.
\url{https://www.tablesgenerator.com/latex_tables#}

\section{Figures}\label{sec:Figures}
{\color{Word}A for tables, figures are captioned with 10\,pt font size, if the default font size is 12\,pt.
Captions are positioned \underline{below} figures, caption of tables above them.}
In \LaTeX figures are inserted into a document with the command \verb|\includegraphics[keyvals]{imagefile}|.
By changing the parameter in the angular brackets, you can choose the height/width of your figure.
In the following brackets you give either the name of your file, if it is located in the same folder as your \texttt{.tex} or you need to add the filepath as we do it here, because or images are located in the folder labelled \enquote{Pictures}.

Here we use \verb|\includegraphics| in an environment, as we did with the tables (see Figure~\ref{fig:Progress}).
\begin{figure}[!h]
	\centering
	\includegraphics[width=0.75\textwidth]{Pictures/Progastination}
	\captionof{figure}[Progress of thesis writing]{Progress of thesis writing (\textit{Time and word range to be adjusted to the scope of your work})} % in the squared brackets you can type a shorter title to be displayed in the table of figures. Use this, if you have some additional notes or comments in your caption or a citation. If not needed, simply remove them.
	\label{fig:Progress}
\end{figure} 
This makes them float to the position \LaTeX thinks is the best and results in a nice and clean layout.
This is what \verb|[htbp]|, which stands for here, top, bottom and next page, does:
Tries to position the object in this order at the best place.
If you do not agree, you can use only one of the placements or force it to the position were you wrote it in the  \texttt{.tex} file with \texttt{!h}.

\section{Math environment}
%Here give my nice description tool, too?
You can write mathematical equations with the formula editor in Word.
In \LaTeX you use \verb|$...$| ti write variables or short equations in a text like temperature $T$, the differential pressure $\Delta p$ and more.
For larger equations \LaTeX offers the \verb|quation| environment.
For a good and short explanation, how to use the math environment and how to display multiple equations you can go to \url{https://www1.cmc.edu/pages/faculty/aaksoy/latex/latexthree.html}.

Here some examples from the link:
\begin{equation}
\int_\alpha^\beta f'(x) \, dx=f(\beta)-f(\alpha).
\end{equation}
We can use the fundamental theorem of calculus to say that
$\int_2^3 x^2 \, dx=\frac{3^3}{3}-\frac{2^3}{3}=\frac{19}{3}$.  
Also note that $\displaystyle \int_2^3 x^2 \, dx=\frac{3^3}{3}-\frac{2^3}{3}=\frac{19}{3}$. 
We can also give this equation its own line.
\[
\int_2^3 x^2 \, dx=\frac{3^3}{3}-\frac{2^3}{3}=\frac{19}{3}.
\]

\section{Enumerations}
Enumerations should be avoided in a thesis.
You should express your thoughts and ideas in a written text.
Bullet points are for presentations.
In some cases it is feasibly reasonable to use a list, here some examples, how do do them in \LaTeX.
{\color{Word} Word users simple press the right button in the menu header, type and press enter for the next bullet point.}

\begin{itemize}
	\item Maybe
	\item I
	\begin{itemize} % For the next sublayer you insert an new itemize environment into the first
		\item should
		\item write
		 \begin{itemize} % For the next sublayer you insert an new itemize environment into the first
		 	\item this
		 	\item in
		 \end{itemize}
	\end{itemize}
    \item one
    \item sentence.
\end{itemize}

\begin{enumerate}
	\item Pour the acid into the water.
	\item Stir for 40 minutes at \SI{60}{\degreeCelsius}
\end{enumerate}


\section{Glossaries}
First you need to define your glossary entries in the associated \texttt{GlossarX.tex} files.

 \subsection{Units/Symbols}
 To make units and symbols appear in the glossary, you need to reference them in the text with the \verb|\gls{label}| command like: The length is 10\,\gls{unit_cm}.
  Or you write: The permeability \gls{symb_k-perm} is 30\,mD and use \verb|\glsadd{label}| to add the unit to the glossary.\glsadd{unit_mD}
  
  \subsection{Acronyms}
  The acronym is displayed full the first time it is referenced.
  For example \gls{CP} is written in its short form, because we already used it in subsection~\ref{subsec:Prerequisites}.
  However, \gls{IOR} is referenced for the first time and any further mention of \gls{IOR} will lead to the display of its short form. The commands and their correct use are listed below:
  \begin{description}
  	\item[\texttt{\textbackslash gls\{label\}}] This command prints the term associated with <label>.
  	\item[\texttt{\textbackslash Gls\{label\}}] This command prints the singular form of the term with the first character converted to upper case.
  	\item[\texttt{\textbackslash glspl\{label\}}] This command prints the plural of the defined term if defined or simply add an \enquote{s}.
  	\item[\texttt{\textbackslash Glspl\{label\}}] Same as before with upper case.
  	\item[\texttt{\textbackslash glsadd\{label\}}] Adds the glossary entry without reference in the text.
  	\item[\texttt{\textbackslash acrfull\{label\}}] Gives the full acronym with abbreviation.
  	\item[\texttt{\textbackslash acrlong\{label\}}] Prints the long version of an acronym without the abbreviation.
  	\item[\texttt{\textbackslash acrshort\{label\}}] Prints only the abbreviation.
  	\item[...]
  \end{description}
  More informations can be found at \url{https://en.wikibooks.org/wiki/LaTeX/Glossary}.
 
\section{References}
Please keep your citations style consistent. 
There are many citation styles available.
For example, SPE prints first the author names directly followed by the year whilst many scientific journals print the publishing year at the close.
Therefore you should never simply copy the citations you find in your sources, but write your references in your own consistent and reasonable way.
Do not change it mid-work and also consider some guidelines by cited papers.
Some journals have to be cited in a specific way and some, like the \textit{Angewandte Chemie} are publishing in two languages, english and german. 
Here you have to cite the international version alongside the german one or, if only refering to the english version, clearly state it is the international version\cite{M00_Zuilhof_angew}.
A good guidance can be the SPE style guide you can find at \url{https://www.spe.org/authors/docs/SPE_Style_Guide_2019.pdf} and especially for references: \url{https://petrowiki.org/Help:Citing_references}.
The correct abbreviations in references are listed here: \url{https://libguides.murdoch.edu.au/APA/abbreviation}

For references in \LaTeX it is recommended to use BibTeX (\url{https://de.overleaf.com/learn/latex/Bibliography_management_with_bibtex}) and the \texttt{natbib} usepackage (\url{https://www.overleaf.com/learn/latex/Bibliography_management_with_natbib}).
You can collect your references in the \texttt{Literature.bib} file and cite them with \verb|\cite{label}|.
However, you are limited to the citation styles offered by \LaTeX.

With the extension bibulous, you can generate customised bibliography entries. 
Here, we wrote our own style based on the citation style used by most scientific papers and you can add your own templates in the \texttt{TUen.bst} file.
You can also use the \texttt{SPE.bst}, which has the SPE style included and automatically shortens the list of authors to a maximum of three and adds  \enquote{et.~al.} if more authors or editors are present.
How to install and use the bibulous add on is explained in the beginning of the main \LaTeX ~file \texttt{00Thesis.tex}.

Below we listed the entry typed that are defined in the \texttt{SPE.bst} style file:
\begin{itemize}
	\item SPE references
	\begin{description}
	\item[\texttt{petrowiki}\cite{Reference}]
	\item[\texttt{proceedingsSPE}\cite{NanoparticleEOR}]
	\item[\texttt{articleSPE}\cite{FlowSim_GeoModel}]
	\item[\texttt{bookspe}\cite{MultilateralWells}]
    \end{description}
	\item Non-SPE references
    \begin{description}
	\item[\texttt{article}\cite{0014a}]
	\item[\texttt{book}\cite{Sheng-EOR}]
	\item[\texttt{inbook}\cite{Particulate_Flotation}]
	\item[\texttt{inproceedings}\cite{DGMK}]
	\item[\texttt{wikipedia}\cite{Latex}]
    \end{description}
\end{itemize}
The result can be viewed at the end of this template in the \enquote{References}.
Below we listed the entry typed that are defined in the \texttt{TUen.bst} style file:
\begin{description}
	\item[\texttt{book}\cite{Sheng-EOR}] Books
	\item[\texttt{inbook}\cite{Particulate Flotation}] Chapter/section in a book
	\item[\texttt{article}\cite{0014a}] Journal article
	\item[\texttt{angewandte}\cite{M00_Zuilhof_angew}] Bilingual journal article of \textit{Angewandte Chemie}
\end{description}
The result is shown in Figure~\ref{fig:References}
\begin{figure}[htbp]
	\centering
	\includegraphics[width=\textwidth]{Pictures/TUbst}
	\captionof{figure}{References generated with the \texttt{TUen.bst} style file}
	\label{fig:References}
\end{figure} 
