3

I would like to print shorthands in the bibliography as separate entries, using biblatex.

My bibliography.bib contains this:

@Collection{Pauly1894--1980,
  editor     = {August Pauly and Georg Wissowa},
  title      = {Pauly’s Real-Encyclopädie der classischen Altertumswissenschaft},
  year       = {1894--1980},
  location   = {Stuttgart},
  shorthand  = {RE},
  shorttitle = {RE},
  }

As the commonly used shorthand for this encyclopedia is ›RE‹, I would like the full entry, which will be sorted under the letter ›P‹ (for Pauly), as well as a very short, separate entry in the bibliography that goes something like this:

RE, viz. Pauly/Wissowa

›, viz. Pauly/Wissowa‹ could be any combination of a textstring and something fished from the original entry. Important is that the shorthand comes first.

\documentclass{scrbook}
\usepackage{fontspec}

\usepackage[backend=biber]{biblatex} 
\addbibresource{bibliography.bib}

\begin{document}
   \nocite{Pauly1894--1980}
   \printbibliography
\end{document}

Some background: I am aware that it is possible to print a list of shorthands. As my bibliography only contains two or three of these, this seems a bit bloated. To me this seems a viable solution for very large bibliographies, but not so much for small ones containing only a few pages.

Edit: After using moewes answer for some of my files – it worked perfectly – I noticed that in the original post I placed ›–‹ instead of ›--‹ in the BibTeX-Key as well as in the \nocite-macro. This posed problems, and therefore I changed it. For the sake of information I wrote this here.

6

One rule of biblatex bibliographies is that you can only have text in the bibliography if there is an entry for it. Another rule is that each entry is processed once in the bibliography.

So if you want a 'second'/'viz.' entry for the shorthand, you need a new entry for that. This entry can, however, be created automatically using Biber's sourcemapping. In the code below this happens with \DeclareSourcemap. If an entry has a shorthand field, a new entry of type specialshorthand is created which holds the shorthand as well as the parent entries key. The sorting is also set correctly.

That special new entry of type specialshorthand is then printed at the correct place in the bibliography. All we have to decide on is the exact output. This is what the \DeclareBibliographyDriver{specialshorthand} does.

We also need a new data model to be able to define specialshorthand. In the MWE this is created using filecontents. In a real-world application you would probably store the created file specialshorthands.dbx somewhere TeX can find it and get rid of filecontents.

\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{filecontents}
\begin{filecontents}{specialshorthands.dbx}
\DeclareDatamodelEntrytypes{specialshorthand}
\DeclareDatamodelFields[type=field, datatype=verbatim]{
  parententry,
}
\DeclareDatamodelEntryfields[specialshorthand]{
  parententry,
  shorthand}
\end{filecontents}
\usepackage[backend=biber, style=authoryear, datamodel=specialshorthands, minxrefs=1]{biblatex} 

\begin{filecontents}{\jobname.bib}
@collection{pauly,
  editor     = {August Pauly and Georg Wissowa},
  title      = {Pauly’s Real-Encyclopädie der classischen Altertumswissenschaft},
  date       = {1894/1980},
  location   = {Stuttgart},
  shorthand  = {RE},
  shorttitle = {RE},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\DeclareSourcemap{
  \maps{
    \map{
      \step[fieldsource=shorthand, final]
      \step[fieldsource=entrykey, match=\regexp{(.*)}]
      \step[fieldset=xref, fieldvalue=shorthand-of-$1]
      \step[entrynew=shorthand-of-$1, entrynewtype=specialshorthand]
      \step[fieldsource=shorthand]
      \step[fieldset=shorthand, origfieldval, entrytarget=shorthand-of-$1]
      \step[fieldset=sortname, origfieldval, entrytarget=shorthand-of-$1]% sortkey would be nicer here
      \step[fieldsource=entrykey]
      \step[fieldset=parententry, origfieldval, entrytarget=shorthand-of-$1]
      \step[fieldset=options, fieldvalue=skiplab, entrytarget=shorthand-of-$1]
    }
  }
}

\NewBibliographyString{videlicet}
\DefineBibliographyStrings{english}{
  videlicet = {viz\adddot},
}

\makeatletter
\DeclareBibliographyDriver{specialshorthand}{%
  \usebibmacro{begentry}%
  \printfield{shorthand}%
  \setunit{\addcomma\space}%
  \bibstring[\mkbibemph]{videlicet}%
  \setunit{\addspace}%
  \entrydata{\thefield{parententry}}{%
  \begingroup
    \DeclareFieldFormat{bibhyperref}{##1}%
    \csuse{blx@hook@cite}%
    \csuse{blx@hook@citekey}%
    \undef\cbx@lasthash
    \undef\cbx@lastyear
    \citetrackerfalse\pagetrackerfalse\backtrackerfalse
    \defcounter{maxnames}{\blx@maxcitenames}%
    \clearfield{shorthand}%
    \usebibmacro{cite}%
  \endgroup}%
  \usebibmacro{finentry}}
\makeatother

\begin{document}
  \nocite{pauly,sigfridsson}
  \printbibliography
\end{document}

enter image description here

With the as-of-yet unreleased biblatex 3.11/Biber 2.11, a few things can be simplified. Then the MWE would like

\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{filecontents}
\begin{filecontents}{specialshorthands.dbx}
\DeclareDatamodelEntrytypes{specialshorthand}
\DeclareDatamodelFields[type=field, datatype=verbatim]{
  parententry,
}
\DeclareDatamodelEntryfields[specialshorthand]{
  parententry,
  shorthand}
\end{filecontents}
\usepackage[backend=biber, style=authoryear, datamodel=specialshorthands]{biblatex} 

\begin{filecontents}{\jobname.bib}
@collection{pauly,
  editor     = {August Pauly and Georg Wissowa},
  title      = {Pauly’s Real-Encyclopädie der classischen Altertumswissenschaft},
  date       = {1894/1980},
  location   = {Stuttgart},
  shorthand  = {RE},
  shorttitle = {RE},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\DeclareSourcemap{
  \maps{
    \map{
      \step[fieldsource=shorthand, final]
      \step[fieldsource=entrykey, match=\regexp{(.*)}]
      \step[entrynew=shorthand-of-$1, entrynewtype=specialshorthand, entrynocite]
      \step[fieldsource=shorthand]
      \step[fieldset=shorthand, origfieldval, entrytarget=shorthand-of-$1]
      \step[fieldset=sortkey, origfieldval, entrytarget=shorthand-of-$1]
      \step[fieldsource=entrykey]
      \step[fieldset=parententry, origfieldval, entrytarget=shorthand-of-$1]
      \step[fieldset=options, fieldvalue=skiplab, entrytarget=shorthand-of-$1]
    }
  }
}

\NewBibliographyString{videlicet}
\DefineBibliographyStrings{english}{
  videlicet = {viz\adddot},
}

\makeatletter
\DeclareBibliographyDriver{specialshorthand}{%
  \usebibmacro{begentry}%
  \printfield{shorthand}%
  \setunit{\addcomma\space}%
  \bibstring[\mkbibemph]{videlicet}%
  \setunit{\addspace}%
  \entrydata{\thefield{parententry}}{%
  \begingroup
    \DeclareFieldFormat{bibhyperref}{##1}%
    \csuse{blx@hook@cite}%
    \csuse{blx@hook@citekey}%
    \undef\cbx@lasthash
    \undef\cbx@lastyear
    \citetrackerfalse\pagetrackerfalse\backtrackerfalse
    \defcounter{maxnames}{\blx@maxcitenames}%
    \clearfield{shorthand}%
    \usebibmacro{cite}%
  \endgroup}%
  \usebibmacro{finentry}}
\makeatother

\begin{document}
  \nocite{pauly,sigfridsson}
  \printbibliography
\end{document}

(Hopefully I will update this answer to remove the old code, once 3.11 is out.)

4
  • I would have preferred sortkey instead of sortname. But sortkey didn't quite give the results I expected: github.com/plk/biber/issues/208
    – moewe
    Jan 27 '18 at 11:00
  • This sortkey issue is fixed in biber 3.11 DEV version.
    – PLK
    Jan 27 '18 at 21:27
  • It may be relevant that a shorthand consisting of two words (for example the shorthand for a single volume of a large encyclopedia → RE VI) will have \field{sortinit}{V}. It can be useful to enclose the shorthand in extra brackets shorthand = {{RE VI}},, depending on which sortinit is relevant for the bibliography (was the case for me with authoryear).
    – Kubo
    Nov 18 '20 at 9:01
  • @Kubo Hmmm, that almost sounds as if the shorthand is parsed like a name. I don't think that should happen. Can you please post a bug report with an example document (I didn't manage to reproduce the behaviour you describe just now) at github.com/plk/biblatex/issues?
    – moewe
    Nov 18 '20 at 16:33

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.