9

In chemistry it's quite common to add prefixes to bibitems or even add notes to the references. See some example in literature to give you a hint what I mean. It is not created with LaTeX!

I've fiddled around with biblatex + biber and the \mcite and \bibnote comand, but came to no solution. I want to add some text in certain references with subentries before the bibitem.

I created this MWE:

\documentclass[english]{article}
\usepackage{selinput}
\SelectInputMappings{adieresis={ä},germandbls={ß},Euro={€}}
\usepackage{babel}
\usepackage[T1]{fontenc}

\usepackage[%
  citestyle=numeric-comp,
  bibstyle=chem-angew,
  sorting=none,
  backend=biber,
  mcite=true,
  subentry,
]{biblatex}
\usepackage{notes2bib}
\usepackage{filecontents}

\begin{filecontents}{example.bib}
@article{Boncella1984,
author = {Boncella, James M. and Andersen, Richard A.},
journal = {Inorg. Chem.},
pages = {432--437},
volume = {23},
year = {1984}
}

@article{Tilley1982,
author = {Tilley, T. Don and Andersen, Richard},
journal = {J. Am. Chem. Soc.},
pages = {1772--1774},
volume = {104},
year = {1982}
}
\end{filecontents}

\addbibresource{example.bib} 

\begin{document}
\section{sec1}

This is some nice text I want to cite.\mcite{set1,*Boncella1984,*Tilley1982}
I want to add this note in references.\bibnote{test note}
Here I cite a single paper from the previous set.\cite{Tilley1982} This is how it should look like with included note.\bibnote{See, for example: \fullcite{set1}}

\printbibliography
\end{document} 

I'm fine with the subentries how they're created in ref 1 by:

\mcite{set1,*Boncella1984,*Tilley1982}

and with citing members of the set by referencing just one key from the predefined set1:

 \cite{Tilley1982}

I'm also fine with notes which I can add to references section like in ref 2 by:

\bibnote{test note}

But I also need to add some text before the bibitem in a certain reference. This should look like in ref 3. However,

\bibnote{See, for example: \fullcite{set1}}

gives me only an endnote followed by a copy of ref 1. This is not applicable as I have to define set1 with \mcite before, which results of course in 2 referneces. Ref 3 is only for demonstration how it should look like. I'm not able to get a single reference which looks like ref 3. Something like

\bibnote{See, for example:\mcite{set1,*Boncella1984,*Tilley1982}}

doesn't work. It gives me 2 references.

How can I create a reference with text followed by subentries? I also want to have the opportunity to cite single members of the set elsewhere, like in ref 1b.

Edit 1:

This is some nice text I want to cite.\bibnote{some added text:\mcite{set1,*Boncella1984,*Tilley1982}}
I want to add this note in references.\bibnote{test note}
Here I cite a single paper from the previous set.\cite{Tilley1982} This is how it should look like with included note.\bibnote{more added text: \fullcite{set1}}

gives me the following:

\bibnote{some added text:\mcite{set1,*Boncella1984,*Tilley1982}}

just adds the text followed by reference in brackets as you can see in ref 1 in the 2nd example. I just want to create a reference with subentries in which some text is followed by subentry (a). It should look like in ref 3. However, ref 3 is just constructed to give you the look. It can not be created as "stand alone" reference, only in combination with a second.

Edit 2:

as it seems still not clear. Apllying only this:

\begin{document}
\section{sec1}

This is some nice text I want to cite.\bibnote{some added text:\mcite{set1,*Boncella1984,*Tilley1982}}

\printbibliography
\end{document} 

gives me the following output: enter image description here

in which 2 references are created instead of 1 desired and none looks the way I want it.

Edit 3:

Inspired by this question I created an example. However, the added note is of course after the corresponding bibitem as in the quoted question. How can I get the added notes before my bibitems, but still after the reference number [X]? I've got a huge document in which every chapter has its own references. Addition of notes seems to work, however not elegant. Since, my notes are work (chapter) related, I don't want to edit my *.bbl. However, the chosen way with loadfiles is not very elegant. But I'm still able to place my note in near of \cite commands. It would be not applicable to put all the notes in the preamble of the document or elsewhere.

To repeat my question: How can I get the added notes in front of my bibiem applying the \loadfiles option to have them look like ref 3 in above examples?

\documentclass[english]{article}
\usepackage{selinput}
\SelectInputMappings{adieresis={ä},germandbls={ß},Euro={€}}
\usepackage{babel}
\usepackage[T1]{fontenc}

\usepackage[%
 citestyle=numeric-comp,
   bibstyle=chem-angew,
   sorting=none,
  backend=biber,
  mcite=true,
  subentry,
  loadfiles=true,
]{biblatex}
\usepackage{notes2bib}
\usepackage{filecontents}

\begin{filecontents}{example.bib}
@article{Boncella1984,
author = {Boncella, James M. and Andersen, Richard A.},
journal = {Inorg. Chem.},
pages = {432--437},
volume = {23},
year = {1984}
}

@article{Tilley1982,
author = {Tilley, T. Don and Andersen, Richard},
journal = {J. Am. Chem. Soc.},
pages = {1772--1774},
volume = {104},
year = {1982}
}
\end{filecontents}

\DeclareFieldFormat{annotation}{#1}
\renewbibmacro*{annotation}{
  \IfFileExists{notes/note-\thefield{entrykey}.tex}{\par}{}
  \printfile[annotation]{notes/note-\thefield{entrykey}.tex}
}

\AtEveryBibitem{
\csappto{blx@bbx@\thefield{entrytype}}{\usebibmacro{annotation}}
}

\addbibresource{example.bib} 

\begin{document}
\section{sec1}
\begin{refsection}
This is some text I want to cite.\mcite{set1,*Boncella1984,*Tilley1982}
\begin{filecontents}{notes/note-set1.tex}
hello world
\endinput
\end{filecontents}
\printbibliography
\end{refsection}

\section{sec2}
\begin{refsection}

This is even more text I want to cite.\mcite{set2,*Boncella1984,*Tilley1982}

\begin{filecontents}{notes/note-set2.tex}
hello again
\endinput
\end{filecontents}
\printbibliography
\end{refsection}
\end{document}

enter image description here

  • Welcome to TeX SE. First, it is great that you post code but you need to complete it. I don't have library.bib so I can't reproduce the issue. I tried faking a couple of entries with appropriate names but when I did that, the output looked fine. So either your entries have a twist missing in my fakes or I'm not understanding what the problem is. – cfr Apr 13 '14 at 1:55
  • 1
    This seems to be more complicated than thought. One thing though: the bibliography is really not the place to place comments before entries. – moewe Apr 13 '14 at 12:02
  • 1
    There is a reason biblatex-chem doesn't attempt to cover this: I don't feel there is a workable interface on an automated basis. The way that (some) chemists give compound citations simply doesn't work: there are too many different ways people include notes. – Joseph Wright Apr 13 '14 at 16:52
  • 1
    @cfr 'bibliography is really not the place to place comments before entries': The example given in the question is actually quite 'tame' by chemistry standards. A classic form is to have a citations which has (1) an introductory sentence, (2) 'see for example', (3) subdivision of the examples (say by metal, or ...), (4) citation of some (but not all!) of those individually labelled cases, (5) post-text of the form 'and references cited therein' :-) – Joseph Wright Apr 13 '14 at 16:54
  • 1
    @cfr It doesn't matter how it's called. No one insists to call it bibliography. This is the way refernces look like in chemistry. – user49794 Apr 13 '14 at 18:15
2

Updated

As I understand it, you want to be able to add a note which will be printed at the start of a bibliographical entry (consistently with the use in your field where the bibliography seems to include material which might, in other fields, appear in footnotes or endnotes).

