我正在使用scrreprt
类和在每章末尾biblatex
包含backend=biber
参考书目。在我的 MWE 中,您可以看到我使用哪些其他包来包含 pdfbookmarks 和设置超链接。此外,我正在使用代码调整使参考资料成为每章的本地参考资料。
我遇到的问题是,每个章节的参考书目链接(在目录和 pdfbookmarks 中)跳转到章节参考书目之前的最后一节,而不是实际的参考书目。
与此同时,我已经弄清楚了我的代码中的哪些行导致了这个问题:它们都与包相关titlesec
并且当前已被注释掉(请参阅下面的 MWE)。
因此,我现在尝试实现我已经实现的相同布局更改titlesec
- 但分别使用另一个包或不同的解决方案。
标题所需的格式是:
- 增加标题及其相应编号的水平分隔
chapter
增加标题和文本之间的垂直间距section
增加标题前后的垂直subsection
间距
请告诉我您的一些建议,以便我能够完成这项工作。提前致谢。请注意,我想坚持上课scrreprt
。
\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}
答案1
也许您需要以下 KOMA-Script 代码:
\renewcommand\chapterformat{\chapapp\ \thechapter}
\renewcommand\sectionformat{\thesection\hspace{1em}}
\renewcommand\subsectionformat{\thesubsection\hspace{1em}}
\RedeclareSectionCommand[
beforeskip=-5pt,
innerskip=0pt,%<- vertical space between chapter number and chapter title
afterskip=150pt
]{chapter}
\RedeclareSectionCommands[
beforeskip=-5.5ex plus -1ex minus -.2ex,
afterskip=4.3ex plus .2ex
]{section,subsection}
\setkomafont{chapter}{\Huge}
%\setkomafont{chapterprefix}{\huge}% I don't know if you want this
\setkomafont{section}{\Large}
\setkomafont{subsection}{\large}