2

I have the following entry in my biblio.bib:

@article{author1:2015,
  author={author1 and author2,
  title={Something good},
  journal={A very good journal},
  year=2015,
  month=jun,
  volume=26,
  pages={20--30},
  number=6,
  issn={1111-1111},
  note={Published online in December 2013},
}

And the following MWE:

\documentclass{article}

\usepackage[backend=bibtex,style=ieee]{biblatex}
\addbibresource{biblio.bib}

\begin{document}

From a very good journal~\cite{author1:2015}.

\printbibliography

\end{document}

The question is: may I format the month and year in the note field according to style that is used for the fields month and year?

9
  • 1
    You may if you do it yourself. The note field is, in biblatex, a "literal field", which is "printed as is". You can style the whole field with \DeclareFieldFormat, but you can't (normally) operate on elements within the field. With backend=biber, however, you can fiddle with things on the fly using regexp. Might be easier to just fix the field yourself, though.
    – jon
    Jul 4, 2015 at 21:53
  • For me the backend is not a problem. So I can use backend=biber. The thing is, when you change style, you must come and change the field note also. Which is not good. That is why I wanted some automatic method.
    – cacamailg
    Jul 4, 2015 at 22:00
  • What about @preamble{ "\providecommand{\mystring}[2]{#1 and #2}" } and then note={Published online in \mystring{Dec.}{2013}}, ..? (Modify as needed --- e.g., set up something for months with \ifcase.)
    – jon
    Jul 4, 2015 at 22:09
  • Not exactly what I wanted. Where do you put this code? Inside biblio.bib?
    – cacamailg
    Jul 4, 2015 at 22:42
  • Yes. And note that it is provide command. That means you can have in your .tex file a \newcommand\mystring[2]{Actually do #2 and #1} and redefine it as necessary. Very portable. Or, like I said, you could use the powers of Biber to change the actual input.
    – jon
    Jul 5, 2015 at 0:12

1 Answer 1

1

The note field is, in biblatex, a "literal field", which is "printed as is". You can style the whole field with \DeclareFieldFormat, but you can't (normally) operate on elements within the field.

Here's a basic solution.

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@preamble{ "\providecommand{\mystring}[2]{#1 and #2}" }
@article{author1:2015,
  author={author1 and author2},
  title={Something good},
  journal={A very good journal},
  year=2015,
  month=jun,
  volume=26,
  pages={20--30},
  number=6,
  issn={1111-1111},
  orignote={Published online in December 2013},
  note={Published online in \mystring{Dec.}{2013}},
}
\end{filecontents}

\usepackage[T1]{fontenc}
\usepackage[backend=bibtex,style=ieee]{biblatex}
\addbibresource{biblio.bib}

% \newcommand\mystring[2]{Actually do #2 and #1}
\begin{document}

From a very good journal~\cite{author1:2015}.

\printbibliography

\end{document}

The \providecommand provides a command if nothing is defined, so you can use \newcommand in the preamble as needed (it will be seen first).

The point of this solution is that you could provide a list of commands for each month in your .bib file with a basic format, and then redefine them in individual .tex files when you want. Not pretty, really, but using the note field in this way doesn't align (in my opinion) with best practices to begin with. (And everyone knows that two hacks make it a-right.)

I believe a \DeclareSourcemap solution is feasible, but I don't have time these days to get one up and running. If no one else does so, I may try to revisit this answer (late) next month. Note that this would require using Biber instead of BibTeX.

2
  • Thank you. Do you have any idea for a Biber approach? My concepts all need some kind of way to tell Biber that the following in the note field needs to be a date.
    – moewe
    Jul 28, 2015 at 5:00
  • @moewe -- No, not really. I can't remember what I was thinking a few weeks ago, but I don't think it was likely to be pretty or efficient.
    – jon
    Jul 28, 2015 at 22:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .