BibLateX 中缺失字段的替换文本

BibLateX 中缺失字段的替换文本

考虑一下这个MWE:

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
    @article{article,
        author  = {Peter Adams}, 
        title   = {The title of the work},
        journal = {The name of the journal},
        year    = 1993,
        number  = 2,
        pages   = {201-213},
        month   = 7,
        note    = {An optional note}, 
        volume  = 4
    }
    @book{book,
        author    = {Peter Babington}, 
        title     = {The title of the work},
        publisher = {The name of the publisher},
        year      = 1993,
        volume    = 4,
        series    = 10,
        address   = {The address},
        edition   = 3,
        month     = 7,
        note      = {An optional note},
        isbn      = {3257227892}
    }
\end{filecontents}

\usepackage[backend=biber]{biblatex}
\addbibresource{\jobname.bib}

\begin{document}

\citefield{article}{journaltitle}

\citefield{book}{journaltitle}

\end{document}

这导致

期刊名称

期刊名称

如何为参考book文献中缺失的期刊标题指定替换文本(即根本没有文本)?

答案1

\citefield命令故意设计得相当低级。我建议定义一个\citejournal引用命令。像这样:

\DeclareCiteCommand{\citejournal}
  {}
  {\printfield{journaltitle}}
  {\multicitedelim}
  {}

这将忽略该引用命令的prenote“and” 。postnote

它还将journaltitle使用当前定义的字段格式进行格式化。如果您不想格式化,请使用:

\DeclareCiteCommand{\citejournal}
  {}
  {\printfield[default]{journaltitle}}
  {\multicitedelim}
  {}

您的完整 MWE 变为:

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
    @article{article,
        author  = {Peter Adams}, 
        title   = {The title of the work},
        journal = {The name of the journal},
        year    = 1993,
        number  = 2,
        pages   = {201-213},
        month   = 7,
        note    = {An optional note}, 
        volume  = 4
    }
    @book{book,
        author    = {Peter Babington}, 
        title     = {The title of the work},
        publisher = {The name of the publisher},
        year      = 1993,
        volume    = 4,
        series    = 10,
        address   = {The address},
        edition   = 3,
        month     = 7,
        note      = {An optional note},
        isbn      = {3257227892}
    }
\end{filecontents}

\usepackage[backend=biber]{biblatex}
\addbibresource{\jobname.bib}

\DeclareCiteCommand{\citejournal}
  {}
  {\printfield{journaltitle}}
  {\multicitedelim}
  {}

\begin{document}

\citejournal{article}

\citejournal{book}

\end{document}

相关内容