4

I realise many similar questions have been made but, after two weeks googling the net and searching on this site without results, I too must ask about this.

I have a document, to compile in XeTeX, with the following preamble:

% Declaration

\documentclass[11pt,a4paper,oneside,titlepage,fleqn]{report}

% Main Packages
\usepackage{fontspec}

\defaultfontfeatures{Mapping=tex-text}

\usepackage{xunicode}
\usepackage{xltxtra}

\usepackage[intlimits]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\usepackage{unicode-math}

\usepackage{mathtools}

% Text Fonts

\setmainfont[
    Path            =   /usr/share/fonts/google-noto/,
    BoldFont        =   NotoSerif-Bold.ttf,
    ItalicFont      =   NotoSerif-Italic.ttf,
    BoldItalicFont  =   NotoSerif-BoldItalic.ttf
    ]{NotoSerif-Regular.ttf}

% Math Fonts

\setmathfont[
    Path            =   /usr/share/fonts/xits/,
    BoldFont        =   xits-mathbold.otf
    ]{xits-math.otf}

\setmathfont[
    Path            =   /usr/share/fonts/google-noto/,
    BoldFont        =   NotoSansGujarati-Bold.ttf,
    range           =   "0A80-"0AFF
    ]{NotoSansGujarati-Regular.ttf}

Now I want to insert a letter from the Gujarati range as a math symbol inside a mathematical expression.

If I wanted to do so in plain text, I could define I wanted to use the Gujarati language or, if I only wanted a sepecific letter as a symbol, I could (and did) do this:

\newfontfamily{\gujarati}[
    Path            =   /usr/share/fonts/google-noto/,
    BoldFont        =   NotoSansGujarati-Bold.ttf
    ]{NotoSansGujarati-Regular.ttf}

\newcommand{\ddha}{{\gujarati\symbol"0AA2}}

If I wanted to simply insert text in a math environment, I could use the command

\text{\gujarati\symbol"0AA2}

but that is not the same as using a math symbol.

In math I have tried using syntax based on


\DeclareMathOperator
\DeclareMathSymbol
\mathchar
\UnicodeMathSymbol
\DeclareUnicodeCharacter

and many others, as I searched the net and this site, but with no success, either because they are overcomplicated or because they were not meant to recognize unicode glyph codes.

How, then, may I insert unicode glyph "0AA2 inside a math expression as a math symbol?

3

U+0AA2 is not a math symbol, so using range does not work. A simple way is to use \textnormal.

\documentclass{article}

% Main Packages
\usepackage{amsmath}
\usepackage{unicode-math}
\usepackage{newunicodechar} % optional

% for Gujarati symbols
\newfontfamily{\gujarati}{FreeSerif}
\newcommand{\ddha}{\textnormal{\gujarati ^^^^0aa2}}
\newunicodechar{ઢ}{\ddha} % optional

\begin{document}

$a+\ddha+ઢ$

\end{document}

I minimized the code, choose the fonts you need. On the other hand, loading xunicode and xltxtra is not recommended any longer (actually, my recommendation is not to load them).

enter image description here

The lines marked “optional” allow you to directly use the character in formulas.

  • Worked perfectly, and the optional syntax solves a lot of problems. Thank you. – Arkaevis Oct 16 '19 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.