Files
latex/docs/parts/reference/cs.tex

69 lines
2.5 KiB
TeX

\newpage
\subsection{CS-Commands}
These commands have to be executed inside math environment
\begin{itemize}
\item \verb|\tct| Time complexity in $\tct{}$-notation (average case)
\item \verb|\tco| Time complexity in $\tco{}$-notation (worst case / upper bound)
\item \verb|\tcl| Time complexity in $\tcl{}$-notation (best case / lower bound)
\item \verb|\t[R, C, N]| Simply prints a capital R, C or N in math mode as normal text. So e.g. use $\tR$ to print an R
\item \verb|\wordbool| Prints $\wordbool$
\item \verb|\words|\{\textit{string}\} Prints $\words{test}$
\item \verb|\wordm|\{\textit{math}\} Prints $\wordm{1}$
\item \verb|\word| Prints $\word$
\item \verb|\alphabets|\{\textit{string}\} Prints $\alphabets{test}$
\item \verb|\alphabetbool| Prints $\alphabetbool$
\end{itemize}
\subsubsection{Algorithms}
\begin{minted}{latex}
\begin{algo}{functionName(A)}
\Procedure{functionName}{$(A)$}
\State\Return "Hello World"
\EndProcedure
\end{algo}
\end{minted}
\begin{algo}{functionName(A)}
\Procedure{functionName}{$(A)$}
\State\Return "Hello World"
\EndProcedure
\end{algo}
\subsubsection{Code}
\label{sec:minted}
If you get compilation errors, be sure to enable \texttt{-shell-escape} for your compiler.
\textit{(Note: Some newer versions of LaTeX do no longer require this and it is better to keep it turned off for security reasons, if it works without)}!
\paragraph{Code inlined in tex file}
\begin{minted}{latex}
\begin{code}{language}
//Code goes here
\end{code}
\end{minted}
This is nothing different than a wrapper for a minted environment with a box drawn around it.
Example (in python):
\begin{code}{python}
def hello_world():
print("hello world!")
\end{code}
\paragraph{Code in separate files}
It is also possible to load code from a source file using the provided commands:
\begin{itemize}
\item \verb|\inputcode|\{\textit{language}\}\{\textit{file}\}, where \textit{language} is the programming language
and \textit{file} is the file name of the file to be loaded, relative to the main tex file.
\item \verb|\inputcodewithfilename|\{\textit{language}\}\{\textit{hidden-path}\}\{\textit{shown-path}\}, where \textit{language} is the programming language,
\textit{hidden-path} is the part of the path you want to hide of the file to be loaded, relative to the main tex file
and \textit{shown-path} is the displayed part.
\end{itemize}
\inlineexample
\begin{minted}{latex}
\inputcodewithfilename{python}{/start/of/path}{/shown/path/file.py}
\end{minted}