1

I want to do something similar to this link, which adds a word between two citations. When I have a range of citations (more than 2 in a row), it like to change the hyphen to the word "to". For some reason changing the \compcitedelim doesn't work for me. Thanks for any suggestions.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber, sorting=none, style=numeric-comp]{biblatex}

\addbibresource{test.bib}

\title{Test}
\author{T. Est }
\date{November 2019}

\renewcommand*{\compcitedelim}{\bibstring{to}}
\renewcommand*{\multicitedelim}{\bibstring{to}

\begin{document}

\maketitle

\section{Introduction}
Test \cite{key1, key2, key3}.
\printbibliography
\end{document}

The bibliography, test.bib, has three entries

@misc{key1,
    author = {Author, O.},
    title = {The First Citation},
    year = {2019},
    howpublished = {Unpublished},
}

@misc{key2,
    author = {Author, T.},
    title = {The Second Citation},
    year = {2019},
    howpublished = {Unpublished},
}

@misc{key3,
    author = {Author, T.},
    title = {The Third Citation},
    year = {2019},
    howpublished = {Unpublished},
}

1 Answer 1

0

The dash (\bibrangedash) is hard-coded in the bibmacro cite:dump (ll. 87-99 of numeric-comp.cbx in biblatex v3.13a), but it is possible to replace it with a customisable macro, \comprangedelim say

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber, sorting=none, style=numeric-comp]{biblatex}

\NewBibliographyString{to}
\DefineBibliographyStrings{english}{
  to = {to},
}

\newcommand*{\comprangedelim}{\addspace\bibstring{to}\space}

\makeatletter
\renewbibmacro*{cite:dump}{%
  \ifnumgreater{\value{cbx@tempcnta}}{0}
    {\ifnumgreater{\value{cbx@tempcnta}}{1}
       {\comprangedelim}
       {\multicitedelim}%
     \bibhyperref[\cbx@lastkey]{%
       \ifdef\cbx@lastprefix
         {\printtext[labelprefix]{\cbx@lastprefix}}
         {}%
       \printtext[labelnumber]{\cbx@lastnumber}}}
    {}%
  \setcounter{cbx@tempcnta}{0}%
  \global\undef\cbx@lastprefix}
\makeatother

\addbibresource{biblatex-examples.bib}

\begin{document}
Test \cite{sigfridsson,worman,geer}.
\printbibliography
\end{document}

Test [1 to 3].


\compcitedelim is only used by the -comp styles of the authortitle and authoryear families. There it separates citations by the same author (where the author name is dropped).

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

\usepackage{xcolor}

\addbibresource{biblatex-examples.bib}

\begin{document}
\cite{knuth:ct:a,knuth:ct:b}

\cite{sigfridsson,worman}

\renewcommand*{\compcitedelim}{\addspace \textcolor{red}{C}\space}
\renewcommand*{\multicitedelim}{\addspace \textcolor{blue}{M}\space}

\cite{knuth:ct:a,knuth:ct:b}

\cite{sigfridsson,worman}

\printbibliography
\end{document}

Knuth 1984, 1986//Sigfridsson and Ryde 1998; Worman 2002//Knuth 1984 C 1986//Sigfridsson and Ryde 1998 M Worman 2002

2
  • Thanks. So what purpose does \compcitedelim have?
    – an4
    Nov 18, 2019 at 21:23
  • @an4 It is used in other styles (authoryear-comp, authortitle-comp and friends) and separates citations where the comp feature was used and the author name dropped. See the edit please.
    – moewe
    Nov 19, 2019 at 5:52

You must log in to answer this question.

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