% biblatex-socialsciences|huberlin --%
% Copyright (c) 2018 and
% maintained by Lukas C. Bossert
%  
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.

%%%%% Disclaimer %%%%%%%%%%%%%%%%%%%%%
% The code of this documentation     %
% has been taken form 'biblatex-ext' %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
\documentclass[DIV=11]{scrartcl}
\usepackage{ifxetex,ifluatex}
\newif\iffontspec
\ifxetex
  \fontspectrue
\else\ifluatex
  \fontspectrue
\else 
  \fontspecfalse
\fi\fi
\iffontspec
  \usepackage{fontspec}
\else
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc} 
\fi
\usepackage[british]{babel}
\usepackage{csquotes}


\usepackage[useregional]{datetime2}
\iffontspec  
\setmainfont[ 
%  Scale       = 0.95,
%  Numbers  = {OldStyle},
  Numbers={Proportional},
%	BoldItalicFont = Gentium Book Basic Bold Italic,
 	Ligatures   = TeX,
  BoldFont={Gentium Basic Bold},
%	BoldFont    = GenBasB,
%  BoldFont={Gentium Basic Bold},
]{Gentium Plus}
\setsansfont[
  Ligatures     = TeX,
  BoldFont      = Dosis-SemiBold,
  ItalicFont    = Dosis-Regular,
  ItalicFeatures={FakeSlant=0.25}
]{Dosis-Light}
\else
\usepackage{lmodern} 
\usepackage[mono=false]{libertine}
\usepackage[libertine]{newtxmath}
  \usepackage[scaled=0.78]{beramono}
\fi
\usepackage{microtype}
\usepackage{hyphenat}
\usepackage{bm}
\usepackage{booktabs}
\usepackage{multicol}
\usepackage{upquote}
\usepackage[svgnames]{xcolor}
\usepackage[listings, breakable, skins]{tcolorbox}%
\usetikzlibrary{arrows.meta}
\usepackage[style=socialscienceshuberlin, backend=biber]{biblatex}
\addbibresource{socialscienceshuberlin-examples.bib}

