% Copyright (C) nemadesign GbR
% $Rev: 56 $:     
% $Date: 2014-09-20 13:52:19 +0200 (Sa, 20. Sep 2014) $:    

% This file contains settings and macros which are used in
% all variants for the siemens stylesheets

\usepackage[scaled]{uarial}                               % Font is Arial
\fontfamily{phv}\fontseries{m}\fontshape{n}\selectfont    % Arial for Headings
\setkomafont{sectioning}{\sffamily\bfseries}
\renewcommand{\familydefault}{\sfdefault}
\usepackage[T1]{fontenc}

%\usepackage[ngerman]{babel}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage[pdftex]{rotating,graphicx}
\usepackage{multirow} 
\usepackage{layout}
\usepackage{lipsum}
\usepackage{subfigure} 
\usepackage{multicol,listings}
\usepackage{courier}
\usepackage[automark]{scrpage2}

\usepackage{titlesec}
\usepackage{scrpage2}
\usepackage{chngcntr}
\usepackage[table,usenames,dvipsnames]{xcolor}
\usepackage{booktabs}
\usepackage{color}
\usepackage{longtable}
\usepackage{colortbl}
\usepackage{fp}
\usepackage{eso-pic,picture}
\usepackage[absolute]{textpos}
\usepackage{multicol}
\usepackage{cite}
\usepackage{titletoc}
\usepackage{moresize}
\usepackage{printlen}
\usepackage{setspace}

% Siemens specific packages
\usepackage[plain]{algorithm}
\usepackage{algorithmic}
\usepackage{array} % for tabular
\usepackage{pifont} % for \myCheck, \myCross
\usepackage[hyphens]{url}
\usepackage[hidelinks]{hyperref} % hyperref without colored links
\usepackage{balance} % for balancing the bibliography
\usepackage{ifthen}


% set title and date in headline
\newcommand{\shorttitle}{Default short title}
\newcommand{\shortdate}{\today}
\newcommand{\copyrightdate}{\today}

% nobody likes Hurenkinder und Schusterjungen
\hyphenpenalty        = 500
\tolerance            = 800
\widowpenalty         = 300
\clubpenalty          = 300
\displaywidowpenalty  = 10000

% change table background colors
\definecolor{lightgray}{gray}{0.9}
\let\oldtabular\tabular
\let\endoldtabular\endtabular
\renewenvironment{tabular}{\rowcolors{2}{white}{lightgray}\oldtabular}{\endoldtabular}

% thick hline in tables
\newcommand{\thickhline}{%
    \noalign {\ifnum 0=`}\fi \hrule height 1pt
    \futurelet \reserved@a \@xhline
}

% global counters for tables and figures
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\counterwithout{footnote}{chapter}
% left align captions
\usepackage[
singlelinecheck=false % <-- important
]{caption}

% No title for TOC
\renewcommand*{\tocbasic@listhead}[1]{%
  \typeout{Ueberschrift ``#1'' nicht ausgeben}%
}


\pagestyle{scrheadings}

% set headline and footline
\lehead{} 
\lohead{}
\cehead{}
\cohead{} 
\rehead{\shorttitle \;| \shortdate}
\rohead{\shorttitle \;| \shortdate}

\lefoot{Restricted \copyright \; Siemens AG \the\year. All rights reserved.}
\lofoot{Restricted \copyright \; Siemens AG \the\year. All rights reserved.}
\cefoot{}
\cofoot{}
\refoot{\thepage}
\rofoot{\thepage}

%\pagestyle{scrheadings}
\deftripstyle{myemptypage}{}{}{}{\thepage}{}{}
\KOMAoptions{cleardoublepage=myemptypage}

% headings and footings for chapter
\renewcommand{\chapterpagestyle}{scrheadings}

% no gap at beginning of chapter
\renewcommand*{\chapterheadstartvskip}{\vspace*{-\topskip}}

% small gap at the end of chapter
\renewcommand*{\chapterheadendvskip}{\vspace{3.0\baselineskip}}


% color definition
\definecolor{orange}{rgb}{0.92,0.47,0.04} % HEX 235 120 10
\definecolor{grey1}{rgb}{0.53,0.61,0.67}	% HEX 135 155 170
\definecolor{grey2}{rgb}{0.31,0.39,0.45}	% HEX 80 100 115

% font style for listings
\lstset{basicstyle=\footnotesize\ttfamily,breaklines=true}
\lstset{framextopmargin=0pt,frame=single}

% stripped pagewidth for title page
\newcommand{\Pw}{\strip@pt\paperwidth}


% sytle for LOF
\addtocontents{lof}{\protect\vspace{0pt}}
\renewcommand*\l@figure{\mdseries\bprot@dottedtocline{1}{0em}{3.0em}}



% shift everything up
\newcommand{\squeezeup}{\vspace{-5mm}}
\titlespacing*{\chapter}{0pt}{0pt}{40pt}

\addtokomafont{sectioning}{\color{orange}}
\def\thespread{30}
\addtokomafont{chapter}{\fontsize{28pt}{1.0}\linespread{\thespread}\selectfont}
\setkomafont{pagehead}{
\normalfont\sffamily}
\setkomafont{pagefoot}{
\normalfont\sffamily}
\setkomafont{pagenumber}{
\normalfont\sffamily}
\addtokomafont{pagenumber}{\color{grey1}} 
\addtokomafont{pagefoot}{\color{grey1}} 
\addtokomafont{pagehead}{\color{grey1}} 

% Make nicer table and figure captions
\setkomafont{captionlabel}{\sffamily\bfseries}
\setkomafont{caption}{\sffamily}

% same identation for all lines in footnotes
\deffootnote{1em}{1em}{\thefootnotemark\ }

% Set first row for tables to bold text
\newcolumntype{$}{>{\global\let\currentrowstyle\relax}}
\newcolumntype{^}{>{\currentrowstyle}}
\newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
  #1\ignorespaces
}

% Macros by nemadesign
\setlength{\fboxsep}{0pt}
\setlength\fboxrule{0.1pt}
\newcommand{\moveup}{\vspace{-7mm}}
\newcommand{\movedown}{\vspace{10mm}}
\newcommand{\picgap}{\vspace{8mm}}
\newcommand{\picgapsmall}{\vspace{0mm}}


% Macros by Siemens
\newcommand{\printAuthors}[2][\empty]
{
  \clearpage % this is important
  \begin{minipage}[b][\textheight]{\textwidth}
    \begin{oldtabular}{rp{0.8\columnwidth}}
      \multicolumn{2}{l}{Authors} \\ 
      & #2
    \end{oldtabular}
    \ifthenelse{\equal{#1}{\empty}}
    {\empty}
    {
      \begin{oldtabular}{rp{0.8\columnwidth}}
        \\
        \multicolumn{2}{l}{Contributors} \\ 
        & #1
      \end{oldtabular}
    } \\
  \end{minipage}
  \clearpage % this is important
}




