Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong extra space in some bibliography elements in new versions of biblatex #983

Closed
ndlecic opened this issue Apr 4, 2020 · 6 comments
Closed
Labels
Milestone

Comments

@ndlecic
Copy link

ndlecic commented Apr 4, 2020

I'm trying to move from biblatex-3.11 to biblatex-3.14, and I have a strange problem with spaces. I'm not sure if this is a bug; please help be to understand it. Consider the following code:

\documentclass[fontsize=10pt,paper=A5,DIV=13]{scrartcl}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\setmainfont{CMU Serif}
\newfontfamily\latinfont{CMU Serif}
\usepackage[
  style=gost-authoryear,
  language=auto,
  autolang=other,
  blockpunct=emdash,
  pagetracker=page,
  alldates=comp,
]{biblatex}
\renewcommand*{\bibfont}{\Huge}
\begin{filecontents}{\jobname.bib}
@Article{Block2006,
    author = {Block, J. and Block, J. H.},
    title = {Nursery School Personality and Political Orientation Two Decades Later},
    journaltitle = {Journal of Research in Personality},
    volume = {40},
    number = {5},
    pages = {734-749},
    year = {2006},
    language = {english},
    langid = {english},
}
\end{filecontents}

\addbibresource{\jobname.bib}
\begin{document}
\cite[]{Block2006}
\printbibliography
\end{document}

The result with biblatex-3-11/biber-2.11 is on the left; biblatex-3.14/biber-2-14 output is on the right.

extra dashes

As you can see in the last two lines, in 3.14/2.14 version all emdashes are preceded by a strange big extra space. In this example, emdash is a part of blockpunct definition:

\renewcommand*{\newblockpunct}{\addperiod\addnbspace\textemdash\space\bibsentence}

I can't find what exactly changed after biblatex-3.11. And I'm not sure if such extra spaces occur somewhere else as well, but bad blockpuncts break all my documents.

@moewew
Copy link
Collaborator

moewew commented Apr 4, 2020

I'll have a closer look later, but could this be a polyglossia issue? With babel the space seems to be OK again

\documentclass[fontsize=10pt,paper=A5,DIV=13]{scrartcl}
\usepackage[english]{babel}
\usepackage[
  style=gost-authoryear,
  language=auto,
  autolang=other,
  blockpunct=emdash,
  pagetracker=page,
  alldates=comp,
]{biblatex}
\renewcommand*{\bibfont}{\Huge}
\begin{filecontents}{\jobname.bib}
@Article{Block2006,
    author = {Block, J. and Block, J. H.},
    title = {Nursery School Personality and Political Orientation Two Decades Later},
    journaltitle = {Journal of Research in Personality},
    volume = {40},
    number = {5},
    pages = {734-749},
    year = {2006},
    language = {english},
    langid = {english},
}
\end{filecontents}

\addbibresource{\jobname.bib}
\begin{document}
\cite[]{Block2006}
\printbibliography
\end{document}

@ndlecic
Copy link
Author

ndlecic commented Apr 4, 2020

I'll have a closer look later, but could this be a polyglossia issue? With babel the space seems to be OK again

Until today, I didn't even think of polyglossia -- but it seems you're right. If you could help to figure out what exactly to report them, it would be great. Because I have this problem in bibliographies only.

@moewew
Copy link
Collaborator

moewew commented Apr 4, 2020

Hrmpf! I don't think we can say this is a polyglossia bug. It has to do with how (non)frenchspacing is activated for languages. I'll have to investigate further.

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\usepackage[
  style=authoryear,
  autolang=other,
]{biblatex}

