调整 biblatex 书目样式

调整 biblatex 书目样式

我之前问过一个关于调整natbib 1,但放弃了并改用biblatex

我正在撰写我的学士论文,需要帮助调整参考书目和引文风格以符合学校的要求。以下是我目前得到的信息:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[norsk]{babel}


\usepackage[style=authoryear-comp,firstinits=true,backend=biber,maxcitenames=3,citetracker=true,maxbibnames=99,dashed=false]{biblatex}

\DeclareNameAlias{sortname}{last-first}
\renewcommand*{\nameyeardelim}{\addcomma\space}

\addbibresource{bachelor.bib}
\usepackage{breakurl}

%from https://tex.stackexchange.com/questions/48846/biblatex-et-al-beginning-from-second-citation
\usepackage{xpatch}

\AtEveryCitekey{\ifciteseen{}{\clearfield{namehash}}}

\xpatchbibmacro{cite}
  {\printnames{labelname}}
  {\ifciteseen
     {\printnames{labelname}}
     {\printnames[][1-99]{labelname}}}
  {}
  {}

\xpatchbibmacro{textcite}
  {\printnames{labelname}}
  {\ifciteseen
     {\printnames{labelname}}
     {\printnames[][1-99]{labelname}}}
  {}
  {}

\begin{document}
\printbibliography[title=Kilder]
\addcontentsline{toc}{chapter}{Kilder}
\end{document}

如果只有一位作者,则使用上述方法@book在引文和参考书目中均能正确显示。如果有多位作者,最后两位作者之间会有“og”(挪威语中“and”的翻译)。我想将其更改为 &。

@inbook需要对参考书目进行一些修改。目前是:

作者(年份)。标题。I:书名。红色。av 编辑。地址:出版商,s。pagefrom-pageto

我需要的是:

作者(年份)。标题。I 编辑(红色),书名(s. pagefrom-pageto)。地址:出版商

上文中的“I”是“In”的挪威语翻译,“mfl.”是“et al.”的挪威语翻译。

此外,我不知道如何防止“et al”被翻译成“mfl”。我想我需要做类似的事情:

\addto\captionsnorsk{%
  \renewcommand{\something}%
    {et al}%
}

但我不知道用什么来代替。

谢谢。

答案1

嗯,这里要做很多修改。

为了将“and others”的翻译从“med flere”改为“et al.”,我们进行定义。

\DefineBibliographyStrings{norsk}{%
  andothers        = {et\addabbrvspace al\adddot},
  andmore          = {et\addabbrvspace al\adddot},
}

您可以在以下位置找到所有 bibstring(本地化关键字)的列表biblatex文档参见 §4.9.2本地化键有关此主题的更多信息,请参阅§4.9本地化模块值得一读。

为了将姓氏分隔符从“og”(“and”)更改为“&”,我们重新定义

\renewcommand*{\finalnamedelim}{%
  %\ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}% there really should be no funny Oxford comma business here
  \addspace\&\space}

请注意,通常处理牛津逗号的第二行在这里没有被注释,但这与挪威语无关,因为挪威语无论如何都不使用牛津逗号。

现在,转到@inbook@incollection

首先,最简单的部分,去掉“I:”(“In:”)后面的冒号,定义

\renewcommand*{\intitlepunct}{\space}

但是,这将删除所有条目类型的冒号;如果您希望为所有其他条目类型保留冒号(为什么要这样做?这会非常不一致),请尝试

\newbibmacro*{in:}{%
  \printtext{%
    \bibstring{in}%
    \ifboolexpr{test {\ifentrytype{inbook}} or test {\ifentrytype{incollection}}}
      {\addspace}%
      {\intitlepunct}}}

最大的问题是重新排序输出。你可以将整个驱动程序复制并粘贴到文档中并进行修改,但既然你xpatch无论如何都会使用,为什么不使用呢?

% This gets rid of page numbers, don't worry they will be re-added later
\xpatchbibdriver{inbook}
  {\newunit\newblock
   \usebibmacro{chapter+pages}}
  {}
  {}
  {}

\xpatchbibdriver{incollection}
  {\newunit\newblock
   \usebibmacro{chapter+pages}}
  {}
  {}
  {}

\xpatchbibdriver{incollection}
  {\usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
  }
  {\renewbibmacro*{date+extrayear}{}%
   \usebibmacro{editor+others}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \ifboolexpr{not (test {\iffieldundef{chapter}} and test {\iffieldundef{pages}})}
     {\nopunct\printtext[parens]{\usebibmacro{chapter+pages}}}%
     {}%
   \newunit\newblock
  }%
  {}
  {\typeout{failed to replace \usebibmacro{byeditor+others} by \usebibmacro{editor+others} in BibliographyDriver{incollection}}}%


