2

I am following moewe's solution for making an author-journal-year citation style, as described in this post.

In the comments to that post, a solution is proposed for using the booktitle field of an inproceedings reference. How can one instead use the title field of a reference if and only if the reference is of type book (not article). I do not know the if/then/else syntax needed to determine if the reference is a book, which would conditionally control the following statements:

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

The MWE of the linked post is reproduced below, with blank lines surrounding the above two lines which must be conditionally gated.

\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}
user001
  • 7,964
  • 3
    Just a note of your MWE: You have added your \setunit{\addcomma\space}\usebibmacro{title} inbetween the true and false arguments of \iffieldundef{shorthand}{<true>}{<false>} (note the closing brace after \usebibmacro{journal} which is in the true argument. This gives you unexpected results. – David Purton Oct 31 '18 at 02:51
  • @DavidPurton: Thanks for pointing that out. I hadn't noticed. – user001 Oct 31 '18 at 06:32

1 Answers1

4

I believe you are looking for \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}

Note that the macro cite:labelyear+extrayear is deprecated, use cite:labeldate+extradate instead.

gusbrs
  • 13,740