2

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.

2
  • Don't load inputenc along with fontspec
    – egreg
    Apr 5, 2015 at 14:56
  • Note also that the "preferred" way of using the \set*font commands from fontspec is now: \setmainfont{<fontname>}[<options>].
    – jon
    Apr 5, 2015 at 15:43

1 Answer 1

3

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

6
  • Thank you @egreg, but still doesn't work... The fonts are not installed in my system, but rather copied in the ./fonts subdirectory Apr 5, 2015 at 15:43
  • @cecadepeca I removed fontenc and inputenc from structure.tex and changed the call of \setmainfont as suggested; did you try removing Path=./.fonts/? It shouldn't be necessary if you have an up-to-date TeX Live.
    – egreg
    Apr 5, 2015 at 15:49
  • Yes, I tried that, but my MikTeX installation is a bit out-of-date, and honestly, I don't have time to update it now. I might try to install the font on my system if necessary, if I found some simple instructions. I have a very bad experience installing LaTeX fonts... :( Apr 5, 2015 at 15:57
  • 1
    @cecadepeca Install Erewhon as a system font.
    – egreg
    Apr 5, 2015 at 15:58
  • Thanks @egreg. Erewhon font installed correctly. Now I can get rid of the Path=./.fonts/line safely. fontenc and inputenc also removed from structure.tex But still got the same problem with the accents.... really strange Apr 5, 2015 at 16:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .