使用现有字段 ( part)

使用现有字段 ( part)

我需要在@book@InProceedings条目中添加一个新字段:该字段是“tome”,例如我有以下标题:

Francesco Bertolini, Società di trasmissione orale: mito e folclore, in Lo spazio letterario della Grecia antica, a cura di G. Cambiano, L. Canfora e D. Lanza, vol. I, tomo I, Salerno, Roma 1992, pp. 47--75.

因此下面的代码是不够的:

@InProceedings{ bertolini:1992,
  author                   = "Francesco Bertolini",
  title                    = "Società di trasmissione orale: mito e folclore",
  booktitle                = "Lo spazio letterario della Grecia antica",
  editor                   = "G. Cambiano and L. Canfora and D. Lanza",
  publisher                = "Salerno",
  location                 = "Roma",
  year                     = "1992",
  volume                   = "1,
  pages                    = "47--75",
}

使用其他代码,我只能生成“tome”字段,但其他字段却存在一般麻烦:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=tome,fieldtarget=usera]
    }
  }
}
\DeclareFieldFormat{usera}{tomo\space{#1}}


\DeclareBibliographyDriver{book}{%
  \usebibmacro{author/editor}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit\newblock
  \usebibmacro{journal+issuetitle}%
  \setunit{\bibpagespunct}%
  \printfield{pages}%
  \newunit\newblock
  \printfield{usera}%
  \usebibmacro{finentry}}
\renewcommand*{\finentrypunct}{}

(对文章有用,但对我的情况没用)。实际上,我无法理解我必须调用哪个 bibmascros...

我尝试写一个biblatex-tome.dbx

\ProvidesFile{biblatex-tome.dbx} 

\DeclareDatamodelFields[type=field,datatype=literal,skipout=false]{tome} 

\DeclareDatamodelEntryfields{tome}

在主.tex文件中我只放入了以下代码:

\DeclareFieldFormat{tome}{\mkbibacro{tome}\addcolon\space #1}
\newcommand*{\patchmoretome}[1]{
  \xpatchbibdriver{#1}%
    {\printfield{tome}}
    {\printfield{tome}%
          \newunit\newblock
     \printfield{tome}}%
    {\typeout{patching #1 to include more tome succeded}}%
    {\typeout{patching #1 to include more tome failed}}%
}
% patch all drivers
\patchmoretome{article}
\patchmoretome{book}
\patchmoretome{collection}
\patchmoretome{inbook}
\patchmoretome{incollection}
\patchmoretome{inproceedings}
\patchmoretome{manual}
\patchmoretome{periodical}
\patchmoretome{proceedings}
\patchmoretome{report}
\patchmoretome{thesis}

但它不会在书目条目中打印该字段。所以我对驱动程序的(重写)非常困惑

答案1

使用现有字段 ( part)

如果您使用该part字段来表示书籍信息1,则标准样式中没有太多可做的事情。但是,如果您有非标准/自定义样式来移动信息part,则需要告诉我们更多信息。

这四行应该可以满足您的要求。它们将字符串部分重新定义为“tomo”,并在卷后打印“,tomo #”。

\DefineBibliographyStrings{italian}{%
  part = {tomo},
}
\DeclareFieldFormat{part}{\addcomma\space\bibstring{part}\space #1}

所有标准样式都使用序列

\printfield{volume}%
\printfield{part}%

来打印part信息,所以我们应该没问题。

(通常,放入\addcomma和类似的东西\DeclareFieldFormat是不受欢迎的,但该part字段似乎很特殊,因为默认格式是这样的,并且在任何标准样式之间和{.#1}之间都没有插入其他标点符号。)volumepart

您的bib参赛作品将是

@InProceedings{bertolini:1992,
  author         = "Francesco Bertolini",
  title          = "Società di trasmissione orale: mito e folclore",
  booktitle      = "Lo spazio letterario della Grecia antica",
  editor         = "G. Cambiano and L. Canfora and D. Lanza",
  publisher      = "Salerno",
  location       = "Roma",
  year           = "1992",
  volume         = "1",
  part           = "2",
  pages          = "47--75",
}

完整 MWE

\documentclass[italian]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[]{biblatex}
\usepackage{filecontents}

%\DeclareFieldFormat{part}{.#1}% physical part of a logical volume
\DefineBibliographyStrings{italian}{%
  part = {tomo},
}
\DeclareFieldFormat{part}{\addcomma\space\bibstring{part}\space #1}

\begin{filecontents*}{\jobname.bib}
@InProceedings{bertolini:1992,
  author         = "Francesco Bertolini",
  title          = "Società di trasmissione orale: mito e folclore",
  booktitle      = "Lo spazio letterario della Grecia antica",
  editor         = "G. Cambiano and L. Canfora and D. Lanza",
  publisher      = "Salerno",
  location       = "Roma",
  year           = "1992",
  volume         = "1",
  part           = "2",
  pages          = "47--75",
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
\cite{bertolini:1992}
\printbibliography
\end{document}

在此处输入图片描述


1biblatex文档第 21 页第 2.2.2 节规定数据字段

part(字段(文字))部分卷的编号。此字段仅适用于书籍,不适用于期刊。当逻辑卷由两个或多个物理卷组成时,可以使用它。在这种情况下,逻辑卷的编号位于字段中,volume该卷的部分的编号位于字段中 part


将字段映射到现有字段(part

您还可以将字段映射到tome,从而part为输入目的创建别名

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=tome]
      \step[fieldset=part, origfieldval]
    }
  }
}

示例条目可能看起来像这样

@InProceedings{bertolini:1992,
  author         = "Francesco Bertolini",
  title          = "Società di trasmissione orale: mito e folclore",
  booktitle      = "Lo spazio letterario della Grecia antica",
  editor         = "G. Cambiano and L. Canfora and D. Lanza",
  publisher      = "Salerno",
  location       = "Roma",
  year           = "1992",
  volume         = "1",
  tome           = "3",
  pages          = "47--75",
}

对于更一般的用途,biblatex将五个通用字段定义userauserf(以及列表字段的为和名称的为lista)。虽然在输入文件中使用这些字段可能很尴尬,因为输入文件中需要更有用的名称,但它们对于内部重新映射很有用。listfnameanamec.bib


声明一个新字段

如果你坚持要创建一个新的数据字段tome,请创建一个新的数据模型文件,,tome.dbx其中包含以下内容,并将其放在 LaTeX 可以找到的地方(从 2.9 版开始这是必要的,在此之前,可以直接在文档中使用数据模型命令,但不能保证一定有效,因此强烈不建议这样做,请参阅数据模型宏不能在序言中使用.dbx;如果您将文件放在与主文档相同的文件夹中, LaTeX 将能够找到该文件.tex,其他使文件全局可用的选项将在https://texfaq.org/FAQ-inst-wlcf)。

\ProvidesFile{tome.dbx}[2019/20/02 add tome field to biblatex data model]

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

(在下面的 MWE 中,使用包自动创建此文件filecontents。)

然后,我们必须biblatex使用选项加载datamodel=tome,以便加载tome定义的正确数据模型。或者,您可以将上述行放入biblatex-dm.cfg(参见如何在参考书目中包含价格?)。

我们再次使用本地化字符串

\NewBibliographyString{tome}
\DefineBibliographyStrings{italian}{%
  tome = {tomo},
}

\DeclareFieldFormat{tome}{\bibstring{tome}\space #1}

然后,我们将必须修补所有驱动程序/宏以包含tome信息,这是一项相当艰巨的任务......

我们renew有一些宏

\renewbibmacro*{maintitle+title}{%
  \iffieldsequal{maintitle}{title}
    {\clearfield{maintitle}%
     \clearfield{mainsubtitle}%
     \clearfield{maintitleaddon}}
    {\iffieldundef{maintitle}
       {}
       {\usebibmacro{maintitle}%
    \newunit\newblock
    \iffieldundef{volume}
      {}
      {\printfield{volume}%
     \setunit{addcomma\space}%
     \printfield{tome}
           \printfield{part}%
           \setunit{\addcolon\space}}}}%
  \usebibmacro{title}%
  \newunit}

\renewbibmacro*{maintitle+booktitle}{%
  \iffieldundef{maintitle}
    {}
    {\usebibmacro{maintitle}%
     \newunit\newblock
     \iffieldundef{volume}
       {}
       {\printfield{volume}%
     \setunit{addcomma\space}%
     \printfield{tome}
        \printfield{part}%
        \setunit{\addcolon\space}}}%
  \usebibmacro{booktitle}%
  \newunit}

并添加到驱动程序中

\newcommand*{\addtometo}[1]{%
  \xpatchbibdriver{#1}
    {\printfield{volume}}
    {\printfield{volume}%
     \setunit{\addcomma\space}%
     \printfield{tome}}
    {}
    {\typeout{failed to add tome to #1 driver}}
}
\addtometo{inproceedings}
\addtometo{book}

平均能量损失

\documentclass[italian]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}


\usepackage{filecontents}
\begin{filecontents*}{tome.dbx}
\ProvidesFile{tome.dbx}[2019/20/02 add tome field to biblatex data model]

\DeclareDatamodelFields[type=field,datatype=literal]{tome}
\DeclareDatamodelEntryfields{tome}
\end{filecontents*}

\usepackage[backend=biber,datamodel=tome]{biblatex}


%\DeclareFieldFormat{part}{.#1}% physical part of a logical volume
\NewBibliographyString{tome}
\DefineBibliographyStrings{italian}{%
  tome = {tomo},
}


\DeclareFieldFormat{tome}{\bibstring{tome}\space #1}

\usepackage{xpatch}

\newcommand*{\addtometo}[1]{%
  \xpatchbibdriver{#1}
    {\printfield{volume}}
    {\printfield{volume}%
     \setunit{\addcomma\space}%
     \printfield{tome}}
    {}
    {\typeout{failed to add tome to #1 driver}}
}
\addtometo{proceedings}
\addtometo{inproceedings}
\addtometo{book}
\addtometo{inbook}

\renewbibmacro*{maintitle+title}{%
  \iffieldsequal{maintitle}{title}
    {\clearfield{maintitle}%
     \clearfield{mainsubtitle}%
     \clearfield{maintitleaddon}}
    {\iffieldundef{maintitle}
       {}
       {\usebibmacro{maintitle}%
    \newunit\newblock
    \iffieldundef{volume}
      {}
      {\printfield{volume}%
     \setunit{addcomma\space}%
     \printfield{tome}
           \printfield{part}%
           \setunit{\addcolon\space}}}}%
  \usebibmacro{title}%
  \newunit}

\renewbibmacro*{maintitle+booktitle}{%
  \iffieldundef{maintitle}
    {}
    {\usebibmacro{maintitle}%
     \newunit\newblock
     \iffieldundef{volume}
       {}
       {\printfield{volume}%
     \setunit{addcomma\space}%
     \printfield{tome}
        \printfield{part}%
        \setunit{\addcolon\space}}}%
  \usebibmacro{booktitle}%
  \newunit}

\begin{filecontents*}{\jobname.bib}
@InProceedings{bertolini:1992,
  author         = "Francesco Bertolini",
  title          = "Società di trasmissione orale: mito e folclore",
  booktitle      = "Lo spazio letterario della Grecia antica",
  editor         = "G. Cambiano and L. Canfora and D. Lanza",
  publisher      = "Salerno",
  location       = "Roma",
  year           = "1992",
  volume         = "1",
  tome           = "3",
  pages          = "47--75",
}
\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
\cite{bertolini:1992}
\printbibliography
\end{document}

那么多麻烦可能不值得,因为我们已经part做得相当好了。

相关内容