summaryrefslogtreecommitdiff
path: root/latexHeaders/commands.sty
diff options
context:
space:
mode:
authormzuenni <michi.zuendorf@gmail.com>2022-06-27 17:19:28 +0200
committermzuenni <michi.zuendorf@gmail.com>2022-06-27 17:19:28 +0200
commit5ab8a5088b729a9953b8dff1b2a985dc8fb2098b (patch)
treeed40d6936c0e9eee40ba62751cbf99ecddbaddc2 /latexHeaders/commands.sty
parentadabbad9c51cf7cd3874bfde8eac1fbcf84fec10 (diff)
updated tcr
Diffstat (limited to 'latexHeaders/commands.sty')
-rw-r--r--latexHeaders/commands.sty49
1 files changed, 49 insertions, 0 deletions
diff --git a/latexHeaders/commands.sty b/latexHeaders/commands.sty
new file mode 100644
index 0000000..abe589d
--- /dev/null
+++ b/latexHeaders/commands.sty
@@ -0,0 +1,49 @@
+% custom commands
+\newcommand{\optional}[1]{
+ \ifoptional
+ #1
+ \fi}
+\newcommand{\runtime}[1]{\ensuremath{\mathcal{O}\left(#1\right)}}
+\newcommand{\code}[1]{\lstinline[breaklines=true]{#1}}
+
+\usepackage{tikz}
+
+
+%new environment to define algorithms
+\usepackage{ifthen}
+\NewDocumentEnvironment{algorithm}{ O{required} m +b }{}{
+ \ifthenelse{\equal{#1}{optional}}{%
+ \optional{
+ \needspace{4\baselineskip}%
+ \subsection{#2\textcolor{gray}{(optional)}}%
+ #3%
+ }
+ }{%
+ \needspace{4\baselineskip}%
+ \subsection{#2}%
+ #3%
+ }
+}
+
+%\ifthenelse{\equal{#3}{}}{}{\runtime{#3}}
+
+\newcommand{\sourcecode}[1]{%
+ \nobreak%
+% \needspace{3\baselineskip}%
+% \nopagebreak%
+ \lstinputlisting{#1}%
+ \penalty -1000%
+}
+\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%
+} \ No newline at end of file