\makeatletter
\ExplSyntaxOn
\cs_set_nopar:Nn{\polyglossia@lang@frenchspacing:n}{
  \prop_get:NxNTF \polyglossia@langsetup {#1/frenchspacing} \l_tmpa_tl
      {
         \typeout{Setting Frenchspacing}%
         %\str_case_e:nnF{\l_tmpa_tl}{
         % {true}{\frenchspacing}
         % {false}{\nonfrenchspacing}
        %}
        %{\xpg@error{frenchspacing~should~be~true~or~false. Is~"\l_tmpa_ttl"~ for~ language~ "#1"}}
      }
      {
        \xpg@error{Could~ not~ retrieve~ key~ frenchspacing~ for~ language~ "#1"}
        \prop_show:N{\polyglossia@langsetup}
      }
}
\ExplSyntaxOff
\makeatother

\renewcommand*{\newblockpunct}{\the\spacefactor\addnbspace\textemdash\space}

\addbibresource{biblatex-examples.bib}
\begin{document}
\cite[]{sigfridsson}
\printbibliography
\end{document}

polyglossia explicitly sets (non)frenchspacing every time a language is selected. This means that selecting English sets \nonfrenchspacing which gives us wrong (or at least unexpected) sfcodes and thus large spaces after periods. We could force \frenchspacing in \blx@beglang, it feels like cheating, but is probably what people expect. Maybe give it an internal name that people can undefine...

@moewew moewew added the bug label Apr 4, 2020
@moewew moewew added this to To Do in biblatex 3.15 Apr 4, 2020
@moewew
Copy link
Collaborator

moewew commented Apr 5, 2020

It doesn't feel quite right, but in d7e3c82 we simply force \frenchspacing when we change the language with polyglossia. That should negate the effects of polyglossia eagerly setting \nonfrenchspacing here. The problem does not occur with babel, because babel's English module does not set \nonfrenchspacin at all, it just relies on the fact that it is the default.

If a user doesn't want the explicit \frenchspaing, they can disable it with

\let\blx@beglang@spacefactors\@empty

If you need a workaround now, try

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{english}
\usepackage[
  style=authoryear,
  language=auto,
  autolang=other,
]{biblatex}

\makeatletter
\@ifpackagelater{biblatex}{2020/04/05}
  {\PackageError{biblatex}
     {Fix for \#983 no longer required}
     {Remove the code for the outdated fix}}
  {\AtBeginDocument{%
     \ifdef\blx@beglang
       {\appto\blx@beglang{\frenchspacing}%
        \iftoggle{blx@autolangbib}
          {\let\blx@beglangbib\blx@beglang}
          {}%
        \iftoggle{blx@autolangcite}
          {\let\blx@beglangcite\blx@beglang}
          {}}
       {}}}
\makeatother

\renewcommand*{\newblockpunct}{\addnbspace\textemdash\space}


\addbibresource{biblatex-examples.bib}
\begin{document}
\cite{sigfridsson}
\printbibliography
\end{document}

The code will automatically throw errors with (future) versions of biblatex to remind you to remove the kludge.

@moewew moewew moved this from To Do to Done in biblatex 3.15 Apr 5, 2020
@moewew moewew added the fixedindev Fixed in current DEV version label Apr 5, 2020
@moewew moewew added this to the v3.15 milestone Apr 5, 2020
@ndlecic
Copy link
Author

ndlecic commented Apr 5, 2020

\makeatletter
\@ifpackagelater{biblatex}{2020/04/05}
  {\PackageError{biblatex}
     {Fix for \#983 no longer required}
     {Remove the code for the outdated fix}}
  {\AtBeginDocument{%
     \ifdef\blx@beglang
       {\appto\blx@beglang{\frenchspacing}%
        \iftoggle{blx@autolangbib}
          {\let\blx@beglangbib\blx@beglang}
          {}%
        \iftoggle{blx@autolangcite}
          {\let\blx@beglangcite\blx@beglang}
          {}}
       {}}}
\makeatother

Great, this works perfectly. Thanks!

Ironically, I think that my problem report reutenauer/polyglossia#182 was among the causes that triggered respective changes in polyglossia... :(

@moewew moewew removed the fixedindev Fixed in current DEV version label Aug 31, 2020
@moewew
Copy link
Collaborator

moewew commented Aug 31, 2020

biblatex 3.15 with the French-spacing workaround has been released. It is now available in MikTeX and TeX live.

@moewew moewew closed this as completed Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
biblatex 3.15
  
Done
Development

No branches or pull requests

2 participants