使用 biblatex 将作者年份引用样式设为粗体

使用 biblatex 将作者年份引用样式设为粗体

我的大学机构要求使用粗体作者-年份引用样式,同时要求使用粗体参考书目作者-年份样式,包括作者和年份。我不是 biblatex 专家,需要您的帮助。包含了一个最低限度的工作示例,但没有尝试应用所需的内容。

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{libertine}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=authoryear,citestyle=authoryear,backend=biber]{biblatex}
\usepackage[pdfborder={0 0 0},pdfborderstyle={}]{hyperref}
%=====================================================
\usepackage{filecontents}
\begin{filecontents}{\mybib.bib}
@Article{caton1989periodontal,
  author  = {Caton, J},
  title   = {Periodontal diagnosis and diagnostic aids: consensus report in Proceedings of the World Workshop in Clinical Periodontics},
  journal = {American Academy of Periodontology},
  year    = {1989},
}
@Book{williams1992pathology,
  author    = {Williams, D.M.},
  title     = {Pathology of Periodontal Disease},
  isbn      = {9780192621207},
  publisher = {Oxford University Press},
  series    = {Oxford medical publications},
  url       = {https://books.google.com.eg/books?id=DbVtQgAACAAJ},
  lccn      = {91027234},
  year      = {1992},
}
\end{filecontents}
\addbibresource{\mybib.bib}

\begin{document}
Periodontitis is a chronic multifactorial inflammatory disease \parencite{caton1989periodontal}.
Periodontal disease is the most common oral condition of human population
\parencite{williams1992pathology}.

\printbibliography
\end{document}

答案1

如果从标准authoryear样式切换biblatex-extext-authoryear,解决方案可能如下所示

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{libertine}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=ext-authoryear, backend=biber]{biblatex}
\usepackage{hyperref}

\newrobustcmd*{\mkboldoutercitedelims}[1]{%
  \mkbibbold{%
    \mkoutercitedelims{#1}}}

\DeclareCiteCommand{\cite}[\mkboldoutercitedelims]
  {\usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}[\mkboldoutercitedelims]
  {\usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareMultiCiteCommand{\cites}[\mkboldoutercitedelims]{\cite}{\multicitedelim}

\newrobustcmd*{\mkboldouterparencitedelims}[1]{%
  \mkbibbold{%
    \mkouterparencitedelims{#1}}}

\DeclareCiteCommand{\parencite}[\mkboldouterparencitedelims]
  {\usebibmacro{prenote}}%
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkboldouterparencitedelims]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeyear}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareMultiCiteCommand{\parencites}[\mkboldouterparencitedelims]{\parencite}{\multicitedelim}

\newrobustcmd*{\mkboldoutertextcitedelims}[1]{%
  \mkbibbold{%
    \mkoutertextcitedelims{#1}}}

\DeclareCiteCommand{\textcite}[\mkboldoutertextcitedelims]
  {\boolfalse{cbx:parens}}
  {\usebibmacro{citeindex}%
   \iffirstcitekey
     {\setcounter{textcitetotal}{1}}
     {\stepcounter{textcitetotal}%
      \textcitedelim}%
   \usebibmacro{textcite}}
  {\ifbool{cbx:parens}
     {\bibcloseparen\global\boolfalse{cbx:parens}}
     {}}
  {\usebibmacro{textcite:postnote}}

\DeclareMultiCiteCommand{\textcites}[\mkboldoutertextcitedelims]{\textcite}{}

\DeclareNameWrapperFormat{sortname}{\mkbibbold{#1}}
\DeclareFieldFormat{biblabeldate}{\mkbibbold{\mkbibparens{#1}}}

\addbibresource{biblatex-examples.bib}

\begin{document}
Lorem \autocite{sigfridsson}
ipsum \autocite{worman}

\printbibliography
\end{document}

“Lorem (Sigfridsson and Ryde 1998) ipsum (Worman 2002)”,引文以粗体显示。参考书目中的名称和年份也以粗体显示。

引文的原始定义可以参见ext-authoryear.cbx。基本上我们只是\mkbibbold向外部分隔符包装器命令中注入了一个。

对于参考书目,我们使用了名称包装器格式sortnamebiblatex-ext年份biblabeldate格式。

相关内容