% SPDX-License-Identifier: CC-BY-SA-4.0
%
% Copyright (c) 2020 Philipp Le
%
% Except where otherwise noted, this work is licensed under a
% Creative Commons Attribution-ShareAlike 4.0 License.
%
% Please find the full copy of the licence at:
% https://creativecommons.org/licenses/by-sa/4.0/legalcode

\documentclass[%
	a4paper,%
	twoside,%
	%bibliography=totocnumbered,
	numbers=noenddot,%
	parskip=half,%
	headsepline,%
	footsepline,%
	headings=small,%
	12pt,%
]{scrreprt}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Language and fonts
\usepackage[UKenglish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[OT2,T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}
\usepackage{array}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Graphics

\usepackage{graphicx}
\usepackage{pdfpages}

% TikZ
\usepackage{tikz}
\usepackage{pgf}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest}
\pgfplotsset{
	scriptsize/.style={
		width=4.5cm,
		height=,
		legend style={font=\scriptsize},
		tick label style={font=\scriptsize},
		label style={font=\footnotesize},
		title style={font=\footnotesize},
		every axis title shift=0pt,
		max space between ticks=15,
		every mark/.append style={mark size=7},
		major tick length=0.1cm,
		minor tick length=0.066cm,
	},
}
\pgfplotsset{legend cell align=left}
\pgfplotsset{xmajorgrids}
\pgfplotsset{ymajorgrids}
\pgfplotsset{scale only axis}
\pgfplotsset{every axis plot/.append style={line width=1pt}}
\addto\extrasngerman{\pgfplotsset{/pgf/number format/.cd,set decimal separator={{{,}}}}}
\pgfplotsset{/pgf/number format/.cd,1000 sep={\,}}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.arrows}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{math}
\usepackage{pgf-umlsd}

% Circuits
\usepackage[european]{circuitikz}

% Custom TikZ blocks
\tikzset{
	block/.style={
		rectangle,
		align=center,
		minimum height=1cm,
		inner sep=.5cm,
		rounded corners=.15cm
	}
}

% Colours
\usepackage{xcolor}
\usepackage{color}

% Subfigures
\usepackage{subfig}

% Controlling floats
%\renewcommand{\topfraction}{0.8}
%\renewcommand{\bottomfraction}{0.33}
%\renewcommand{\floatpagefraction}{0.66}
%\renewcommand{\textfraction}{0.10}

