[Tex/LaTex] Package inputenc Error: Unicode char not set up for use with LaTeX

equationsunicode

I am generating latex expressions with Unicode characters with code and they don't show up in the formula. I am using LaTeXiT to get equations with \usepackage[utf8]{inputenc} in the header and xelatex to compile it.
A generic form of my latex expression looks like: {g^{{i_1}{j_1}}_{{⍺_1}{β_1}}}. None of the Unicode characters are shown in the output.

I tried it the expression in a document, but it didn't work.

Your input is greatly appreciated. Thanks!

Best Answer

Never use inputenc with xetex, its processing would scramble the input of a unicode TeX, however it detects xetex and luatex and simply issues a warning and does nothing (so you will not get the warning in the title if using xelatex)

By default xetex uses classic 8 bit math fonts

so

\documentclass{article}

 \usepackage[utf8]{inputenc}

\begin{document}

$α$

\end{document}

does not produce the warning to the title (you would get that with pdftex) However I will assume since you say you are using xelatex that that is what you intended.

The log file will also show the warning

Missing character: There is no α in font cmmi10!

If you want to keep using classic math fonts then the easiest thing is to use the standard markup $\alpha$ for the alpha, or you could use egreg's newunicodechar package to make α active and expand to \alpha (but then you can not use it in command names)

So

\documentclass{article}

\usepackage{newunicodechar}

\newunicodechar{α}{\TextOrMath{\char`\α}{\alpha}}

\begin{document}

$α$ α

\end{document}

Then the math works but there is no textual greek in Latin Modern, so you will get the warning

Missing character: There is no α in font [lmroman10-regular]:mapping=tex-text;!

unless you select a suitable font via fontspec

Or you can use a Uniocde math font, then unicode-math will set up α directly, without making it active.

enter image description here

\documentclass{article}

\usepackage{unicode-math}
\setmainfont{TeX Gyre Termes}
\setmathfont{TeX Gyre Termes Math}


\begin{document}

$α$ α

\end{document}