2

I'd like to discard the author field of a biblatex entry in a specific \cite command (just as if it had no author at all), but still have it listed in the biliography.

I need this because the figures are my original works, and repeating my name in the citations themselves is akward. So basically:

\begin{figure}[!hbt]
  \centering
  \includegraphics[width=300px]{image.jpg}
  \caption{\cite[]{the-biblatex-entry}} % *shouldn't* produce my name, only title, date, etc...
\end{figure}

\printbibliography % *should* produce my name, along with title, date, etc...

I'm ok with using some other command other than \cite. I'd really like to have a \citenoauthor command if I only knew how to make it.

EDIT: here is a MWE

\documentclass{article}
\usepackage{filecontents}

\begin{filecontents}{example.bib}
@book{somebook,
title = {Book's title},
author = {Author, Some},
location = {The City},
publisher = {Publisher},
date = {2005},
}
\end{filecontents}

\usepackage[style=verbose,backend=bibtex]{biblatex} %backend tells biblatex what you will be using to process the bibliography file
\bibliography{example}

\begin{document}
\cite{somebook} % I'd like this to not include the author, only the other fields
\printbibliography % All the fields, please
\end{document}
  • Maybe \AtNextCitekey{\clearname{labelname}}\cite{the-biblatex-entry}? Hard to say without a compilable (but minimal, please!) example for people to examine. Also: biblatex-chicago had (and still has, I'd guess) the commands \headlesscite and \headlessfullcite, which you could use for inspiration. – jon Jan 20 '17 at 21:54
  • Added a MWE. How can I use those commands "for inspiration"? – Joao Tavora Jan 20 '17 at 23:35
  • Forgot to add that your \AtNextCitekey idea didn't work. It produces no effect. – Joao Tavora Jan 20 '17 at 23:43
  • \AtNextCitekey{\clearname{author}} for BibTeX (hence need for MWE; otherwise we can only guess). By 'inspiration', I meant you could adapt them to your own use. (Obviously, prior to the MWE, no one else could be certain how they could be adapted or, indeed, whether a better solution was available.) – jon Jan 20 '17 at 23:56
  • I see. It does work, but not inside \caption :-( EDIT: Holdon, it does work, never mind. There's something fishy – Joao Tavora Jan 21 '17 at 0:50
2

The \caption problem can be fixed with a judicious use of \protect or you can define your own 'robust' command with etoolbox's \newrobustcmd (biblatex requires and loads etoolbox by default). That is:

\caption{%
  \AtNextCitekey{\protect\clearname{author}}%
  \cite{somebook}}

or:

\newrobustcmd{\hlcite}[1]{%
  \AtNextCitekey{\clearname{author}}%
  \cite{#1}}

Complete example:

\documentclass{article}
\usepackage{filecontents}

\begin{filecontents}{example.bib}
@book{somebook,
title = {Book's title},
author = {Author, Some},
location = {The City},
publisher = {Publisher},
date = {2005},
}
\end{filecontents}

\usepackage[style=verbose,backend=bibtex]{biblatex}
%\bibliography{example}% <-- deprecated
\addbibresource{example.bib}
\usepackage{caption}

\newrobustcmd{\hlcite}[1]{%
  \AtNextCitekey{\clearname{author}}%
  \cite{#1}}

\begin{document}
\begin{figure}
  \rule{3cm}{3cm}
  \caption{%
    \AtNextCitekey{\protect\clearname{author}}%
    \cite{somebook}}
\end{figure}

\begin{figure}
  \rule{3cm}{3cm}
  \caption{\hlcite{somebook}}
\end{figure}

\printbibliography
\end{document}
|improve this answer|||||
  • Note that it is probably nicer to define \hlcite via \DeclareCiteCommand, because then the optional arguments will still work properly. – moewe Jan 21 '17 at 12:48
  • @moewe -- Yes, absolutely. The point of it was more to showcase \newrobustcmd in the context of \caption's moving argument as compared to \protect. – jon Jan 21 '17 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.