biblatex:继承简写

biblatex:继承简写

更新 MWE

我想引用百科全书中的文章,并使用百科全书的简写:例如

姓氏,名字。艺术。文章标题. 出处:NG,第 11 卷,第 30-40 页,第 35 页。

我想在参考书目中引用它。

我迄今为止的代码(MWE):

\documentclass{article}
\usepackage[style = verbose-ibid]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@mvreference{NG,
title={The new Grove dictionary of music and musicians},
editor={Stanley Sadie},%begr. von Grove, George
year={1980},
volumes={20},
shorthand={NG}
}

@reference{NG-BD11,
crossref={NG},
title={Lindeman - Mean-tone},
volume={11},
year={1980},
location={London},
publisher={Macmillan}
}

@inreference{author-NG-ML,
crossref={NG-BD11},
author={Firstname Lastname},
title={articletitle},
pages={30--40}
}

\end{filecontents}
\addbibresource{\jobname.bib}

%what to print out?
\DeclareBibliographyDriver{inreference}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \printtext{Art.}%added
  \newunit%added
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{in:}%
  \iffieldundef{shorthand}{%added
    \usebibmacro{maintitle+booktitle}}%
    {\printfield{mainshorthand}}%added, here I want the shorthand from the mvreference (NG)
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \printfield{edition}%
  \newunit
  \iffieldundef{maintitle}
    {\printfield{volume}%
     \printfield{part}}
    {}%
  \newunit
  \printfield{volumes}%
  \newunit\newblock
  \usebibmacro{series+number}%
  \newunit\newblock
  \printfield{note}%
  \newunit\newblock
  \usebibmacro{publisher+location+date}%
  \newunit\newblock
  \usebibmacro{chapter+pages}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{isbn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}


\begin{document}
\nocite{*}
\noindent{}The author wrote something about my subject.\autocite[35]{author-NG-ML}
\printshorthands
\printbibliography[nottype=mvreference, nottype=reference]
\end{document}



输出:

姓氏,名字。艺术。文章标题。 在:新版格罗夫音乐与音乐家词典.第11卷:林德曼——卑鄙的语气。斯坦利·萨迪 (Stanley Sadie) 编。20 卷。伦敦:麦克米伦,1980 年,第 30-40 页。

我曾尝试使用命令\DeclareDataInheritance来继承速记,但无法使其工作。

答案1

该解决方案可能非常适合您的需求。

正如评论中所提到的,最好有一个mainshorthand可以inreference从中继承的mvreference

这是通过名为的自定义数据模型文件完成的refinherit.dbx,您必须将此文件放在 LaTeX 可以找到的地方。

\ProvidesFile{refinherit.dbx}[2014/04/03]
\RequireBiber[3]

\DeclareDatamodelFields[type=field,datatype=literal]{mainshorthand}
\DeclareDatamodelEntryfields{mainshorthand}
\endinput

在下面的 MWE 中,这是通过实现的filecontents,显然您会在实际用例中将文件放在适当的位置。

我们通过选项加载此数据datamodel模型

\usepackage[style=verbose-ibid, backend=biber, datamodel=refinherit]{biblatex}

然后我们声明继承

\DeclareDataInheritance{mvreference}{inreference,reference}{%
  \inherit{shorthand}{mainshorthand}
  \noinherit{volumes}
}

也就是说,mvreferenceshorthand变成了inreferencemainshorthand

最后,我们修改驱动程序以省略一些信息,并在可用时inreference打印mainshorthand

\DeclareBibliographyDriver{inreference}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \printtext{Art.}%added
  \newunit%added
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{in:}%
  \iffieldundef{mainshorthand}
    {\usebibmacro{maintitle+booktitle}%
     \usebibmacro{byeditor+others}%
     \newunit\newblock
     \printfield{edition}}%
    {\printfield{mainshorthand}}%
  \newunit
  \printfield{volume}%
  \printfield{part}%
  \newunit
  \iffieldundef{mainshorthand}
    {\printfield{volumes}%
     \newunit\newblock
     \usebibmacro{series+number}%
     \newunit\newblock
     \printfield{note}%
     \newunit\newblock
     \usebibmacro{publisher+location+date}}%
    {}%
  \newunit\newblock
  \usebibmacro{chapter+pages}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{isbn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}

平均能量损失

\documentclass[ngerman]{article}
\usepackage{filecontents}
\begin{filecontents*}{refinherit.dbx}
\ProvidesFile{refinherit.dbx}[2014/04/03]
\RequireBiber[3]

\DeclareDatamodelFields[type=field,datatype=literal]{mainshorthand}
\DeclareDatamodelEntryfields{mainshorthand}
\endinput
\end{filecontents*}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[style=verbose-ibid, backend=biber, datamodel=refinherit]{biblatex}

\begin{filecontents*}{\jobname.bib}
@mvreference{NG,
  title       = {The new Grove dictionary of music and musicians},
  editor      = {Stanley Sadie},
  editora     = {Grove, George},
  editoratype = {founder},
  year        = {1980},
  volumes     = {20},
  shorthand   = {NG},
  location    = {London},
  publisher   = {Macmillan},
}

@reference{NG-BD11,
  crossref  = {NG},
  title     = {Lindeman -- Mean-tone},
  volume    = {11},
  year      = {1980},
}

@inreference{author-NG-ML,
  crossref  = {NG-BD11},
  author    = {Arnold Uthor},
  title     = {Firstname Lastname},
  pages     = {30--40},
}

\end{filecontents*}
\addbibresource{\jobname.bib}

\DeclareDataInheritance{mvreference}{inreference,reference}{%
  \inherit{shorthand}{mainshorthand}
  \noinherit{volumes}
}

%what to print out?
\DeclareBibliographyDriver{inreference}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \printtext{Art.}%added
  \newunit%added
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{in:}%
  \iffieldundef{mainshorthand}
    {\usebibmacro{maintitle+booktitle}%
     \usebibmacro{byeditor+others}%
     \newunit\newblock
     \printfield{edition}}%
    {\printfield{mainshorthand}}
  \newunit
  \printfield{volume}%
  \printfield{part}%
  \newunit
  \iffieldundef{mainshorthand}
    {\printfield{volumes}%
     \newunit\newblock
     \usebibmacro{series+number}%
     \newunit\newblock
     \printfield{note}%
     \newunit\newblock
     \usebibmacro{publisher+location+date}}%
    {}%
  \newunit\newblock
  \usebibmacro{chapter+pages}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{isbn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}%
  \usebibmacro{finentry}}


\begin{document}
\nocite{*}
\noindent{}The author wrote something about my subject.\autocite[35]{author-NG-ML}
\printshorthands
\printbibliography[nottype=mvreference, nottype=reference]
\end{document}

在此处输入图片描述

相关内容