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

accentsxetex

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}
]{Erewhon-Regular}

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.

\documentclass{article}
\usepackage[spanish,american]{babel}
\usepackage{fontspec}
\setmainfont{erewhon}

\begin{document}

This is American English: Alcalá de Henares

\selectlanguage{spanish}

Esto es español: Alcalá de Henares

\end{document}

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:

\setmainfont[
  Path            = ./fonts/,
  Extension       = .otf,
  UprightFont     = *-Regular,
  BoldFont        = *-Bold,
  ItalicFont      = *-Italic,
  BoldItalicFont  = *-BoldItalic,
]{Erewhon}

enter image description here