\xpatchbibdriver{inbook}
  {\usebibmacro{bybookauthor}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
  }
  {\renewbibmacro*{date+extrayear}{}%
   \usebibmacro{editor+others}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
   \newunit\newblock
   \ifboolexpr{not (test {\iffieldundef{chapter}} and test {\iffieldundef{pages}})}
     {\nopunct\printtext[parens]{\usebibmacro{chapter+pages}}}%
     {}%
  }%
  {}
  {\typeout{failed to replace \usebibmacro{byeditor+others} by \usebibmacro{editor+others} in BibliographyDriver{inbook}}}%

我们将编辑器宏移到标题之前,但使用editorbyeditor宏。

要获取括号中的字符串“editor”并删除其前面的逗号,请使用

\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\xpatchbibmacro{bbx:editor}%
  {\setunit{\addcomma\space}%
  }
  {\setunit{\addspace}%
  }
  {}
  {\typeout{failed to patch bibmacro{bbx:editor}}}

相当长,不太 M WE

\documentclass[norsk,12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{lmodern}
\usepackage[style=authoryear-comp, firstinits=true, backend=biber, maxcitenames=3, citetracker=true, maxbibnames=99, dashed=false,texencoding=ascii]{biblatex}

\DeclareNameAlias{sortname}{last-first}
\renewcommand*{\nameyeardelim}{\addcomma\space}

\addbibresource{biblatex-examples.bib}
\usepackage{breakurl}

\DefineBibliographyStrings{norsk}{%
  andothers        = {et\addabbrvspace al\adddot},
  andmore          = {et\addabbrvspace al\adddot},
}

%from http://tex.stackexchange.com/questions/48846/biblatex-et-al-beginning-from-second-citation
\usepackage{xpatch}

\AtEveryCitekey{\ifciteseen{}{\clearfield{namehash}}}

\xpatchbibmacro{cite}
  {\printnames{labelname}}
  {\ifciteseen
     {\printnames{labelname}}
     {\printnames[][1-999]{labelname}}}
  {}
  {}

\xpatchbibmacro{textcite}
  {\printnames{labelname}}
  {\ifciteseen
     {\printnames{labelname}}
     {\printnames[][1-999]{labelname}}}
  {}
  {}

\renewcommand*{\finalnamedelim}{%
  %\ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}% there really should be no funny Oxford comma business here
  \addspace\&\space}

%\renewcommand*{\intitlepunct}{\space}

\newbibmacro*{in:}{%
  \printtext{%
    \bibstring{in}%
    \ifboolexpr{test {\ifentrytype{inbook}} or test {\ifentrytype{incollection}}}
      {\addspace}%
      {\intitlepunct}}}

\xpatchbibdriver{inbook}
  {\newunit\newblock
   \usebibmacro{chapter+pages}}
  {}
  {}
  {}

\xpatchbibdriver{incollection}
  {\newunit\newblock
   \usebibmacro{chapter+pages}}
  {}
  {}
  {}

\xpatchbibdriver{incollection}
  {\usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
  }
  {\renewbibmacro*{date+extrayear}{}%
   \usebibmacro{editor+others}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \ifboolexpr{not (test {\iffieldundef{chapter}} and test {\iffieldundef{pages}})}
     {\nopunct\printtext[parens]{\usebibmacro{chapter+pages}}}%
     {}%
   \newunit\newblock
  }%
  {}
  {\typeout{failed to replace \usebibmacro{byeditor+others} by \usebibmacro{editor+others} in BibliographyDriver{incollection}}}%


\xpatchbibdriver{inbook}
  {\usebibmacro{bybookauthor}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
  }
  {\renewbibmacro*{date+extrayear}{}%
   \usebibmacro{byeditor+others}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
   \newunit\newblock
   \ifboolexpr{not (test {\iffieldundef{chapter}} and test {\iffieldundef{pages}})}
     {\nopunct\printtext[parens]{\usebibmacro{chapter+pages}}}%
     {}%
  }%
  {}
  {\typeout{failed to replace \usebibmacro{byeditor+others} by \usebibmacro{editor+others} in BibliographyDriver{inbook}}}%

\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\xpatchbibmacro{bbx:editor}%
  {\setunit{\addcomma\space}%
  }
  {\setunit{\addspace}%
  }
  {}
  {\typeout{failed to patch bibmacro{bbx:editor}}}

\begin{document}
  \cite{aksin} again \cite{aksin}.
  \nocite{wilde,kant:kpv,hyman,pines,baez/article}
  \printbibliography[title=Kilder]
\end{document}

产量

在此处输入图片描述

相关内容