编辑 Biblatex BibliographyDriver @online:使用 \iffieldundef 并使用不同的语言

编辑 Biblatex BibliographyDriver @online:使用 \iffieldundef 并使用不同的语言

几周前我刚开始使用 LaTeX,现在我越来越熟练了。但现在当我尝试形成自己的.bbx风格时,biblatex我陷入了困境:我无法编辑online驱动程序的参考书目以满足我的需求。我想提一下,如果我在网上找到的文章也发表在书籍或期刊上。

这是我到目前为止所得到的结果:

 \DeclareBibliographyDriver{online}{%
   \usebibmacro{bibindex}%
   \usebibmacro{begentry}%
   \usebibmacro{author/editor+others/translator+others}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{title}%
   \newunit
   \printlist{language}%
   \newunit\newblock
   \usebibmacro{url+urldate}%
   \usebibmacro{addendum+pubstate}%
   \setunit{\addspace}%
   \iffieldundef{crossref}{}{\usebibmacro{in:}}%
   \usebibmacro{bybookauthor}%
   \setunit*{\addslash} \newblock
   \usebibmacro{byeditor+others}%
   \setunit{\addcolon\space}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{journal+issuetitle}%
   \printfield{edition}%
   \newunit\newblock
   \printfield{note}%
   \newunit\newblock
   \usebibmacro{publisher+location+date}%
   \newunit\newblock
   \usebibmacro{chapter+pages}%
   \newunit\newblock
   \iftoggle{bbx:isbn}
   {\printfield{isbn}}
   {}%
   \newunit\newblock
   \printfield{doi}%
   \newunit\newblock
   \printfield{eprint}%
   \usebibmacro{finentry}}

如您所见,我尝试使用\iffieldundef{crossref},这样只要field{crossref}定义了,就会bibmacro{in:}显示,如果未定义字段,则会忽略。但使用上面的定义,它根本不会打印“In:”!

我还想修改打印的文本bibmacro{in:}。例如,如果field{crossref}使用英语定义:

   Huber, Gerald (2013): Having trouble with biblatex. www.goforlatex.com. 
   [Visited on 02/19/2013] **Also in**: Jacobs, Daniel (ed.) (2013): 
   Solvingall the biblatex problems. Vienna: Latex University Press, pp. 1-999.

另一方面使用德语:

   Huber, Gerald (2013): Having trouble with biblatex. www.goforlatex.com. 
   [Besucht am 19.2.2013] **Auch in**: Jacobs, Daniel (ed.) (2013): Solving all 
   the biblatex problems. Vienna: Latex University Press, S. 1-999.

field{crossref}应该只导致:

   Huber, Gerald (2013): Having trouble with biblatex. www.goforlatex.com. 
   [Visited on 02/19/2013]

因此,一方面,我需要使bibmacro{in:}依赖于field{crossref}并修改它,以在使用英语时显示“Also in:”或在使用德语时显示“Auch in:”。

我不知道尝试解决第一个问题是否是个好主意,\iffieldundef而且关于语言问题,我不知道从哪里开始。所以我向你们寻求帮助,巨大的网络空间-(bib)latex-社区。

这里有一个例子,说明我目前所拥有的内容:

\documentclass[a4paper,12pt]{scrreprt}

\usepackage[ngerman]{babel} 

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage[babel]{csquotes}

%%%bibliography entries
\begin{filecontents}{literatur.bib}

@online{huber.12o,%
    author = {1 Crossref},
    title = {Having trouble with biblatex},
    year = {2013},
    url = {www.goforlatex.com}, 
    urldate = {2013-02-19},
    crossref = {huber.12},
    }

@article{huber.12,%
    author = {1 Crossref},
    title = {Having trouble with biblatex},
    year = {2013},
    journal = {The Great Biblatex Journal},
    volume = {3},
    number = {11},
    pages = {1-999},
    }

@online{huber.13o,%
    author = {2 Crossref},
    title = {Having trouble with biblatex},
    year = {2013},
    url = {www.goforlatex.com}, 
    urldate = {2013-02-19},
    crossref = {huber.13},
    }   

@inbook{huber.13,%
    crossref = {jacobs.13},
    title = {Having trouble with biblatex},
    author = {2 crossref},
    pages = {1--999},
    year = {2013},
     }

@book{jacobs.13,%
    editor = {Daniel Jacobs},
    year = {2013},
    address = {Vienna},
    publisher = {Latex University Press},
    title = {Solving all the Latex problems},
    edition = {5}
    }

@online{nocrossref,%
    author = {Crossref No},
    title = {Some articles are just available in the www},
    url = {www.whereisthecross.com},
    urldate = {2013-02-19},
    year = {2013},
    }
\end{filecontents}

\usepackage[citestyle=authoryear,bibstyle=authoryear,sorting=nyt,maxbibnames=3,bibencoding=utf8,backend=biber]{biblatex} 

