# biblatex: test whether a command is inside a cite command

The idea is the following: Normally, \fullcite just prints the full bibliography entry by calling \usedriver. In my style biblatex-fiwi I added the option to suppress stuff like foreword and afterword. At the moment, this option is for both, the bibliographic entry and the result of \fullcite.

I'd like to have the possibility to distinguish between the result of \printbibliography and \fullcite. But since \fullcite relies on the same mechanism as \printbibliography, this is tricky. What I need is a test which tells me whether we are currently inside a \cite command. This would then allow me to add a \fullcite-only option.

As far as I know, no test of this kind exists.

-

Anything wrong with \ifbibliography (see section 4.6.2 of the manual for details)?

\documentclass{article}

\usepackage{biblatex}

\renewbibmacro{begentry}{\ifbibliography{}{\clearname{foreword}}}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
foreword = {Buthor, B.},
}
\end{filecontents}

\begin{document}

\fullcite{A01}

\printbibliography

\end{document}


-
D'oh, not only is there \ifbibliography, there is also \ifcitation. Thanks a lot. – Simifilm Nov 5 '12 at 14:03

I don't think there's a built-in way to do this [update: wrong]: at least, if there is, I don't know it [that part, sadly, was not: see Lockstep's answer for the correct approach].

The easiest way, I think, would be to do something with \AtBeginBibliography. Options include: setting some sort of toggle which you can test in your driver, and which would indicate that it was being called within a bibliography environment [that's unnecessary, because one is already provided], or setting up a driver alias to trigger at that point, so that you effectively replace the driver that \fullcite will "see" with another driver that only takes effect in the bibliography [I think that remains a possible alternative, which could be sensible if there was a lot that needed changing].

-
– Guido Nov 5 '12 at 10:42
@Guido The test used there ensures \fullcite generates the same output as the bibliography. For the problem here \ifbibliography or \ifcitation work just fine. – Audrey Nov 5 '12 at 14:21