For the test case:
\documentclass{article}
\usepackage{ifxetex}
\ifxetex
\usepackage{polyglossia}
\setdefaultlanguage{english}
\defaultfontfeatures{Ligatures={TeX}}
\setmainfont[BoldFont=cmunbx.otf, ItalicFont=cmunti.otf, BoldItalicFont=cmunbi.otf]{cmunrm.otf}
\setsansfont{CMU Sans Serif}
\setmonofont{CMU Typewriter Text}
\else
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[utf8]{inputenc}
\fi
\begin{document}
\section{Main}
Euro (€): ^^e2^^82^^ac\par
Heavy Check Mark (U+2714): ^^e2^^9c^^94\par
% ✔
\end{document}
got error:
Unicode character ✔ (U+2714) not set up for use with LaTeX. Heavy Check Mark (U+2714): ^^e2^^9c^^94
while building with PDFLaTeX.
There are lot of similar issues here, but even solution from the closest one (Unicode characters in pdflatex output using hexcode without UTF-8 input) didn't work. How to fix it?
No such error while building with XeLaTeX (though it draws characters incorrectly, so suggestions how to fix it are also appreciated).
Best Answer
Hoping to have a file that compiles with both XeLaTeX and
pdflatex
is, I'm afraid, generally hopeless.In any case, XeLaTeX doesn't accept input such as
^^e2^^82^^ac
; actually it does, but the result is not what you seem to expect.You can set up replacements for missing symbols. I also redefine the Euro symbol for
pdflatex
, because the one you get with European Modern is “funny”.Output with XeLaTeX
Output with
pdflatex