\part{Parts Only Serve Demonstration Purposes Here}
\begingroup
%save space by avoiding a pagebreak between a new part and its first chapter
\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}{}
\chapter{Spacing}
\endgroup%reinstate normal function of the clearpage commands
%
\section{Special Spacing for The First Chapter in a Given Part}\label{sec:part-nopagebreak-chapter}
%
Here is how to save space by avoiding a pagebreak between a new part and its first chapter:
\begin{lstlisting}
\begingroup
%save space by avoiding a pagebreak between a new part and its first chapter
\renewcommand{\cleardoublepage}{}%only necessary if the openright option is used in the documentclass options. Otherwise only acting on \clearpage is sufficient, but renewing also \cleardoublepage does no harm.
\renewcommand{\clearpage}{}
\chapter{Spacing}
\endgroup%reinstate normal function of the clearpage commands
\end{lstlisting}
%
\section{Margins}
%
I tried to get the current margin sizes for even and odd pages, so I can set new custom margin sizes to adjust for the binding. The macro you find below prints a short text which describes left and right margins and whether the code thinks that it is currently on an odd or even page (relevant to grant more space to the binding). You can then jump to the next page (which is then the other of odd or even) and let it give you the margin sizes there. This did not work fully for me (odd / even page recognition failed), but at least it worked for either an even or an odd page, which was good enough for me.\\
%
\begin{lstlisting}
%get margins
%https://tex.stackexchange.com/questions/537078/how-to-access-geometry-length
\usepackage{ifoddpage}% subsequent commands need the siunitx package. If you use the code from the steckexchange link, be sure not to keep the siunitx package options given there for your final version, otherwise all values of the \SI command will be given with the specified (two-decimal) precision, which sucks if you cannot make such a precise statement or only wanted to get a consistently formatted order of magnitude. Made this mistake and got over-precise polymer content (\SI{4}{\wtpercent} yielded "4.00 wt%" instead of "4 wt%") or completely wrong output (\SI{e7}{\hertz} yielded ".0010^7 Hz" instead of "10^7 Hz").
\makeatletter
% Macro for nicely printing a length in centimeters. You don't need it to *use* the lengths.
\newcommand*{\convertToCm}[1]{%
	\begingroup
	\edef\tmp{\strip@pt\dimexpr(#1)/7227*254\relax}%
	\SI{\tmp}{\centi\meter}%
	\endgroup
}
\makeatother
\newlength{\myLeftMargin}
\newlength{\myRightMargin}
\newcommand*{\myComputeMargins}{% To be called just after \checkoddpage
	\setlength{\myLeftMargin}{%
		\dimexpr 1in + \ifoddpage\oddsidemargin\else\evensidemargin\fi \relax}%
	\setlength{\myRightMargin}{%
		\dimexpr \paperwidth - \textwidth - \myLeftMargin \relax}%
}
\newcommand*{\myMarginCheck}{%this command did not differentiate between even and odd page for me, but was nonetheless useful to figure out how large the margin is
	\checkoddpage\myComputeMargins
	This is an \ifoddpage odd\else even\fi\ page. The left margin is thus an
	\ifoddpage inner\else outer\fi\ one and its width is
	\the\myLeftMargin, that is \convertToCm{\myLeftMargin}. The right margin is
	\the\myRightMargin, that is \convertToCm{\myRightMargin}.\par
}
\end{lstlisting}
%
\begin{lstlisting}
Example usage:\\
\myMarginCheck
\newpage
\myMarginCheck
\end{lstlisting}
Example usage:\\
\myMarginCheck
\newpage
\myMarginCheck
%
\chapter{References with \textbackslash cref}\label{sec:cleveref}
%
\section{Simple Uses of \textbackslash cref}\label{sec:cleveref_simple}
%
I assume you are familiar with the basic \mbox{\textbackslash label} and \mbox{\textbackslash ref} functionality of \LaTeX. Let me just add that there is the \mbox{\textbackslash cref} command from the cleveref package, which automatically detects the environment (e.g. chapter, subsection, equation) it is used in. This comes in handy if you want to convert, say, a section into a chapter. If you simply always used \mbox{\textbackslash cref}, you don't need to find all instances like ``As mentioned in sec. \textbackslash ref\{test\}'' and adjust them to ``As mentioned in chap. \textbackslash ref\{test\}''.
%
\section{Highlighting References}\label{sec:highlighting_links}
%
You can highlight references as document-internal links one can click on to jump to the corresponding page of the document. Commonly, the hyperref package is used for that, whereby I found customizing the following package options useful:
\begin{lstlisting}
\usepackage{hyperref}%package options are handled with the hypersetup command
\hypersetup{
	colorlinks   = true, %Colours links instead of ugly boxes. hidelinks option removes boxes but then does not highlight links at all
	%	hidelinks, %un-comment to suppress link colors for the print version. Note that this does not have the "option=true/false" syntax.
	urlcolor     = blue, %Colour for external hyperlinks
	linkcolor    = blue, %Colour of internal links
	citecolor    = red, %Colour of citations
	plainpages   = false,%so that hyperref treats page ii and page 2 as separate pages, https://tex.stackexchange.com/questions/93889/why-does-backref-refer-to-wrong-page
	pdfpagelabels,%glossary pagenumbers get offset by 1 per \part, at least when I also mess with clearpage commands. trying solution of https://tex.stackexchange.com/questions/21698/how-to-get-correct-glossary-links-with-frontmatter-pages
}
\end{lstlisting}
Highlighting links is nice for the electronic version, but does not make sense for the printed dissertation. To disable link-colours, you can conveniently use the ``hidelinks'' option. Note that hidelinks is not set to e.g. ``true'' or ``false'', you just write ``hidelinks'' and move on to the next package option.\\
%
The cleveref package should be loaded after any package without specific support for cleveref. It is safest to load it at the very end of the preamble. You may or may not want to use the [nameinlink] option to include/exclude reference types (equation, section etc.) in hyperlink. nameinlink appears to be too recent for the current installation on my office computer (as of 2024-12-17).
\begin{lstlisting}
Example usage:\\
%
Reference a section, cf. \cref{sec:cleveref_simple}. Here is a reference to two figures at once: \cref{fig:binodal-spinodal-phase-diagram,fig:energylevelszeeman-qp1}.\\
%
Here is a reference of two different things (a section and a table) at once: \cref{sec:polym_concentration_dependences,tab:list-of-samples}. And a reference to three subsequent sections \cref{sec:first_cycle,sec:ageing_days,sec:ageing_hours}.
\end{lstlisting}
Example usage:\\
%
Reference a section, cf. \cref{sec:cleveref_simple}. Here is a reference to two figures at once: \cref{fig:binodal-spinodal-phase-diagram,fig:energylevelszeeman-qp1}.\\
%
Here is a reference of two different things (a section and a table) at once: \cref{sec:cleveref,tab:list-of-samples}. And a reference to three subsequent sections \cref{sec:cleveref_simple,sec:highlighting_links,sec:cleveref_advanced}.
%
\section{Advanced Uses of \textbackslash cref}\label{sec:cleveref_advanced}
%
This part stems from a niche use case I was too stubborn to let go of: I wanted to be able to reference a set of subequations (say, equations 1a) and 1b)), whereby the (abbreviated) word for the reference type would signal a plural ``eqs.'' although only the common equation number is displayed, i.e. ``eqs. 1)''. With the default configuration, I could only manage things like ``eqs. 1a) and 1b)''. On the road I also picked up how to change the referencing labels in general, so maybe this helps you:
\begin{lstlisting}
%customize abbreviations of e.g. section and chapter references. You probably don't want to repeat this with the capitalizing version, \Crefname, as abbreviations at the beginning of a sentence apparently are considered bad style.
%crefname command structure: \crefname{type}{singular}{plural}
\crefname{equation}{eq.}{eqs.}
\crefname{section}{sec.}{secs.}
\crefname{chapter}{chap.}{chaps.}
%
%How to make a plural-reference to a set of subequations with a single label.
%Originally I tried the solution from this link: https://tex.stackexchange.com/questions/35772/referencing-subequations-with-cleveref
%unfortunately, Multi-references also require all the other cross-reference formats to be defined, so I redefined those as well. A brief explanation of the command structures:
%crefformat arguments: #1=formatted label counter, #2=start of hyperlink, #3=end of hyperlink
%crefmultiformat arguments: \crefmultiformat{type}{format for the first cross-reference in a list of multiple cross-references}{format for the second cross-reference in a list of two cross-references}{format for any middle (not first or last) cross-reference in a list of more than two cross-references}{format for the last cross-reference in a list of more than two cross-references}
\crefformat{equation}{eq.~(#2#1#3)}
\Crefformat{equation}{Eq.~(#2#1#3)}%
\crefmultiformat{equation}{eqs.~(#2#1#3)}{ and~(#2#1#3)}{, (#2#1#3)}{ and~(#2#1#3)}
\crefformat{section}{sec.~#2#1#3}%crefformat overwrites at least the singular from crefname
\Crefformat{section}{Section~#2#1#3}%explicitly define \Crefformat, instead of using the default (\MakeUppercase together with \crefformat) because abbreviations at the beginning of a sentence are bad style.
%\crefrangeformat{section}{secs.~(#3#1#4) and~(#5#2#6)}
\crefmultiformat{section}{secs.~#2#1#3}{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}
%Note that there is also \crefrangemultiformat, which I however did not need to specify
\crefformat{chapter}{chap.~#2#1#3}
\Crefformat{chapter}{Chapter~#2#1#3}
\crefmultiformat{chapter}{chaps.~#2#1#3}{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}
\crefformat{figure}{fig.~#2#1#3}%crefformat overwrites at least the singular from crefname
\Crefformat{figure}{Figure~#2#1#3}%explicitly define \Crefformat, instead of using the default (\MakeUppercase together with \crefformat) because abbreviations at the beginning of a sentence are bad style.
%\crefrangeformat{figure}{figs.~(#3#1#4) and~(#5#2#6)}
\crefmultiformat{figure}{figs.~#2#1#3}{ and~#2#1#3}{, #2#1#3}{ and~#2#1#3}
\end{lstlisting}
%
\chapter{Citations}\label{sec:citations}
%
I used biblatex and found customizing the following package options and additions useful:
\begin{lstlisting}
\usepackage[
style=alphabetic,% with this style citations in the text are based on author names. Other people may prefer the style ``numeric''
maxnames=2,%sets maximum number of names in citations for both intext (maxcitenames) as well as bibliography. If there are more authors, your settings for abbreviating lists of authors in citations, i.e. ``minnames'' kick in
maxalphanames=2,%not sure what max|minalphanames do differently from max|mincitenames, but if I use them it looks like I want it to.
minalphanames=1,
minnames=1,%if number of names in citation is larger than maxnames, cut after minnames-many names and add '+'
maxbibnames=99,%overwrite maximum number of names bevor truncations in bibliography
uniquelist=true,%allows deviations from maxnames to make lists unique
backref,%references the pages where the citation was used
%url=false,%url can be set to false to ignore the url-fields of the .bib file. I did not want to generically throw away urls here, because I want to cite e.g. the grace-website. URLs are handled below.
]{biblatex}

\usepackage{xurl}% load after biblatex. Avoids URLS of references reaching into the margin. see https://tex.stackexchange.com/questions/686510/break-line-in-bibliography-for-doi

%avoid references with (chemicals in) titles reaching into the margins by manually adding discretionary hyphens (\-) in the affected entries of the .bib file. see https://tex.stackexchange.com/questions/381542/article-title-not-linebreaking-correctly-in-bibliography

%failed to have bibliography in two columns, with the title as for a onecolumn page. Contending myself with smaller font to keep required space reasonable. Feel free to try yourself, maybe one of these links help:
%https://tex.stackexchange.com/questions/137100/two-columns-10pt-bibliography-specific-pages-only-in-a-one-column-12pt-text
\appto{\bibfont}{\small}%onecolumn, normal fontsize: 40 pages. small: 32 pages. footnotesize: 28 pages
%\appto{\bibsetup}{\raggedright\twocolumn}
%\AtEndBibliography{\onecolumn}
%https://tex.stackexchange.com/questions/20758/bibliography-in-two-columns-section-title-in-one
%\usepackage{multicol}
%\usepackage{etoolbox}
%\patchcmd{\thebibliography}{\section*{\refname}}
%{\begin{multicols}{2}[\section*{\refname}]}{}{}
	%\patchcmd{\endthebibliography}{\endlist}{\endlist\end{multicols}}{}{}

\AtBeginRefsection{\GenRefcontextData{sorting=ynt}}%ensure that (also) a ynt sorted refcontext is created
\AtEveryCite{\localrefcontext[sorting=ynt]}%use the ynt refcontext for sorting within a citation. Did not trust this and sorted references manually, if there were multiple references in a single citation command

\addbibresource{/autohome/saeckech/Seafile/Sync_Seafile/Literatur_Promotion/Library/Promotion_Literatur.bib}%(path for office computer)

%do not cite fields like 'comment' in the bibliography
\AtEveryBibitem{%
	\clearfield{note}%
	%	\clearfield{url}%handled below
	\clearfield{eprint}%
	\clearfield{isbn}%
	\clearfield{issn}%
	\clearfield{month}%
	\clearfield{abstract}%
	\clearfield{creationdate}%
	\clearfield{pages}%
	\clearfield{file}%
	\clearfield{issue}%
	\clearfield{number}%
	\clearfield{keywords}%
	\clearfield{numpages}%
	\clearfield{printed}%
	\clearfield{ranking}%
	\clearfield{readstatus}%
	\clearfield{edition}%did not enter edition for every book and want to keep output consistent. Also, output formatting for first editions ("First") is for some reason different from other editions ("2nd ed.")
}
% want to show specific URLs only. Solution stolen from: https://tex.stackexchange.com/questions/152869/show-url-only-for-one-reference, 2024-11-04
%create a new category, for which the URL will be printed in the references
\DeclareBibliographyCategory{needsurl}
\newcommand{\entryneedsurl}[1]{\addtocategory{needsurl}{#1}}
\renewbibmacro*{url+urldate}{%
	\ifcategory{needsurl}
	{\printfield{url}%
		\iffieldundef{urlyear}
		{}
		{\setunit*{\addspace}%
			\printurldate}}
	{}}
%manually set bib-entries which should have their URL printed in the references with the new ``entryneedsurl'' command defined above. Example:
\entryneedsurl{PubChem2005NIPAM}
\end{lstlisting}
%
\begin{lstlisting}
Example usage: Basic citation \autocite{Halperin2015}, citation with a page number \autocite[2]{Halperin2015}, multiple basic citations \autocite{Fujishige1989,Halperin2015,Korde2019}, multiple citations with a page number \autocites[1]{Fujishige1989}[1]{Halperin2015}, citations with a mentioned author \textcite{Halperin2015} and multiple citations with mentioned authors each \textcite{Halperin2015,Korde2019}.\\
%
The following citation should keep its URLs in the bibliography \autocite{PubChem2005NIPAM}.
\end{lstlisting}
Example usage: Basic citation \autocite{Halperin2015}, citation with a page number \autocite[2]{Slichter1990}, multiple basic citations \autocite{Fujishige1989,Halperin2015,Korde2019}, multiple citations with a page number \autocites[1]{Fujishige1989}[1]{Halperin2015}, citations with a mentioned author \textcite{Halperin2015} and multiple citations with mentioned authors each \textcite{Halperin2015,Korde2019}.\\
%
The following citation should keep its URLs in the bibliography \autocite{PubChem2005NIPAM}.\\
%
Recall that you may need to compile the bibliography (and potentially the glossary, if you use one) separately from the ``normal'' \LaTeX\space compiling, especially if you want to update the pagenumbers (``backref option'') on which the references were cited. If you use Texstudio as editor, you can compile the bibliography via Tools$\rightarrow$Bibliography (F8 key by default).\\\\
%
%
When talking about the \CPMG pulse sequence, I wanted to make sure that both authors of both publications are explicitly named with the \mbox{\textbackslash textcite} command. The document-wide settings for how many names are to be mentioned may, however, differ. I therefore used a variable ``globalmaxnames'' for the document-wide settings (not included in the example code of \cref{sec:citations}, but you can check the actual source code), then set the number of names to 2 directly before the citations, then set the number of names back to the document default
\begin{lstlisting}
	Example usage: The \CPMG sequence, originally devised by \setmaxcitenames{2}\textcite{Carr1954}\setmaxcitenames{\globalmaxnames} %setmaxcitenames to 2 (even though it is the current (2025-04-10) default) to ensure that both Carr and Purcell are mentioned by name
	and later improved upon by \setmaxcitenames{2}\textcite{Meiboom1958}\setmaxcitenames{\globalmaxnames}%setmaxcitenames to 2 (even though it is the current (2025-04-10) default) to ensure that both Meiboom and Gill are mentioned by name
	, repeatedly refocusses dephasing spins
\end{lstlisting}
Example usage: The \CPMG sequence, originally devised by \setmaxcitenames{2}\textcite{Carr1954}\setmaxcitenames{\globalmaxnames} %setmaxcitenames to 2 (even though it is the current (2025-04-10) default) to ensure that both Carr and Purcell are mentioned by name
and later improved upon by \setmaxcitenames{2}\textcite{Meiboom1958}\setmaxcitenames{\globalmaxnames}%setmaxcitenames to 2 (even though it is the current (2025-04-10) default) to ensure that both Meiboom and Gill are mentioned by name
, repeatedly refocusses dephasing spins.
%
\chapter{Glossary}
%
\glsresetall%
Glossaries are quite some work to get running, but I think they are worth it in the end. I hope this chapter reduces the work you need to put in until it works the ways you want it to. Feel free to simply use my glossary.tex file, but be aware that it contains some customization and editing based on my personal preferences.\\
%
Why should you use a glossary in the first place? Maybe less so for what you classically expect from a glossary (to look up the meanings of words in a list at the end of a book), but rather to make sure that acronyms and symbols are properly introduced. For instance, you want to tell the reader what \gls{pNIPAM} is the first time you mention it, but from there on by default only use the abbreviation \gls{pNIPAM}. But what if you later rearrange your sections? Sure, you can manually search for the text where you originally introduced the abbreviation and edit it, but that is annoying and there is a risk you overlook some such word at some point. If you use the glossary package, it will handle this for you. If required, you can also manually tell \LaTeX\space to use the term as if it had not been used before (example in source code: \fakefirstacr{pNIPAM}). For instance, I wanted to make sure that \fakefirstacr{CPMG} is spelled out when I explain what it is in the experimental details section, even though I might have mentioned it previously. To do so, I used a custom modification of the package-included \mbox{\textbackslash genacrfullformat} command (and similar for grammatical variations):
\begin{lstlisting}
\newcommand{\fakefirstacr}[1]{\ifglsused{#1}{\glsdisp{#1}{\genacrfullformat{#1}}}{\gls{#1}}}%manually set an acronym to be displayed as if it was its first use, in order to have the long forms displayed e.g. in the conclusion to give clarity to readers which only read the conclusion. Dont want to simply reset uses, such that occurrence counts are kept and thus document-wide single-uses do not have a redundant abbreviation introduced
\end{lstlisting}
%
For non-acronyms, there was no need to count how often they occur in total (cf \cref{sec:glossary_occurrence_counts}). To simply reset the glossary's internal tracker for ``did I use this before?'', a glossary-package-included command, \mbox{\textbackslash glsreset}, is available. With it, you can e.g. mention in you abstract which range of \glspl{Larmor frequency} you measured but then have the \glsreset{Larmor frequency}\gls{Larmor frequency} treated as a novel term when you mention it for the first time in your theory section.\\
%
Glossaries can, in principle, also handle symbols with a special symbol-glossary, but I just messed with my existing glossary instead, e.g. for the \gls{Rh}, which I can subsequently use in the text (example: \gls{Rh}) without introducing the symbol again. Note: If you do so, make sure that you use the same symbol, $\Rh$, in actual math environments, e.g. via:
\begin{lstlisting}
\newcommand{\Rh}{\ensuremath{R_\mathrm{h}}}%hydrodynamic radius
\newglossaryentry{Rh}{name=hydrodynamic radius, first=hydrodynamic radius \textnormal{(\Rh)}, prefixfirst={a\ }, prefix={an\ }, plural=hydrodynamic radii, type=unignored, description={}, user1={off}}
\end{lstlisting}
%
You can easily adjust glossary terms for grammar, i.e. plural form and/or capital first letter (for this example I suppress the function that the abbreviation should only be introduced on the first occurrence by resetting any possible prior use of the glossary term ``LCST'' via \mbox{\textbackslash glsreset\{LCST\}}):
\begin{lstlisting}
Example usage: \gls{LCST}\glsreset{LCST}, \Gls{LCST}\glsreset{LCST}, \glspl{LCST}\glsreset{LCST}, \Glspl{LCST}\glsreset{LCST}
\end{lstlisting}
Example usage: \gls{LCST}\glsreset{LCST}, \Gls{LCST}\glsreset{LCST}, \glspl{LCST}\glsreset{LCST}, \Glspl{LCST}\glsreset{LCST}.\\\\
%
%
The default plural form simply appends an ``s'' to the term, but you can set the plural form to something else when you create the glossary entry:
\begin{lstlisting}
\newglossaryentry{spectral density}{name=spectral density, plural=spectral densities, type=ignored, description={}, user1={off}}
Example usage: \glspl{spectral density}\glsreset{spectral density} instead of \gls{spectral density}s
\end{lstlisting}
Example usage: \glspl{spectral density}\glsreset{spectral density} instead of \gls{spectral density}s.\\\\
%
%
Also, the article before the term (``a'' or ``an'') may depend on whether the long or the short form follows, which can also be handled by the glossary. To have this article functionality, you need at least the ``glossaries-prefix'' package, instead of the ``glossaries'' package. I did in fact use the glossaries-prefix package, however, in hindsight, I should have used the ``glossaries-extra'' package, which provides even more useful (professional) functionalities, for which I had to sometimes create messy custom solutions. To use a glossary term with its article, use the \mbox{``\textbackslash pgls''} command or its grammatical variations like \mbox{\textbackslash Pgls}.
\begin{lstlisting}
\newacronym[
prefixfirst={a\ },%prefix used on first use
prefix={an\ }%prefix used on subsequent use
]{LCST}{LCST}{lower critical solution temperature}
Example usage: \glsreset{LCST} first use with article \pgls{LCST} and subsequent use with article \pgls{LCST} and grammatical variation \Pgls{LCST}.
\end{lstlisting}
Example usage: \glsreset{LCST} first use with article \pgls{LCST} and subsequent use with article \pgls{LCST} and grammatical variation \Pgls{LCST}.\\\\
%
%
I created a custom glossary (I called it the ``ignored'' glossary because it does not list the words it contains at the end of the thesis) to get special formatting (here: italic) for uncommon words (which are not acronyms) the first time they occur, for instance when I describe what an \gls{athermal} solvent is. When I speak of an \gls{athermal} solvent the next time, I want normal formatting. Again, you could manually change the font, e.g. to italic (or better: use \mbox{\textbackslash emph} to highlight the word by giving it \emph{italic} typeface in normal cases, \textit{and \emph{roman} typeface if the surrounding text is already italic}), but you run into the same problems as for acronyms when you rearrange your sections.\\
%
Later on, I changed my mind on which words I consider highlight-worthy, but I had already used the glossary-command structure for every occurrence of the word, so I could not simply remove the corresponding glossary entry without heaving to find and replace every occurrence in the code (annoying) -- and what if I later changed my mind again? So I created another, very similar glossary type (I called it the ``unignored'' glossary), which allows me to keep the command structure, but does not apply any special formatting.\\\\
%
%
You can also make \LaTeX\space behave as if it was using the glossary term while displaying something else. This made sense for me as I defined a glossary entry for ``\gls{complexation}''\glsreset{complexation}, but maybe first mention solvent ``\glsdisp{complexation}{complexes}'', which refers to the same idea but is beyond a simple grammar variation. With the ``\textbackslash glsdisp\{complexation\}\{complexes\}'' command, I can let \LaTeX\space know that I refer to the idea of \gls{complexation} without making separate entries for every possible related case.\\\\
%
%
Also, I wanted different formatting (italic long form, roman short form) for acronyms, so I created a custom acronym style which you can see in the glossary.tex file if you are interested.
%
\section{Special Cases Depending on Acronym Occurrence Counts}\label{sec:glossary_occurrence_counts}
%
The basic glossary functions can already handle many cases. Depending on your ambitions, however, it can get complicated: Say you have an acronym, ``\gls{TSUA}'', which you use only once in the entire document, then it neither makes sense to introduce the abbreviation nor to create a link to the list of acronyms at the end of the thesis.\\
%
You can account for such a case by using the flag \mbox{``\textbackslash glsenableentrycount''} (place before \mbox{\textbackslash begin\{document\}}), which counts the occurrences of the corresponding glossary command (may need two compile runs, which you probably do anyways, maybe even without knowing). Then use \mbox{``\textbackslash cgls'' commands instead of \mbox{``\textbackslash gls''}. If you dont feel like typing an extr}a letter in the command, or dont want to replace a bunch of \mbox{\textbackslash gls} commands you already used, you can redefine the \textbackslash gls commands to function like the \textbackslash cgls commands via \mbox{``\textbackslash let\textbackslash gls\textbackslash cgls''} and similarly for the other grammatical versions like the plural \mbox{\textbackslash glspl} command.
%
\subsection{Extra Special Cases Depending on Acronym Occurrence Counts}\label{sec:glossary_occurrence_counts_resets}
%
For even more complexity, counting occurrences gets messed up by glossary resets. I initially wanted to reset all the glossaries after the abstracts (both after the German and the English abstract each) and prior to the conclusion. This way, the acronyms would be re-introduced together with their long forms in the main part and in the conclusion, which readers may find helpful if they skip the abstract and/or only read the conclusion. But what happens when, say, an acronym occurs several times in the main part, but only once in the conclusion? If you aren't careful with the glossary reset, this will be considered as a single occurrence in the conclusion and thus not get an abbreviation or link to the list of acronyms at the end of the thesis. Catching such cases apparently can be done automatically, but seemed to be more effort than I wanted to invest for these fringe cases. Instead, I wrote code which forces a like-first-use style when applied to an acronym and manually applied it to relevant occurrences of acronyms in the conclusion when it was close to the final version.\\
%
To test it, here is more than one mention of \gls{TMUSC}, \gls{TMUSC} in the main text. See also \cref{sec:conclusion}.\\
%
In theory, similar issues arise if an acronym is mentioned exactly once in the abstract(s) and exactly once in the rest of the document (main part and conclusion combined), but I just hoped that this would never be the case.\\\\
%
%
Recall that you may need to compile the glossary (and potentially the bibliography, especially if you use the ``backref'' option) separately from the ``normal'' \LaTeX\space compiling, especially if you want to update the pagenumbers (``backref option'') on which the references were cited or when you care about occurrence counts. If you use Texstudio as editor, you can compile the glossary via Tools$\rightarrow$Glossary (F9 key by default).
%
\chapter{Macros}
%
``Macros'' may sound more complex than it needs to be. Sure, you can make it very elaborate, but you can also get a lot of value without getting too involved. You can think of macros as commands, which tell \LaTeX\space to do some specific thing you previously defined. For a very simple example, this can save you some typing for long words or annoying commands, i.e. I can define a command \mbox{``\textbackslash ctg''} which makes \LaTeX\space spell out ``coil-to-globule transition'' in the pdf wherever I type \mbox{``\textbackslash ctg''} in the code. To do so, I would create the command via:
\newcommand*{\ctg}{coil-to-globule transition}%actually need to define the command now.
\begin{lstlisting}
\newcommand*{\ctg}{coil-to-globule transition}
Example usage: From then on, \mbox{\textbackslash ctg} is available: \ctg
\end{lstlisting}
Example usage: From then on, \mbox{\textbackslash ctg} is available: \ctg.\\\\
%
%
These macros may also contain other \LaTeX\space commands, i.e. just like above I can define a command \mbox{``\textbackslash pNIPAM''} which triggers the corresponding glossary entry:
\begin{lstlisting}
\newcommand{\pNIPAM}{\gls{pNIPAM}\xspace}
\end{lstlisting}
Although with such very simple macros, I can only make use of one of the glossary grammar cases (here the basic \mbox{\textbackslash gls} for singular and non-capitalized first letter)\\
%
It is considered good practice (which I myself did rarely adhere to) to use the ``starred version'' of the \mbox{\textbackslash newcommand} command.\\
%
Be aware that \LaTeX\space usually does not print the whitespace after a command in the code. For instance, using the \mbox{\textbackslash ctg} command mentioned above, I might want to have it followed directly (without a whitespace) by the character ``s'' to make the word a plural. To do so, I would write as code
\begin{lstlisting}
\ctg s
Example usage: \ctg s
\end{lstlisting}
Example usage: \ctg s.\\
%
If I mistakenly wrote as code ``\mbox{\textbackslash ctgs}'', \LaTeX\space would try to find my definition of the command ``\mbox{\textbackslash ctgs}'' which probably does not exist or has a different function.\\
%
Alternatively, I might want to write a separate word next. To do so, I could write as code
\begin{lstlisting}
Example usage: \ctg\space is a series of words
\end{lstlisting}
Example usage: \ctg\space is a series of words.\\
%
This works but it is clunky. People are lazy and invented the xspace package which provides the \mbox{\textbackslash xspace} command, which automatically decides whether a whitespace should be printed. This way I could simply append \mbox{\textbackslash xspace} to most of my custom commands. If you want to get rid of this automatic whitespace for a given use, you can use the \mbox{\textbackslash unskip} command, i.e.
\newcommand*{\ctgnew}{coil-to-globule transition\xspace}%actually need to define the command now.
\begin{lstlisting}
\newcommand*{\ctgnew}{coil-to-globule transition\xspace}
Example usage: \ctgnew say something \ctgnew\unskip s \ctgnew \ctgnew, (mind the non-whitespace between commands and before interpunctation) \ctgnew1
\end{lstlisting}
Example usage: \ctgnew say something \ctgnew\unskip s \ctgnew \ctgnew, (mind the non-whitespace between commands and before interpunctation) \ctgnew1.\\
%
\section{Typesetting}
%
\subsection{Actual Notes on Typesetting}
%
\subsubsection{Indices}
%
Although it is not what this section is meant to be about, you can read up on the use of italic vs roman font in scientific context here: \url{https://iupac.org/wp-content/uploads/2016/01/ICTNS-On-the-use-of-italic-and-roman-fonts-for-symbols-in-scientific-text.pdf}.
%
\subsubsection{Units}
%
Most readers of this template will already know the siunitx package. Therefore I just briefly mention here that custom units can be defined and options to style the expression to your liking exist, e.g.
\begin{lstlisting}
\DeclareSIUnit{\wtpercent}{wt\%}
Example usage: \SI{1}{\wtpercent}, \si{\wtpercent}, $\leq\SI[per-mode=reciprocal-positive-first]{1}{\mole\square\meter\per\second\per\kilogram}$
\end{lstlisting}
Example usage: \SI{1}{\wtpercent}, \si{\wtpercent}, $\leq\SI[per-mode=reciprocal-positive-first]{1}{\mole\square\meter\per\second\per\kilogram}$.\\
%
It seems to be considered better practice to use the \mbox{\textbackslash qty} commands, because the command name ``SI'' is awkward if you use a non-SI unit, see \url{https://tex.stackexchange.com/questions/603217/should-i-use-qty-or-si-for-siunitx}. However, as of this writing, the \mbox{\textbackslash qty} behaves weirdly (maybe it clashes with the physics package?), so I cannot provide examples. Curiously, while \mbox{\textbackslash SIrange} does not work, \mbox{\textbackslash qtyrange} does:
\begin{lstlisting}
Example usage: \qtyrange{1}{2}{\wtpercent}
\end{lstlisting}
Example usage: \qtyrange{1}{2}{\wtpercent}.\\
%
I did not know until now that the \mbox{\textbackslash SIrange} or \mbox{\textbackslash qtyrange} commands exist and they would have come in handy for me while writing the dissertation. You can probably also customize package options of the qtyrange commands to your linking, i.e. e.g. to either use a format like \mbox{``1\,wt\% to 2\,wt\%''} or like \mbox{``1 -- 2\,wt\%''}.
%
\subsubsection{Dashes and Space Between ``e.g.''}
%
A few somewhat out-of-context remarks which I didn't yet find a better place to mention:\\
%
You may also want to be aware of the difference of a single minus - in the latex text environment vs double minus -- which looks slightly different.\\
%
Thin spaces in the German ``z.\,B.'' apparently aren't a thing in English. Depending on your language and setup, you may want to add
\begin{lstlisting}
\frenchspacing%avoid double whitespace after ``.'', usefull in abbreviations e.g. ``e.g.''
\end{lstlisting}
to your preamble.
%
\subsubsection{Odds and Ends}\label{sec:linebreak_packages}
%
\begin{lstlisting}
	%avoid single empty lines (called widows and orphans) on paragraph- or pagestart and -end
	\clubpenalty=10000% penalizes orphans
	\widowpenalty=10000% penalizes widows
	\displaywidowpenalty=10000% penalizes widows that are immediately followed by a formula \[ ... \]
	\usepackage{microtype}%supposedly more visually appealing borders of the textblocks%needs scalable fonts, therefore may not work on all machines. However, it deals well with (avoiding) line breaks and respecting the margins e.g. for macros
	\usepackage[parfill]{parskip}%controls indentation after linebreak and todonotes. https://tex.stackexchange.com/questions/74170/have-new-line-between-paragraphs-no-indentation
\end{lstlisting}
%
\subsubsection{Textsuperscript \textsuperscript{2}H vs Math Mode $^2$H}
%
In section titles, you probably want to use \textbackslash textsuperscript\{2\}H to type $^2$H in order to keep the section-header font. Similar for subscripts.
%
\subsection{Macros for Typesetting}
%
More towards the purpose of this template, in this section I wanted to suggest you think about the use of macros to keep your options open about typesetting and naming. Of course, this cannot reasonably be done for every word you ever type, but makes sense in some cases: For instance, if you are not yet sure which symbol to use for the \glsunset{Larmor frequency}\gls{Larmor frequency} (maybe $\omega_L$, $\omega_\mathrm{L}$ or $\omega_0$) and whether or not the possible ``L'' in the index should be italic or roman (maybe you know this one, but what about italic vs roman regarding the axis of a spin $\hat{I}_\AxisTypeface{z}$ or rank and order of a spherical harmonic $Y_l^m$?), you could use
\begin{lstlisting}
\newcommand{\wL}{\ensuremath{\omega_\mathrm{L}}}
\end{lstlisting}
and, if you or a higher power have a change of mind, you can later change what the command does to 
\begin{lstlisting}
\newcommand{\wL}{\ensuremath{\omega_0}}
\end{lstlisting}
%
As another example, you could use
\begin{lstlisting}
\newcommand{\qpAsym}{\ensuremath{\eta}}
\end{lstlisting}
for the asymmetry parameter of quadrupolar coupling. If you later find that you also want to speak of viscosity or other coupling asymmetry parameters (maybe chemical shift), which conventionally go with the the same symbol, $\eta$, you can simply change what the command \mbox{\textbackslash qpAsym} does to e.g.
\begin{lstlisting}
\newcommand{\qpAsym}{\ensuremath{\eta_$\mathrm{Q}$}}
\end{lstlisting}
%
Third example: there are packages (mchem or chemformula) to write chemistry-stuff with \LaTeX. For the little chemistry we usually need to write in the physics department, a simple macro will do
\begin{lstlisting}
\newcommand*\chem[1]{\ensuremath{\mathrm{#1}}}%math mode to allow subscripts as in $H_2O$. Could also have used \textsubscript instead. Use a macro to penaltize hyphenation and easily unify (and possibly change) typesetting. Big packages like mchem or chemformula are a bit overkill for me.
%
Example usage: Here is a chemical: \chem{NaNO_3^-}
\end{lstlisting}
Example usage: Here is a chemical: \chem{NaNO_3^-}.\\
%
%
You cannot define the same command twice, i.e.
\begin{lstlisting}
\newcommand{\qpAsym}{\ensuremath{\eta}}
%possibly write a lot of text with a lot of uses of \qpAsym which you don't want to find and edit.
\newcommand{\qpAsym}{\ensuremath{\eta_$\mathrm{Q}$}}
\end{lstlisting}
would give you an error. However, you can change what a command does mid-document with the \mbox{\textbackslash renewcommand} command:
\begin{lstlisting}
Example usage:\\
\newcommand{\qpAsym}{\ensuremath{\eta}\xspace}%
This \qpAsym is \qpAsym a \qpAsym line \qpAsym of \qpAsym text \qpAsym.\\
\renewcommand{\qpAsym}{\ensuremath{\eta}\xspace}%
This \qpAsym is \qpAsym a \qpAsym line \qpAsym of \qpAsym text \qpAsym
\end{lstlisting}
Example usage:\\
\newcommand{\qpAsym}{\ensuremath{\eta}\xspace}%
This \qpAsym is \qpAsym a \qpAsym line \qpAsym of \qpAsym text \qpAsym.\\
\renewcommand{\qpAsym}{\ensuremath{\eta_\mathrm{Q}}\xspace}%
This \qpAsym is \qpAsym a \qpAsym line \qpAsym of \qpAsym text \qpAsym.\\
%
In this example it does not make much sense to change what \mbox{\textbackslash qpAsym} does in the middle of your thesis, but your use case might well be different. Admittedly, most of the time I used \mbox{\textbackslash renewcommand}, it was in order to mess with predefined functionalities of other packages. For instance, to avoid pagebreaks between the headings of a part and the first chapter in it, see \cref{sec:part-nopagebreak-chapter}.
%
\subsubsection{Row Vectors}
%
If you want to save vertical space while writing a vector, you could use a (transposed) row vector. To be honest, I don't understand the code myself (it seems to require the xparse package), but here is where I got it from and what it is:\\
\url{https://tex.stackexchange.com/questions/39051/typesetting-a-row-vector} as of 2024-10-22\\
\begin{lstlisting}
\ExplSyntaxOn
\NewDocumentCommand{\Rowvec}{ O{,} m }
{
	\vector_main:nnnn { p } { & } { #1 } { #2 }
}
\NewDocumentCommand{\Colvec}{ O{,} m }
{
	\vector_main:nnnn { p } { \\ } { #1 } { #2 }
}

\seq_new:N \l__vector_arg_seq
\cs_new_protected:Npn \vector_main:nnnn #1 #2 #3 #4
{
	\seq_set_split:Nnn \l__vector_arg_seq { #3 } { #4 }
	\begin{#1matrix}
		\seq_use:Nnnn \l__vector_arg_seq { #2 } { #2 } { #2 }
	\end{#1matrix}
}
\ExplSyntaxOff
%Optional transpose macro:
\newcommand{\Transpose}{\ensuremath{^\mathrm{T}}\xspace}
\end{lstlisting}
You can then use this as follows
\begin{lstlisting}
Example usage:
\begin{equation}\label{eq:b1-rotating}
	\bm{B}_1(t) = B_1 \Rowvec[;]{\cos(\omega_\mathrm{rf} t + \varphi_\mathrm{rf}), -\sin(\omega_\mathrm{rf} t + \varphi_\mathrm{rf}), 0}\Transpose\eqend{.}
\end{equation}
which is even more handy for footnotes\footnote{$\bm{B}_1^\text{lin} = 2B_1 \Rowvec[;]{\cos(x),0,0}\Transpose = B_1\cdot \left[ \Rowvec[;]{\cos(x),\sin(x),0}\Transpose + \Rowvec[;]{\cos(x),-\sin(x),0}\Transpose \right]$.} %
where otherwise a lot of whitespace would be above and/or below the line with a column vector.
\end{lstlisting}
Example usage:
\begin{equation}\label{eq:b1-rotating}
	\bm{B}_1(t) = B_1 \Rowvec[;]{\cos(\omega_\mathrm{rf} t + \varphi_\mathrm{rf}), -\sin(\omega_\mathrm{rf} t + \varphi_\mathrm{rf}), 0}\Transpose\eqend{.}
\end{equation}
which is even more handy for footnotes\footnote{$\bm{B}_1^\text{lin} = 2B_1 \Rowvec[;]{\cos(x),0,0}\Transpose = B_1\cdot \left[ \Rowvec[;]{\cos(x),\sin(x),0}\Transpose + \Rowvec[;]{\cos(x),-\sin(x),0}\Transpose \right]$.} %
where otherwise a lot of whitespace would be wasted above and/or below the line with a column vector.
%
\subsection{Macros with Arguments}
%
Sometimes you may want to be able to influence what a command does without creating a new command. For instance, if I want to stay consistent with how I denote mixtures (e.g. ``pNIPAM-something mixture'' vs ``pNIPAM/something mixture''), I can create a macro which still needs me to tell it what the second part of the mixture is:
\begin{lstlisting}
\newcommand{\pNIPAMbinary}[1]{\mbox{\pNIPAM/}\allowbreak#1\unskip\xspace}%pNIPAM in binary mixtures such as ``pNIPAM/water''
\end{lstlisting}
and also use the macro for any such mixture, e.g. for both \pNIPAMbinary{water} and \pNIPAMbinary{ethanol}.\\\\
%
%
In this example, the argument is mandatory, i.e. will complain if you don't specify what the second part of the mixture is. You can also create commands with optional arguments (note the second set of square brackets) like
\begin{lstlisting}
\newcommand{\TOne}[1][]{\ensuremath{{T_1^\textrm{#1}}}\xspace}%spin-lattice relaxation time T1
%need braces around T_1 macros to avoid ``double superscript error'' when writing something like \TOne^{-1}
Example usage: To then either use as \TOne without any argument or as \TOne[scaled] or \TOne[s, $^{17}$O] where needed
\end{lstlisting}
Example usage: To then either use as \TOne without any argument or as \TOne[scaled] or \TOne[s, $^{17}$O] where needed.\\\\
%
%
Yet another example in support of using macros: How much space do you allow between an equation and e.g. a comma? Say you introduce
\begin{equation}\label{eq:magnetic_moment}
	\hat{\bm{\mu}} = \gamma \hat{\bm{I}}\eqend{,}
\end{equation}
which you want to follow by ``whereby $\gamma$ is the gyromagnetic ratio''. You need to place a comma somewhere. If you like, you could keep your options open by defining a macro
\begin{lstlisting}
	\newcommand{\eqend}[1]{\text{\quad#1}}%argrument is intended for punctuation in math environment after an equation.
\end{lstlisting}
which currently leaves one ``quad'' of space and can be changed if you feel like it. You only have to consistently use it in the equations, e.g. the code for \cref{eq:magnetic_moment} is
\begin{lstlisting}
	\begin{equation}\label{eq:magnetic_moment}
		\hat{\bm{\mu}} = \gamma \hat{\bm{I}}\eqend{,}
	\end{equation}
\end{lstlisting}
%
%
\paragraph{More Complicated Macro Example}\label{sec:samplename_macros} The probably most complex thing I used macros for was sample naming. For the following example, you would also need packages which handle simple calculations and allow the use of if-then-else code structure
\begin{lstlisting}
\usepackage{calculator}%For simple calculations of e.g. automatically determine water fraction part of sample name when etoh fraction is known. Package suggested here https://tex.stackexchange.com/questions/453454/calculations-on-variables-using-latex
%documentation here: https://mirrors.ibiblio.org/CTAN/macros/latex/contrib/calculator/calculator.pdf
\usepackage{xifthen}%check if either component is 100%, and if so, suppress label of absent component
%documentation here: https://mirror.funkfreundelandshut.de/latex/macros/latex/contrib/xifthen/xifthen.pdf

%naming of samples with linear pNIPAM
\newcommand{\pLinSample}[2][O]{\mbox{%mbox to prevent linebreaks in sample name
		\ifthenelse{\cnttest{#2}{=}{100}}%if (outer)
		{\textrm{Lin-E#2\xspace}}%then (outer)
		{\ifthenelse{\cnttest{#2}{=}{0}}%if (inner)
			{\textrm{Lin-W\ensuremath{_\text{#1}}\SUBTRACT{100}{#2}{\wfrac}\wfrac}\xspace}%then (inner)
			{\textrm{Lin-E#2W\ensuremath{_\text{#1}}\SUBTRACT{100}{#2}{\wfrac}\wfrac}\xspace}%else (inner)
		}%else (outer)
	}%close mbox
}%linear pNIPAM samples. Arg1=EtOH Concentration, Arg2=deviations from ``O'' (oxygen) index for water labelling (e.g. \pLinSample[D]{0}). Syntax: \newcommand{\commandname}[total number of arguments][default value of optional arguments, which are numbered from 1 to the total number of arguments]{code}
%Example usage: \pLinSample{10}, \pLinSample{100}, \pLinSample[D]{30}, \pLinSample[D]{0}.
\end{lstlisting}
%
Example usage: \pLinSample{10}, \pLinSample{100}, \pLinSample[D]{30}, \pLinSample[D]{0}.
%
\section{Hyphenation}\label{sec:hyphenation_explanation}
%
Hyphenation on linebreaks fails in some cases and this is not necessary your fault, see \url{https://tex.stackexchange.com/questions/171084/why-does-usepackagebritishbabel-hyphenate-the-word-alternate-incorrectly}.\\
%
You can fix this by manually defining the hyphenation of words you notice being wrongly hyphenated in (the close to final version of) your thesis with commands like (assuming you use the british language babel package)
\begin{lstlisting}
\babelhyphenation[british]{be-yond}
\end{lstlisting}
To check how to hyphenate a word, I sometimes used this website: \url{https://www.hyphenator.net/en/word/beyond}.
%
\subsection{Controlling Linebreaks}
%
Usually, \LaTeX\space is good at finding good spots for linebreaks (not so good at hyphenation though, see \cref{sec:hyphenation_explanation}), but may be pressed for options if there are very few very long words without hyphenation options in one or in two subsequent lines.\\
%
You can avoid linebreaks by placing whatever you want to write inside an \mbox{\textbackslash mbox} environment. If you overdo it and a long linebreak-protected word happens to be at the end of a line, the word will reach into the margin. Also, you can designate spots where you find it okay for \LaTeX\space to insert a linebreak, even if it is normally hesitant to do so, via the \mbox{\textbackslash allowbreak} command. I.e.
\begin{lstlisting}
\newcommand{\pNIPAMternary}[2]{\mbox{\pNIPAM/}\allowbreak \mbox{#1\unskip/}\allowbreak #2\unskip\xspace}%pNIPAM in ternary mixtures such as ``pNIPAM/ethanol/water''
Example usages:\\
Latex Does Not Always Find A Good Spot To Place A Linebreak On Its Own \pNIPAMternary{water}{ethanol}\\%allows linebreaks in the long expression at certain places if necessary.
\newcommand{\pNIPAMbadTernary}[2]{\pNIPAM/#1/#2}%
Latex Does Not Always Find A Good Spot To Place A Linebreak On Its Own \pNIPAMbadTernary{wtr}{thnl}\\% reaches into the margin. Avoid hyphention-triggering characters (vowels) in the arguments for demonstration purposes
Latex Does Not Always Find A Good Spot To Place A Linebreak On On Its Own \textbackslash allowbreak\\%linebreak inside the ``command''
Latex Does Not Always Find A Good Spot To Place A Linebreak On On Its Own \mbox{\textbackslash allowbreak}\\%backslash and ``command'' are forced to stay together
\end{lstlisting}
Example usages:\\
Latex Does Not Always Find A Good Spot To Place A Linebreak On Its Own \pNIPAMternary{water}{ethanol}\\%allows linebreaks in the long expression at certain places if necessary.
\newcommand{\pNIPAMbadTernary}[2]{\pNIPAM/#1/#2}%
Latex Does Not Always Find A Good Spot To Place A Linebreak On Its Own \pNIPAMbadTernary{wtr}{thnl}\\% reaches into the margin. Avoid hyphention-triggering characters in the arguments for demonstration purposes
Latex Does Not Always Find A Good Spot To Place A Linebreak On On Its Own \textbackslash allowbreak\\%linebreak inside the ``command''
Latex Does Not Always Find A Good Spot To Place A Linebreak On On Its Own \mbox{\textbackslash allowbreak}\\%backslash and ``command'' are forced to stay together
%
\chapter{Variables}
%
\section{Booleans}
%
Booleans are a special type of variables which can either have the value ``true'' or the value ``false''. In \LaTeX, you can setup a boolean variable like this:
\begin{lstlisting}
\newif\ifshownotes%created a variable "shownotes" which I could then set to be true or false. I used this to show or hide a sections of text
\shownotesfalse% sets the value of this variable to false. change the ending from "false" to "true" to set it to true. I.e.: \shownotesfalse or \shownotestrue
%https://tex.stackexchange.com/questions/61933/best-practice-for-getting-if-not-foo-conditionals
\end{lstlisting}
You can then e.g. toggle whether to show or hide a section of text by
\begin{lstlisting}
Example usage:\\
\shownotesfalse%make sure that shownotes is false in this example
\ifshownotes%
this is a comment which is only shown if the variable ``shownotes'' has the value ``true''.\\
\fi%end of the shownotes conditional
Here is some text which is shown regardless of the shownotes variable\xspace%
\ifshownotes%
and this is another comment which is only shown if the variable ``shownotes'' has the value ``true''%
\fi%end of the shownotes conditional
.
\end{lstlisting}
Example usage:\\
\shownotesfalse%make sure that shownotes is false in this example
\ifshownotes%
this is a comment which is only shown if the variable ``shownotes'' has the value ``true''.\\
\fi%end of the shownotes conditional
Here is some text which is shown regardless of the shownotes variable\xspace%
\ifshownotes%
and this is another comment which is only shown if the variable ``shownotes'' has the value ``true''%
\fi%end of the shownotes conditional
.
\begin{lstlisting}
Example usage:\\
\shownotestrue%make sure that shownotes is true in this example
\ifshownotes%
this is a comment which is only shown if the variable ``shownotes'' has the value ``true''.\\
\fi%end of the shownotes conditional
Here is some text which is shown regardless of the shownotes variable\xspace%
\ifshownotes%
and this is another comment which is only shown if the variable ``shownotes'' has the value ``true''%
\fi%end of the shownotes conditional
.
\end{lstlisting}
Example usage:\\
\shownotestrue%make sure that shownotes is false in this example
\ifshownotes%
this is a comment which is only shown if the variable ``shownotes'' has the value ``true''.\\
\fi%end of the shownotes conditional
Here is some text which is shown regardless of the shownotes variable\xspace%
\ifshownotes%
and this is another comment which is only shown if the variable ``shownotes'' has the value ``true''%
\fi%end of the shownotes conditional
.
%
\subsection{Todonotes}
%
Using a boolean variable in this way only makes sense if it is a large section of text, or if the text needs to be adjusted in multiple places. For simple, short comments, I would recommend you use the todonotes package instead. Note that I used the parskip package in combination with todonotes, see \cref{sec:linebreak_packages}.\\
%
You can create notes in the margin or in between textlines with the commands
\begin{lstlisting}
Example usage: \todo{text displayed in the margin} and a bit more text \todo[inline]{this goes into the main text area} and yet more text.
\end{lstlisting}
Example usage: \todo{text displayed in the margin} and a bit more text \todo[inline]{this goes into the main text area} and yet more text.\\
%
You can also print a list of your todo notes with \mbox{\textbackslash listoftodos} or hide your todonotes by using the package option ``disable''.\\
%
You can also set the background colour of a todo note, which I used to mark e.g. how crucial it is that I take care of it, or which proofreader made which comments. For dark colours, you will want to adjust the colour saturation so you can still read (black) text:
\begin{lstlisting}
	Example usage: \todo[inline, color=blue!20]{This background is blue with only 20 percent saturation.}
\end{lstlisting}
Example usage: \todo[inline, color=blue!20]{This background is blue with only 20 percent saturation.}
%
\section{Other Types of Variables}
%
Other variables can take continuous values rather than true/false. For example, you can define a variable for the horizontal space your figures should occupy.
\begin{lstlisting}
\def\defaultfigurewidth{0.95\linewidth}%used as the default value for how much of the linewidth a figure with a single panel should occupy
\def\defaulttwosubfigwidth{0.49\linewidth}%used as the default value for how much of the linewidth a subfigure of a figure with two panels should occupy
\end{lstlisting}