\usepackage[ 
  headsepline, 
  footsepline,
  automark, 
  draft=false,
]{scrlayer-scrpage} 
\pagestyle{scrheadings}
\clearscrheadfoot
\rohead{\texttt{bib}\LaTeX-style \texttt{socialsciences|huberlin \socialscienceshuberlinversion}}%
\lohead{\copyright\ by Lukas C. Bossert}
\rofoot{\normalfont\footnotesize  \textbf{\sffamily \thepage}}
\lofoot{\normalfont\footnotesize  \href{http://digitales-altertum.de}{digitales-altertum|de}}
\setkomafont{pageheadfoot}{\normalfont\footnotesize}
\setkomafont{footnotereference}{\normalfont\addfontfeature{Numbers=Lining}\selectfont}
\addtokomafont{footnotenumber}{\footnotesize\normalfont}
\deffootnote%
  %[\normalparindent]%<width of mark>
  {0.075cm}%<indent of footnote text>
  {\normalparindent}%<paragraph indent in the footnote text>
  {\makebox[\normalparindent][r]%
  {\thefootnotemark\hspace*{4pt}}}%<definition of mark>
\newlength{\normalparindent}
\AtBeginDocument{\setlength{\normalparindent}{\parindent}}
 \setfootnoterule{0pt}% Kein Fußnotenstrich
 %\setfootnoterule[<height>]{<length>}

\makeatletter
\iffontspec
\def\textvisiblespace{%
  \raisebox{-2.2pt}{%
    \mbox{\kern.04em\vrule \@height.5ex \@width.12ex}%
    \vbox{\hrule \@width.2em \@height.12ex}%
    \hbox{\vrule \@height.5ex \@width.12ex}%
    \kern.04em}}
\fi
\makeatother


\usepackage{ltxdockit}
\usepackage{btxdockit}
\usepackage{cleveref}
\hypersetup{%
  colorlinks=true,
  allcolors=spot,
  bookmarksopen=true,
  bookmarksnumbered=false,
  plainpages=false}

\definecolor{highlight1}{RGB}{240, 0, 0}
\definecolor{highlight2}{RGB}{0,153, 153}
\definecolor{spot}{rgb}{0,0.2,0.6}

\lstdefinestyle{extblxstylegeneral}{%
  aboveskip    = {0\p@ \@plus 6\p@},
  belowskip    = {0\p@ \@plus 6\p@},
  tabsize      = 2,
  breaklines   = true,
  breakatwhitespace = true,
  keepspaces   = true,
  escapeinside = {(*@}{@*)},
  moredelim    = {[is][\ttfamily\bfseries\color{highlight1}]{|}{|}},
  moredelim    = {[is][\ttfamily\bfseries\color{highlight1}]{|1}{1|}},
  moredelim    = {[is][\ttfamily\bfseries\color{highlight2}]{|2}{2|}},
}

\lstdefinelanguage{extBibTeX}{%
  morekeywords=[1]{%
    @article,@artwork,@audio,@bibnote,@book,@bookinbook,@booklet,%
    @collection,@commentary,@customa,@customb,@customc,@customd,%
    @custome,@customf,@inbook,@incollection,@inproceedings,%
    @inreference,@image,@jurisdiction,@legal,@legislation,@letter,%
    @manual,@misc,@movie,@music,@mvcollection,@mvreference,%
    @mvproceedings,@mvbook,@online,@patent,@performance,@periodical,%
    @proceedings,@reference,@report,@review,@set,@software,@standard,%
    @suppbook,@suppcollection,@suppperiodical,@thesis,@unpublished,@video%
   },
   morekeywords=[2]{author,title,date,owner,timestamp,journaltitle,%
   location,publisher,booktitle,subtitle,booksubtitle,pages,series,%
   shortseries,serieseditor,number,volume,year,date,pubstatus,editor,%
   shorthand,shortauthor,keywords,options,groups,shorteditor,translator,%
   origlanguage,origtitle,edition,origdate,doi},
   keywordstyle=[1]{\bfseries\spotcolor},
   keywordstyle=[2]{\spotcolor},
   sensitive=true,
}

\lstdefinestyle{extblxstylelatex}{%
  language  = {[LaTeX]TeX},
  style     = {extblxstylegeneral},
}

\lstdefinestyle{extblxstylebibtex}{%
  language  = {extBibTeX},
  style     = {extblxstylegeneral},
}


\newcommand*{\highlight}[2][1]{\textcolor{highlight#1}{#2}}
\newcommand*{\highlightbf}[2][1]{\textcolor{highlight#1}{\textbf{#2}}}
\DeclareFieldFormat{highlight1}{\textcolor{highlight1}{#1}}
\DeclareFieldFormat{highlight2}{\textcolor{highlight2}{#1}}

\newtcolorbox{bibexample}[1][]{enhanced,
                               colframe=spot!75!black, colback=spot!5!white,
                               breakable,
                               #1}
\newtcblisting{biblatexcode}{enhanced,
                             colframe=black!75!white, colback=black!5!white,
                             listing only,
                             frame hidden,
                             breakable,
                             listing style=extblxstylelatex}
\newtcblisting{bibtexfile}{enhanced,
                           colframe=black!75!white, colback=black!5!white,
                           listing only,
                           frame hidden,
                           breakable,
                           listing style = extblxstylebibtex}
\newcommand\edtobibexample[2][]{
\begin{bibexample}[#1]
  \begin{refsection}
  #2\par
  \hrulefill
  \printbibliography[heading=none]
  \end{refsection}
\end{bibexample}
}


\newtcbinputlisting\inputexamplebibfile[2][]{%
  listing file={#2},
  enhanced,
  colframe=black!75!white, 
  colback=black!5!white,
  listing only,
  frame hidden,
  breakable,
  %listing style = extblxstylebibtex,
  #1}




\makeatletter
\AtUsedriver*{%
  \let\newblock\relax
  \let\abx@macro@bibindex\@empty
  \let\abx@macro@pageref\@empty}


% this is taken from ltxdockit.cls, which is not loaded
\newrobustcmd*{\fnurl}[1][]{\hyper@normalise\ltd@fnurl{#1}}
\def\ltd@fnurl#1#2{\footnote{#1\hyper@linkurl{\Hurl{#2}}{#2}}}

\newrobustcmd*{\email}{\hyper@normalise\ltd@email}
\def\ltd@email#1{\href{mailto:#1}{#1}}

% title
\providecommand*{\titlepage}{}
\providecommand*{\titlefont}{}
\renewrobustcmd*{\titlepage}[1]{\setkeys{ltd@ttp}{#1}}
\renewcommand*{\titlefont}{
  \bfseries
  \sffamily
  }
\define@key{ltd@ttp}{title}{\def\ltd@title@title{#1}}
\define@key{ltd@ttp}{subtitle}{\def\ltd@title@subtitle{#1}}
\define@key{ltd@ttp}{url}{\def\ltd@title@url{#1}}
\define@key{ltd@ttp}{author}{\def\ltd@title@author{#1}}
\define@key{ltd@ttp}{link}{\def\ltd@title@link{#1}}
\define@key{ltd@ttp}{revision}{\def\ltd@title@revision{#1}}
\define@key{ltd@ttp}{date}{\def\ltd@title@date{#1}}

\providecommand*{\printtitlepage}{}
\renewrobustcmd*{\printtitlepage}{%
  \begingroup
  \centering\titlefont
  \begingroup\LARGE
    \ifundef\ltd@title@url
      {\ltd@title@title}
      {\href{\ltd@title@url}{\ltd@title@title}}%
    \par
  \endgroup
  \vspace{0.25\baselineskip}
  \begingroup\large
    \ltd@title@subtitle\par
  \endgroup
  \vspace{0.25\baselineskip}
  \begin{multicols}{2}
  \raggedleft
    \ltd@title@author\par
    \expandafter\email\expandafter{\ltd@title@link}\par
  \raggedright
    Version \ltd@title@revision\par\ltd@title@date
  \end{multicols}
  \endgroup}

\BeforeStartingTOC[toc]{\begin{multicols}{2}}
\AfterStartingTOC[toc]{\end{multicols}}

\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}{\acr{PDF}}
\newrobustcmd*{\utf}{\mbox{\acr{UTF}-8}}

\pdfstringdefDisableCommands{%
  \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}%
}

\let\accentcolour\spotcolor

\addtokomafont{section}{\accentcolour}
\addtokomafont{subsection}{\accentcolour}
\addtokomafont{subsubsection}{\accentcolour}

\renewcommand*{\verbatimfont}{\ttfamily}
\renewcommand*{\displayverbfont}{\ttfamily}
\renewcommand*{\marglistfont}{\accentcolour\sffamily\small}
\renewcommand*{\margnotefont}{\sffamily\small}
\renewcommand*{\optionlistfont}{\accentcolour\sffamily\displayverbfont}
\renewcommand*{\ltxsyntaxfont}{\ttfamily}
\renewcommand*{\ltxsyntaxlabelfont}{\accentcolour\displayverbfont}
\renewcommand*{\changelogfont}{\normalfont}
\renewcommand*{\changeloglabelfont}{\accentcolour\sffamily\bfseries}
\newcommand*{\stylelistfont}{\accentcolour\sffamily\small}

\newenvironment*{stylelist}
  {\list{}{%
     \setlength{\labelwidth}{\marglistwidth}%
     \setlength{\labelsep}{\marglistsep}%
     \setlength{\leftmargin}{0pt}%
     \renewcommand*{\makelabel}[1]{\hss\stylelistfont##1}}%
   \def\styleitem##1{%
     \item[{##1}]%
     \ltd@pdfbookmark{##1}{##1}}}
  {\endlist}

\newenvironment*{keymarglistbook}
  {\marglist
   \setlength{\itemsep}{0pt}%
   \raggedright
   \let\@@item\item
   \def\item[##1]{%
     \@@item[{##1}]%
     \ltd@pdfbookmark{##1}{##1}}}
  {\endmarglist}

% modified for correct measurements
\def\ltd@option@i#1#2#3#4[#5]{%
  \item[#2]%
  \ltd@pdfbookmark{#1}{#1}%
  \begingroup\raggedright
  \ltd@textverb{=}%
  \settowidth\@tempdimb{\ltd@textverb{=}}%
  \settowidth\@tempdimc{\optionlistfont#2}%
  \ifdim\@tempdimc>\marglistwidth
    \@tempdimc=\dimexpr\@tempdimc-\marglistwidth\relax
  \else
    \@tempdimc=0pt
  \fi
  \@tempdima=\dimexpr\linewidth-\@tempdimb-\@tempdimc\relax
  \ifblank{#4}
    {}
    {\settowidth\@tempdimb{default: #4}%
     \@tempdima=\dimexpr\@tempdima-\@tempdimb-2em\relax}%
  \parbox[t]{\@tempdima}{\raggedright #3}%
  \ifblank{#4}
    {}
    {\hfill default:~#4}%
  \ifblank{#5}
    {}
    {\marginpar{\margnotefont #5}}%
  \par\endgroup
  \nobreak\vspace{\itemsep}}

%\blx@inputonce{ext-biblatex-aux.def}{auxiliary code for ext-biblatex}{}{}{}{}
\newcommand*{\biblatexversion}{\extblx@requiredbiblatexversion}
\newcommand*{\biblatexdate}{\extblx@requiredbiblatexdate}

\AtEndPreamble{%
  \deflength{\marglistwidth}{(\oddsidemargin+2cm)*85/100}}
\makeatother

% By Stefan Kottwitz, see https://tex.stackexchange.com/a/799/35864
\newcommand*\justify{%
  \fontdimen2\font=0.4em% interword space
  \fontdimen3\font=0.2em% interword stretch
  \fontdimen4\font=0.1em% interword shrink
  \fontdimen7\font=0.1em% extra space
  \hyphenchar\font=`\-% allowing hyphenation
}

% no \mbox here, we may have to break things
\renewrobustcmd*{\sty}[1]{{\verbatimfont\justify #1}}
\renewrobustcmd*{\bibfield}[1]{\sty{#1}}
\renewrobustcmd*{\opt}[1]{\sty{#1}}
\newrobustcmd*{\bibmacro}[1]{\sty{#1}}
\renewrobustcmd*{\bibtype}[1]{\sty{@#1}}
\renewrobustcmd*{\cmd}[1]{\sty{\textbackslash #1}}


\newcommand*{\gitbaseurl}{https://github.com/LukasCBossert/biblatex-socialsciences-huberlin}
\newcommand*{\biber}{Biber}
\newcommand*{\gitissuelink}[1]{%
  \href{\gitbaseurl/issues/#1}{issue \##1 on github}}

\titlepage{%
  title    = {The \sty{biblatex-socialscienceshuberlin} style},
  subtitle = {Style used for social sciences at Humbold-Universität zu Berlin},
  url      = {\gitbaseurl},
  author   = {Lukas C. Bossert},
  link     = {lukas@digitales-altertum.de},%
  revision = {\socialscienceshuberlinversion},
  date     = {{\socialscienceshuberlindate}},
}

\hypersetup{%
  pdftitle    = {The biblatex-'socialsciences|huberlin' style},
  pdfsubject  = {\sty{biblatex}-style 'socialsciences|huberlin'},
  pdfauthor   = {Lukas C. Bossert},
  pdfkeywords = {latex, biblatex, bibtex, bibliography, references, citation},
}

\hyphenation{%
  star-red
  un-star-red
  bib-lio-gra-phy
  white-space
  bib-open-paren
  bib-close-paren
  bib-open-bracket
  bib-close-bracket
  main-title-after-title
}

\begin{document}

\printtitlepage
\tableofcontents

\section{Introduction}\label{sec:int}
\subsection{About}
The \sty{biblatex-socialscienceshuberlin} style provides the citation and bibliography styles used at the Department of Social Sciences at Humboldt-Universität zu Berlin.

This style is built upon \sty{biblatex-ext}\fnurl{https://ctan.org/pkg/biblatex-ext} and uses \sty{ext-authoryear} for  citations and for the bibliography.
Several customisations have been done so far.

\subsection{Installation}\label{sec:install}
This style is available on \mkbibacro{CTAN}.%
\fnurl{https://ctan.org/pkg/biblatex-socialscienceshuberlin}
The current release is also available in \miktex{} and \texlive{} 2018 or
newer.
If at all possible you should install this style via your \tex{} distribution
(using \miktex{} Console\fnurl{https://miktex.org/howto/miktex-console} or
\sty{tlmgr} for \texlive\fnurl{https://www.tug.org/texlive/pkginstall.html}).
If you must install this package manually, get the files from \mkbibacro{CTAN}
and install the \sty{.bbx}, \sty{.cbx}  files preferably to
\path{tex/latex/editiontopoi} of your local or home \TeX{} tree, the other
files (\path{README.md}, \path{editiontopoi.tex},
\path{editiontopoi.pdf} and \path{editiontopoi-examples.bib}) go to
\path{doc/latex/editiontopoi}, you may have to refresh your file name database
afterwards, so \tex{} can find the files.

\subsection{License}\label{sec:license}
Permission is granted to copy, distribute and\slash or modify this software
under the terms of the \lppl, version 1.3c%
\fnurl{https://www.latex-project.org/lppl/lppl-1-3c.txt}
or (at your option) any later version%
\fnurl{https://www.latex-project.org/lppl.txt}.
This style is maintained by Lukas C. Bossert (\textcopyright 2018).


\section{How to use it}
For a general introduction to \sty{biblatex} see its documentation available on \mkbibacro{CTAN}\fnurl{http://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf},
or have a look at the short \sty{biblatex}-tutorial by Paul Stanley\fnurl{https://github.com/PaulStanley/biblatex-tutorial/releases/download/0.2/biblatex-tutorial.pdf}. 

% There is one option so far: You can chose whether the author’s/editor’s names are colored and you can also define the color.

Note that the author’s/editor’s names are colored so far.
This will be an option in further releases.


\section{Bibliography examples}
\nocite{*} 
\begin{bibexample}[breakable]
\printbibliography
\end{bibexample}

\end{document}
\endinput
