I am defining my own bibliographic printouts, to be used with biblatex/biber:

(\citefield{#1}{year}). \citefield{#1}{note}

The command above (\articleinfo{}) looks for a certain label (argument #1) in a bibtex file (thisbiblio.bib) and, when invoked in the document body, it prints a bunch of info from the bibtex entry's fields. I have a custom field called note, that I want to use to print custom info, for instance "a preprint of this paper is available from [url]". However, I want this to be optional, i.e., print the note field only if it is defined in the bibtex file for this particular entry, otherwise leave it blank. At the moment I get a note printout (like that, in bold face). How can I achieve that?

  • You should declare a new cite command with \DeclareCiteCommand and set field formats appropriately rather than construct things from the \citefield macro. – David Purton Sep 11 at 13:19
  • @DavidPurton This is not meant to be used as the \cite command, but to print bibliographic information in line. – Miguel Sep 11 at 13:24
  • hmmm. Can you provide a full MWE? I think a cite command is still what you want. – David Purton Sep 11 at 13:32
  • This is for a list of publications, so I'm using, e.g., \item \articleinfo{miguel_paper}. I have a bunch of different definitions, for instance if the paper is on arXiv or a regular journal, etc., each printing the info I want to display. – Miguel Sep 11 at 13:38
  • Right, but you can use a new cite command to format things like you want and then you can take advantage of punctuation tracker and \printfield. A citation command can print anything you want. I'll add an answer and see if it does what you want. – David Purton Sep 11 at 13:44

Instead of making new commands with \newcommand and \citefield, I suggest making a new cite command. Then you can take advantage of biblatex's punctuation tracker and the \printfield command, which tests if a field is used.

Depending on your exact requirements, you could minimise the code you repeat for your different sorts of articles with booleans and tests if various fields exist.




% I'm not sure if your field formats should be global or not.
% I've set the article ones globally to match your question.




MWE output

  • Fantastic, thanks so much. They only issue is that I can't use \mknormrange, it may be newer than my Livetex installation, so I changed it to \mkcomprange instead. Thanks again – Miguel Sep 11 at 14:23
  • @Miguel, Yes, I think \mknormrange is a new command. – David Purton Sep 11 at 14:25

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.