[Tex/LaTex] Problems with accents and special characters using xelatex template for CV


I am building my CV using this xeLaTeX template.

When trying to include accents as I usually do in LaTeX, I got wrong symbols like this:

wrong symbol

Looking at the template code, it includes the following:

\usepackage[utf8]{inputenc} % Required for inputting international characters

\usepackage[T1]{fontenc} % Output font encoding for international characters

\usepackage{fontspec} % Required for specification of custom fonts

\setmainfont[Path = ./fonts/,
Extension = .otf,
BoldFont = Erewhon-Bold,
ItalicFont = Erewhon-Italic, 
BoldItalicFont = Erewhon-BoldItalic,
SmallCapsFeatures = {Letters = SmallCaps}

I also tried to use babel,

\usepackage[spanish, american]{babel}

switching back and forth between American and Spanish with \selectlanguage command. No success.

Any ideas about how to solve this issue?

Thanks in advance.

Best Answer

Don't load inputenc nor fontenc (this one might be needed in special occasions, though) when you compile with XeLaTeX or LuaLaTeX and use fontspec.



This is American English: Alcalá de Henares


Esto es español: Alcalá de Henares


The declaration \setmainfont{erewhon} might need to be more detailed, depending on whether you installed the font in your system or not. In case it is not installed as a system font, then your declarations are good, but probably it's better to use shortcuts:

  Path            = ./fonts/,
  Extension       = .otf,
  UprightFont     = *-Regular,
  BoldFont        = *-Bold,
  ItalicFont      = *-Italic,
  BoldItalicFont  = *-BoldItalic,

enter image description here