16

Why are non-Latin characters not displayed in formulas, even when using XeLaTeX?

\documentclass{article}
\usepackage{xltxtra}

\begin{document}

$\omega$ %displyed  
$ω$ %not displyed

\end{document}

A complementary for following answers:

You can use the following sites to copy and paste a lot of math symbols directly to your tex file, using unicode-math package:

Beside more readability in your markup you have not to search for a specific package that provide a special symbol.

Real Dreams
  • 8,298
  • 12
  • 56
  • 78

2 Answers2

28

You can't use non-latin alphabets in math formulas for font reasons, even XeTeX use traditional Type1/MetaFont math fonts by default.

You can, however, use unicode-math package with OpenType math fonts:

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}
\begin{document}

$α + β + γ + δ = ε$

\[
∫f(x)dx = ∑_k Λ_k
\]

\end{document}
Leo Liu
  • 77,365
  • @ Is unicode-math stable and reliable enough? Can I replace common math packages with it? – Real Dreams May 07 '12 at 10:05
  • @Reza: Just use it. It is good enough. – Leo Liu May 07 '12 at 11:29
  • It is not quite perfect yet though (the version in TeX Live 2012 should be significantly improved). On the other hand, Unicode mathematics is so much nicer to type/read that I don't really care about the bad typesetting. – Caramdir May 18 '12 at 04:07
  • @Caramdir: how do you type that nicely? Do you have a space cadet keyboard, or is there some trick that I am not aware of to type math symbols on a regular keyboard without intensive keymap modding? – Federico Poloni May 27 '12 at 18:36
  • 3
    @FedericoPoloni Using the Neo keyboard layout (I actually imported a German keyboard, as the US keyboard has a slightly different physical layout, that makes Neo uncomfortable to use.) See also http://tex.stackexchange.com/questions/1979/good-keyboard-layouts-for-typing-latex – Caramdir May 27 '12 at 18:56
  • It doesn't help to answer the question, but "You can't use non-latin alphabets in math formulas" is not exactly true. One can easily type Unicode input in ConTeXt with pdfTeX for example and the same could be done with LaTeX (see also egreg's answer, I guess that a fix in inputenc's utf8 would be needed). It might only be that a suitable package is missing and there might not be enough interest to write one for pdfTeX. But unicode-math is the future anyway. – Mojca Miklavec May 27 '12 at 20:13
  • @Mojca: I know you're an expert of ConTeXt, but this is certainly a LaTeX answer for a LaTeX question. What egreg provided is also a XeTeX/LuaTeX solution. And, anyway, there is no such a inputenc for math material and I don't think it would be important since XeTeX/LuaTeX are better. – Leo Liu May 28 '12 at 03:24
  • @leo-liu: I didn't want to suggest using ConTeXt, I only wanted to argue that (non)ability to use Unicode input is not a limitation of Type1 fonts. For example, the following works for me in pdfLaTeX:`\documentclass[a4paper]{article} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \DeclareUnicodeCharacter{03C9}{\omega}
    \begin{document}
    $\omega=ω$
    \end{document}` but I totally agree that one should rather use `unicode-math`.
    
    – Mojca Miklavec May 28 '12 at 11:12
15

Not at all difficult:

\documentclass[a4paper]{article}
\usepackage{fontspec}

\mathcode`ω=\omega

\begin{document}

$\omega=ω$

\end{document}

Repeat for all the symbols you need, along the same path. However, switching to unicode-math might be handier:

\documentclass[a4paper]{article}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}

\begin{document}

$\omega=ω$

\end{document}
egreg
  • 1,121,712