latex3 / babel

The babel system for LaTeX, LuaLaTeX and XeLaTeX
LaTeX Project Public License v1.3c
124 stars 34 forks source link

\selectlanguage{spanish} in preamble causes errors #251

Closed tomh-overleaf closed 11 months ago

tomh-overleaf commented 11 months ago

Minimal Example

\documentclass{article}

\usepackage[spanish]{babel}

\selectlanguage{spanish}

\begin{document}

Hello, world!

\end{document}

Error message

! Incomplete \iffalse; all text was ignored after line 129.
<inserted text> 
                \fi 
l.7 \begin{document}
                    ^^M

Listfiles

 *File List*
 article.cls    2023/05/17 v1.4n Standard LaTeX document class
  size10.clo    2023/05/17 v1.4n Standard LaTeX file (size option)
   babel.sty    2023/07/09 v3.91 The Babel package
 spanish.ldf
babel-spanish.tex
l3backend-pdftex.def    2023-04-19 L3 backend support: PDF output (pdfTeX)
 ***********

Observations

josephwright commented 11 months ago

I think it's a file loading issue: if I manually force expl3 loading in the preamble it works, so there is an issue loading the backend code.

josephwright commented 11 months ago

I see the issue: the catcodes are being activated in begindocument/before, which is before we load l3backend, which then chokes. Thinking where the solution is.

jbezos commented 11 months ago

I’m preparing a new version fixing that.

josephwright commented 11 months ago

@jbezos I think the activation is in the wrong hook, but I'm not sure why begindocument/before was chosen.

jbezos commented 11 months ago

@josephwright See #240. The problem was \normalsfcodes, so I moved \selectlanguage before, but that was clearly wrong (even if all my tests passed). I’ve restored the place where the language was selected (which is the correct one) and devised another fix.

@tomh-overleaf I’ll upload a new version to CTAN very likely in a few hours.

tomh-overleaf commented 11 months ago

@tomh-overleaf I’ll upload a new version to CTAN very likely in a few hours.

Thanks, Javier! We'll pull it next week :)