Paying keen attention to package loading order, I wonder if babel should be loaded before or after fontspec. Neither manual carries information on the loading order.

Furthermore, there are contradictory views about this in this forum, even in answers by experts.

For instance, this question answered by egreg on July 2014 recommends to load fontspec after babel.

However, egreg seems to contradict himself in his answer on October 2014 to this question and suggests to load fontspec before babel.

I am sure this confusion is simply due to my lack of understanding of the details. What am I missing, and what should be the correct loading order?

  • 1
    usually it makes no difference and anyway the format has changed since then as prior to 2015 xelatex defaulted to 7-bit OT1 font encoding, the same as pdflatex but sice then it defaults to TU (Unicode) – David Carlisle Sep 2 '18 at 20:05
  • @DavidCarlisle thank you. Does it make any difference for luatex? I guess luatex was always unicode and should make no difference. – Krishna Sep 2 '18 at 20:32
  • no the encoding was OT1 for lualatex until 2015 as well – David Carlisle Sep 2 '18 at 21:34
  • Should be pointed out that unicode input encoding and unicode font encoding are different things. The default font encoding changed for both engines in 2015. – Johannes_B Sep 3 '18 at 4:40

You wouldn't expect the loading order to make any difference: babel is about choosing language customisation and fontspec is about choosing fonts and these are only slightly related. Of course babel includes many different language files by many different authors and there may be some edge cases where loading in a different order solves some issue, but I am not aware of any.

Note that the linked questions are both to old versions pre 2015 when xelatex and lualatex defaulted (like pdftex) to the original TeX OT1 7bit encoding, so some babel files may have warned that that encoding could not support the requested language. However both lualatex and xelatex now default to (and typically only use) TU (Unicode) so the choice of language should not affect the encodings used, although of course not all fonts cover all language scripts.

Note the situation is different in (pdf)latex where you are restricted to 8bit encodings and so need to change encoding to support different languages. This means that fontenc (not fontspec) may need to be called before babel to avoid warnings, eg to load LGR encoding to support Greek, or T1 for most western Euroean languages, but even here I think in most cases the babel files will arrange the right encoding even if fontenc has not been explicitly loaded in advance.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.