TransWikia.com

Format "annotation" field in biblatex

TeX - LaTeX Asked by Hans Chr on March 13, 2021

I’m using biblatex to produce an annotated reading list. For longer annotations the formatting options available inside the annotation field are limited. Currently I’m using par to get a new paragraph in the annotation in the reading list. Is it possible to get normal paragraphs working (<CR><CR>) inside the annotation? This would make external annotation files much more flexible.

One Answer

Biber parses all new-line characters into normal spaces (as does BibTeX, I think), so you can't get a new paragraph with a blank line in the .bib file. par seems the simplest option.

But I would say that the .bib file might simply not be the best place to write long annotations about your entries.

If you want to add larger annotations to your .bib entries it might be more convenient to use an external .tex file to store these annotations (where you can use blank lines for par). See also How to embed a review in biblatex?, §3.13.8 External Abstracts and Annotations and §4.11.3 External Abstracts and Annotations of the biblatex manual.

documentclass[british]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{babel}
usepackage{csquotes}

usepackage[style=authoryear, loadfiles, backend=biber]{biblatex}

renewbibmacro{finentry}{%
  setunit{%
    finentrypunct
    renewcommand*{finentry}{}%
    par}%
  usebibmacro{annotation}%
  finentry
}

begin{filecontents}{jobname.bib}
@book{appleby,
  author     = {Humphrey Appleby},
  title      = {On the Importance of the Civil Service},
  date       = {1980},
}
end{filecontents}
begin{filecontents}{bibannotation-appleby.tex}
Lorem ipsum [x^2+y^2=z^2] that was mathy.
Also $a+b=c$ and so forth.
Just a few words to make the next
paragraph stand out properly.

We can even have a new paragraph.
end{filecontents}

addbibresource{jobname.bib}
addbibresource{biblatex-examples.bib}


begin{document}
cite{sigfridsson,appleby}
printbibliography
end{document}

Entry with long annotation and new paragraph


For a heavier paragraph markup you can either customise

setlength{bibparsep}{0.5baselineskip plus 2pt}

or just change the paragraph settings before you print annotation (normally you would probably not set both parskip and parindent to non-zero values, but this is just for demonstration purposes)

renewbibmacro{finentry}{%
  setunit{%
    finentrypunct
    renewcommand*{finentry}{}%
    par}%
  setlength{parskip}{0.5baselineskip plus 2pt}%
  setlength{parindent}{1em}%
  usebibmacro{annotation}%
  finentry
}

(I'm not too fond of having formatting settings like this just in a bibmacro, but that was the easiest way to get them right since they act on paragraphs.)

Correct answer by moewe on March 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP