2

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!

4
  • 3
    While there is something like unicodemath the canonical way of punching this in is g^{i_1j_1}_{\alpha_1\beta_1} (in math mode of course).
    – user194703
    Nov 23, 2019 at 5:34
  • 1
    I should correct myself, the package is unicode-math with a hyphen. But still. If you want to upload stuff on the arXiv, say, you may want to consider using the traditional methods of typesetting an \alpha in math mode in LaTeX.
    – user194703
    Nov 23, 2019 at 7:02
  • by default a few hundred unicode characters (almost all text characters) are mapped to tex commands, but there are tens of thousands of Unicode characters so most will give the error you show, you can define the ones you need using \DeclareUnicodeCharacter{...}{...} Nov 23, 2019 at 8:43
  • note that you will not get the error message that you state from xelatex. Please always provide complete test documents and show the log that generates the error. Nov 23, 2019 at 11:06

1 Answer 1

2

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}

You must log in to answer this question.

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