2

I am trying to rework my CV a little and decided I'd just use a plain old article format. When I made the CV itself with lualatex, fontspec, and polyglossia it worked fine with \setdefaultlanguage{icelandic}. However wen I tried to create a cover letter with the exact same stuff in the preamble (except the \let\ps@plain\ps@empty bit, but I tried taking it out and it made no difference) it didn't work:

% !TEX program = lualatex
\documentclass[12pt,a4paper]{article}
\usepackage{fontspec}
\setlength\parskip{0pt}

\usepackage{polyglossia}
\setdefaultlanguage{icelandic}

\usepackage[margin=2cm]{geometry}

\usepackage{tcolorbox}

\usepackage{titlesec,titletoc}

% section
\titleformat{\section}
{\itshape\LARGE}
{\scshape \oldstylenums{\thesection}}
{1ex minus .1ex}
{\itshape\LARGE}
\titlespacing*{\section}
{0pt}{30pt}{16pt}

\makeatletter
  \let\ps@plain\ps@empty
\makeatother

\author{\textbf{Þórhalla Guðmundsdóttir Beck} \\ \textit{málvísindamaður -- orðakuklari}}
\title{}
\date{Reykjavík, \today}

\begin{document}

\begin{tcolorbox}
\maketitle
\end{tcolorbox}

\end{document}

With an empty file except the \maketitle in a tcolorbox (I also tried taking them out but it made no difference either), I get the error:

! Package polyglossia Error: language english is not loaded. Please load it before using it..
See the polyglossia package documentation for explanation. 

If I use \setmainlanguage{icelandic} alone (or with \setdefaultlanguage{english}) it compiles. If I try putting the language call after all other packages, as suggested in the documentation, it still doesn't compile. And apart from this I couldn't find anything to help me in the documentation. I am starting to think that it's some blindingly obvious misprint or mistake I have made somewhere but I'm not seeing it.

For comparison, here is the preamble from the CV with the same header. It compiles perfectly.

% !TEX program = lualatex
\documentclass[10pt,a4paper]{article}
\usepackage{fontspec}
\setlength\parskip{0pt}

\usepackage{polyglossia}
\setdefaultlanguage{icelandic}

\usepackage[margin=2cm]{geometry}

\usepackage{tcolorbox}

\usepackage{titlesec,titletoc}

% section
\titleformat{\section}
{\itshape\LARGE}
{\scshape \oldstylenums{\thesection}}
{1ex minus .1ex}
{\itshape\LARGE}
\titlespacing*{\section}
{0pt}{30pt}{16pt}

\author{\textbf{Þórhalla Guðmundsdóttir Beck} \\ \textit{málvísindamaður -- orðakuklari}}
\title{Ferilskrá}
\date{Reykjavík, \today}

\begin{document}

\begin{tcolorbox}
\maketitle
\end{tcolorbox}

\end{document}

I do realise that I can make it work by using \setmainlanguage{icelandic} instead of \setdefaultlanguage{icelandic} but I need to know why this isn't working. The polyglossia documentation says that you can set the default language with \setdefaultlanguage "or, equivalently, \setmainlanguage"! Which begs the question, what is the difference, if any? (and maybe is one preferred over the other?).

2
  • 1
    I get no error from your first code. Moreover \setmainlanguage and \setdefaultlanguage have the same first level expansion, so they're perfectly equivalent.
    – egreg
    Feb 25 '21 at 18:23
  • 2
    that can happen when you switch languages, simply hit enter or s to continue the next compilation should be fine. Or delete the aux-file. Feb 25 '21 at 18:33
3

The error is raised when you change the default/main language.

If you have

\documentclass{article}
\usepackage{polyglossia}

\setmainlanguage{english}

\begin{document}

text

\end{document}

and run it, you'll get no error. But if you change the language line into

\setmainlanguage{icelandic}

and don't remove the .aux file, rerunning XeLaTeX (or LuaLaTeX) on the file will produce

! Package polyglossia Error: language english is not loaded. Please load it 
before using it..

and several other errors at the first run. The next run will end without problems.

So it's not a question of \setmainlanguage or \setdefaultlanguage, but of main language change. Actually, the two commands are defined in exactly the same way, so this cannot be the issue.

I agree that polyglossia might be more friendly when the main language is changed and not produce scores of error messages, but that's a different problem.

1
  • 1
    I removed the .aux files and reran it and it compiled fine. Thanks. I've had problems before where doing that fixed it. Should have thought of that. But at least I was right in that it was something completely obvious that I was missing. #headdesk
    – Plergux
    Feb 25 '21 at 19:01

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.