4

The title for the online entry type will be printed in italic by default when we use \printbibliography in the tex file in which the biblatex package is used. To make the title normal (non italic) we can easily add this line in the preamble:

\DeclareFieldFormat[online]{title}{#1}

What I understand about the meaning of this line (referring to biblatex package page 188) is the following:

  1. [online] is the entry (reference) type.
  2. {title} is the field for the [online] entry type.
  3. The code #1 is the format for which the field (title in this case) will be printed.

I have the following questions:

  1. Where is the documentation telling us code #1 makes the online title normal instead of italic, the default.
  2. Is there any other code such as #2, or #3 that makes the field format different?

Below is my tex file:

\documentclass{book}
 % to run: step1: pdflatex step 2: biber step3: pdflatex
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@online{myonline,
      author       = {my author},
      date         = {2020},
      title        = {my title},
      url          = {https://mywebsite.qrst},
        }
   \end{filecontents}
 \DeclareFieldFormat[online]{title}{#1}
 \addbibresource{\jobname.bib}
 \begin{document}
 \textcite{myonline}
 \printbibliography
 \end{document}

1 Answer 1

5

In

\DeclareFieldFormat[online]{title}{#1}

you have to understand the #1 as a (placeholder) variable for the actual title of your entry.

This is analogous to how macro definitions work in LaTeX. For example in

\newcommand*{\foo}[1]{A#1B}

which can be used as

\foo{bar}

the #1 is a placeholder for the argument of the macro (in case of the example call \foo{bar} #1 would become bar; if you say \foo{boo}, #1 becomes boo).

As such

\DeclareFieldFormat[online]{title}{#1}

is telling biblatex to do nothing with the title. Doing nothing means that no special formatting is applied.

On the other hand,

\DeclareFieldFormat[online]{title}{\mkbibemph{#1}}

would apply the macro \mkbibemph to the title, which would make it come out in \emph, which usually gives italics. Similarly

\DeclareFieldFormat[online]{title}{\mkbibquote{#1}}

wraps the title into quotation marks.


This is explained in the documentation of \DeclareFieldFormat (§4.4.2 Formatting Directives, p. 199 in v3.15 of the biblatex documentation)

[\DeclareFieldFormat[<entrytype, …>]{<format>}{<code>}] Defines the field format <format>. This formatting directive is arbitrary <code> to be executed by \printfield. The value of the field will be passed to the <code> as its first and only argument.

Essentially this says that the <code> you give in \DeclareFieldFormat will be executed whenever the field <format> is used and that #1 in the code will be replaced by the actual contents of the field in this instance.

In particular your explanation in point three above

The code #1 is the format for which the field (title in this case) will be printed.

is correct, but the example \DeclareFieldFormat[online]{title}{#1} might not help us to fully understand what is going on.

So maybe we should look at

\DeclareFieldFormat[online]{title}{\mkbibemph{#1}}

and say that

  1. The code \mkbibemph{#1} controls the format of the field (title in this case). Here #1 is the placeholder for the actual field value and we can use arbitrary LaTeX code to format it.

In \DeclareFieldFormat only #1 is valid (as a placeholder for the actual field value), #2 and #3 will throw errors (! Illegal parameter number in definition of \blx@defformat@d.).

2
  • Typo? \mkbibqoute should be \mkbibquote I think
    – zwol
    Dec 27, 2020 at 16:23
  • @zwol Yes. Thanks for catching that. Corrected.
    – moewe
    Dec 27, 2020 at 17:22

You must log in to answer this question.

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