%%
%% This is file `hu-berlin-bundle-style.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% hu-berlin-bundle.dtx  (with options: `sty,style')
%% ----------------------------------------------------------------
%% hu-berlin-bundle
%% Author:  Lukas C. Bossert
%% E-mail:  lukas@texografie.de
%% License: Released under the LaTeX Project Public License v1.3c or later
%% See:     http://www.latex-project.org/lppl.txt
%% Various parts my have a different licence,
%% please consider and respect them carefully.
%% ----------------------------------------------------------------
%% 
\def\Version{2021/01/31 v1.1.1}
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\ProvidesPackage{hu-berlin-bundle-style}
  [\Version\space hu-berlin - package for style the documentation]
  \PackageInfo{hu-berlin}{* * * hu-berlin * * *\MessageBreak
  Part of the hu-berlin Bundle}
\makeatletter
\addtolength\marginparwidth{-40pt}
\addtolength\marginparsep{4mm}
\addtolength\oddsidemargin{-20pt}
\addtolength\evensidemargin{-20pt}
\let\PrintDescribeMacro=\@gobble
\let\PrintDescribeEnv=\@gobble
\makeatother
\AtBeginDocument{\normalmarginpar}
\setlength\MacrocodeTopsep{.5\baselineskip}
\setlength\MacroIndent{6mm}

\RequirePackage{luatexbase}
\RequirePackage[ngerman,english]{babel}
\RequirePackage{calc}

\RequirePackage[
  paper      = a4paper,  %  - use A4 paper size
  foot       = 2cm,
  inner      = 3cm,  %  - total body: left margin (odd pages)
  top        = 3cm,  %  - total body: top margin
  outer      = 3cm,  %  - total body: right margin (odd pages)
  bottom     = 3cm,  %  - total body: bottom margin
  marginparwidth = 2cm,  %  - width for side note
  marginparsep   = .5cm,  %  - space between notes and body text (content)
]{geometry}

\newlength\fullwidth
\setlength\fullwidth{\textwidth+\marginparwidth+\marginparsep}

\KOMAoptions{
numbers    = noenddot,
}
\AtBeginDocument{
  \KOMAoptions{
footheight = 20pt,
headheight = 29pt,
captions   = tableheading,
}}

\title{\huberlintitle}
\author{\huberlinauthor}
\date{\Version}

\RequirePackage{ifluatex,luatex85}
\ifx\directlua\relax
  \let\directlua\UnDeFiNeD
