\documentclass[11pt, a4paper]{article} % \usepackage[utf8]{inputenc} \usepackage[english]{babel} \usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry} \usepackage{mathtools} \usepackage{esdiff} % derivatives \usepackage{braket} \usepackage{graphicx} \usepackage{etoolbox} \usepackage{substr} \usepackage{xcolor} \usepackage{float} \usepackage[hidelinks]{hyperref} \usepackage{subcaption} \hypersetup{colorlinks = true, % Colours links instead of ugly boxes urlcolor = blue, % Colour for external hyperlinks linkcolor = cyan, % Colour of internal links citecolor = red % Colour of citations } % \usepackage[version=4,arrows=pgf-filled]{mhchem} \usepackage{siunitx} \sisetup{output-decimal-marker = {,}} \sisetup{separate-uncertainty} \sisetup{per-mode = power} \sisetup{exponent-product=\ensuremath{\cdot}} \DeclarePairedDelimiter\abs{\lvert}{\rvert} \DeclareMathOperator{\e}{e} \usepackage{translations} \newcommand{\TODO}[1]{{\color{red}#1}} % put an explanation above an equal sign % [1]: equality sign (or anything else) % 2: text (not in math mode!) \newcommand{\explUnderEq}[2][=]{% \underset{\substack{\uparrow\\\mathrlap{\text{\hspace{-1em}#2}}}}{#1}} \newcommand{\explOverEq}[2][=]{% \overset{\substack{\mathrlap{\text{\hspace{-1em}#2}}\\\downarrow}}{#1}} % % TRANSLATION COMMANDS % % The lower case commands use \fqname based keys, the upper case absolute keys. % Example: % \dt[example]{german}{Beispiel} % defines the key \fqname:example % \ger[example]{Beispiel} % defines the key \fqname:example % \DT[example]{german}{Beispiel} % defines the key example % \Ger[example]{Beispiel} % defines the key example % % For ease of use in the ttext environment and the optional argument of the \Part, \Section, ... commands, % all "define translation" commands use \fqname as default key % Get a translation % expandafter required because the translation commands dont expand anything % shortcuts for translations % 1: key \newcommand{\gt}[1]{\expandafter\GetTranslation\expandafter{\fqname:#1}} \newcommand{\GT}[1]{\expandafter\GetTranslation\expandafter{#1}} \newcommand{\IfTranslationExists}{ \IfTranslation{\languagename} } \newcommand{\iftranslation}[1]{\expandafter\IfTranslationExists\expandafter{\fqname:#1}} % Define a new translation % [1]: key, 2: lang, 3: translation \newcommand{\dt}[3][\fqname]{ % hack because using expandafter on the second arg didnt work \def\tempaddtranslation{\addtranslation{#2}} \ifstrequal{#1}{\fqname}{ \expandafter\tempaddtranslation\expandafter{\fqname}{#3} }{ \expandafter\tempaddtranslation\expandafter{\fqname:#1}{#3} } } \newcommand{\DT}[3][\fqname]{ % hack because using expandafter on the second arg didnt work \def\tempaddtranslation{\addtranslation{#2}} \ifstrequal{#1}{\fqname}{ \expandafter\tempaddtranslation\expandafter{\fqname}{#3} }{ \expandafter\tempaddtranslation\expandafter{#1}{#3} } } % [1]: key, 2: translation \newcommand{\ger}[2][\fqname]{\dt[#1]{german}{#2}} \newcommand{\eng}[2][\fqname]{\dt[#1]{english}{#2}} \newcommand{\GER}[2][\fqname]{\DT[#1]{german}{#2}} \newcommand{\ENG}[2][\fqname]{\DT[#1]{english}{#2}} % use this to define text in different languages for the key % the translation for when the environment ends. % (temporarily change fqname to the \fqname: to allow % the use of \eng and \ger without the key parameter) \newenvironment{ttext}[1]{ \edef\realfqname{\fqname} \edef\fqname{\fqname:#1} }{ \expandafter\GT\expandafter{\fqname} \\ \edef\fqname{\realfqname} } % "automate" sectioning % start
, 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} } \usepackage{xstring} \newcommand{\insertEquationLine}[2]{ \par\noindent\ignorespaces % \textcolor{gray}{\hrule} \vspace{0.5\baselineskip} % \fbox{ \begin{minipage}{0.3\textwidth} \iftranslation{#1}{ \raggedright \gt{#1} }{} \iftranslation{#1_desc}{ \\ {\color{darkgray} \gt{#1_desc}} }{} \end{minipage} % } \hfill \fbox{ \begin{minipage}{0.6\textwidth} % \vspace{-\baselineskip} % remove the space that comes from starting a new paragraph #2 % \noindent\iftranslation{#1_defs}{ \begingroup \color{darkgray} \gt{#1_defs} % \edef\temp{\GT{#1_defs}} % \expandafter\StrSubstitute\expandafter{\temp}{:}{\\} \endgroup }{} % \vspace{-\baselineskip} % remove the space that comes from starting a new paragraph \end{minipage} } \textcolor{lightgray}{\hrule} \vspace{0.5\baselineskip} % \par % \hrule } \newcommand{\insertEquation}[2]{ \insertEquationLine{#1}{ \begin{align} \label{eq:\fqname:#1} #2 \end{align} } } \newcommand{\insertFLAlign}[2]{ % eq name, #cols, eq \insertEquationLine{#1}{% \begin{flalign}% % dont place label when one is provided % \IfSubStringInString{label}\unexpanded{#3}{}{ % \label{eq:#1} % } #2% \end{flalign} } } \newcommand{\insertAlignedAt}[3]{ % eq name, #cols, eq \insertEquationLine{#1}{% \begin{alignat}{#2}% % dont place label when one is provided % \IfSubStringInString{label}\unexpanded{#3}{}{ % \label{eq:#1} % } #3% \end{alignat} } } \newenvironment{formula}[1]{ % key \newcommand{\desc}[4][english]{ % language, name, description, definitions \dt[#1]{##1}{##2} \ifblank{##3}{}{\dt[#1_desc]{##1}{##3}} \ifblank{##4}{}{\dt[#1_defs]{##1}{##4}} } \newcommand{\eq}[1]{ \insertEquation{#1}{##1} } \newcommand{\eqAlignedAt}[2]{ \insertAlignedAt{#1}{##1}{##2} } \newcommand{\eqFLAlign}[1]{ \insertFLAlign{#1}{##1} } }{\ignorespacesafterend} \title{Formelsammlung} \author{Matthias Quintern} \date{\today} \begin{document} \maketitle \tableofcontents \newpage \setcounter{page}{1} % \nuwcommand{\eq}[4][desc]{ % \vspace*{0.1cm} % \begin{minipage}{0.3\textwidth} % \raggedright % .#2 \\ % \ifstrequal{#1}{desc}{}{ % {\color{gray}#1} % } % \end{minipage} % \begin{minipage}{0.7\textwidth} % \begin{align} % \label{eq:#4} % #3 % \end{align} % \end{minipage} % \newline % } % \newcommand{\eqd}[5][desc]{ % \vspace*{0.1cm} % \begin{minipage}{0.3\textwidth} % \raggedright % .#2 \\ % \ifstrequal{#1}{desc}{}{ % {\color{gray}#1} % } % \end{minipage} % \begin{minipage}{0.7\textwidth} % \begin{align} % \label{eq:#5} % #3 % \end{align} % {\color{gray}with: #4} % \end{minipage} % \newline % } \IfSubStringInString{lol}{lol\frac{asdsd}{lol} & l}{YES!}{ NO! } \input{translations.tex} \input{trigonometry.tex} \input{quantum_mechanics.tex} \input{atom.tex} \input{quantum_computing.tex} %\newpage % \bibliographystyle{plain} % \bibliography{ref} \end{document}