3

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?

3
  • You do realise though that you do clear the number field for article, so in your bibliography no entry has a number field (\ifentrytype{article}{\clearfield{number}}{}). So do you just want a comma for @articles instead of a colon (or the period)?
    – moewe
    Sep 3, 2014 at 14:29
  • @moewe Yes, I included the code where I'm clearing the number field in case that should become relevant. But, I don't clear the volume field. I just want a comma if the volume field is empty. (The number field is what's normally called 'issues').
    – Sverre
    Sep 3, 2014 at 14:31
  • Oh, I'm sorry, I confused number and volume.
    – moewe
    Sep 3, 2014 at 14:33

2 Answers 2

3

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

2

Is that like you want?

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\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)

 \renewcommand\bibpagespunct{\iffieldundef{volume}{\addcomma\space}{\addcolon\space}}

\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"}
@ARTICLE{Ricoeur:2000ga,
    AUTHOR = {Ricœur, Paul}, 
    TITLE = {{L'écriture de l'histoire et la représentation du passé}},
    JOURNAL = {AHESS},
    YEAR = {2000},
    VOLUME = {55},
    NUMBER = {4},
    PAGES = {731--747},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}

\nocite{*}
\printbibliography

\end{document} 

enter image description here

4
  • No, because this simply undoes my own renewcommand{\bibpagespunct} where I make sure that a colon is printed between the volume number and the page range. I only want to remove the colon if there is no volume number. Your \renewcommand\bibpagespunct{\addcomma\space} won't print a colon anywhere.
    – Sverre
    Sep 3, 2014 at 13:59
  • Do you mean you want a colon if there's a volume number and a comma or nothing if there's none?
    – Bernard
    Sep 3, 2014 at 14:18
  • Yes. The question I posed was "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?".
    – Sverre
    Sep 3, 2014 at 14:20
  • @Sverre: see my updated answer.
    – Bernard
    Sep 3, 2014 at 15:04

You must log in to answer this question.

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