fancyhdr 与 biblatex printbibliography

fancyhdr 与 biblatex printbibliography

我在使用包时遇到问题fancyhdr。我制作了一个可以正常工作的标题,但在章节参考中,标题看起来不同。我怎样才能使它们看起来都一样?

\documentclass[a4paper, 11 pt, liststotoc, bibtotoc, bibtotocnumbered, liststotocnumbered ]{scrartcl}
\usepackage[a4paper]{geometry}          
\geometry{top=4cm , bottom=4cm}
%\geometry{width=15cm, left=3.5cm, top=3cm , bottom=4cm}
\usepackage[utf8]{inputenc}
\usepackage{ngerman}[babel]
\usepackage{helvet}
\usepackage{fontenc}[T1]

\usepackage[backend=biber,
style=numeric
]{biblatex}
\addbibresource{literatur.bib}
\usepackage{fancyhdr}

\begin{document}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{\leftmark} % 1. sectionname
\fancyfoot[C]{\thepage}
\fancypagestyle{plain}

\section{Einleitung}
hello \cite{mi}
\subsection{first chapter}

\newpage

\printbibliography[title=Referenzen]

\newpage
\end{document}

参考书目literatur.bib

@article{mi,
    author = {mira},
    title = {cgc},
    journaltitle = {journaltitle},
    date = {2020},
}

答案1

运行文档时,您应该在.log文件中看到类似以下的警告

Class scrartcl Warning: Usage of package `fancyhdr' together
(scrartcl)              with a KOMA-Script class is not recommended.
(scrartcl)              I'd suggest to use 
(scrartcl)              package `scrlayer' or `scrlayer-scrpage', because
(scrartcl)              they support KOMA-Script classes.
(scrartcl)              With `fancyhdr' several features of class `scrartcl'
(scrartcl)              like options `headsepline', `footsepline' or command
(scrartcl)              `\MakeMarkcase' and the commands `\setkomafont' and
(scrartcl)              `\addtokomafont' for the page style elements need
(scrartcl)              explicite user intervention to work.
(scrartcl)              Nevertheless, using requested
(scrartcl)              package `fancyhdr' on input line 19.

正如警告所解释的那样,fancyhdr与 配合使用效果不是特别好scrartcl。如果将这两者一起使用,可能出现的一个问题是,列标题可能并不总是看起来统一(取决于或是否fancyhdr保留scrartcl对标题的控制)。

我会遵循警告中的建议,并且如果您使用 KOMA-Script 类,我会fancyhdr放弃。scrlayer-scrpage

下面的输出应该与您现在得到的结果非常相似。

\documentclass[a4paper, 11pt, listof=numbered, bibliography=numbered]{scrartcl}
\usepackage{geometry}
\geometry{top=4cm , bottom=4cm}
\usepackage[utf8]{inputenc}
\usepackage{helvet}
\usepackage{fontenc}[T1]
\usepackage[ngerman]{babel}

\usepackage[backend=biber,
style=numeric
]{biblatex}
\addbibresource{biblatex-examples.bib}

\usepackage[automark, headsepline, markcase=upper]{scrlayer-scrpage}

\ohead*{\rightmark}
\chead*{}
\cefoot*{\thepage}
\pagestyle{headings}

\begin{document}
\section{Einleitung}
hello \cite{sigfridsson}
\subsection{first chapter}

\clearpage

\nocite{*}
\printbibliography

\clearpage
\end{document}

包含全部大写标题的参考书目第一页的屏幕截图。


如果必须坚持,fancyhdr您可以尝试重新定义\MakeMarkcase。这在示例中有效,但在较大的文档中可能需要额外的工作。

\documentclass[a4paper, 11pt, listof=numbered, bibliography=numbered]{scrartcl}
\usepackage{geometry}
\geometry{top=4cm , bottom=4cm}
\usepackage[utf8]{inputenc}
\usepackage{helvet}
\usepackage{fontenc}[T1]
\usepackage[ngerman]{babel}

\usepackage[backend=biber,
style=numeric
]{biblatex}
\addbibresource{biblatex-examples.bib}

\newcommand\MakeMarkcase{\MakeUppercase}

\usepackage{fancyhdr}

\begin{document}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{\leftmark} % 1. sectionname
\fancyfoot[C]{\thepage}
\fancypagestyle{plain}

\section{Einleitung}
hello \cite{sigfridsson}
\subsection{first chapter}

\clearpage

\nocite{*}
\printbibliography

\clearpage
\end{document}

相关内容