%%%%% title %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\title{\textbf{\huge\sffamily\tr{Introduction to\\[1ex] Scientific Computing}{Einf\"uhrung in die\\[1ex] wissenschaftliche Datenverarbeitung}}}
\author{{\LARGE Jan Grewe \& Jan Benda}\\[5ex]Abteilung Neuroethologie\\[2ex]\includegraphics[width=0.3\textwidth]{UT_WBMW_Rot_RGB}\vspace{3ex}}
\date{WS 15/16\\\vfill \centerline{\includegraphics[width=0.7\textwidth]{announcements/correlationcartoon}\rotatebox{90}{\footnotesize\url{www.xkcd.com}}}}

%%%% language %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \newcommand{\tr}[2]{#1}  % en
% \usepackage[english]{babel}
\newcommand{\tr}[2]{#2}  % de
\usepackage[german]{babel}

%%%%% packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{pslatex}   % nice font for pdf file
\usepackage[breaklinks=true,bookmarks=true,bookmarksopen=true,pdfpagemode=UseNone,pdfstartview=FitH,colorlinks=true,citecolor=blue]{hyperref}

%%%% layout %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[left=25mm,right=25mm,top=20mm,bottom=30mm]{geometry}
\setcounter{tocdepth}{1}

%%%%% section style %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[sf,bf,it,big,clearempty]{titlesec}
\setcounter{secnumdepth}{1}

%%%%% units %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[mediumspace,mediumqspace,Gray]{SIunits}      % \ohm, \micro

%%%%% graphics %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{subcaption}
\usepackage{graphicx}

%%%%%%%%%%%%% Colors %%%%%%%%%%%%%%%%
\usepackage{xcolor}
\definecolor{lightblue}{rgb}{.7,.7,1.}
\definecolor{mygreen}{rgb}{0.2,0.7,0.2}
\definecolor{myred}{rgb}{1.,0,0}
\pagecolor{white}

%%%%% figures %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% gnuplot figures:
\newcommand{\texinputpath}{}
\newcommand{\texpicture}[1]{{\sffamily\footnotesize\input{\texinputpath#1.tex}}}
\newcommand{\figlabel}[1]{\textsf{\textbf{\large \uppercase{#1}}}}

% maximum number of floats:
\setcounter{topnumber}{2}
\setcounter{bottomnumber}{0}
\setcounter{totalnumber}{2}

% float placement fractions:
\renewcommand{\textfraction}{0.2}
\renewcommand{\topfraction}{0.8}
\renewcommand{\bottomfraction}{0.0}
\renewcommand{\floatpagefraction}{0.5}

% spacing for floats:
\setlength{\floatsep}{12pt plus 2pt minus 2pt}
\setlength{\textfloatsep}{20pt plus 4pt minus 2pt}
\setlength{\intextsep}{12pt plus 2pt minus 2pt}

% spacing for a floating page:
\makeatletter
  \setlength{\@fptop}{0pt}
  \setlength{\@fpsep}{8pt plus 2.0fil}
  \setlength{\@fpbot}{0pt plus 1.0fil}
\makeatother

% rules for floats:
\newcommand{\topfigrule}{\vspace*{10pt}{\hrule height0.4pt}\vspace*{-10.4pt}}
\newcommand{\bottomfigrule}{\vspace*{-10.4pt}{\hrule height0.4pt}\vspace*{10pt}}

% captions:
\usepackage[format=plain,singlelinecheck=off,labelfont=bf,font={small,sf}]{caption}

% put caption on separate float:
\newcommand{\breakfloat}{\end{figure}\begin{figure}[t]}

%%%%% figure references %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% references to panels of a figure within the caption:
\newcommand{\figitem}[1]{\textsf{\bfseries\uppercase{#1}}}
% references to figures:
\newcommand{\panel}[1]{\textsf{\uppercase{#1}}}
\newcommand{\fref}[1]{\textup{\ref{#1}}}
\newcommand{\subfref}[2]{\textup{\ref{#1}}\,\panel{#2}}
% references to figures in normal text:
\newcommand{\fig}{\tr{Fig.}{Abb.}}
\newcommand{\Fig}{\tr{Figure}{Abb.}}
\newcommand{\figs}{\tr{Figs.}{Abb.}}
\newcommand{\Figs}{\tr{Figures}{Abb.}}
\newcommand{\figref}[1]{\fig~\fref{#1}}
\newcommand{\Figref}[1]{\Fig~\fref{#1}}
\newcommand{\figsref}[1]{\figs~\fref{#1}}
\newcommand{\Figsref}[1]{\Figs~\fref{#1}}
\newcommand{\subfigref}[2]{\fig~\subfref{#1}{#2}}
\newcommand{\Subfigref}[2]{\Fig~\subfref{#1}{#2}}
\newcommand{\subfigsref}[2]{\figs~\subfref{#1}{#2}}
\newcommand{\Subfigsref}[2]{\Figs~\subfref{#1}{#2}}
% references to figures within bracketed text:
\newcommand{\figb}{\tr{Fig.}{Abb.}}
\newcommand{\figsb}{\tr{Figs.}{Abb.}}
\newcommand{\figrefb}[1]{\figb~\fref{#1}}
\newcommand{\figsrefb}[1]{\figsb~\fref{#1}}
\newcommand{\subfigrefb}[2]{\figb~\subfref{#1}{#2}}
\newcommand{\subfigsrefb}[2]{\figsb~\subfref{#1}{#2}}

%%%%% table references %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\tref}[1]{\textup{\ref{#1}}}
% references to tables in normal text:
\newcommand{\tab}{\tr{Tab.}{Tabelle}}
\newcommand{\Tab}{\tr{Tabel}{Tabelle}}
\newcommand{\tabs}{\tr{Tabs.}{Tabellen}}
\newcommand{\Tabs}{\tr{Tabels.}{Tabellen}}
\newcommand{\tabref}[1]{\tab~\tref{#1}}
\newcommand{\Tabref}[1]{\Tab~\tref{#1}}
\newcommand{\tabsref}[1]{\tabs~\tref{#1}}
\newcommand{\Tabsref}[1]{\Tabs~\tref{#1}}
% references to tables within bracketed text:
\newcommand{\tabb}{\tr{Tab.}{Tabelle}}
\newcommand{\tabsb}{\tr{Tab.}{Tabelle}}
\newcommand{\tabrefb}[1]{\tabb~\tref{#1}}
\newcommand{\tabsrefb}[1]{\tabsb~\tref{#1}}

%%%%% equation references %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\newcommand{\eqref}[1]{(\ref{#1})}
\newcommand{\eqn}{\tr{Eq}{Gl}.}
\newcommand{\Eqn}{\tr{Eq}{Gl}.}
\newcommand{\eqns}{\tr{Eqs}{Gln}.}
\newcommand{\Eqns}{\tr{Eqs}{Gln}.}
\newcommand{\eqnref}[1]{\eqn~\eqref{#1}}
\newcommand{\Eqnref}[1]{\Eqn~\eqref{#1}}
\newcommand{\eqnsref}[1]{\eqns~\eqref{#1}}
\newcommand{\Eqnsref}[1]{\Eqns~\eqref{#1}}

%%%%% listings %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{listings}
\lstset{
  basicstyle=\ttfamily\footnotesize,
  numbers=left,
  showstringspaces=false,
  language=Matlab,
  commentstyle=\itshape\color{red!60!black},
  keywordstyle=\color{blue!50!black},
  stringstyle=\color{green!50!black},
  backgroundcolor=\color{blue!10},
  breaklines=true,
  breakautoindent=true,
%  columns=flexible,   % this kills the monospace font
  frame=single,
  caption={\protect\filename@parse{\lstname}\protect\filename@base},
  captionpos=t,
  xleftmargin=2.5em,
  xrightmargin=1mm,
  aboveskip=1ex,
  belowskip=2ex
}

%%%%%%%%%%%%%   Table stuff %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{multirow}

%%%%% math stuff: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath}
\usepackage{bm} 
\usepackage{dsfont}
\newcommand{\naZ}{\mathds{N}}
\newcommand{\gaZ}{\mathds{Z}}
\newcommand{\raZ}{\mathds{Q}}
\newcommand{\reZ}{\mathds{R}}
\newcommand{\reZp}{\mathds{R^+}}
\newcommand{\reZpN}{\mathds{R^+_0}}
\newcommand{\koZ}{\mathds{C}}

%%%%% code/matlab commands: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\code}[1]{\setlength{\fboxsep}{0.5ex}\colorbox{blue!10}{\texttt{#1}}}
\newcommand{\matlab}{MATLAB}
\newcommand{\matlabfun}[1]{(\tr{\matlab{}-function}{\matlab-Funktion} \setlength{\fboxsep}{0.5ex}\colorbox{blue!10}{\texttt{#1}})}

%%%%% exercises environment: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% usage:
%
% \begin{exercise}[somecode.m]
%   Write a function that computes the median.
% \end{exercise}
%
% result:
%
% Exercise 1:
% Write a function that computes the median.
% Listing 1: somecode.m
% the listing
%
% Innerhalb der exercise Umgebung ist enumerate umdefiniert, um (a), (b), (c), .. zu erzeugen.
\usepackage{ifthen}
\usepackage{framed}
\newcounter{maxexercise} 
\setcounter{maxexercise}{10000}  % show listings up to exercise maxexercise
\newcounter{exercise}[chapter]
\setcounter{exercise}{0}
\newcommand{\theexercise}{\arabic{exercise}}
\newcommand{\codepath}{}
\newenvironment{exercise}[2]%
{\newcommand{\exercisesource}{#1}%
  \newcommand{\exerciseoutput}{#2}%
  \setlength{\fboxsep}{2mm}%
  \newcommand{\saveenumi}{\theenumi}\renewcommand{\labelenumi}{(\alph{enumi})}%
  \renewcommand{\FrameCommand}{\colorbox{yellow!15}}%
  \MakeFramed{\advance\hsize-\width \FrameRestore}%
  \stepcounter{exercise}%
  \noindent\textbf{\tr{Exercise}{\"Ubung} \thechapter.\theexercise:}\newline}%
{\ifthenelse{\equal{\exercisesource}{}}{}%
  {\ifthenelse{\value{exercise}>\value{maxexercise}}{}%
    {\lstinputlisting[belowskip=0pt]{\codepath\exercisesource}%
      \ifthenelse{\equal{\exerciseoutput}{}}{}%
      {\addtocounter{lstlisting}{-1}\lstinputlisting[language={},title={\textbf{\tr{Output}{Ausgabe}:}},belowskip=0pt]{\codepath\exerciseoutput}}}}%
  \endMakeFramed%
  \renewcommand{\theenumi}{\saveenumi}}