\documentclass[11pt, a4paper]{article}
% \usepackage[utf8]{inputenc}
\usepackage[german]{babel}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
% ENVIRONMENTS etc
\usepackage{adjustbox}
\usepackage{colortbl}  % color table
\usepackage{tabularx}  % bravais table
\usepackage{multirow}  % for superconducting qubit table
\usepackage{hhline}    % for superconducting qubit table
% TOOLING
\usepackage{graphicx}
\usepackage{etoolbox}
\usepackage{luacode}
\usepackage{expl3} % switch case and other stuff
\usepackage{substr}
\usepackage{xcolor}
% FORMATING
\usepackage{float}  % float barrier
\usepackage{subcaption} % subfigure
\usepackage[hidelinks]{hyperref}
\usepackage[shortlabels]{enumitem} % easily change enum symbols to i), a. etc
\usepackage{titlesec}  % colored titles
\usepackage{array}
\newcolumntype{C}{>{$}c<{$}} % math-mode version of "c" column type
% \usepackage{sectsty}
% TRANSLATION
\usepackage{translations}
\input{util/translation.tex}
\input{util/colorscheme.tex}
% GRAPHICS
\usepackage{tikz} % drawings
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{calc}
% speed up compilation by externalizing figures
% \usetikzlibrary{external}
% \tikzexternalize[prefix=tikz_figures]
% \tikzexternalize
\usepackage{circuitikz}
% SCIENCE PACKAGES
\usepackage{mathtools}
\usepackage{MnSymbol}  % for >>> \ggg sign
% \usepackage{esdiff} % derivatives
% esdiff breaks when taking \dot{q} has argument
\usepackage{derivative}
\usepackage[version=4,arrows=pgf-filled]{mhchem}
\usepackage{bbold}  % \mathbb font
\usepackage{braket}
\usepackage{siunitx}
\sisetup{output-decimal-marker = {,}}
\sisetup{separate-uncertainty}
\sisetup{per-mode = power}
\sisetup{exponent-product=\ensuremath{\cdot}}
% DUMB STUFF
% \usepackage{emoji}
% \newcommand\temoji[1]{\text{\emoji{#1}}}
% \def\sigma{\temoji{shark}}
% \def\lambda{\temoji{sheep}}
% \def\psi{\temoji{pickup-truck}}
% \def\pi{\temoji{birthday-cake}}
% \def\Pi{\temoji{hospital}}
% \def\rho{\temoji{rhino}}
% \def\nu{\temoji{unicorn}}
% \def\mu{\temoji{mouse}}

\newcommand{\TODO}[1]{{\color{bright_red}TODO:#1}}
\newcommand{\ts}{\textsuperscript}

% "automate" sectioning
% start <section>, get heading from translation, set label
% fqname is the fully qualified name: the keys of all previous sections joined with a ':'
% [1]: code to run after setting \fqname, but before the \part, \section etc
% 2: key
\newcommand{\Part}[2][desc]{
    \newpage
    \def\partname{#2}
    \def\sectionname{}
    \def\subsectionname{}
    \def\subsubsectionname{}
    \edef\fqname{\partname}
    #1
    \part{\GT{\fqname}} 
    \label{sec:\fqname}
}
\newcommand{\Section}[2][]{
    \def\sectionname{#2}
    \def\subsectionname{}
    \def\subsubsectionname{}
    \edef\fqname{\partname:\sectionname}
    #1
    \section{\GT{\fqname}} 
    \label{sec:\fqname}
}
% \newcommand{\Subsection}[1]{\Subsection{#1}{}}
\newcommand{\Subsection}[2][]{
    \def\subsectionname{#2}
    \def\subsubsectionname{}
    \edef\fqname{\partname:\sectionname:\subsectionname}
    #1
    \subsection{\GT{\fqname}}
    \label{sec:\fqname}
}
\newcommand{\Subsubsection}[2][]{
    \def\subsubsectionname{#2}
    \edef\fqname{\partname:\sectionname:\subsectionname:\subsubsectionname}
    #1
    \subsubsection{\GT{\fqname}}
    \label{sec:\fqname}
}

% Make the translation of #1 a reference to a equation
% 1: key
\newrobustcmd{\fqEqRef}[1]{%
    % \edef\fqeqrefname{\GT{#1}}
    % \hyperref[eq:#1]{\fqeqrefname}
    \hyperref[eq:#1]{\GT{#1}}%
}
\newrobustcmd{\qtyRef}[1]{%
    \hyperref[qty:#1]{\GT{#1}}%
}
\newrobustcmd{\constRef}[1]{%
    \hyperref[const:#1]{\GT{#1}}%
}
% Make the translation of #1 a reference to a section
% 1: key
\newrobustcmd{\fqSecRef}[1]{%
    \hyperref[sec:#1]{\GT{#1}}%
}

% \usepackage{xstring}


\input{circuit.tex}
\input{util/macros.tex}
\input{util/environments.tex}  % requires util/translation.tex to be loaded first

\def\inputOnlyFile{\relax}
\newcommand\Input[1]{
    \ifstrequal{\relax}{\inputOnlyFile}{
        \input{#1}
    }{
        \ifstrequal{#1}{\inputOnlyFile}{
            \input{#1}
        }{}
    }
}

% \includeonly{mechanics}
% \includeonly{low_temp}

\title{Formelsammlung}
\author{Matthias Quintern}
\date{\today}
\begin{document}
\IfFileExists{\jobname.translations.aux}{%
  \input{\jobname.translations.aux}
}{}


\newwrite\translationsaux
\immediate\openout\translationsaux=\jobname.translations.aux
\immediate\write\translationsaux{\noexpand\def\noexpand\MYVAR{AUSM AUX}}%
\AtEndDocument{\immediate\closeout\translationsaux}

\maketitle
\tableofcontents
\newpage
\setcounter{page}{1}

\input{util/translations.tex}

% \include{maths/linalg}
% \include{maths/geometry}
\input{maths/analysis.tex}
% \include{maths/probability_theory}

\include{mechanics}

\include{statistical_mechanics}

\include{electrodynamics}
    
% \include{quantum_mechanics}
% \include{atom}

\include{condensed_matter}
\input{cm/charge_transport.tex}
\input{cm/low_temp.tex}
\input{cm/semiconductors.tex}
% \include{cm/techniques}

\include{topo}

% \include{quantum_computing}

\include{computational}

\include{quantities}
\include{constants}

\newpage
% \DT[english]{ttest}{TESTT EN}
% \DT[german]{ttest}{TESTT DE}

\paragraph{Testing GT, GetTranslation, IfTranslationExists, IfTranslation}
\addtranslation{english}{ttest}{This is the english translation of \texttt{ttest}}
\noindent
GT: ttest = \GT{ttest}\\
GetTranslation: ttest = \GetTranslation{ttest}\\
Is english? = \IfTranslation{english}{ttest}{yes}{no} \\
Is german? = \IfTranslation{german}{ttest}{yes}{no} \\
Is defined = \IfTranslationExists{ttest}{yes}{no} \\

\paragraph{Testing translation keys containing macros}
\def\ttest{NAME}
% \addtranslation{english}{\ttest:name}{With variable}
% \addtranslation{german}{\ttest:name}{Mit Variable}
% \addtranslation{english}{NAME:name}{Without variable}
% \addtranslation{german}{NAME:name}{Without Variable}
\DT[\ttest:name]{english}{DT With variable}
\DT[\ttest:name]{german}{DT Mit Variable}
\noindent
GT: {\textbackslash}ttest:name = \GT{\ttest:name}\\
GetTranslation: {\textbackslash}ttest:name = \GetTranslation{\ttest:name}\\
Is english? = \IfTranslation{english}{\ttest:name}{yes}{no} \\
Is german? = \IfTranslation{german}{\ttest:name}{yes}{no} \\
Is defined? = \IfTranslationExists{\ttest:name}{yes}{no} \\
Is defined? = \expandafter\IfTranslationExists\expandafter{\ttest:name}{yes}{no}

% \DT[qty:test]{english}{HAHA}

\paragraph{Testing hyperrefs}
\noindent{This text is labeled with "test" \label{test}}\\
\hyperref[test]{This should refer to the line above}\\
Link to quantity which is defined after the reference: \qtyRef{test}\\
\DT[qty:test]{english}{If you read this, then the translation for qty:test was expandend!}
Link to defined quantity: \qtyRef{mass}
\begin{equation}
    \label{qty:test}
    E = mc^2
\end{equation}

\paragraph{Testing translation keys with token symbols like undescores}
\noindent
\GT{absolute_undefined_translation_with_underscors}\\
\gt{relative_undefined_translation_with_underscors}\\
\GT{absolute_undefined_translation_with_&ampersand}






\newpage
\Eng[appendix]{Appendix}
\Ger[appendix]{Anhang}
\part*{\GT{appendix}}
% \listofmyenv
\listofquantities
\listoffigures
\listoftables
% \bibliographystyle{plain}
% \bibliography{ref}
\end{document}
