Biblatex authoryear-ibid:参考书目具体变化

Biblatex authoryear-ibid:参考书目具体变化

首先,感谢 tex.stackexchange 成为网络上最好的 TeX 参考资料。我已经使用档案库好几个月了,总能找到问题的答案。

但现在我陷入困境:

我正在使用biblatexauthoryear-ibid样式。我需要对我的参考书目进行一些特定的更改。

目前,@incollection-entry 的打印内容如下:

爱因斯坦,阿尔伯特 (1929)。《使用 LaTeX》。《LaTeX 用户指南》。斯蒂芬·霍金斯编辑。纽约:出版社,第 15-40 页。网址:http:\\en.wikipedia.org。

但我还必须参考@collection如下打印内容:

Hawkins, Stephen 编。(1929 年)。Latex 用户指南。纽约:出版社。网址:http:\\en.wikipedia.org。

现在第一个问题是:出版商、地址和 URL 都打印在条目中,@incollection这使得我的参考书目变得人为且不必要的长。

我想要的是:

爱因斯坦,阿尔伯特 (1929)。»使用 LaTeX«。在:Latex 用户指南。由斯蒂芬·霍金斯编辑,第 15-40 页。

第二个问题:当编辑也是同一@collection本书的作者时,所有内容都会打印两次,这也使得参考书目人为地变长。目前它打印如下

Hawkins, Stephen 编辑 (1929a)。Latex 用户指南。纽约:出版社。网址:http:\\en.wikipedia.org。

--- (1929b)。《理解 LaTeX》。《LaTeX 用户指南》。Stephen Hawkins 编辑。纽约:出版社,第 1-15 页。网址:http:\\en.wikipedia.org。

但我更希望它打印出如下内容:

Hawkins, Stephen 编辑 (1929a)。Latex 用户指南。纽约:出版社。网址:http:\\en.wikipedia.org。

--- (1929b)。《理解 LaTeX》。由同一人编辑,收录于《Latex 用户指南》,第 1-15 页。

(德语中是:)

霍金斯,斯蒂芬斯 (1929b)。《理解 LaTeX》。在以下位置:Latex 用户指南,第 1-15 页。

我怎样才能实现这一点?

非常感谢

编辑:

最小工作示例(使用 xelatex 和 biber 编译)

\documentclass[12pt,a4paper,oneside]{memoir}

\usepackage[ngerman]{babel}
\usepackage[german=guillemets]{csquotes}

\usepackage[%
            style=authoryear-ibid,
            backend=biber,
            backref=true,
            backrefstyle=none,
            doi=false,
            isbn=false,
            maxcitenames=2,
            maxbibnames=2,
            ]{biblatex}
            
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@collection{hawkins.1923,
    editor  = "Hawkins, Stephen",
    title   = "The Latex User's Guide",
    year    = "1923",
    publisher = "Publisher",
    address = "New York",
    url = "en.wikipedia.org",
}
@incollection{hawkins.1923b,
    author = "Hawkins, Stephen",
    title = "Understanding LaTeX",
    crossref = "hawkins.1923",
    pages = "1-15",
}

@incollection{einstein.1923,
    author = "Einstein, Albert",
    title = "Using LaTeX",
    crossref = "hawkins.1923",
    pages = "16-45",
}
\end{filecontents}

\bibliography{\jobname} 

\begin{document}

\nocite{*}

\printbibliography

\end{document}

答案1

大部分问题可以通过改变字段从交叉引用条目@collection到其子@incollection条目的继承来解决。请注意,默认继承(biblatex 手册附录中描述)只能使用 biber 进行更改。

其余部分可以通过跟踪editor书目条目之间的名称来处理。这里通过重新定位\indexnames和比较字段来完成hash

\documentclass{article}
\usepackage[american]{babel}
%\usepackage[german]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,style=authoryear-ibid]{biblatex}
\usepackage{xpatch}

% just for demo
\ExecuteBibliographyOptions{abbreviate=false}

\NewBibliographyString{same}
\DefineBibliographyStrings{american}{same = {same}}
\DefineBibliographyStrings{german}{same = {ders}}

% @incollection gets editor not publisher, address, url from @collection
\DeclareDataInheritance{collection}{incollection}{
  \inherit{editor}{editor}
  \noinherit{publisher}
  \noinherit{location}
  \noinherit{url}
}

