仅当书目条目属于“书籍”类型时才在引用中使用标题

仅当书目条目属于“书籍”类型时才在引用中使用标题

我遵循 moewe 的解决方案来制作作者-期刊-年份引用样式,如这个帖子

在该帖子的评论中,提出了使用引用booktitle字段的解决方案。当且仅当引用的类型为(not ) 时inproceedings,如何才能使用引用字段。我不知道确定引用是否为 所需的语法,这将有条件地控制以下语句:titlebookarticleif/then/elsebook

\setunit{\addcomma\space}%
\usebibmacro{title}%

链接帖子的 MWE 如下所示,其中空行围绕着必须有条件地进行门控的上面两行。

\documentclass{beamer}
\usepackage[english]{babel}
\usepackage[style=authoryear]{biblatex}
\addbibresource{biblatex-examples.bib}
\usetheme{Madrid}


\renewbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\usebibmacro{cite:label}%
        \setunit{\addspace}}
       {\printnames{labelname}%
        \setunit{\nameyeardelim}}%
     \usebibmacro{cite:labelyear+extrayear}%
     \setunit{\addcomma\space}%
     \usebibmacro{journal}}%
     %
     \setunit{\addcomma\space}%
      \usebibmacro{title}%
     %
    {\usebibmacro{cite:shorthand}}}

\begin{document}
\begin{frame}{Polaron Transformation}

\begin{itemize}         

\item The original theory was  developed by Munn-Silbey{\tiny \footcite{cicero}\footcite{aksin}\footcite{angenendt}} and further refined by Zhao et al. \footcite{bertram}\footcite{doody} 

\end{itemize}   
\end{frame}
\end{document}

答案1

我相信您正在寻找\ifentrytype{type}{true}{false}

\documentclass{beamer}
\usepackage[english]{babel}
\usepackage[style=authoryear]{biblatex}
\addbibresource{biblatex-examples.bib}
\usetheme{Madrid}


\renewbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\usebibmacro{cite:label}%
        \setunit{\addspace}}
       {\printnames{labelname}%
        \setunit{\nameyeardelim}}%
     \usebibmacro{cite:labeldate+extradate}%
     \setunit{\addcomma\space}%
     \usebibmacro{journal}%
     \ifentrytype{book}
      {\setunit{\addcomma\space}%
      \usebibmacro{title}}{}}%
    {\usebibmacro{cite:shorthand}}}

\begin{document}
\begin{frame}{Polaron Transformation}

\begin{itemize}

\item The original theory was  developed by Munn-Silbey{\tiny \footcite{cicero}\footcite{aksin}\footcite{angenendt}} and further refined by Zhao et al. \footcite{bertram}\footcite{doody}

\end{itemize}
\end{frame}
\end{document}

请注意,该宏cite:labelyear+extrayear已被弃用,请改用cite:labeldate+extradate

相关内容