I've had various tries at this during the course of today, getting somewhat closer each time. I think the best solution is probably along these lines:

  1. We define a command \prenotation{key}{text} which writes to the .aux file. The reason for doing it this way is that we need to use \AtEveryBibitem, which can only be used in the preamble; but its inconvenient to have to give all these notations in the preamble (though it would work).

  2. What actually gets written to the .aux file is an internal command which sets up a check that is made at every bibitem. This could slow things down if you have lots of these notes, but I'm assuming that will not be a problem. I've refined the check so that if by any chance a given key gets used more than once (as it might if there are multiple bibliographies) the note gets printed only on the first occasion.

  3. We then need some housekeeping to undefine this internal command (or,rather, to castrate it) so that we don't try to use \AtEveryBibitem when the .aux file gets read in again at the end.

\documentclass[english]{article}
\usepackage{selinput}
\SelectInputMappings{adieresis={ä},germandbls={ß},Euro={€}}
\usepackage{babel}
\usepackage[T1]{fontenc}

\usepackage[%
 citestyle=numeric-comp,
   bibstyle=chem-angew,
   sorting=none,
  backend=biber,
  mcite=true,
  subentry,
  loadfiles=true,
]{biblatex}
\usepackage{notes2bib}
\usepackage{filecontents}

\begin{filecontents}{example.bib}
@article{Boncella1984,
author = {Boncella, James M. and Andersen, Richard A.},
journal = {Inorg. Chem.},
pages = {432--437},
volume = {23},
year = {1984}
}

@article{Tilley1982,
author = {Tilley, T. Don and Andersen, Richard},
journal = {J. Am. Chem. Soc.},
pages = {1772--1774},
volume = {104},
year = {1982}
}
\end{filecontents}

\makeatletter
\newcommand{\prenotation}[2]{%
  \write\@mainaux{\noexpand\bl@makeprenotation{#1}{#2}}}
\newcommand{\bl@makeprenotation}[2]{%
  \AtEveryBibitem{%
    \ifcsdef{bl@prenote#1}
      {}
      {\iffieldequalstr{entrykey}{#1}
         {\expandafter\gdef\csname bl@prenote#1\endcsname{}%
          #2}
         {}}}}
\AtBeginDocument{\let\bl@makeprenotation\@gobbletwo}
\makeatother

\addbibresource{example.bib} 

\begin{document}

\section{sec1}
\begin{refsection}
This is some text I want to cite.\mcite{set1,*Tilley1982,*Boncella1984}
\prenotation{set1}{Here is an introductory text for set 1: }%

\printbibliography
\end{refsection}

\section{sec2}
\begin{refsection}

This is even more text I want to cite \mcite{set2,*Tilley1982,*Boncella1984}, with a note \bibnote{And here is a bibnote.}. 

\prenotation{set2}{Here is an introductory text for set 2: }%

\printbibliography
\end{refsection}
\end{document}

enter image description here

  • This looks promising, however I could not reproduce it. I get this error message. ! LaTeX Error: Can be used only in preamble. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.9 \AtEveryBibitem {\iffieldequalstr {entrykey}{set1}{Here is some text to ... – user49794 Apr 14 '14 at 14:44
  • Eek! Sorry: so do I (latexmk was hiding the error from me). That is what I was trying (and failing) to avoid by using the .aux file. Let me think again, slightly. – Paul Stanley Apr 14 '14 at 14:57
  • I'm using MiKTeX 2.9 biblatex 2.8a and biber 1.8 with WinEdt, as far as this might be relevant. – user49794 Apr 14 '14 at 15:01
  • It wasn't relevant! The fault was all mine. Given the absence of time, I haven't struggled to find a way to do this in such a way that the command can be placed anywhere. This now works, and requires only one run, but the \prenotation commands must, I'm afraid, be put in the preamble. The way to avoid this would be to write them to an external file and read them in, but (my bad) the .aux file is not going to do it. – Paul Stanley Apr 14 '14 at 15:05
  • Okay, this is fine, at least your example. I'll try now to implement it in my thesis... – user49794 Apr 14 '14 at 15:10

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.