\fi
\ifluatex
\else
\GenericError{hu-berlin}%
 {Please use `LuaLaTeX' as Compiler.^^J I abort here.}
\fi
\RequirePackage{fontspec}
\RequirePackage[mono=false]{libertine}
\RequirePackage{amssymb}

\defaultfontfeatures{%
  Ligatures = TeX
}
\setmainfont[%
   Ligatures = TeX
  ,Numbers   = OldStyle]{TeX Gyre Pagella}
\setmonofont[%
  Scale=1
]{TeX Gyre Cursor}
\setsansfont[%
  ,LetterSpace = .8
]{TeX Gyre Adventor-Regular}
\linespread{1.05}

\RequirePackage{marginnote}
\renewcommand*{\marginfont}{%
  \rule{0pt}{0.7\baselineskip}%
  \footnotesize%
  \color{hu-berlin-brown}}

\RequirePackage[
  german = guillemets,
  style  = german,
]{csquotes}

\RequirePackage{enumitem}
\setlist{
  nosep,
  % itemindent=1em,
  % labelindent=0.5\parindent,
  leftmargin=*}
\newlist{tabitemize}{itemize}{2}% neue Listenumgebung
\setlist[tabitemize]{%
  nosep,
  leftmargin=*
 }
\setlist[tabitemize,1]{label=\labelitemi}
\setlist[tabitemize,2]{label=\labelitemii}

\clubpenalty=10000  % prevent single lines at the beginning of a paragraph (Schusterjungen)
\widowpenalty=10000  % prevent single lines at the end of a paragraph (Hurenkinder)
\displaywidowpenalty=10000    %

\RequirePackage{pdfpages}
\RequirePackage{biblatex}
\addbibresource{\jobname-bibliography.bib}
\addbibresource{\jobname-ctan.bib}
\RequirePackage{ccicons} %creative commons
\RequirePackage{xparse}
\RequirePackage{ragged2e}
\RequirePackage{microtype}
\RequirePackage{xspace}
\RequirePackage{graphicx}
\graphicspath{{img/}}
\RequirePackage{etoolbox}
\AfterEndPreamble{%
  \maketitle
  \renewcommand\MacroFont{\ttfamily}
  \renewcommand\AltMacroFont{\ttfamily\linespread{.8}}% slanted verbatim
}

\makeatletter
\renewcommand*{\maketitle}{%
  % taken and shortened from /usr/share/texmf/tex/latex/koma-script/scrartcl.cls
  \begin{titlepage}
  \newgeometry{left=3cm,right=3cm,top=1.5cm,bottom=2cm}
  \global\@topnum=\z@
  \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
  \null
   {\large\@author\hfill \href{mailto:lukas@texografie.de}{lukas@texografie.de}\par}
  \vskip 10em%
{\begin{center}\color{hu-berlin-blue}
{\fontsize{50}{55}\selectfont\huberlinshort{} \par\vskip .5em%
\Large\sffamily\@title}\par
\vskip .5em
\end{center}}%
{\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
\null\vskip 5em%
\blockcquote[195]{Hoare1973}{Documentation must be regarded as an integral part of the process of design and coding.
 A good programming language will encourage and assist the programmer to write clear,
 self-documenting code,
 and even perhaps to develop
 and display a pleasant style
 of writing.}
\null\vfill
{\usekomafont{subtitle}{\@date \hfill
\includegraphics[width=4cm]{img/texografie-logo.pdf}\\}}%
  \par
 \vskip 0em
  \restoregeometry
  \end{titlepage}
}%
\makeatother

\RequirePackage{xcolor}
\definecolor{hu-berlin-blue}{RGB}{0,65,137} % HEX 004189
\definecolor{hu-berlin-green}{RGB}{150,190,20} % HEX 93C11A % Topoi
\definecolor{hu-berlin-grey}{RGB}{169,169,169}
\definecolor{hu-berlin-brown}{RGB}{82,79,60}
\definecolor{hu-berlin-red}{RGB}{180,0,0}

\RequirePackage{dirtree}
\renewcommand*\DTstylecomment{%
  \color{hu-berlin-grey}%
  \footnotesize%
  \sffamily}
\renewcommand*\DTstyle{%
  \ttfamily%
  \small%
  }

\RequirePackage[
  markcase    = noupper,
  footsepline = .5pt,
  % headsepline = .5pt,
  autooneside = false,% use left and right marks with a onesided document
  automark,% set \leftmark and \rightmark automatically by *\section and \subsection
  draft  = false,
  ]{scrlayer-scrpage}

\pagestyle{scrheadings}
\clearscrheadfoot
\rofoot*{\thepage}
\lofoot*{\textcolor{hu-berlin-blue}{\huberlintitle}\ \vrule\ \textcolor{hu-berlin-brown}{\huberlinsubtitle}}
\rohead*{hu-berlin-bundle}
\lohead*{Version: \Version}
\newcommand*\partnumber{}
\DeclareNewLayer[
  background,
  textarea,
  addwidth=\marginparsep+\marginparwidth,
  mode=picture,
  contents={%
\putC{\makebox[0pt][c]{\raisebox{-.5\height}{\scalebox{50}{\textcolor{black!5}{\partnumber}}}}}\gdef\partnumber{}%
  }
]{partnumber}
\DeclareNewPageStyleByLayers{part}{partnumber}
\renewcommand\partpagestyle{part}
\renewcommand*{\partformat}{\gdef\partnumber{\thepart}}

\newcommand*\changedpartwidth[1]{%
  \makebox[\linewidth][l]{%
\parbox{\dimexpr\textwidth+\marginparsep+\marginparwidth\relax}{\raggedpart#1}%
  }%
}
\addtokomafont{part}{\Huge\changedpartwidth}

\deffootnote%
  %[\normalparindent]%<width of mark>
  {0.0cm}%<indent of footnote text>
  {\normalparindent}%<paragraph indent in the footnote text>
  {\makebox[\normalparindent][r]%
  {\thefootnotemark\hspace*{3pt}}}%<definition of mark>
\newlength{\normalparindent}
\AtBeginDocument{\setlength{\normalparindent}{\parindent}}
 \setfootnoterule{0pt}% Kein Fußnotenstrich
 %\setfootnoterule[<height>]{<length>}

\renewcommand\sectionlinesformat[4]{%
  \makebox[0pt][r]{#3}#4%
}
\RequirePackage{url}

\setkomafont{title}{\sffamily\color{hu-berlin-blue}\flushleft\bfseries}
\setkomafont{disposition}{\color{hu-berlin-brown}\sffamily\bfseries\large}
\setkomafont{section}{\usekomafont{disposition}}
\setkomafont{subsection}{\usekomafont{disposition}}
\setkomafont{subsubsection}{\usekomafont{disposition}}
\setkomafont{subtitle}{\large\color{hu-berlin-brown}\sffamily\flushleft}
\setkomafont{pageheadfoot}{\footnotesize\sffamily\color{hu-berlin-grey}}
\setkomafont{descriptionlabel}{\bfseries}
\setkomafont{footnotelabel}{\bfseries}
\addtokomafont{titlehead}{\flushright}
\addtokomafont{caption}{\scriptsize}
\setkomafont{captionlabel}{\bfseries\sffamily}
\setkomafont{subject}{\bfseries\sffamily}
\setcapindent{0pt}

\raggedbottom

\RequirePackage{listings}
\PassOptionsToPackage{final}{listings}
\RequirePackage[%
   skins
  ,listings
  ,breakable
  ,xparse
  ,documentation
]{tcolorbox}
\lstMakeShortInline[language=TeX,basicstyle=\ttfamily]|
\RequirePackage{hyperxmp}
\RequirePackage{hyperref}
\hypersetup{% setup the hyperref-package options
  unicode    = true,
  pdfauthor      = {hu-berlin}, %   - author (PDF meta)
  pdfauthortitle     = {},
  pdfcopyright   = {Copyright (c) \the\year . All rights reserved.},
  pdfhighlight   = /N,
  pdfdisplaydoctitle = true,
  pdflang    = {},%de en
  pdfcaptionwriter   = {Lukas C. Bossert},
  pdfkeywords    = {hu-berlin},
  pdfencoding    = auto,
  pdfproducer    = {hu-berlin with LuaLaTeX},
  bookmarksnumbered  = true,
  bookmarksopenlevel = 2,
  bookmarksopen  = true,
  bookmarksdepth = 3,
  colorlinks     = true,    %Colours links instead of ugly boxes
  urlcolor       = hu-berlin-blue,    %Colour for external hyperlinks
  linkcolor      = black,   %Colour of internal links
  citecolor      = black,   %Colour of citations
  linktoc        = page,
  pdfborder      = {0 0 0},
  breaklinks     = true,  %allow line break inside links
  final
}
\RequirePackage{bookmark}

\RequirePackage[
  sort,
  nameinlink,
  compress,
  ngerman,english
]{cleveref}

\newcommand{\TeXografie}{Lukas C. Bossert
  (www.texografie.de)}
\newcommand\huberlin{\huberlintitle\xspace}

\newcommand\huberlinFolder{%
  \begingroup%
  \normalfont%
  \color{hu-berlin-blue}%
  % \faFolderOpen% taken from fontawesome
  \hspace{.3em}%
  \endgroup}

\RedeclareSectionCommands[
  tocraggedpagenumber,
  toclinefill=\tocpageseparator,
  tocindent=0em,
  tocnumwidth=4em,
  tocpagenumberbox=\tocpagenumberbox% <- added
]{chapter,section,subsection,subsubsection,paragraph}

\newcommand\tocgobble[1]{}% <- added
\newcommand\tocpageseparator{\footnotesize\,\mbox{---}\,}
\newcommand\tocpagenumberbox[1]{\mbox{#1}}% <- added
\KOMAoptions{toc=indentunnumbered}

\RedeclareSectionCommand[
   ,tocentryformat=\large\scshape%
   ,tocindent=0em
   ,tocnumwidth=4em
   ,tocpagenumberbox=\tocgobble% <- added
]{part}

\RedeclareSectionCommand[%
,tocentryformat=\textbf%
  %  ,toclinefill={\TOCLineLeaderFill}%\TOCLineLeaderFill[\textbf{.}]
]{chapter}

\newtcolorbox{example}[1][]{
  breakable,
  top=5pt,
  bottom=5pt,
  colback=hu-berlin-blue!10,
  colframe=hu-berlin-blue,
  left=5pt,
  right=5pt,
   sharp corners,
  boxrule=0pt,
  bottomrule=2pt,
  toprule=2pt,
   enhanced jigsaw,
  lefttitle=0pt,
   coltitle=white,
   fonttitle=\bfseries,
   fontupper=\small,%\ttfamily,
  % colbacktitle=hu-berlin-blue!20
  #1,
}

\makeatletter
\def\lst@visiblespace{\lst@ttfamily{\char32}$\textcolor{hu-berlin-grey}{\cdot}$}
\makeatother

\lstset{%
  basicstyle = \linespread{0.7}\ttfamily
 ,breaklines = true
 ,breakatwhitespace
 ,alsoletter=\\\{\}\*\[\]\-
 ,showstringspaces=true
 }

\lstdefinestyle{hu-berlinlistingstyledef}{%
  tabsize      = 4,
  breaklines   = true,
  breakatwhitespace = true,
  postbreak=\mbox{$\hookrightarrow$},
  %keepspaces   = true,
  escapeinside = {(*@}{@*)},
  moredelim    = {[is][\ttfamily\bfseries\color{hu-berlin-blue}]{|}{|}},
  moredelim    = {[is][\ttfamily\bfseries\color{hu-berlin-blue}]{|1}{1|}},
  moredelim    = {[is][\ttfamily\bfseries\color{hu-berlin-red}]{|2}{2|}},
  aboveskip=0pt,
  belowskip=0pt,
  captionpos=b,
  resetmargins=true,
  sensitive=true,
  upquote=true,
  showspaces=true,
  showtabs=true,
  tab=\textcolor{hu-berlin-grey}{\rightarrowfill},
  %numbers=left,
  %numberstyle=\footnotesize\ttfamily\color{hu-berlin-grey},
  comment      = [l]{\%},
  commentstyle = \footnotesize\color{hu-berlin-grey}\addfontfeature{LetterSpace=.7},
  % deletecomment = [l]{\%<}
  % morecomment  = [l][\nullfont]{\%<},
  % deletecomment  = [is]{\%<}{>},
}

\lstdefinestyle{hu-berlinlistingstyle}{%
  language  = {TeX},
  style     = {hu-berlinlistingstyledef},
}

\tcbset{%
hu-berlinstyle/.style={%
  enhanced,
  before skip=2mm,
  after skip=3mm,
  boxrule=0.7pt,
  left=2mm,
  right=2mm,
  top=2mm,
  bottom=2mm,
  sharp corners,
  colback=white,
  colbacklower=white,
  % fonttitle=\sffamily\bfseries,
  breakable,
  %before skip=\baselineskip,
  coltitle=white,
  colbacktitle=hu-berlin-blue!50!black,
  fonttitle=\bfseries\sffamily\footnotesize,
  % before upper={\mynote{\thetcbcounter}},
  title={\hfill{Example \thetcbcounter}},
  },
codecomment/.style={%
  listing outside comment,%
  boxrule=0pt,
  colback=white,
  }
}

\newtcolorbox{warning}[1][]{
  enhanced,
  before skip=2mm,
  after skip=3mm,
  boxrule=0.7pt,
  left=5mm,
  right=2mm,
  top=2mm,
  bottom=2mm,
  colback=white,
  colframe=yellow!20!black,
  sharp corners,
  rounded corners=southeast,
  arc is angular,
  arc=3mm,
  underlay={%
\path[fill=hu-berlin-grey!80!black] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
\path[draw=hu-berlin-grey,shorten <=-0.05mm,shorten >=-0.05mm] ([yshift=3mm]interior.south east)--++(-0.4,-0.1)--++(0.1,-0.2);
\path[fill=red!50!black,draw=none] (interior.south west) rectangle node[white]{\Huge\bfseries !} ([xshift=4mm]interior.north west);
},
  drop fuzzy shadow,
  #1
  }

\newtcblisting[%
  auto counter,
  crefname   = {example}{examples},
  Crefname   = {Example}{Examples},
]{codetext}[2][]{%
  hu-berlinstyle,
  rounded corners=northeast,
  arc=6mm,
  listing style=hu-berlinlistingstyle,
  label = #2,
  #1,
  }

\newtcblisting[%
  use counter from=codetext,
  crefname={code example}{code examples},
  Crefname={Code example}{Code examples}%
]{code}[2][]{%
  hu-berlinstyle,
  rounded corners=southeast,
  arc=6mm,
  listing only,
  listing style=hu-berlinlistingstyle,
  label = #2,
  #1,
}

\DeclareTCBInputListing[%
  use counter from=codetext,
  crefname={code example}{code examples},
  Crefname={Code example}{Code examples}%
]{\huberlinlisting}{ O{} m }{%
  hu-berlinstyle,
  listing file={#2},
  listing only,
    listing style=hu-berlinlistingstyle,
  #1,
}

\makeatletter
\newrobustcmd*{\fnurl}[1][]{\hyper@normalise\ltd@fnurl{#1}}
\def\ltd@fnurl#1#2{\footnote{#1\hyper@linkurl{\Hurl{#2}}{#2}}}
\makeatother
\RequirePackage{newfile}
\newoutputstream{pkglist}
\NewDocumentCommand{\pkg}{om}{%
  \IfNoValueTF{#1}
{\lowercase{\href{http://www.ctan.org/pkg/#2}}{\textbf{#2}}}
{\lowercase{\href{http://www.ctan.org/pkg/#1-#2}}{\textbf{#2}}}%
\space\cite{#2}%
\addtostream{pkglist}{#2}}
\newrobustcmd*{\lit}[1]{\textsf{#1}}
\newrobustcmd*{\Code}[1]{\texttt{#1}}
\newrobustcmd*{\tex}{\TeX}
\newrobustcmd*{\etex}{\mbox{e-TeX}}
\newrobustcmd*{\pdftex}{pdf\-\tex}
\newrobustcmd*{\xetex}{Xe\-\tex}
\newrobustcmd*{\luatex}{Lua\-\tex}
\newrobustcmd*{\latex}{\LaTeX}%{La\kern-0.07em TeX}
\newrobustcmd*{\pdflatex}{pdf\-\latex}
\newrobustcmd*{\xelatex}{Xe\-\latex}
\newrobustcmd*{\lualatex}{Lua\-\latex}
\newrobustcmd*{\miktex}{Mik\-\tex}
\newrobustcmd*{\texlive}{\tex~live}
\newrobustcmd*{\bibtex}{Bib\kern-0.07em TeX}
\newrobustcmd*{\lppl}{\latex{} Project Public License}
\newrobustcmd*{\pdf}{{PDF}}
\newrobustcmd*{\md}{{MarkDown}}
\newrobustcmd*{\utf}{\mbox{{UTF}-8}}
\newrobustcmd*{\bibfield}[1]{\Code{#1}}
\newrobustcmd*{\opt}[1]{\Code{#1}}
\newrobustcmd*{\bibmacro}[1]{\Code{#1}}
\newrobustcmd*{\bibtype}[1]{\Code{@#1}}
\renewrobustcmd\meta[1]{\normalfont{\textlangle}{\itshape#1\/}{\textrangle}}

\renewrobustcmd\marg[1]{%
  {\ttfamily\textcolor{hu-berlin-red}{\{}}%
   \meta{#1}%
  {\ttfamily\textcolor{hu-berlin-red}{\}}}%
  }

\renewrobustcmd\oarg[1]{%
  {\ttfamily\textcolor{hu-berlin-green}{[}}%
   \meta{#1}%
  {\ttfamily\textcolor{hu-berlin-green}{]}}%
  }

\renewrobustcmd\cmd[1]{%
  \texttt{\color{hu-berlin-blue}\textbackslash\string#1}\xspace%
  }

\newrobustcmd\env[2][]{%
  \texttt{%
\color{hu-berlin-blue}%
\textbackslash begin\{\string#2\}#1}%
  \ldots
  \texttt{%
\color{hu-berlin-blue}%
\textbackslash end\{\string#2\}}%
  \xspace}
\newcommand\param[1]{%
  \begingroup%
  \normalfont%
  \ttfamily%
  \bfseries%
  \textless%
  #1%
  \ttfamily%
  \bfseries%
  \textgreater%
  \endgroup}
\pdfstringdefDisableCommands{%
 \def\lstinline#1{<#1>}
 \def\tex{TeX}%
 \def\etex{e-TeX}%
 \def\xetex{XeTeX}%
 \def\latex{LaTeX}%
 \def\xelatex{XeLaTeX}%
 \def\bibtex{BibTeX}%
 \def\lppl{LaTeX Project Public License}%
 \def\pdf{PDF}%
 \def\utf{UTF-8}%
 \def\\{}%
 \def\texttt#1{<#1>}%
 \def\marg#1{\{#1\}}%
 \def\oarg#1{[#1]}%
 \def\color#1#2{}%
 \def\env#1{<#1>}
 \def\cmd#1{#1}
}
\makeatletter
\patchcmd{\scr@startchapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\makeatother
\RequirePackage[tightLists=false]{markdown}
\markdownSetup{rendererPrototypes={%
link = {\href{#3}{#1}}%
}}
%% 
%% Copyright (C) 2019-2020
%%
%% End of file `hu-berlin-bundle-style.sty'.
