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

Break line first call of \text<lang> or \foreignlanguage #1041

Closed
miticollo opened this issue Aug 27, 2020 · 14 comments
Closed

Break line first call of \text<lang> or \foreignlanguage #1041

miticollo opened this issue Aug 27, 2020 · 14 comments
Labels
Milestone

Comments

@miticollo
Copy link

miticollo commented Aug 27, 2020

With the following code:

% !TeX encoding = UTF-8
% !TeX TS-program = lualatex

\documentclass{report}

\usepackage{polyglossia}
\setmainlanguage{italian}
\setotherlanguage{english}

\usepackage{biblatex}

\begin{document}
	
	% Questo è un esempio \foreignlanguage{english}{inline}.

	Questo è un esempio \textenglish{inline}.
	
	Anche questo è un esempio \foreignlanguage{english}{inline}.
	
	Un altro esempio è il seguente \textenglish{inline}.
\end{document}

The results are

  • with biblatex 3.14 (CORRECT)
    3_14
  • with biblatex 3.15 or above
    3_15
@moewew
Copy link
Collaborator

moewew commented Aug 27, 2020

Oh, bother!

Thank you very much for reporting this issue. I think I could figure out why it appears (the .lbx file may be read in normal document context and may contain blank lines leading to a \par), but I'll have to find a solution that ideally requires no changes to existing .lbx files.

@moewew moewew added the bug label Aug 27, 2020
moewew added a commit that referenced this issue Aug 27, 2020
@moewew
Copy link
Collaborator

moewew commented Aug 27, 2020

Hopefully e7e7c38 fixes this.

Some more tests in real world documents would be appreciated. Just add the \makeatletter...\makeatother block below to your preamble after loading biblatex.

\documentclass{report}

\usepackage{polyglossia}
\setmainlanguage{italian}
\setotherlanguage{english}

\usepackage{biblatex}

