如何在 biblatex 中创建 \citejournal、\citebooktitle、\cite... 命令?

如何在 biblatex 中创建 \citejournal、\citebooktitle、\cite... 命令?

在 biblatex 中我们找到命令\citetitle\citeauthor...在科学文章等中,有时需要引用参考书目中的其他条目。

例如,您只需要引用期刊的名称。因此您需要一个类似这样的命令\citejournal。有人知道如何创建这样的命令吗?

答案1

您可以使用类似这样的方法:

\documentclass{article}
\usepackage[style=authoryear,backend=biber]{biblatex}

\DeclareCiteCommand{\citejournal}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \usebibmacro{journal}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{test,
  author = {Author, A.},
  year = {2011},
  title = {Some relevant article},
  journal = {Test journal}
}
\end{filecontents}

\bibliography{\jobname}

\begin{document}

Some text~\citejournal{test}

\printbibliography

\end{document}

在此处输入图片描述

编辑:Audrey 提供了以下改进:

\citetitle\citetitle*禁用引文跟踪。新命令可以定义为一致的。通用书目宏会打印整个标题,包括副标题和标题附加内容,这是可以避免的。单个命令也可用于引用参考文献的“主要”标题。所有这些都在下面进行了演示。

\documentclass{article}
\usepackage{biblatex}

\DeclareCiteCommand{\citejournal}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \usebibmacro{journal}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\citebooktitle}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \usebibmacro{booktitle}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\citeintitle}% Based on \citetitle from biblatex.def
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexfield{indextitle}}
     {}%
   \iffieldundef{journaltitle}
     {\iffieldundef{booktitle}
        {\iffieldundef{maintitle}
          {\printfield[citetitle]{labeltitle}}% Behave like \citetitle if no "main" title
          {\printtext[maintitle]{\printfield[titlecase]{maintitle}}}}
        {\printtext[booktitle]{\printfield[titlecase]{booktitle}}}}
     {\printtext[journaltitle]{\printfield[titlecase]{journaltitle}}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@Article{yoon,
  author = {Yoon, Myeong S. and Ryu, Dowook and Kim, Jeongryul and Ahn, Kyo Han},
  title = {Palladium pincer complexes with reduced bond angle strain: efficient catalysts
    for the Heck reaction},
  journaltitle = {Organometallics},
  volume = {25},
  number = {10},
  date = {2006},
  pages = {2409--2411}}
@InProceedings{salam,
  author = {Salam, Abdus},
  editor = {Svartholm, Nils},
  title = {Weak and Electromagnetic Interactions},
  booktitle = {Elementary Particle Theory},
  booksubtitle = {Relativistic Groups and Analyticity},
  booktitleaddon = {Proceedings of the Eighth Nobel Symposium},
  eventdate = {1968-05-19/1968-05-25},
  venue = {Aspen{\"a}sgarden, Lerum},
  publisher = {Almquist \& Wiksell},
  location = {Stockholm},
  date = {1968},
  pages = {367--377}}
@InProceedings{moraux,
  author = {Moraux, Paul},
  editor = {Lloyd, G. E. R. and Owen, G. E. L.},
  title = {Le \emph{De Anima} dans la tradition gr{\`e}cque},
  subtitle = {Quelques aspects de l'interpretation du trait{\'e}, de Theophraste {\`a}
    Themistius},
  shorttitle = {\emph{De Anima} dans la tradition gr{\`e}cque},
  booktitle = {Aristotle on Mind and the Senses},
  booktitleaddon = {Proceedings of the Seventh Symposium Aristotelicum},
  eventdate = {1975},
  publisher = cup,
  location = {Cambridge},
  date = {1979},
  pages = {281--324}}
@InCollection{pines,
  author = {Pines, Shlomo},
  editor = {Twersky, Isadore},
  indextitle = {Limitations of Human Knowledge According to Al-Farabi, ibn Bajja, and
    Maimonides, The},
  title = {The Limitations of Human Knowledge According to Al-Farabi, ibn Bajja, and
    Maimonides},
  shorttitle = {Limitations of Human Knowledge},
  booktitle = {Studies in Medieval Jewish History and Literature},
  publisher = hup,
  location = {Cambridge, Mass.},
  date = {1979},
  pages = {82--109}}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\noindent
\citeintitle{yoon} versus \citejournal{yoon} \\\\
\citeintitle{salam} versus \citebooktitle{salam} \\\\
\citeintitle{moraux} versus \citebooktitle{moraux} \\\\
\citeintitle{pines} versus \citebooktitle{pines}
\printbibliography

\end{document}

在此处输入图片描述

相关内容