summaryrefslogtreecommitdiff
path: root/content/latexHeaders/commands.sty
blob: 73a7dca31b8cd13e1043c5598c4378f77f029097 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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%
}