I have a custom footnote citation command defined by modifying this answer in the following way:
\DeclareCiteCommand{\citejournal} % to get the journal entry
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{journal}}
{\multicitedelim}
{\usebibmacro{postnote}}
\newcommand{\cfootcite}[1]{
\tiny{\citeauthor{#1}, \citetitle{#1}, \citejournal{#1}, \citeyear{#1}}} % to get author, title, journal, year
which works perfectly for .bib entries that have all those fields.
But now I have a .bib file consisting of many articles, but also some books (ergo without a journal entry) that I want to cite using this command.
How can I make a conditional that checks whether there is a journal entry in the .bib file, and changes the output accordingly?
I have tried playing around with the answers presented in this question, but apparently I am too unfamiliar with conditionals in LaTeX to make it work.
Any help is appreciated.
(I am aware that the simplest solution would be to define two separate commands for articles and books.)
MWI:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{bib.bib}
@article{article,
author = {Vimes, Samuel},
title = {The Influence of Species Diversity in the City Watch},
journal = {Unseen University Non-Magical Journal},
date = {1988}
}
@book{book,
author = {Vimes, Samuel},
title = {How To Be A Good Copper},
date = {2002}
}
\end{filecontents}
\usepackage[backend=biber,maxcitenames=1,maxbibnames=2,
giveninits=true]{biblatex}
\bibliography{bib.bib}
% \usepackage{xstring} % for if clause
\DeclareCiteCommand{\citejournal}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{journal}}
{\multicitedelim}
{\usebibmacro{postnote}}
\newcommand{\cfootcite}[1]{
{\tiny{\citeauthor{#1}, \citetitle{#1}, \citejournal{#1}, \citeyear{#1}}}} % to get author, title, journal, year
\begin{document}
Article:\\ \cfootcite{article}
Book:\\ \cfootcite{book}
\end{document}


\citecommands from other\cite...commands. Commands defined like\cfootciteusually can't deal with multiple citations (\cfootcite{sigfridsson,nussbaum}) properly and need extra work to process pre- and postnote arguments. Additionally it can get increasingly complicated to get citation tracking and other context-senstive stuff right when you execute several\cite...-like macros at once. Commands like these are better defined with\DeclareCiteCommand. The additional advantage of\DeclareCiteCommandfor your case is that ... – moewe Nov 22 '18 at 20:31\DeclareCiteCommandand declares everything within that one command. – moewe Nov 22 '18 at 20:32