#8 migrated code listings to minted
This commit is contained in:
parent
8bf9519b91
commit
5f9a41bc40
|
@ -11,7 +11,7 @@ latexmk:
|
||||||
- main.pdf
|
- main.pdf
|
||||||
expire_in: 2d
|
expire_in: 2d
|
||||||
script:
|
script:
|
||||||
- latexmk -xelatex main.tex
|
- latexmk main.tex
|
||||||
|
|
||||||
hunspell:
|
hunspell:
|
||||||
stage: test
|
stage: test
|
||||||
|
|
2
.latexmkrc
Normal file
2
.latexmkrc
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
$pdf_mode = 1;
|
||||||
|
$pdflatex = 'xelatex --shell-escape';
|
14
README.md
14
README.md
|
@ -144,13 +144,17 @@ If you introduce acronyms, add them to `config/abkuerzungen.tex` in the followin
|
||||||
**(i)** Please note: If you have acronyms that are longer than four characters, you may extend the parameter in brackets behind the `\begin{acronym}` statement.
|
**(i)** Please note: If you have acronyms that are longer than four characters, you may extend the parameter in brackets behind the `\begin{acronym}` statement.
|
||||||
|
|
||||||
### Code Listings
|
### Code Listings
|
||||||
Listings (code snippets) are done using the `\lstlisting` environment.
|
Listings (code snippets) are done using the `minted` environment.
|
||||||
It can have it's own caption, positioned with the parameter `captionpos` (see official docs):
|
It provides syntax highlighting for several languages via an external Python library (*Pygments*) and has comprehensive layout capabilities.
|
||||||
|
Though, handling of captions is a bit complicated, which is why it's wrapped into a custom `code` environment:
|
||||||
|
|
||||||
```latex
|
```latex
|
||||||
\begin{lstlisting}[caption=caption goes here,captionpos=b]
|
\begin{code}
|
||||||
// code goes here...
|
\inputminted{bash}{resources/yoursource.sh}
|
||||||
\end{lstlisting}
|
\label{yourlabel}
|
||||||
|
\captionof{listing}{Some Caption goes here...}
|
||||||
|
\source{and you can tell people where you got the code from...}
|
||||||
|
\end{code}
|
||||||
```
|
```
|
||||||
|
|
||||||
Config for syntax highlighting is centrally provided in `config/config.tex` using the `\lstset` directive (defaulting to `C#` in this boilerplate).
|
Config for syntax highlighting is centrally provided in `config/config.tex` using the `\lstset` directive (defaulting to `C#` in this boilerplate).
|
||||||
|
|
|
@ -135,62 +135,16 @@
|
||||||
\usepackage{scrhack}
|
\usepackage{scrhack}
|
||||||
|
|
||||||
% Sourcecode-Listings
|
% Sourcecode-Listings
|
||||||
\usepackage{listings}
|
\usepackage[chapter,newfloat]{minted}
|
||||||
|
|
||||||
\definecolor{bluekeywords}{rgb}{0.13,0.13,1}
|
\setminted{
|
||||||
\definecolor{lightbluekeywords}{rgb}{0.13,0.7,1}
|
linenos=true,
|
||||||
\definecolor{greencomments}{rgb}{0,0.5,0}
|
frame=lines,
|
||||||
\definecolor{redstrings}{rgb}{0.9,0,0}
|
baselinestretch=1,
|
||||||
|
breaklines=true,
|
||||||
\lstset{language=[Sharp]C,
|
breakautoindent=true,
|
||||||
showspaces=false,
|
fontsize=\small
|
||||||
showtabs=false,
|
|
||||||
breaklines=true,
|
|
||||||
showstringspaces=false,
|
|
||||||
escapeinside={(*@}{@*)},
|
|
||||||
commentstyle=\color{greencomments},
|
|
||||||
keywordstyle=[0]\color{bluekeywords}\bfseries,
|
|
||||||
keywordstyle=[1]\color{lightbluekeywords}\bfseries,
|
|
||||||
stringstyle=\color{redstrings},
|
|
||||||
basicstyle=\small\ttfamily,
|
|
||||||
fontadjust,
|
|
||||||
xrightmargin=1mm,
|
|
||||||
keywords=[0]{string, int, public, var, static, using, object, void},
|
|
||||||
keywords=[1]{File,UPFConfig,JsonConvert},
|
|
||||||
tabsize=2,
|
|
||||||
lineskip=-0.1em,
|
|
||||||
frame=tb,
|
|
||||||
numbers=left,
|
|
||||||
numberstyle=\tiny,
|
|
||||||
stepnumber=1,
|
|
||||||
numbersep=5pt,
|
|
||||||
escapeinside=||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
%% http://tex.stackexchange.com/questions/126839/how-to-add-a-colon-after-listing-label
|
\newenvironment{code}{\captionsetup{type=listing}}{}
|
||||||
\makeatletter
|
\SetupFloatingEnvironment{listing}{name=Listing,listname=Listingverzeichnis}
|
||||||
\begingroup\let\newcounter\@gobble\let\setcounter\@gobbletwo
|
|
||||||
\globaldefs\@ne \let\c@loldepth\@ne
|
|
||||||
\newlistof{listings}{lol}{\lstlistlistingname}
|
|
||||||
\endgroup
|
|
||||||
\let\l@lstlisting\l@listings
|
|
||||||
\makeatother
|
|
||||||
|
|
||||||
\renewcommand*\cftfigpresnum{Abbildung~}
|
|
||||||
\renewcommand*\cfttabpresnum{Tabelle~}
|
|
||||||
\renewcommand*\cftlistingspresnum{Listing~}
|
|
||||||
\renewcommand{\cftfigaftersnum}{:}
|
|
||||||
\renewcommand{\cfttabaftersnum}{:}
|
|
||||||
\renewcommand{\cftlistingsaftersnum}{:}
|
|
||||||
\settowidth{\cftfignumwidth}{\cftfigpresnum 99~\cftfigaftersnum}
|
|
||||||
\settowidth{\cfttabnumwidth}{\cfttabpresnum 99~\cftfigaftersnum}
|
|
||||||
\settowidth{\cftlistingsnumwidth}{\cftlistingspresnum 99~\cftfigaftersnum}
|
|
||||||
\setlength{\cfttabindent}{1.5em}
|
|
||||||
\setlength{\cftfigindent}{1.5em}
|
|
||||||
\setlength{\cftlistingsindent}{1.5em}
|
|
||||||
|
|
||||||
\renewcommand\lstlistlistingname{Listingverzeichnis}
|
|
||||||
|
|
||||||
\makeatletter
|
|
||||||
\def\l@lstlisting#1#2{\@dottedtocline{1}{0em}{1.5em}{\lstlistingname\space{#1}}{#2}}
|
|
||||||
\makeatother
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user