xdanaux / moderncv

A modern curriculum vitae class for LaTeX
1.8k stars 552 forks source link

Issue with polyglossia #94

Open lazzalazza opened 3 years ago

lazzalazza commented 3 years ago

Using polyglossia & xelatex with the moderncv class leads to unexpected output. I'm using TeX Live under MacOs Catilina 10.15.4.

Is there a way to solve this?

\documentclass[11pt, a4paper]{moderncv}
\usepackage{polyglossia}
\setdefaultlanguage{italian}
\setotherlanguages{french, spanish, german}

\firstname{Name}
\familyname{Surname}
\title{Curriculum Vitae}
\address{Random Address 15, 000123, Ran (DOM)}
\phone{+39 348/3852269}
\email{some.mail@mail.me}

\moderncvstyle{classic}
\moderncvcolor{black}

\begin{document}
\makecvtitle
\section{Section}
Some content
\end{document}

mwe.pdf

cryptointerest commented 3 years ago

This seems to be due to polyglossia needing to be loaded before hyperref. There is no straight forward solution to this because it requires writing a parsable option for the document class, e.g. something like

\documentclass[11pt,a4paper,sans,polyglossia,pgldefaultlang={[lang option]<lang>},pglotherlang={[lang option]<lang>},pglotherlangs={<lang1>,<lang2>,...}]{moderncv}

which would then setup polyglossial before hyperref. Alternatively, write setter functions that allow to set the default language before hyperref is loaded. I have no idea how to achieve this. If somebody knows something, step up.

For now, you can alter your copy of moderncv.cls. Around line 84 you should see

% font loading
\RequirePackage{ifxetex,ifluatex}
\newif\ifxetexorluatex
\ifxetex
  \xetexorluatextrue
\else
  \ifluatex
    \xetexorluatextrue
  \else
    \xetexorluatexfalse
  \fi
\fi

Thereafter, insert the following lines

\ifxetexorluatex
  \RequirePackage{polyglossia}
  \setdefaultlanguage{italian}
  \setotherlanguages{french, spanish, german}
\else
    \RequirePackage[utf8]{inputenc}
    \RequirePackage[T1]{fontenc}
\fi

to setup polyglossia in like in your MWE.

Alternatively, forget all that and use babel.