josephwright / biblatex-phys

A biblatex implementation of the AIP and APS bibliography style
LaTeX Project Public License v1.3c
25 stars 5 forks source link

Wrong colon spacing in eprint formatting when using french babel #16

Open cebamps opened 7 years ago

cebamps commented 7 years ago

In biblatex, \addcolon typesets the colon according to the selected babel language. The issue is that the french colon has some spacing prepended to it, which makes eprint formatting look wrong compared to the spaceless version:

french

I believe the lack of \addspace after \addcolon is meant to mimic the usual formatting of arXiv references (as in REVTeX, i.e., arXiv:1234.5678 with no spaces around the colon)? In any case, the spacing ends up making it look like arxiv :1234.5678. In comparison, the default biblatex styles typeset it in a more conventional way using \addcolon\addspace, which looks like arxiv : 1234.5678 in french and arxiv: 1234.5678 in english.

MWE:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage[french]{babel}
\usepackage[style=phys,articletitle=false,eprint=true]{biblatex}
\addbibresource{\jobname.bib}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{oldstyle,
 author = {Maldacena, J.}, year = 1997,
 archivePrefix = {arXiv},
 eprint = {hep-th/9711200},
}
@article{newstyle,
 author = {Aad, G. and others}, year = 2012,
 archivePrefix = {arXiv},
 primaryClass = {hep-ex},
 eprint = {1207.7214},
}
\end{filecontents}

\begin{document}
\nocite{*}
\printbibliography
\end{document}
josephwright commented 7 years ago

There are two possible solutions here: add a space (as you say) or force a string colon (still an issue with LuaTeX, I guess).

josephwright commented 5 years ago

I've thought about this, and really it's a problem beyond biblatex-phys: the active colon needs to be disabled within the bibliography. Fixing it 'here' would at best be a hack: in particular, LuaLaTeX is a real issue.

@moewew Any thoughts here? I'm not sure what to say here beyond 'French babel set up is a PITA'.

moewew commented 5 years ago

Actually it's not only babel-french biblatex's french.lbx is actively PITA-ing too

https://github.com/plk/biblatex/blob/e8229b12c5a366f52a3cf0c6a50e5b68745ad267/tex/latex/biblatex/lbx/french.lbx#L43-L56

I don't think the actively/spacey colon should be disabled elsewhere in the bibliography. I assume that for all other uses people would expect the normal French behaviour.

Something like

\documentclass{article}
\usepackage{csquotes}
\usepackage[french]{babel}
\usepackage[style=phys,articletitle=false,eprint=true]{biblatex}

\makeatletter
\DeclareFieldFormat{eprint:arxiv}{%
  \let\FDP@colonspace\empty
  \csuse{NoAutoSpacing}%
  \ifhyperref
    {\href{https://arxiv.org/\abx@arxivpath/#1}{%
        arXiv\addcolon
        \nolinkurl{#1}%
        \iffieldundef{eprintclass}
          {}
          {\addspace\UrlFont{\mkbibbrackets{\thefield{eprintclass}}}}}}
    {arXiv\addcolon
      \nolinkurl{#1}%
      \iffieldundef{eprintclass}
        {}
        {\addspace\UrlFont{\mkbibbrackets{\thefield{eprintclass}}}}}}
\makeatother

\addbibresource{biblatex-examples.bib}

\begin{document}
\nocite{baez/article}
\printbibliography
\end{document}

should hopefully work (unless someone other than babel-french defines \NoAutoSpacing).

I guess we could define a \addunspacedcolon (or something like that) in biblatex that automatically does this and could be used by package authors who definitely know that they don't want the French colon behaviour.

josephwright commented 5 years ago

@moewew Sounds good: something at the core level would 'feel' right

moewew commented 5 years ago

Tracked at https://github.com/plk/biblatex/issues/925. I'll be busy for the next two weeks, so I will probably forget about this short-term. Comments for the name and implementation issues are highly appreciated.

moewew commented 4 years ago

I removed an earlier post which showed \addcolonnonfrench, since I'm not sure about how to proceed.

@josephwright Given the issues mentioned in https://github.com/plk/biblatex/issues/925 (namely that not only French messes with punctuation spacing but other languages might do so as well and that there is no unified interface to turn off the spacing changes) do you still think that this is something that we should try to implement in biblatex? At the moment I tend towards scrapping the idea of implementing an \addcolon that tries to work against the various language modules that might try to influence colon spacing.

josephwright commented 4 years ago

@moewew Agreed: this needs action 'elsewhere'

moewew commented 4 years ago

Thanks for the comment. I backed out of \addcolonnonfrench for now.

I realise that this leaves the issue here with no great solution, but an overall approach that works for all languages seems tricky.