\makeatletter
% {<file>}{<message>}{<preload>}{<postload>}{<success>}{<failure>}
\protected\long\def\blx@lbx@input@handler@simple#1#2#3#4#5#6{%
  \blx@info@noline{Trying to load #2..}%
  \IfFileExists{#1}
    {\blx@info@noline{... file '#1' found}%
     \csuse{blx@lbxfilehook@simple@preload@#1}%
     #3%
     \setbox\@tempboxa=\hbox\bgroup\@@input\@filef@und\egroup
     #4%
     \csuse{blx@lbxfilehook@simple@postload@#1}%
     #5%
     \ifcsundef{blx@file@lbx@simple@#1}
       {\listxadd\blx@list@req@stat{#1}%
        \@addtofilelist{#1}%
        \global\cslet{blx@file@lbx@simple@#1}\@empty}
       {}}
    {\blx@info@noline{... file '#1' not found}%
     \csuse{blx@lbxfilehook@simple@failure@#1}%
     #6}}

% {<file>}{<message>}{<preload>}{<postload>}{<success>}{<failure>}
\protected\long\def\blx@lbx@input@handler@once#1#2#3#4#5#6{%
  \ifcsundef{blx@file@lbx@once@#1}
    {\blx@info@noline{Trying to load #2..}%
     \IfFileExists{#1}
       {\blx@info@noline{... file '#1' found}%
        \csuse{blx@lbxfilehook@once@preload@#1}%
        #3%
        \setbox\@tempboxa=\hbox\bgroup\@@input\@filef@und\egroup
        #4%
        \csuse{blx@lbxfilehook@once@postload@#1}%
        #5%
        \ifcsundef{blx@file@lbx@simple@#1}
          {\listxadd\blx@list@req@stat{#1}%
           \@addtofilelist{#1}}
          {}}
       {\blx@info@noline{... file '#1' not found}%
        \csuse{blx@lbxfilehook@once@failure@#1}%
        #6}%
     \global\cslet{blx@file@lbx@once@#1}\@empty
     \global\cslet{blx@file@lbx@simple@#1}\@empty}
    {#5}}
\makeatother

\begin{document}
  % Questo è un esempio \foreignlanguage{english}{inline}.

  Questo è un esempio \textenglish{inline}.

  Anche questo è un esempio \foreignlanguage{english}{inline}.

  Un altro esempio è il seguente \textenglish{inline}.
\end{document}

@miticollo
Copy link
Author

Sorry :(. But it doesn't work.

@hvoss49
Copy link

hvoss49 commented Aug 27, 2020 via email

@miticollo
Copy link
Author

Sorry for my mistake. It works. Thank you.

@telemachus
Copy link

I was having the same problem when using Polyglossia and switching from English (main language) to ancient Greek.

I'm happy to say that this fixes the problem. Thanks for the quick fix!

@moewew
Copy link
Collaborator

moewew commented Aug 28, 2020

I'm sorry for the confusion. Serves me right for not posting a full MWE. Yes the code must be wrapped in \makeatletter...\makeatother or must be used in a context where \makeatletter is implicit (a .sty file for example). I updated the example in my post above to a full MWE (with \makeatletter...\makeatother) to avoid any confusion.


Still testing in larger documents would be appreciated. I have conducted a few small tests, but it would be good to hear if this change has any negative impact on other parts of the document that wasn't present in these tests. I'm particularly interested in bibstrings and localisation. So you may want to double check that all biblatex strings are translated correctly.

@miticollo miticollo changed the title Break line first call of \textenglish or \foreignlangue{english}{...} Break line first call of \text<lang> or \foreignlangue{<lang>}{...} Aug 28, 2020
@miticollo miticollo changed the title Break line first call of \text<lang> or \foreignlangue{<lang>}{...} Break line first call of \text<lang> or \foreignlanguage{<lang>}{...} Aug 28, 2020
@miticollo miticollo changed the title Break line first call of \text<lang> or \foreignlanguage{<lang>}{...} Break line first call of \text<lang> or \foreignlanguage Aug 28, 2020
@telemachus
Copy link

I have conducted a few small tests, but it would be good to hear if this change has any negative impact on other parts of the document that wasn't present in these tests. I'm particularly interested in bibstrings and localisation. So you may want to double check that all biblatex strings are translated correctly.

@moewew The new code can handle something like the following fine:

@article{ worlfsdorf-eironeia-aristophanes-plato-2008,
	author = {Wolfsdorf, David},
	title = {\textgreek{Εἰρωνεία} in Aristophanes and Plato},
	shorttitle = {\textgreek{Εἰρωνεία}},
	journal = {Classical Quarterly},
	year = {2008},
	volume = {58},
	number = {2},
	pages = {666-672},
	keywords = {secondary,irony,aristophanes},
}

That item appears correctly both in footnotes and in the final bibliography when I use the new patch.

@moewew
Copy link
Collaborator

moewew commented Aug 28, 2020

@telemachus Great. Thanks for testing. If you find anything that doesn't work, please don't hesitate to complain here.

@moewew moewew added this to the v3.15b milestone Aug 31, 2020
@moewew
Copy link
Collaborator

moewew commented Sep 2, 2020

I'm not too happy about boxing the file contents when reading. @u-fischer had a few suggestions in https://tex.stackexchange.com/questions/560329/a-phantom-linebreak-with-polyglossia-and-biblatex#comment1414497_560329, so I might want to explore those in the next days when I have time. (I think catcode trickery is out, so at the moment the .aux solution seems best, but we shall see.)

moewew added a commit that referenced this issue Sep 15, 2020
Languages that are loaded on the fly and are not reported via the
official channels by babel/polyglossia are recorded in the .aux file
and loaded on a subsequent run. A rerun warning is emitted if required.

Allows us to roll back e7e7c38.
@moewew
Copy link
Collaborator

moewew commented Sep 15, 2020

1b12b2a contains a different, more sophisticated fix for this issue. As suggested by Ulrike in https://tex.stackexchange.com/questions/560329/a-phantom-linebreak-with-polyglossia-and-biblatex#comment1414497_560329 we now 'collect' languages we haven't loaded in the .aux file and can then load all .lbx files \AtBeginDocument.

Testing would be very much appreciated. Because the code changes are a bit deeper than the few lines we had in e7e7c38 (which is reverted now) https://gist.github.com/moewew/55f8a7de54f5b7033ed9cb00efbd3371 contains a drop-in replacement version of biblatex.sty you can use for testing. I strongly recommend you only use that file for testing (for example by dropping it in a new, empty test folder), I wouldn't recommend it for production use.

If you find any issues with https://gist.github.com/moewew/55f8a7de54f5b7033ed9cb00efbd3371 please let me know.

@telemachus
Copy link

@moewew I apologize for not replying sooner. (I'm a teacher, and school just started up again. Busy, busy.)

I'm using your replacement for biblatex.sty, and it's been perfect in initial tests. The problem is fixed, and it doesn't seem to create any new issues. I'll keep using it in other projects and let you know if I notice anything else. Thanks.

@moewew
Copy link
Collaborator

moewew commented Sep 22, 2020

@telemachus Thank you very much for testing the changes and the feedback!

@moewew moewew added the fixedindev Fixed in current DEV version label Sep 22, 2020
@moewew
Copy link
Collaborator

moewew commented Jan 3, 2021

biblatex v3.16 with a fix for this issue was released on 31 Dec 2020 and is available now in TeX live and MikTeX.

@moewew moewew closed this as completed Jan 3, 2021
@moewew moewew removed the fixedindev Fixed in current DEV version label Jan 3, 2021
telemachus added a commit to telemachus/socratic-notes that referenced this issue Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants