summaryrefslogtreecommitdiff
path: root/content/latexHeaders/commands.sty
diff options
context:
space:
mode:
Diffstat (limited to 'content/latexHeaders/commands.sty')
-rw-r--r--content/latexHeaders/commands.sty61
1 files changed, 61 insertions, 0 deletions
diff --git a/content/latexHeaders/commands.sty b/content/latexHeaders/commands.sty
new file mode 100644
index 0000000..73a7dca
--- /dev/null
+++ b/content/latexHeaders/commands.sty
@@ -0,0 +1,61 @@
+% custom commands
+\newcommand{\optional}[1]{
+ \ifoptional
+ #1
+ \fi}
+\newcommand{\runtime}[1]{\ensuremath{\mathcal{O}\left(#1\right)}}
+\newcommand{\code}[1]{\lstinline[breaklines=true]{#1}}
+\let\codeSafe\lstinline
+
+\ifoptional
+ \renewcommand{\columnbreak}{}
+ \newcommand\opthint{\textcolor{gray}{(optional)}}
+\fi
+
+\usepackage{tikz}
+\usetikzlibrary{angles,quotes}
+
+
+%new environment to define algorithms
+\usepackage{ifthen}
+\NewDocumentEnvironment{algorithm}{ O{required} m +b }{}{
+ \ifthenelse{\equal{#1}{optional}}{%
+ \optional{
+ \needspace{4\baselineskip}%
+ \subsection{#2 \opthint}%
+ #3%
+ }
+ }{%
+ \needspace{4\baselineskip}%
+ \subsection{#2}%
+ #3%
+ }
+}
+
+%\ifthenelse{\equal{#3}{}}{}{\runtime{#3}}
+
+\newcommand{\sourcecode}[1]{%
+ \label{code:#1}%
+ \nobreak%
+% \needspace{3\baselineskip}%
+% \nopagebreak%
+ \lstinputlisting{#1}%
+ \penalty -1000%
+}
+\newcommand{\sourceref}[1]{{%
+ \color{comment}\bfseries\itshape{}Seite \pageref{code:#1}%
+}}
+
+\newcommand{\method}[4][]{\texttt{#2}~~#3~~\runtime{#4}#1\par}
+
+\newenvironment{methods}[1][lll]{%
+ %\begin{minipage}{\linewidth}%
+ \renewcommand{\method}[4][]{\texttt{##2}&##3&\ifthenelse{\equal{##4}{}}{}{\runtime{##4}}##1\\}%
+ \begin{tabular}{@{}#1@{}}%
+}{%
+ \end{tabular}%
+ %\end{minipage}%
+ \nobreak%
+ \needspace{3\baselineskip}%
+ \nobreak%
+}