21

I have the following document :

\documentclass{article}
\usepackage[backend=biber,style=numeric,maxnames=2,maxbibnames=6,firstinits]{biblatex}
\bibliography{sample}

\begin{document}
Here we want to generate a long sentence so the citation will split \textcite{fictive}.
\printbibliography
\end{document}

with corresponding bib file :

@article{fictive,
    author = {John Doe and John Smith and John Carpenter and John McCain},
    year = 2012,
    title = {Super awesome paper},
    journal = {Super awesome journal}}

The rendering of this document is such :

Here we want to generate a long sentence so the citation will split Doe et al.
[1].

With the line break exactly at the same place. This doesn't feel right. I would prefer the following, i.e. having a non-breaking space instead of a breaking space between authors and citation number :

Here we want to generate a long sentence so the citation will split Doe 
et al. [1].

Writing it textually in a tex file :

Doe et al.~[1]

Anyone else agree that this is the right way to do it? How do I go about changing this?

levesque
  • 12,993
  • 12
  • 43
  • 52

1 Answers1

18

The biblatex command \addnbspace is a non-breakable variant of \addspace. You can swap these commands in the textcite bibliography macro defined in numeric.cbx. For older versions of biblatex, this can easily be done by adding the following to your preamble.

\usepackage{xpatch}
\xpatchbibmacro{textcite}{\addspace}{\addnbspace}{}{}

For more recent versions there is a dedicated delimiter. It can be changed by adding the following to your preamble.

\renewcommand\namelabeldelim{\addnbspace}

The patch will also work for the numeric-comp and numeric-verb styles.

In your MWE this induces a linebreak in "et al." To avoid this, you can increase the penalty in breaking at \addabbrvspace - the space used in abbreviated localization strings. In biblatex.def this penalty is assigned the value

\defcounter{abbrvpenalty}{\hyphenpenalty}

which defaults to 50. You can increase the penalty at the risk of some overfull boxes with, say

\defcounter{abbrvpenalty}{9000}

or

\xpretobibmacro{textcite}{\defcounter{abbrvpenalty}{9000}}{}{}

Values at or above 10000 will make \addabbrvspace non-breakable.

Stefan Pinnow
  • 29,535
Audrey
  • 28,881
  • 1
    @egreg Thanks. Any plans on extending the patch commands to formatting directives? – Audrey Oct 01 '12 at 20:58
  • Which family of commands are they? – egreg Oct 01 '12 at 21:00
  • @egreg For fields the CS names go by: abx@ffd@<entrytype>@<format>. Default formats use * instead of entrytype. Names and lists are similar, but with nfd and lfd instead of ffd. Indexing directives use fid, nid, lid. – Audrey Oct 01 '12 at 21:07
  • 3
    +1 but this does show the trade off. If you introduce too many non-breaking spaces in a bibliography driver it can be really tough to deal with overfull boxes, because it's nearly impossible to clean up by hand. It may be easier to live with the odd less-than-perfect break. Would adding a high penalty space rather than an unbreakable space be a possible compromise? – Paul Stanley Oct 01 '12 at 21:12
  • @Audrey Something like \xpatchfieldformat[<entrytype>]{<format>}{<before>}{<after>}{<success>}{<failure>}, with default value for the optional argument *? – egreg Oct 01 '12 at 21:25
  • @PaulStanley This is why I gave the last patch that confines the increased penalty to textcite. Instead of \addnbspace there is \addhighpenspace, but it is typically used to delimit name parts. Its penalty defaults to \hyphenpenalty. – Audrey Oct 01 '12 at 21:26
  • @egreg Yes, exactly. Forgot to mention format names are detokenized. If you need help testing, ping me in chat and I'll get around to it. – Audrey Oct 01 '12 at 21:28
  • @Audrey You find in chat an example. – egreg Oct 01 '12 at 21:38
  • I couldn't find it and I didn't want to ask a question about it, because I believe the problem is similar to Levesque's: I use numeric-comp style and when my \cite results in a range, e.g. [1-3] near the end of a line, it is possible the range is broken at the line end after the -- (range hyphen). I believe this looks badly. How do I redefine the range hyphen to be the \nbhyphen (see biblatex' documentation) and will this solve my problem? – Erik Dec 21 '14 at 20:58