%%% here is where it gets interesting...      
\DeclareBibliographyDriver{online}{%
    \usebibmacro{bibindex}%
    \usebibmacro{begentry}%
    \usebibmacro{author/editor+others/translator+others}%
    \setunit{\labelnamepunct}\newblock
    \usebibmacro{title}%
    \newunit
    \printlist{language}%
    \newunit\newblock
    \usebibmacro{url+urldate}%
    \usebibmacro{addendum+pubstate}%
    \setunit{\addspace}%
    \iffieldundef{crossref}{}{\usebibmacro{in:}}%
    \usebibmacro{bybookauthor}%
    \setunit*{\addslash} \newblock
    \usebibmacro{byeditor+others}%
    \setunit{\addcolon\space}\newblock
    \usebibmacro{maintitle+booktitle}%
    \newunit\newblock
    \usebibmacro{journal+issuetitle}%
    \printfield{edition}%
    \newunit\newblock
    \printfield{note}%
    \newunit\newblock
    \usebibmacro{publisher+location+date}%
    \newunit\newblock
    \usebibmacro{chapter+pages}%
    \newunit\newblock
    \iftoggle{bbx:isbn}
    {\printfield{isbn}}
    {}%
    \newunit\newblock
    \printfield{doi}%
    \newunit\newblock
    \printfield{eprint}%
    \usebibmacro{finentry}}

\bibliography{literatur.bib}

\begin{document}

\nocite{huber.12o}
\nocite{huber.13o}
\nocite{nocrossref}

\printbibliography

\end{document}

希望有人能帮助我,任何提示都会受到赞赏......

答案1

字段crossref可以看作是指向bbl文件中父条目的指针。如果父条目不满足mincrossrefs纳入的阈值bbl,则子crossref条目的字段将未定义。要解决这个问题,您可以使用加载 biblatex mincrossrefs=1,但您可能需要从参考书目中过滤掉未引用的父条目。

biblatex 2.0/biber 1.0 引入的 biber-only 相关条目功能避免了这种复杂情况。交叉引用的条目列在字段中related。字段中给出的键relatedtype指定用于设置相关条目数据的分隔字符串和参考书目宏。相关条目仅在直接引用时才会出现在参考书目中。

以下示例还演示了如何在序言中定义新的参考书目字符串。如果您正在创建样式,您可能希望定义自己的英语和德语本地化文件。这些文件可以在标准模块english.lbx和之上轻松定义german.lbx。请参阅austrian.lbx示例和 biblatex 手册以了解更多详细信息。

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[backend=biber]{biblatex}
\usepackage[colorlinks]{hyperref}

\renewcommand*{\relatedpunct}{\addcolon\space}
\renewcommand*{\relateddelim}{\addsemicolon\space}

\NewBibliographyString{alsoin}
\DefineBibliographyStrings{english}{alsoin = {also in}}
\DefineBibliographyStrings{german}{alsoin = {auch in}}

\newbibmacro*{related:alsoin}[1]{%
  \entrydata*{#1}{%
    \usedriver
      {\renewbibmacro{in:}{}%
       \ifnamesequal{author}{savedauthor}{\clearname{author}}{}%
       \iffieldsequal{title}{savedtitle}{\clearfield{title}}{}}
      {\thefield{entrytype}}}}

\begin{filecontents}{\jobname.bib}
@article{kasher/toc,
  author = {Roy Kasher and Julia Kempe},
  title = {Two-Source Extractors Secure Against Quantum Adversaries},
  year = {2012},
  pages = {461-486},
  doi = {10.4086/toc.2012.v008a021},
  journal = {Theory of Computing},
  volume = {8},
  number = {1}}
@online{kasher/arxiv,
  author = {Kasher, Roy and Kempe, Julia},
  title = {Two-Source Extractors Secure Against Quantum Adversaries},
  eprinttype = {arxiv},
  eprintclass = {quant-ph},
  eprint = {1005.0512},
  month = may,
  year = {2010},
  related = {approx13,kasher/toc},
  relatedtype = {alsoin}}
@proceedings{approx13,
  editor = {Serna, Maria and Shaltiel, Ronen and Jansen, Klaus and Rolim, Jos{\'e}},
  title = {Proceedings of the 13th international conference on Approximation,
    and the 14th International conference on Randomization, and combinatorial
    optimization: algorithms and techniques},
  series = {APPROX/RANDOM'10},
  year = {2010},
  venue = {Barcelona, Spain},
  publisher = {Springer-Verlag},
  location = {Berlin, Heidelberg}}
\end{filecontents}

\addbibresource{\jobname.bib}
\begin{document}
\cite{kasher/arxiv,approx13}
\printbibliography
\end{document}

在此处输入图片描述

相关内容