如何自定义 biblatex 风格?

如何自定义 biblatex 风格?

所以我一直在尝试学习 latex 以适应我的用途,但我需要修改 biblatex 的引用和引文样式以符合我所在机构的要求。我在 texsx 上找到了很多问题,尝试了一些方法,但根本没有用。

以下是我想使用 authoryear 样式进行更改的一些内容:

  • 删除参考书目中的引号
  • 删除参考书目中参考文献年份的括号
  • 在引用时使用“&”符号代替“and”

我尝试关注这个回复(自定义 biblatex 样式的指南),但所有改变均无效。

请在此处逐步帮助。

以下是我可能做的类似事情的示例:

\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\usepackage{lipsum}

\usepackage{filecontents}

\begin{filecontents}{ref.bib}
   @article{merdith_full-plate_2017,
    Author = {Merdith, Andrew S. and Collins, Alan S. and Williams, Simon E. and Pisarevsky, Sergei and Foden, John D. and Archibald, Donnelly B. and Blades, Morgan L. and Alessio, Brandon L. and Armistead, Sheree and Plavsa, Diana and Clark, Chris and M{\"u}ller, R. Dietmar},
   Date = {2017},
    Title = {A full-plate global reconstruction of the Neoproterozoic}}

   @article{england_active_1997,
   Author = {England, Philip and Molnar, Peter},
   Date = {1997},
   Number = {5338},
   Pages = {647--650},
   Title = {Active deformation of Asia: from kinematics to dynamics},
   Volume = {278}}
}
\end{filecontents}

\addbibresource{ref.bib}

\begin{document}
\lipsum[1-2]
\cite{merdith_full-plate_2017} and \cite{england_active_1997}

\printbibliography

\end{document}

在此处输入图片描述

答案1

对于您的三个问题,解决方案实际上很简短。

唯一带引号的格式是title“依赖”/@in...类似条目类型

\DeclareFieldFormat
  [article,inbook,incollection,inproceedings,patent,thesis,unpublished]
  {title}{#1\isdot}

你的第二个请求可以这样处理biblatex:如何删除 authoryear 样式中年份周围的括号?,但我采用了直接方法。

\renewbibmacro*{date+extrayear}{%
  \iffieldundef{labelyear}
    {}
    {\setunit{\addperiod\space}%
     \printtext{%
       \iffieldsequal{year}{labelyear}
         {\printlabeldateextra}%
         {\printfield{labelyear}%
          \printfield{extrayear}}}}}

对于你的第三个问题,我们可以使用问题中的代码Biblatex:引用中有“and”,但参考书目中有“&”,无需区分引文和参考书目

\DeclareDelimFormat{finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\&\space}

完整的 MWE 和一些奖励代码

\documentclass[british]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=authoryear,backend=biber]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
   @article{merdith_full-plate_2017,
    Author = {Merdith, Andrew S. and Collins, Alan S. and Williams, Simon E. and Pisarevsky, Sergei and Foden, John D. and Archibald, Donnelly B. and Blades, Morgan L. and Alessio, Brandon L. and Armistead, Sheree and Plavsa, Diana and Clark, Chris and M{\"u}ller, R. Dietmar},
   Date = {2017},
    Title = {A full-plate global reconstruction of the Neoproterozoic}}

   @article{england_active_1997,
   Author = {England, Philip and Molnar, Peter},
   Date = {1997},
   Number = {5338},
   Pages = {647--650},
   journal = {Science},
   Title = {Active deformation of Asia: from kinematics to dynamics},
   Volume = {278}}
}
\end{filecontents}

\addbibresource{\jobname.bib}

% issue 1
\DeclareFieldFormat
  [article,inbook,incollection,inproceedings,patent,thesis,unpublished]
  {title}{#1\isdot}

% issue 2
\renewbibmacro*{date+extrayear}{%
  \iffieldundef{labelyear}
    {}
    {\setunit{\addperiod\space}%
     \printtext{%
       \iffieldsequal{year}{labelyear}
         {\printlabeldateextra}%
         {\printfield{labelyear}%
          \printfield{extrayear}}}}}

% issue 3
\DeclareDelimFormat{finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\&\space}

% bonus
\renewbibmacro{in:}{%
  \ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
% (from https://tex.stackexchange.com/q/10682/35864)
\DeclareFieldFormat[article,periodical]{volume}{\mkbibbold{#1}}
\DeclareFieldFormat[article,periodical]{number}{\mkbibparens{#1}}
\renewbibmacro*{volume+number+eid}{%
  \printfield{volume}%
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}
\renewcommand*{\bibpagespunct}{\addcolon\space}
\DeclareFieldFormat[article]{pages}{#1}

\begin{document}
\cite{merdith_full-plate_2017} and \cite{england_active_1997}

\printbibliography

\end{document}

相关内容