如何将文内引用设置为斜体?

如何将文内引用设置为斜体?

我使用 biblatex 的 authoryear-comp citestyle,希望文内引用中的作者和年份以斜体显示。经过一番研究,我找到了以下命令,但它只会将作者显示为斜体:

\renewcommand{\mkbibnamelast}[1]{\mkbibemph{#1}}

有谁知道如何根据以下示例将年份也变为斜体?

\documentclass{scrbook}

\usepackage[backend=biber, bibstyle=authoryear, citestyle=authoryear-comp,sorting=nyt]{biblatex}
\addbibresource{\jobname.bib}
\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
    @book{Knu86,
        author = {Knuth, Donald E.},
        year = {1986},
        title = {The \TeX book},
    }
\end{filecontents*}

非常感谢您看完这篇文章并致以最良好的祝愿,

答案1

使引用变为斜体的一种方法是将想要以斜体显示的相关命令\mkbibemph的包装器代码注入其中。\DeclareCiteCommand\...cite

您可以\DeclareCiteCommand<citestyle>.cbx(就您的情况而言authoryear-comp.cbx)中找到声明。请注意,这些定义在不同的样式之间可能有所不同,因此您需要确保获得了正确的定义。

在示例中,我们展示了如何使\cite/\cite*\parencite/\parencite*变为斜体。原始定义可以在authoryear-comp.cbx,v3.18b 中的第 160-190 行:因为\cite我们只是添加\mkbibemph包装器命令(因为\cite没有包装器)。因为\parencite我们\mkbibemph与包装器结合(更改和\mkbibparens的顺序以使括号也变为斜体)。\mkbibemph\mkbibparens\mkbibemphparens

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber, style=authoryear-comp]{biblatex}

\DeclareCiteCommand{\cite}[\mkbibemph]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}[\mkbibemph]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {}
  {\usebibmacro{postnote}}

\newcommand*{\mkbibemphparens}[1]{\mkbibparens{\mkbibemph{#1}}}

\DeclareCiteCommand{\parencite}[\mkbibemphparens]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibemphparens]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {}
  {\usebibmacro{postnote}}

\addbibresource{biblatex-examples.bib}

\begin{document}
Lorem \autocite{sigfridsson}
ipsum \parencite{nussbaum}
dolor \cite{worman}

\printbibliography
\end{document}

Lorem(Sigfridsson 和 Ryde 1998)ipsum(Nussbaum 1978)dolor Worman 2002 [引文标签以斜体显示]

相关内容