%based on xhversion{v3.01 SiU} %PdJ,PdL,PdM,PdS,PdU,Pe6,PeI,PfB,PfD,RbN,RbP,RcL,RdC,RdD,RdF,Sb7,ScN,SiT,SiU,Sj3,
%
% Inherited from Michale Reitmeir, 2019, adopted by tyrolyean 2020
% adoption for usage with xelatex and a lot of stuff beeing thrown out because
% xelatex doesn't care about them.
%

\listfiles			%lists included files while processing 'pdflatex'
\documentclass[12pt,a4paper]{article}
  %\documentclass[12pt,a4paper]{book}
  %\documentclass[11pt,a4paper]{article}
  %\documentclass[12pt,a4paper]{report}

  %\usepackage{etex}		%gegen 'no more room for new dimen...' error bei 'tikz' xh@RaE1

\usepackage[utf8]{inputenc}
\usepackage[english,ngerman,]{babel}
\selectlanguage{english}
\usepackage[OT2,T1]{fontenc}

\usepackage{svg} % Allows the inclusion of SVG files
\usepackage{amssymb}
\usepackage{ulem}
\usepackage{amsmath}
\usepackage{amscd}
  %\usepackage{extarrows}	%\xleftrightarrow[obentext]{untentext}
\usepackage{wasysym}
\usepackage{pxfonts}
\usepackage{verbatim}
\usepackage{alltt}
\usepackage{moreverb}
\usepackage{graphicx}
\usepackage{wrapfig}
%\usepackage{subfigure}	% Probleme mit tocloft? -MR
  %\usepackage{theorem}
  %\usepackage[dvips]{color}
  %\usepackage{lmodern}
  %\usepackage{textcomp}
\usepackage{multicol}		% 2-, 3-, ... -spaltige Formatierung mit 'multicols'
\usepackage{multirow}		% fuer 'tabular' - Tabellen
 %\usepackage{makeidx}
\usepackage{imakeidx}		% erspart dieses externe Stichwortprogramm
  %\usepackage{pdfpages}	% fuer 'includepdf' (stattdessen nimmi meistens 'includegraphics[page=1,...]')
\usepackage{mdwlist}		% f. 'compact lists' "itemize*", "enumerate*", "description*"
  %\usepackage{ulem}		%... produziertma nFehler ban 'latex' run
\usepackage{longtable}		% fuer tabellen ueber mehrere Seiten
\usepackage{makecell}		% Zeilenumbruch in Tabellenzelle	-MR
\usepackage{xcolor}
 \definecolor{lltgy}	{gray}{0.96}	% selbstdefinierte Farben
 \definecolor{ltgy}	{gray}{0.91}
 \definecolor{dkgn}	{rgb}{0.0,0.7,0.0}
 \definecolor{dkbu}	{rgb}{0.0,0.0,0.6}
 \definecolor{ddkbu}	{rgb}{0.0,0.0,0.45}

\usepackage{ifthen}		% fuer 'ifthenelse{}{}{}'
\usepackage{ifpdf}		% fuer {\ifpdf ... \fi}
\usepackage{beramono}	% monospace font -MR
\usepackage{listings}

\lstdefinestyle{default}{
	columns=space-flexible,
	basicstyle=\fontsize{9pt}{9pt}\selectfont\ttfamily,
	frame=single,
	frameround=tttt,
	showstringspaces=false,
	breaklines=true,
	tabsize=4,
	numbers=left,
	captionpos=b
}

\lstdefinestyle{terminal}{
	style=default,
	language=bash,
	frame=none,
	numbers=none,
	backgroundcolor=\color{ltgy}
}

\lstdefinelanguage{customvhdl}[]{VHDL}{
	morekeywords=[2]{std_logic, std_logic_vector, natural, integer, bit, string},
}

\lstdefinestyle{vhdlstyle}{
	language=customvhdl,
	belowcaptionskip=1\baselineskip,
	keywordstyle=\bfseries\color{green!40!black},
	keywordstyle=[2]\bfseries\color{blue!80!white},
	commentstyle=\itshape\color{purple},
	backgroundcolor=\color{lightgray!20},
	stringstyle=\color{orange},
	xleftmargin=\parindent,
	title=\lstname,
}