% Custom functions
\tikzmath{
	function sinc(\x) {
		if  abs(\x) < .001 then { % (|x| < .001) ~ (x = 0)
			return 1;
		} else {
			return sin(\x r)/\x;
		};
	};
}
\tikzmath{
	function asinc(\x, \y) {
		if  abs(\x) < .001 then { % (|x| < .001) ~ (x = 0)
			return 1;
		} else {
			return sin(\y * deg(\x) / 2)/(\y * sin(deg(\x)/2));
		};
	};
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Symbols

\usepackage{textcomp}

% Mathematics
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{bm}
\usepackage{trsym}

% Quotes
\usepackage{csquotes}

% Formatting units
\usepackage[load-configurations=binary]{siunitx}
\sisetup{per-mode=fraction,mode=math}
\addto\extrasngerman{\sisetup{output-decimal-marker={,}}}
\addto\extrasenglish{\sisetup{output-decimal-marker={.}}}
\addto\extrasngerman{\sisetup{range-phrase={ bis~}}} 
\addto\extrasenglish{\sisetup{range-phrase={ to~}}}

% Cyrillic
\DeclareSymbolFont{cyrletters}{OT2}{wncyr}{m}{n}
\DeclareMathSymbol{\Sha}{\mathalpha}{cyrletters}{"58}

% Custom symbols
%\newcommand{\vect}[1]{\boldsymbol{\vec{\mathbf{#1}}}}
\newcommand{\vect}[1]{\vec{\bm{#1}}}
\newcommand{\cmplxvect}[1]{\vect{\underline{#1}}}
\newcommand{\mat}[1]{\bm{\mathrm{#1}}}
\newcommand{\E}{\mathrm{E}}
\newcommand{\Var}{\mathrm{Var}}
\newcommand{\Cov}{\mathrm{Cov}}
\def\j{\mathsf{j}}
\DeclareMathOperator*{\argmax}{arg\,max}
\DeclareMathOperator*{\argmin}{arg\,min}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Tables

% Lines for Tables
\usepackage{booktabs}

\usepackage{multirow}
\usepackage{longtable}

\usepackage{makecell}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Page layout

\usepackage{setspace}
\onehalfspacing

\usepackage[a4paper, margin=2.5cm, headheight=22pt]{geometry}

\usepackage{pdflscape}

\usepackage[bottom]{footmisc}
\interfootnotelinepenalty=10000

% Don't restart footnote count on each chapter
\let\counterwithout\relax
\let\counterwithin\relax
\usepackage{chngcntr}
\counterwithout{footnote}{chapter}
%\usepackage{remreset}
%\makeatletter
%\@removefromreset{footnote}{chapter}
%\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Formatting

\usepackage[normalem]{ulem}

\usepackage{adjustbox}
\usepackage{xspace}
\usepackage{xfrac}
\usepackage{bigfoot}

%\usepackage{float}
%\usepackage{rotating}
\usepackage{rotfloat}

% make \emph{} bold
%\makeatletter
%\DeclareRobustCommand{\em}{%
%  \@nomath\em \if b\expandafter\@car\f@series\@nil
%  \normalfont \else \bfseries \fi}
%\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Bibliography

\usepackage[backend=biber,sorting=none]{biblatex}
\addbibresource{../DCS.bib}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Directories

\usepackage[subfigure]{tocloft}

% Acronyms
\usepackage[printonlyused]{acronym}

%\usepackage[xindy,numberedsection,section=section,toc]{glossaries}
%\makeglossaries
%\GlsSetXdyCodePage{duden-utf8}

% Indicies
\usepackage[xindy]{imakeidx}
\makeindex[title=Index]

% ToDo list
\newlistof{todos}{mcf}{To Do}
\newcommand{\todo}[1]{\texttt{\textbf{\#\# TODO \#\# #1 \#\#}} \addcontentsline{mcf}{todos}{#1}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Nomenclature

\usepackage[english]{nomencl}
\makenomenclature
%\usepackage{etoolbox}


\renewcommand\nomgroup[1]{%
	\item[\bfseries
	\ifstrequal{#1}{C}{Physics Constants}{%
		\ifstrequal{#1}{N}{Notation}{%
			\ifstrequal{#1}{S}{Symbols}{%
				\ifstrequal{#1}{F}{Functions}{%
					\ifstrequal{#1}{B}{Block Symbols}{%
					}%
				}%
			}%
		}%
	}%
]}

\newcommand{\nomunit}[1]{%
	\renewcommand{\nomentryend}{\hspace*{\fill}#1}}

\nomenclature[C]{$c$}{Speed of light}

\nomenclature[Na]{$\underline{a}$}{Value, explicitly marked complex valued}
\nomenclature[Nb]{$\vect{a}$}{Vector}
\nomenclature[Nba]{$\vect{\underline{a}}$}{Vector, explicitly marked complex valued}
\nomenclature[Nc]{$\mat{A}$}{Matrix}
\nomenclature[Nca]{$\mat{\underline{A}}$}{Matrix, explicitly marked complex valued}
\nomenclature[Nxa]{$\underline{x}(t)$}{Analog signal in time domain}
\nomenclature[Nxb]{$\underline{X}(\j \omega)$}{Analog signal in frequency domain (Fourier transform)}
\nomenclature[Nxb]{$\underline{X}(\underline{s})$}{Analog signal in frequency domain (Laplace transform)}
\nomenclature[Nxc]{$\underline{x}[k] = \underline{x}\left(k T_S\right)$}{Digital signal in time domain, with sampling period $T_S$}
\nomenclature[Nxd]{$\underline{X}(\underline{z})$}{Digital signal in frequency domain (z-transform)}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Listings

\usepackage{listings}
\usepackage{algorithm2e}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Exercises

\usepackage{exsheets}
\SetupExSheets{
	headings = block-subtitle,
	headings-format = \bfseries\sffamily,
	subtitle-format = \bfseries\sffamily,
	counter-within = chapter,
	counter-format = ch.qu\IfQuestionSubtitleT{:},
	toc-level = {subsection},
	% solution/print = true % uncomment for tutors
}
\usepackage{tasks}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PDF Metadata

\input{../build/vcs_info.tex}

\def\hyperrefgeneraltitle{Digital Communication Systems - \thekindofdocument{}}
\ifdefined\thesubtitle
\def\hyperreftitle{\hyperrefgeneraltitle{} - \thesubtitle{}}
\else
\def\hyperreftitle{\hyperrefgeneraltitle{}}
\fi

\usepackage[
	pdftitle={\hyperreftitle{}},
	pdfauthor={Philipp Le},
	pdfcreator={LaTeX with hyperref and KOMA-Script on Arch Linux, Git commit \VcsCommitHashLong (\VcsCleanStr{}\VcsDirtyStr{})},
	pdfsubject={},
	pdfkeywords={},
	pdfstartview={Fit},
	pdflang={en-GB},
	pdfduplex={DuplexFlipLongEdge},
	%hidelinks,
]{hyperref}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Own commands

\newcommand{\licensequote}[3]{\textit{Reproduced from #1. Copyright by #2. License: #3.}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Own environments

\usepackage{tcolorbox}
\tcbuselibrary{breakable, skins}

\newenvironment{attention}{%
	\begin{tcolorbox}[colframe=red]%
	{\sffamily\bfseries Attention!}\par%
}{%
	\end{tcolorbox}%
}

\newenvironment{definition}[1]{%
	\begin{tcolorbox}[enhanced jigsaw, breakable, colframe=gray]%
	{\sffamily\bfseries Definition: #1}\par%
}{%
	\end{tcolorbox}%
}

\newenvironment{fact}{%
	\begin{tcolorbox}[colframe=gray!80]%
	\bfseries%
}{%
	\end{tcolorbox}%
}

\newenvironment{proof}[1]{%
	\begin{tcolorbox}[enhanced jigsaw, breakable, colframe=black]%
	{\sffamily\bfseries Proof: #1}\par%
}{%
	\end{tcolorbox}%
}

\newenvironment{derivation}[1]{%
	\begin{tcolorbox}[enhanced jigsaw, breakable, colframe=black]%
	{\sffamily\bfseries Derivation: #1}\par%
}{%
	\end{tcolorbox}%
}

\newenvironment{example}[1]{%
	\begin{tcolorbox}[enhanced jigsaw, breakable, colframe=black!60]%
	{\sffamily\bfseries Example: #1}\par%
}{%
	\end{tcolorbox}%
}

\newenvironment{excursus}[1]{%
	\begin{tcolorbox}[enhanced jigsaw, breakable, colframe=gray!40]%
	{\sffamily\bfseries Excursus: #1}\par%
}{%
	\end{tcolorbox}%
}

\newenvironment{remark}{%
	\textit{Remark:} %
}{%
}

\newenvironment{conclusion}{%
	\begin{tcolorbox}[enhanced jigsaw, breakable, colframe=black]%
	{\sffamily\bfseries Conclusion:}\par%
}{%
	\end{tcolorbox}%
}


