[Tex/LaTex] Change separator for articles in journals without volume number (biblatex)

biblatex

I have the following code:

\documentclass{article}
\usepackage[style = authoryear-comp]{biblatex}

\AtEveryBibitem{\ifentrytype{article}{\clearfield{number}}{}} % don't print issue for article entries
\renewbibmacro{in:}{\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}} % don't print "in" for articles
\renewcommand{\bibpagespunct}{\ifentrytype{article}{\addcolon}{\addperiod\addspace}} % colon between volume and page ranges for journal articles, period plus space for articles in books
\DeclareFieldFormat[article, incollection, unpublished]{pages}{#1} % no word 'pages' for articles in the bibliography (print as is)

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@ARTICLE{jensen1916,
    AUTHOR = "Alfred Jensen",
    TITLE = "Bemerkninger til dagligtalen i Kristiania",
    JOURNALTITLE = "Maal og Minne",
    YEAR = "1916",
    NUMBER = "1--2",
    PAGES = "60--89"}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

The bibliographic entry is an article in a journal that doesn't use volume numbers (because it issues one volume each year, so the year itself is sufficient information). The code above will print a colon separator between the name of the journal and the page range. I think this looks weird.

enter image description here

In such cases I'd prefer either white space:

Jensen, Alfred (1916). "Bemerkninger til dagligtalen i Kristiania". Maal og Minne 60-89.

or a comma plus a space:

Jensen, Alfred (1916). "Bemerkninger til dagligtalen i Kristiania". Maal og Minne, 60-89.

How can I achieve this, so that it prints a colon when the journal has a volume number, but white space or comma plus white space when there is no volume number?

Best Answer

We can flesh out the logic in \renewcommand{\bibpagespunct}{\ifentrytype{article}{\addcolon}{\addperiod\addspace}} a bit more to

\renewcommand*{\bibpagespunct}{%
  \ifentrytype{article}{%
     \iffieldundef{volume}
       {\addcomma\space}
       {\addcolon}}
    {\addperiod\addspace}}

This prints a comma if the entry is an @article without a volume, prints a colon, if we have an @article with a volume and a full stop otherwise.

\documentclass{article}
\usepackage[style = authoryear-comp]{biblatex}

\AtEveryBibitem{\ifentrytype{article}{\clearfield{number}}{}} % don't print issue for article entries
\renewbibmacro{in:}{\ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}} % don't print "in" for articles
 % colon between volume and page ranges for journal articles, period plus space for articles in books
\DeclareFieldFormat[article, incollection, unpublished]{pages}{#1} % no word 'pages' for articles in the bibliography (print as is)

\renewcommand{\bibpagespunct}{%
  \ifentrytype{article}{%
     \iffieldundef{volume}
       {\addcomma\space}
       {\addcolon}}
    {\addperiod\addspace}}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@ARTICLE{jensen1916,
    AUTHOR = "Alfred Jensen",
    TITLE = "Bemerkninger til dagligtalen i Kristiania",
    JOURNALTITLE = "Maal og Minne",
    YEAR = "1916",
    NUMBER = "1--2",
    PAGES = "60--89"}
\end{filecontents*}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\begin{document}
\nocite{angenendt,jensen1916}
\printbibliography
\end{document}

enter image description here

Related Question