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?).
\setmainlanguageand\setdefaultlanguagehave the same first level expansion, so they're perfectly equivalent. – egreg Feb 25 '21 at 18:23