I am using the scrreprt
class and biblatex
with backend=biber
to include bibliographies at the end of each chapter.
In my MWE you can see which other packages I am using to include pdfbookmarks and to set up hyperlinks.
Also, I am using a code tweak to make the references local to each chapter.
I had the issue that the links of the bibliographies for each chapter (both in ToC and in pdfbookmarks) jump to the last section before the chapter bibliographies instead of the actual bibliographies instead.
In the meantime, I have figured out which lines in my code cause this issue: They are all related to the titlesec
package and are currently commented out (see MWE below).
Thus, I am now trying to achieve the same layout changes I had realised using titlesec
- but with another package or a different solution, respectively.
The desired formatting of titles is:
- increase horizontal separation of the titles and their corresponding numbering
- increase vertical spacing between
chapter
title and text - increase vertical spacing before and after
section
andsubsection
titles
Please let me know some of your suggestions to make this work. Thanks in advance.
Please note that I want to stick to the scrreprt
class.
\documentclass[12pt, twoside, openright, chapterprefix, numbers=noenddot]{scrreprt}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm,headheight=15pt,includeheadfoot]{geometry}
\usepackage[automark,headsepline=off]{scrlayer-scrpage}
\usepackage[ngerman]{babel} % deutsche Trennregeln
\usepackage{lmodern} % fixes bug with \usepackage[T1]{fontenc}; ändert Schriftart zudem in Latin Modern
\usepackage[T1]{fontenc} % für europäische Autoren ratsam; % wichtig für Trennung von Wörtern mit Umlauten
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage{etoolbox}
\usepackage{patchcmd}
\usepackage{xpatch}
\usepackage{lipsum}
\usepackage{hyperref}
\hypersetup{colorlinks=true, linktocpage=true, linktoc=all,
citecolor=blue, filecolor=blue, urlcolor=blue, breaklinks=false,
bookmarksopen=true, colorlinks, linkcolor = black}
\usepackage[all]{hypcap} % needed to help hyperlinks direct correctly;
\usepackage[numbered]{bookmark}
\usepackage{booktabs}
\usepackage{tocloft}
%%% References
\usepackage[style=authoryear, backend=biber,
refsegment=chapter % benutze automatisch Kapitel als Biobliographie-Abschnitte...
]{biblatex}
\ExecuteBibliographyOptions{firstinits=true,maxcitenames=2,maxbibnames=999,isbn=false,doi=false,url=false,labeldate=true,uniquelist=minyear}
%%% making links local in refsegments (https://tex.stackexchange.com/questions/303503/hyperref-inside-refsegment-always-linking-to-first-bibliography-not-current-bib)
% refsegment allows to use the same labels throughout the whole document
\makeatletter
\appto\blx@mkhyperref{%
\let\blx@anchors\@empty
\ifundef\hyper@natanchorstart
{\protected\def\blx@anchor{%
\xifinlist{\the\c@refsection @\the\c@refsegment @\abx@field@entrykey}{\blx@anchors}
{}
{\listxadd\blx@anchors{\the\c@refsection @\the\c@refsegment @\abx@field@entrykey}%
\hypertarget{cite.\the\c@refsection @\the\c@refsegment @\abx@field@entrykey}{}}}}
{\protected\def\blx@anchor{%
\xifinlist{\the\c@refsection @\the\c@refsegment @\abx@field@entrykey}{\blx@anchors}
{}
{\listxadd\blx@anchors{\the\c@refsection @\the\c@refsegment @\abx@field@entrykey}%
\hyper@natanchorstart{\the\c@refsection @\the\c@refsegment @\abx@field@entrykey}%
\hyper@natanchorend}}}}
\appto\blx@mkhyperref{%
\protected\def\blx@imc@bibhyperref{%
\@ifnextchar[%]
{\blx@bibhyperref}
{\blx@bibhyperref[\abx@field@entrykey]}}%
\ifundef\hyper@natanchorstart
{\long\def\blx@bibhyperref[#1]#2{%
\blx@sfsave\hyperlink{cite.\the\c@refsection @\the\c@refsegment @#1}{\blx@sfrest
#2%
\blx@sfsave}\blx@sfrest}%
\protected\long\def\blx@imc@bibhyperlink#1#2{%
\blx@sfsave\hyperlink{cite.\the\c@refsection @\the\c@refsegment:#1}{\blx@sfrest
#2%
\blx@sfsave}\blx@sfrest}%
\protected\long\def\blx@imc@bibhypertarget#1#2{%
\blx@sfsave\hypertarget{cite.\the\c@refsection @\the\c@refsegment:#1}{\blx@sfrest
#2%
\blx@sfsave}\blx@sfrest}}%
{\long\def\blx@bibhyperref[#1]#2{%
\blx@sfsave\hyper@natlinkstart{\the\c@refsection @\the\c@refsegment @#1}\blx@sfrest
#2%
\blx@sfsave\hyper@natlinkend\blx@sfrest}%
\protected\long\def\blx@imc@bibhyperlink#1#2{%
\blx@sfsave\hyper@natlinkstart{\the\c@refsection @\the\c@refsegment:#1}\blx@sfrest
#2%
\blx@sfsave\hyper@natlinkend\blx@sfrest}%
\protected\long\def\blx@imc@bibhypertarget#1#2{%
\blx@sfsave\hyper@natanchorstart{\the\c@refsection @\the\c@refsegment:#1}\blx@sfrest
#2%
\blx@sfsave\hyper@natanchorend\blx@sfrest}}
\let\blx@imc@ifhyperref\@firstoftwo
\def\blx@sf{\spacefactor}%
\def\blx@sfsave{%
\blx@leavevmode
\numgdef\blx@sf{\spacefactor}}%
\def\blx@sfrest{%
\ifhmode\spacefactor\blx@sf\relax\fi
\gdef\blx@sf{\spacefactor}}}
\makeatother
%%% Fixing page headers for bibliographies
%https://tex.stackexchange.com/questions/394102/page-header-with-references-at-end-of-each-chapter#394181
\defbibheading{subbibintoc}[\refname]{\addsec{#1}}
%%% Example bibliography
\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Giancoli,
Author = {Douglas C. Giancoli},
Publisher = {Pearson},
Title = {Physics for Scientists \& Engineers},
Year = {2014},
Date-Added = {2015-10-05 12:23:12 +0000},
Date-Modified = {2015-10-05 12:23:50 +0000},
}
\end{filecontents}
\addbibresource{\jobname.bib}
%%%% Change Chapter Prefix
\setkomafont{chapterprefix}{\huge} % Default is \LARGE
%%% No Spacing Between Chapter Title and Prefix
\RedeclareSectionCommand[innerskip=0pt]{chapter} % <--- Vary distance here (Thanks @esdd!)
%%%% heading format + horizontal spacing between heading and numbering
%\usepackage[noindentafter]{titlesec}
%\titleformat{\subsection}{\sffamily \bfseries \large }{\thesubsection}{1em}{} % add "\itshape" für kursive Schreibweise
%\titleformat{\section}{\sffamily\bfseries\Large}{\thesection}{1em}{}
%\titleformat{\chapter}{\sffamily \Huge\bfseries}{\chaptername\ \thechapter}{0pt}{\vskip 0pt\raggedright} %\vskip 20pt\raggedright
%
%
%%%%% verstical spacing between Chapter-Title and text
%% Alter <after-sep> in the macro below to vary the separation after the \chapter title.
%\titlespacing{\chapter}{0pt}{5pt}{150pt}% \titlespacing{<command>}{<left>}{<before-sep>}{<after-sep>}[<right>]
%% try \parskip, 5\baselineskip and 150pt
%
%
%%%% vertical spacing before and after section/subsection-titles
%%\titlespacing*{<command>}{<left>}{<before-sep>}{<after-sep>}
%\titlespacing*{\section}
%{0pt}{5.5ex plus 1ex minus .2ex}{4.3ex plus .2ex}
%\titlespacing*{\subsection}
%{0pt}{5.5ex plus 1ex minus .2ex}{4.3ex plus .2ex}
%%% DOCUMENT
\begin{document}
%%% ToC
\phantomsection
\pdfbookmark{Inhaltsverzeichnis}{toc} %include ToC in Hyperlink-Navigation
\setcounter{tocdepth}{4}
\tableofcontents
%%% Test Chapeters
\chapter{Test-Kapitel}
\lipsum
\section{Test-Section}
\lipsum
Some \cite{Giancoli} text \autocite{Giancoli}
\lipsum
\lipsum
\lipsum
\subsection{Test-Section}
\lipsum
%%% Test Bibliography for Test Chapter
\printbibliography[segment=\therefsegment, heading=subbibintoc, title={Literatur}]
\clearpage
\end{document}
KOMA script
classes. For horizontal space between number and title see tex.stackexchange.com/a/373260/134144. For vertical space around titles see tex.stackexchange.com/a/223524/134144.