\lstset{
	style=default,
	literate={ö}{{\"o}}1
	         {ä}{{\"a}}1
	         {ü}{{\"u}}1
	         {Ö}{{\"O}}1
	         {Ä}{{\"A}}1
	         {Ü}{{\"U}}1
}
%% fix minus sign conflict with listings and breqn
\mathchardef\hyphenmathcode=\mathcode`\-
\let\origlstlisting=\lstlisting
\let\endoriglstlisting=\endlstlisting
\renewenvironment{lstlisting}
    {\mathcode`\-=\hyphenmathcode
     \everymath{}\mathsurround=0pt\origlstlisting}
    {\endoriglstlisting}

\usepackage{fancyhdr}
  %\usepackage{framed}		%'\begin{framed}' ... '\end{framed}', schautAusWiePartezettel:-)
\usepackage{hyphenat}		%fuer '\hyph{}'
\usepackage{lastpage}	%fuer '\pageref{LastPage}' - **funzt nid bei allen**
\usepackage[hyphens]{url}		%fuer '\url{...}'

% lscape oder pdflscape: ('landscape' == Querformat)
\usepackage{lscape}
  %\usepackage{pdflscape}
\usepackage{rotating}		%f. 'rotate' und 'turn'
\usepackage[active]{pst-pdf}
\usepackage{pst-circ}
\usepackage{pst-plot}
\usepackage{pst-uml}
  %\usepackage{calc}
\usepackage{fp}
  %\usepackage[official]{eurosym}
\usepackage[gen]{eurosym}

% YHs Raender links 30mm rechts 25mm einstellen:
\setlength{\hoffset}	{30mm-1in}
\setlength{\oddsidemargin}{0pt}		%bei doppelseitigem Druck umstellen!
\setlength{\textwidth}	{\paperwidth-55mm}

\setlength{\topmargin}	{0pt}
\addtolength{\voffset}  {-16.2mm}
\addtolength{\textheight}{39mm}

%\setcounter{tocdepth}{4}		%bringt auch 'paragraph{titel}' ins Inhaltsverzeichnis
%
\definecolor{ydkbu}{rgb}{0.0,0.0,0.6}	% YHs blaue Schriftfarb
\newcommand{\yhbu}[0]{\color{ydkbu}}	% Macro fuer schreibfaulen XH
%\newcommand{\yhbu}[0]{\color{ydkbu}\usefont{T1}{laess}{m}{n}}	% Macro fuer schreibfaulen XH
\definecolor{corrclr}{rgb}{0.7,0.2,0.2}		% XHs Korrekturen-Farb ...
\newcommand{\korr}[0]{\color{corrclr}\fontsize{8pt}{9pt}\selectfont\bf} %plus Faulheitsmacro
\makeindex

%%% BibLaTeX settings
\usepackage[citestyle = ieee]{biblatex}
\usepackage{csquotes}
\addbibresource{./bibliographies/DP.bib}
\addbibresource{./bibliographies/AB.bib}
\DeclareNameAlias{sortname}{family-given}
\renewcommand\multinamedelim{;\ }
\renewcommand\finalnamedelim{;\ }
\renewcommand\intitlepunct{:\ }
\renewcommand\labelnamepunct{:\ }
\DeclareFieldFormat{title}{#1}	%title not italic
%\bibnamedash
%\renewcommand\newunitpunct{OWO}

\usepackage{float} % Allows the H floating option
\usepackage{tabularx} % Allows the H floating option
\usepackage[headheight=0mm, margin=2.5cm]{geometry}
%%% MR-packages:
\usepackage{hyperref}
\hypersetup{
	pdfauthor={Daniel Plank, Armin Brauns},
	pdftitle=YARM,
	pdfproducer=5ABHEL,
	bookmarks=true,
	pdfcreator=xelatex,
}

\usepackage{tikz,pgfplots}
	\usetikzlibrary{plotmarks}
	\usetikzlibrary{angles,quotes,babel,shapes,arrows,positioning,calc}
\usepackage{tikz-timing}
\tikzset{
block/.style = {draw, fill=white, rectangle, minimum height=3em, minimum width=3em,align=center},
tmp/.style  = {coordinate},
sum/.style= {draw, fill=white, circle, node distance=1cm},
input/.style = {coordinate},
output/.style= {coordinate},
pinstyle/.style = {pin edge={to-,thin,black}
}
}
% https://www.overleaf.com/learn/latex/LaTeX_Graphics_using_TikZ:_A_Tutorial_for_Beginners_(Part_3)%E2%80%94Creating_Flowcharts
\tikzstyle{startstop} = [rectangle, rounded corners, minimum width=3cm, minimum
height=1cm,align=center, text width=3cm, draw=black, fill=red!30]
\tikzstyle{io} = [trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=3cm,
minimum height=1cm, align=center, text width=3cm, draw=black, fill=blue!30]
\tikzstyle{process} = [rectangle, minimum width=3cm, minimum height=1cm, align=center, text width=3cm, draw=black, fill=orange!30]
\tikzstyle{decision} = [diamond, minimum width=3cm, minimum height=1cm, align=center, text width=3cm, draw=black, fill=green!30]
\tikzstyle{arrow} = [thick,->,>=latex]
\usetikzlibrary{external}
\usepackage[european, straightvoltages]{circuitikz}
\usepackage[per-mode=fraction]{siunitx}
\usepackage{breqn}	
\usepackage{physics}
\usepackage{caption}
\usepackage{slashed}
\input kvmacros 
\usepackage{mdframed}
\usepackage{lipsum}
\usepackage{blindtext}
\usepackage{pgfgantt}

%%% Title formatting
\usepackage{titlesec}
\titleformat{\section}{\normalfont\bfseries\scshape\fontsize{16pt}{19pt}\selectfont}{\thesection}{1em}{}
%%% ToC formatting
\usepackage{tocloft}
\renewcommand{\cftloftitlefont}{\section}
\renewcommand{\cftlottitlefont}{\section}
\renewcommand{\cftsecfont}{}
\renewcommand\cftsubsecdotsep{.2}
\renewcommand{\cftsecleader}{\cftdotfill{\cftsubsecdotsep}}
\setlength\cftbeforesecskip{3.84pt}
\setlength\cftsubsecindent{4.2mm}
% command for regular footer in ToC
\fancypagestyle{plain}{%
	\fancyhf{}
	\fancyhead[L]{\HtlHeader}
	\fancyfoot[L]{Brauns, Plank}
	\fancyfoot[R]{\thepage}
	\setlength{\headwidth}{1.0\textwidth}
	\setlength{\headheight}{12mm}
	\renewcommand{\headrulewidth}{0.0pt}
	\renewcommand{\footrulewidth}{0.33pt}
}

% make listoflistings its own section
\usepackage{tocbasic}
\addtotoclist[float]{lol}
\renewcommand*\lstlistoflistings{\listoftoc[{\lstlistlistingname}]{lol}}
\DeclareTOCStyleEntry[
    level=1,
    indent=1.5em,
    numwidth=2.3em
]{default}{listing}
\doforeachtocfile[float]{%
  \setuptoc{#1}{numbered}%
}


	%/* Xh Macros: */
\newcommand{\cmnt}[1]{}			%eigene Kommentier-Funktion \cmnt{ ...Kommentar... }
\newcommand\tbs{\textbackslash}		%'\textbackslash{}' isma z'long zan tippen ;-)
\newcommand{\xilist}[6]{		%XHs eigenes Auflistungs-Format
	\noindent\\[#3mm]\protect\begin{list}{#1}{\setlength\topsep{-4mm}%
	\setlength\partopsep{-1.0mm}\setlength\itemsep{#4mm}\setlength\leftmargin{#2mm}%
	\setlength\itemindent{-0.0mm}\setlength{\baselineskip}{0.9\baselineskip} }%
	#6%
	\protect\end{list}\hfill\\[#5mm]%
}


	%/* Line Spacing: */
\usepackage{setspace}
% \newcommand{\mylinespacing}[0]{\singlespace}	% 1,0-ZeilenAbstand
\newcommand{\mylinespacing}[0]{\onehalfspace}	% 1,5-ZeilenAbstand
% \newcommand{\mylinespacing}[0]{\doublespace}	% 2,0-ZeilenAbstand


	%/* serifenlose Schrift-Grundeinstellung: */
% /*Font Family:*/
%\renewcommand*{\familydefault}{\rmdefault}	%klassisches 'Roman' (statt MicroMurx...)
\renewcommand*{\familydefault}{\sfdefault}	%klassisches 'Helvetica' statt 'Murx-Arial'

%%% Autoren:
\newcommand\AB{\lfoot{Armin Brauns}}
\newcommand\DP{\lfoot{Daniel Plank}}
\newcommand\allAuth{\lfoot{Brauns, Plank}}

\newcommand\TikZ{Ti\textit{k}Z}

\newcommand{\HtlHeader}[0]{%
	%\hspace*{-11mm}%
	%\raisebox{-1mm}{\logoB{0.12}}%
	{
	 \includesvg[width=10.3mm]{pics/logoBpdf.svg}
	}
	\hspace*{2mm}%
	\parbox[b]{110mm}{\flushleft
		{\fontsize{20pt}{20pt}\selectfont\bf HTL}
		{\fontsize{16.2pt}{16.2pt}\selectfont\color{teal}\bf Anichstra\ss e}
		\\[-4.05mm]{\color{darkgray}\rule{110mm}{0.5pt}}
		\\[-2.24mm]{\fontsize{7pt}{7pt}\selectfont\color{darkgray}
			Biomedizin $\cdot$ Elektronik $\cdot$ Elektrotechnik 
			$\cdot$
			Maschinenbau $\cdot$ Wirtschaftsingenieure
			\rule{0pt}{0mm}
		%\vspace*{1.1mm}
		}
	}%
	\hspace*{5mm}%
	\raisebox{-0.2mm}{ \includegraphics[width=25mm]{pics/HTLgenlogo02}}
	\\[-1.5mm]\rule{\textwidth}{0.5pt}
	%\hfill
}%HtlHeader

\lstnewenvironment{bash}
{\lstset{numbers=left,language=bash,keywordstyle={\color{blue}}}}
{}

\definecolor{backcolour}{rgb}{0.95,0.95,0.92}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{background}{HTML}{EEEEEE}
\definecolor{delim}{RGB}{20,105,176}
\colorlet{numb}{magenta!60!black}
\colorlet{punct}{red!60!black}


\lstdefinestyle{cstyle}{
    backgroundcolor=\color{backcolour},
    commentstyle=\color{green},
    keywordstyle=\color{red},
    numberstyle=\tiny\color{codegray},
    stringstyle=\color{purple},
    basicstyle=\ttfamily\footnotesize,
    breakatwhitespace=false,
    breaklines=true,
    captionpos=b,
    keepspaces=true,
    numbers=left,
    columns=fixed,
    showspaces=false,
    showstringspaces=false,
    showtabs=false,
    tabsize=4
}

\lstdefinelanguage{json}{
    basicstyle=\normalfont\ttfamily,
    numbers=left,
    numberstyle=\scriptsize,
    stepnumber=1,
    numbersep=8pt,
    showstringspaces=false,
    breaklines=true,
    frame=lines,
    backgroundcolor=\color{background},
    literate=
     *{0}{{{\color{numb}0}}}{1}
      {1}{{{\color{numb}1}}}{1}
      {2}{{{\color{numb}2}}}{1}
      {3}{{{\color{numb}3}}}{1}
      {4}{{{\color{numb}4}}}{1}
      {5}{{{\color{numb}5}}}{1}
      {6}{{{\color{numb}6}}}{1}
      {7}{{{\color{numb}7}}}{1}
      {8}{{{\color{numb}8}}}{1}
      {9}{{{\color{numb}9}}}{1}
      {:}{{{\color{punct}{:}}}}{1}
      {,}{{{\color{punct}{,}}}}{1}
      {\{}{{{\color{delim}{\{}}}}{1}
      {\}}{{{\color{delim}{\}}}}}{1}
      {[}{{{\color{delim}{[}}}}{1}
      {]}{{{\color{delim}{]}}}}{1},
}

\lstdefinelanguage{bash}{
    basicstyle=\normalfont\ttfamily,
    numbers=left,
    numberstyle=\scriptsize,
    stepnumber=1,
    numbersep=8pt,
    showstringspaces=false,
    breaklines=true,
    frame=lines,
    backgroundcolor=\color{background},
    literate=
     *{0}{{{\color{numb}0}}}{1}
      {1}{{{\color{numb}1}}}{1}
      {2}{{{\color{numb}2}}}{1}
      {3}{{{\color{numb}3}}}{1}
      {4}{{{\color{numb}4}}}{1}
      {5}{{{\color{numb}5}}}{1}
      {6}{{{\color{numb}6}}}{1}
      {7}{{{\color{numb}7}}}{1}
      {8}{{{\color{numb}8}}}{1}
      {9}{{{\color{numb}9}}}{1}
      {:}{{{\color{punct}{:}}}}{1}
      {,}{{{\color{punct}{,}}}}{1}
      {\{}{{{\color{delim}{\{}}}}{1}
      {\}}{{{\color{delim}{\}}}}}{1}
      {[}{{{\color{delim}{[}}}}{1}
      {]}{{{\color{delim}{]}}}}{1},
}

\usepackage{titling}
\usepackage{datetime}
\yyyymmdddate
\renewcommand{\dateseparator}{-}

\setlength{\parindent}{0pt}
\setlength{\parskip}{1em}

\usepackage{footnote}

\newcommand\instrset{rv32i}

\newcommand{\entityheader}[2]{
	\lstinputlisting[style=vhdlstyle,title=\texttt{#2}]{#1}
}

\usepackage{tcolorbox}

\newtcbox{\codeBox}[1][gray]{
	on line,
	arc=2pt,
	colback=black!5,
	colupper=black!80,
	colframe=black!20,
	before upper={
		\rule[-3pt]{0pt}{10pt}
	},
	boxrule=1pt,
	boxsep=0pt,
	left=3pt,
	right=3pt,
	top=2pt,
	bottom=0pt
}
\newcommand{\icode}[1]{\codeBox{\texttt{#1}}}

\sloppy