% collect editor name hash
\newcommand*{\editorhash}{}
\newcommand*{\lasteditorhash}{}
\DeclareIndexNameFormat{gethash}{\xappto{\editorhash}{\thefield{hash},}}

% replace recurrent editor list with same string
\AtEveryBibitem{%
  \let\lasteditorhash\editorhash
  \renewcommand*{\editorhash}{}%
  \indexnames[gethash]{editor}%
  \ifdefstrequal{\lasteditorhash}{\editorhash}
    {\xapptobibmacro{byeditor+othersstrg}
       {\setunit{\addspace}\bibstring{same}\clearname{editor}}{}{}}
    {}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Collection{hawkins:ed,
  editor       = {Hawkins, Stephen},
  title        = {The Latex User's Guide},
  year         = 1923,
  publisher    = {Publisher},
  url          = {en.wikipedia.org},
  address      = {New York},
}
@InCollection{hawkins,
  author       = {Hawkins, Stephen},
  title        = {Understanding LaTeX},
  pages        = {1-15},
  crossref     = {hawkins:ed},
}
@InCollection{einstein,
  author       = {Einstein, Albert},
  title        = {Using LaTeX},
  pages        = {16-45},
  crossref     = {hawkins:ed},
}
\end{filecontents}
\bibliography{\jobname,biblatex-examples} 

\begin{document}
\nocite{hawkins:ed,hawkins,einstein,nietzsche:ksa,nietzsche:ksa1}
\printbibliography
\end{document}

在此处输入图片描述

请注意,当重复出现时,我没有费心去反转“在......”和“由......编辑”片段editor,但您可以通过将代码挂接到参考书目宏中来实现这一点in:

答案2

不幸的是,要实现这一目标还有很多工作要做。

代码的第一部分确保将编辑器移至@inbook和的标题之前@incollection

\newbibmacro*{ineditor+others}{%
  \ifboolexpr{
    not test {\ifnameundef{editor}}
  }
    {\ifnamesequal{editor}{author}% if author equals editor, print idem
      {\printtext{\bibstring{idem\thefield{gender}}}%
       \setunit{\labelnamepunct}\newblock}%
      {\printnames{editor}}%
     \setunit{\addcomma\space}%
     \usebibmacro{editor+othersstrg}%
     \clearname{editor}}%
    {}}

\newbibmacro*{inauthor/editor+others/translator+others}{%
  \ifboolexpr{
    not test {\ifnameundef{bookauthor}}
  }
    {\usebibmacro{bybookauthor}}
    {\ifboolexpr{
       not test {\ifnameundef{editor}}
     }
       {\usebibmacro{ineditor+others}}
       {%\usebibmacro{translator+others}
       }}}

\xpatchbibdriver{incollection}
  {\usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
  }
  {\usebibmacro{ineditor+others}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
%       \usebibmacro{byeditor+others}%
  }%
  {\typeout{replaced \usebibmacro{byeditor+others} by \usebibmacro{ineditor+others} in BibliographyDriver{incollection}}}
  {\typeout{failed to replace \usebibmacro{byeditor+others} by \usebibmacro{ineditor+others} in BibliographyDriver{incollection}}}%


\xpatchbibdriver{inbook}
  {\usebibmacro{bybookauthor}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
  }
  {\usebibmacro{inauthor/editor+others/translator+others}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
  }%
  {}
  {\typeout{failed to replace \usebibmacro{byeditor+others} by \usebibmacro{ineditor+others} in BibliographyDriver{inbook}}}%

如果参考书目中已有条目,则以下内容缩短条目crossref@in....crossref

\newcommand{\shortxref}[1]{%
  \xpatchbibdriver{#1}
    {\usebibmacro{publisher+location+date}%
    }
    {\ifentryinbib{\thefield{crossref}}
      {}
      {\usebibmacro{publisher+location+date}}%
    }%
    {}
    {\typeout{failed to shorten crossref in #1}}%
  \xpatchbibdriver{#1}
    {\iftoggle{bbx:isbn}
      {\printfield{isbn}}
      {}%
    }
    {\ifentryinbib{\thefield{crossref}}
      {}
      {\iftoggle{bbx:isbn}
        {\printfield{isbn}}
        {}}%
    }%
    {}
    {\typeout{failed to shorten crossref in #1}}
  \xpatchbibdriver{#1}
    {\usebibmacro{series+number}}
    {\ifentryinbib{\thefield{crossref}}
      {}
      {\usebibmacro{series+number}}%
    }%
    {}
    {\typeout{failed to shorten crossref in #1}}
}
\shortxref{incollection}
\shortxref{inbook}

我没有在这里删除 URL,但可以通过以下方式完成

\xpatchbibdriver{#1}
  {\usebibmacro{doi+eprint+url}}
  {\ifentryinbib{\thefield{crossref}}
     {}
     {\usebibmacro{doi+eprint+url}}%
  }%
  {}
  {\typeout{failed to shorten crossref in #1}}

平均能量损失

\documentclass[12pt,a4paper,oneside]{memoir}
\usepackage{xpatch}
\usepackage[ngerman]{babel}
\usepackage[german=guillemets]{csquotes}

\usepackage[%
            style=authoryear-ibid,
            backend=biber,
            backref=true,
            backrefstyle=none,
            doi=false,
            isbn=false,
            maxcitenames=2,
            maxbibnames=2,
            ]{biblatex}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@collection{hawkins.1923,
    editor  = "Hawkins, Stephen",
    title   = "The Latex User's Guide",
    year    = "1923",
    publisher = "Publisher",
    address = "New York",
    url = "en.wikipedia.org",
    series = {A Series},
    number  = {6},
}
@incollection{hawkins.1923b,
    author = "Hawkins, Stephen",
    title = "Understanding LaTeX",
    crossref = "hawkins.1923",
    pages = "1-15",
}

@incollection{einstein.1923,
    author = "Einstein, Albert",
    title = "Using LaTeX",
    crossref = "hawkins.1923",
    pages = "16-45",
}
\end{filecontents*}

\addbibresource{\jobname.bib}

\newbibmacro*{ineditor+others}{%
  \ifboolexpr{
    not test {\ifnameundef{editor}}
  }
    {\ifnamesequal{editor}{author}% if author equals editor, print idem
      {\printtext{\bibstring{idem\thefield{gender}}}%
       \setunit{\labelnamepunct}\newblock}%
      {\printnames{editor}}%
     \setunit{\addcomma\space}%
     \usebibmacro{editor+othersstrg}%
     \clearname{editor}}%
    {}}

\newbibmacro*{inauthor/editor+others/translator+others}{%
  \ifboolexpr{
    not test {\ifnameundef{bookauthor}}
  }
    {\usebibmacro{bybookauthor}}
    {\ifboolexpr{
       not test {\ifnameundef{editor}}
     }
       {\usebibmacro{ineditor+others}}
       {%\usebibmacro{translator+others}
       }}}

\xpatchbibdriver{incollection}
  {\usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
  }
  {\usebibmacro{ineditor+others}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
%       \usebibmacro{byeditor+others}%
  }%
  {\typeout{replaced \usebibmacro{byeditor+others} by \usebibmacro{ineditor+others} in BibliographyDriver{incollection}}}
  {\typeout{failed to replace \usebibmacro{byeditor+others} by \usebibmacro{ineditor+others} in BibliographyDriver{incollection}}}%


\xpatchbibdriver{inbook}
  {\usebibmacro{bybookauthor}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
  }
  {\usebibmacro{inauthor/editor+others/translator+others}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}%
  }%
  {}
  {\typeout{failed to replace \usebibmacro{byeditor+others} by \usebibmacro{ineditor+others} in BibliographyDriver{inbook}}}%

\newcommand{\shortxref}[1]{%
  \xpatchbibdriver{#1}
    {\usebibmacro{publisher+location+date}%
    }
    {\ifentryinbib{\thefield{crossref}}
      {}
      {\usebibmacro{publisher+location+date}}%
    }%
    {}
    {\typeout{failed to shorten crossref in #1}}%
  \xpatchbibdriver{#1}
    {\iftoggle{bbx:isbn}
      {\printfield{isbn}}
      {}%
    }
    {\ifentryinbib{\thefield{crossref}}
      {}
      {\iftoggle{bbx:isbn}
        {\printfield{isbn}}
        {}}%
    }%
    {}
    {\typeout{failed to shorten crossref in #1}}
  \xpatchbibdriver{#1}
    {\usebibmacro{series+number}}
    {\ifentryinbib{\thefield{crossref}}
      {}
      {\usebibmacro{series+number}}%
    }%
    {}
    {\typeout{failed to shorten crossref in #1}}
}
\shortxref{incollection}
\shortxref{inbook}

\begin{document}
  \nocite{*}

  \printbibliography
\end{document}

在此处输入图片描述

相关内容