0

I want to write a greek-english text. I am using babel+XeLaTex. I have a problem with the table of contents: When these lines are included in my code

\setDefaultTransitions{\selectlanguage{english}}{\selectlanguage{english}}
\setTransitionTo{GreekAndCoptic}{\selectlanguage{greek}} 

it produces the following error:

"LaTeX Error: Command \rmfamily invalid in math mode. output.toc, line 67"

and a warning at the ' \tableofcontents ' command, mentioning:

Package babel Warning: \englishcontentsname not set. Please, define it after the language has been loaded (typically in the preamble) with something like: \renewcommand\englishcontentsname{..} Reported on input line 23.

In the pdf, instead of ' Contents ' at the start of the ToC, it has ' ?contentsname? '

Here is the MWE:

\documentclass[12pt]{extarticle}

\usepackage{babel}
\usepackage{ucharclasses}

\babelprovide{greek,english}
\babelfont{rm}[Ligatures={Common,Rare}, Scale=1.0]{Libertinus Serif}
\babelfont{sf}[Ligatures={Common,Rare}]{Libertinus Sans}
\babelfont{tt}{Libertinus Mono}

\babelfont[Language=greek]{rm}{Kerkis}
\babelfont[Language=greek]{sf}{Kerkis}
\babelfont[Language=greek]{tt}{kerkis}

\setDefaultTransitions{\selectlanguage{english}}{\selectlanguage{english}}
\setTransitionTo{GreekAndCoptic}{\selectlanguage{greek}} 

\begin{document}
some text
blabla μπλαμπλα

\newpage
\tableofcontents
\newpage

\section{Introduction-Εισαγωγή}

\subsection{test}

\end{document}
1
  • wrt babel, load the package with \usepackage[greek, english]{babel}, remove the line with \babelprovide, remove Language= in \babelfont so that the result is something like \babelfont[greek]{rm}{Kerkis}. Some problems related to ucharclasses remain, but I don't use it, so I'm not sure how to fix them. Apr 12 at 13:00
1

Need further clarification on what you want to achieve.

When I make Greek the main language in babel, and set the fonts for the transitions (making Greek blue, to show which font made it into the table of contents), the TOC is OK.

Greek TOC

MWE

\documentclass[12pt]{extarticle}
\usepackage{xcolor}
\usepackage{fontspec}
\newfontfamily{\defaultfont}{Noto Serif}
\newfontfamily{\greekfont}{Kerkis}[Colour=blue]
\usepackage[english,greek]{babel}
\usepackage{ucharclasses}
\setDefaultTransitions{\defaultfont}{}
\setTransitionsForGreek{\greekfont}{}
%\babelprovide{greek,english}
%\babelfont{rm}[Ligatures={Common,Rare}, Scale=1.0]{Libertinus Serif}
%\babelfont{sf}[Ligatures={Common,Rare}]{Libertinus Sans}
%\babelfont{tt}{Libertinus Mono}
%
%\babelfont[Language=greek]{rm}{Kerkis}
%\babelfont[Language=greek]{sf}{Kerkis}
%\babelfont[Language=greek]{tt}{kerkis}

%\setDefaultTransitions{\selectlanguage{english}}{\selectlanguage{english}}
%\setTransitionTo{GreekAndCoptic}{\selectlanguage{greek}} 

\begin{document}
some text
blabla μπλαμπλα

\newpage
\tableofcontents
\newpage

\section{Introduction-Εισαγωγή}

\subsection{test}

\end{document}

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.