\ProvidesPackage{starstyle}
%%%%
%% Package for styling the output (primarily in pdf)
%%%%

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Number sections down to subsubsection level
\setcounter{secnumdepth}{4}

% %%% Formatting of the section headging
\newcommand{\colorsection}[1]{%
\colorbox{bblue}{\strut\parbox{\dimexpr\textwidth-2\fboxsep}{\thesection\ \quad #1}{\huge\strut}}}

\newcommand{\colorsectionnumberless}[1]{%
\colorbox{bblue}{\strut\parbox{\dimexpr\textwidth-2\fboxsep}{#1}\strut}}


% % Section headings (including numberless)

\ifpdf
\titleformat{name=\section}%
{\normalfont\Large\bfseries}{}{0pt}{\colorsection}
\titleformat{name=\section,numberless}%
{\normalfont\Large\bfseries}{}{0pt}{\colorsectionnumberless}
\fi

%... Chapter headings
\ifwithchapters
  \titleformat{name=\chapter}[display]%
  {\normalfont\huge\bfseries\thispagestyle{plain}}{%
    \chaptertitlename\ \thechapter}{0pt}{}

  \titleformat{name=\chapter,numberless}[display]%
  {\normalfont\huge\bfseries\thispagestyle{plain}}{}{0pt}{\Huge}

  %... spacing after chapter headings
  \titlespacing*{\chapter}{0pt}{0pt}{20pt}

\fi


%.. section spacing
\titlespacing*{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{\subsection}{0pt}{2ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\subsubsection}{0pt}{2ex plus 1ex minus .2ex}{1ex plus .2ex}
\titlespacing*{\paragraph}{0pt}{2ex plus 1ex minus .2ex}{1em}
\titlespacing*{\subparagraph}{\parindent}{2ex plus 1ex minus
  .2ex}{1em}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% Page styles (e.g. headers and footers)

\pagestyle{fancy}
\fancyhf{}
\rhead{\slshape \thestardocinitials{}/\thestardocnumber{} \leftmark}
\lhead{\thepage}
\renewcommand{\headrulewidth}{0.0pt}


\ifwithchapters
\renewcommand{\chaptermark}[1]{
  \markboth{#1}{}}
\else
\renewcommand{\sectionmark}[1]{
  \markboth{#1}{}}
\fi

% .. Reset the plain pagestyle (used on chapter pages) to only have
% the page number and no rules. 
\fancypagestyle{plain}{%
\fancyhf{}%

\iftwoside
\fancyhead[RE,LO]{\thepage}%
\fancyhead[LE,RO]{\slshape
  \thestardocinitials{}/\thestardocnumber{}\nouppercase{---\leftmark}}%
\else
\fancyhead[LO]{\thepage}
\fancyhead[RO]{\slshape
\thestardocinitials{}/\thestardocnumber{}\nouppercase{---\leftmark}}%
\fi

\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0pt}%
}

% ensure correct chaptermakr is used when in pagestyle plain
\pagestyle{plain}
\fancyhf{}

\iftwoside
\fancyhead[LE,RO]{\slshape \thestardocinitials{}/\thestardocnumber{} \nouppercase{---\leftmark}}
\fancyhead[RE,LO]{\thepage}
\else
\lhead{\slshape \thestardocinitials{}/\thestardocnumber{} \nouppercase{---\leftmark}}
\rhead{\thepage}
\fi

\renewcommand{\headrulewidth}{0.0pt}

\ifwithchapters
\renewcommand{\chaptermark}[1]{
  \markboth{#1}{}}
\else
\renewcommand{\sectionmark}[1]{
  \markboth{#1}{}}
\fi


\renewcommand{\headrulewidth}{0pt}%
\renewcommand{\footrulewidth}{0pt}%

\ifwithchapters
\renewcommand{\chaptermark}[1]{\markboth{{#1}}{}}%
\else
\renewcommand{\sectionmark}[1]{\markboth{{#1}}{}}%
\fi

%% Select the fancy pagestyle as default
\pagestyle{fancy}




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% General spacing
\setlength{\headheight}{1.5cm}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\renewcommand{\arraystretch}{1.5}


%%%% Set up defaults for floats
% maximum size of 'top area'
\renewcommand{\topfraction}{0.9}
% maximum size of 'bottom area'
\renewcommand{\bottomfraction}{0.9}
% minimum amount of text on a non-float page
\renewcommand{\textfraction}{0.1}



%Enumerate list appearance
\setlist[enumerate,1]{label=(\arabic*)}


% macros for typesetting parameters
\providecommand{\aparam}[1]{\texttt{#1}}     % ADAM parameter
\providecommand{\cparam}[1]{\texttt{#1}}     % CONFIG parameter
\providecommand{\ndfcomp}[1]{\texttt{#1}}    % NDF component



\newcommand{\menuitem}[2]{\item[\protect{\hyperref[#1]{#1}}] #2}
\newcommand{\classitem}[1]{\item [\protect{\hyperref[#1]{#1}}]}