5

Consider the input

\documentclass{article}
\usepackage{fontspec}
\usepackage[french,main=american]{babel}
% \usepackage{fontspec}%%% Doesn't matter where you use fontspec
\begin{document}
Nothing.
\end{document}

No matter which of the two lines including the fontspec package is enabled, the warning

Package frenchb.ldf Warning: Add \usepackage{fontspec} to the 
(frenchb.ldf)                preamble of your document, on input line 5.

is printed to the log when compiling with xelatex or lualatex.

The output file seems to be ok. Is the warning bogus?

Versions:

  • XeTeX 3.14159265-2.6-0.99996 (TeX Live 2016)
  • LuaTeX Version 0.95.0 (TeX Live 2016)
  • LaTeX2e <2017/01/01> patch level 1
  • Babel 2016/04/23 3.9r
  • Fontspec 2017/01/24 v2.5d
  • 3
    Make a bug report to the french.ldf maintainer. He should adapt the code to the newest fontspec version (which no longer loads xunicode). – Ulrike Fischer Jan 31 '17 at 14:07
4

This is a consequence of the recent changes in fontspec that stopped loading xunicode by default. The relevant code in frenchb.ldf is

\ifFBunicode
   \ifdefined\DeclareUTFcharacter
   \else
      \@ifpackageloaded{luainputenc}{}%
        {\PackageWarning{frenchb.ldf}%
         {Add \protect\usepackage{fontspec} to the\MessageBreak
         preamble of your document,}%
        }%
   \fi
\else
  [...irrelevant part...]
\fi

The \ifBunicode conditional is true when the engine used is either XeTeX or LuaTeX; in this case nothing is done if \DeclareUTFcharacter is defined, assuming this means fontspec has been loaded. This is the wrong test to do, because it just checks whether xunicode is loaded, not fontspec. Since this package doesn't load it any longer, the test returns false, so the warning is issued, because you aren't loading luainputenc, of course.

You can use the silence package to get rid of this spurious warning until babel-french is updated to look for, say, \setmainfont.


Update

With babel-french version 3.2g, released 2017/01/30, the problem should be fixed. In the notes of the .dtx file we see

\changes{v3.2g}{2017/01/24}{fontspec defines TU encoding now and
  no longer loads xunicode.sty. Test changed.}

that shows the maintainers were already aware of the issue. Now the test is

\ifFBunicode
  \@ifpackageloaded{fontspec}{}%
     {\@ifpackageloaded{luainputenc}{}%
         {\PackageWarning{frenchb.ldf}%
             {Add \protect\usepackage{fontspec} to the\MessageBreak
              preamble of your document, reported}%
         }%
     }
\else
[...irrelevant part...]
\fi

so the loading of fontspec is checked specifically.

However, this doesn't allow (as it was before) to load fontspec after babel.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy