2

The question is in the title: I would like to get a ⩽ whenever I type ≤, and I don't understand how to tell unicode-math that it should re-map the character.

(I know that I could re-map my keyboard...)

Sorry if this is a duplicate, I couldn't find the aswer but I may have missed something.

2 Answers 2

6

enter image description here

As in classic tex you can set the math code of the typed character to be the character that you want in the output.

I set it mid-document here to show the effect, commented out is a setting that would set it for the whole document.

\documentclass{article}

\usepackage{unicode-math}

\AtBeginDocument{%
% \Umathcodenum`≤=\Umathcodenum`⩽ %
}

\begin{document}

$ a ≤ b $

\Umathcodenum`≤=\Umathcodenum`⩽ %

$ a ≤ b $

\end{document}

works with lualatex and xelatex.

2
  • 2
    Works with OpTeX too. Commented Apr 9, 2024 at 19:59
  • 1
    @wipet yes (as you know) it's just direct use of the tex primitive Commented Apr 9, 2024 at 20:08
9

If you prefer slanted inequalities, some math fonts (Erewhon-Math, XCharter-Math, LatoMath, etc.) provide "features" to turn on slanted inequalities. It doesn't happen at unicode-math level but relies on a font StylisticSet feature. Here is an example with XCharter-Math.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath}
\usepackage{xcharter-otf}

\parindent=0pt
\begin{document}
\[x\leq y \quad x\geqq y \quad x \lesseqgtr y \]

\verb+\setmathfont{XCharter Math}[Style={leqslant}]+
\setmathfont{XCharter Math}[Style={leqslant}]
\[x\leq y \quad x\geqq y \quad x \lesseqgtr y \]
\end{document}

and the output:

enter image description here

See the fonts' documentation for more information.

3
  • Unfortunately I use another font, but thanks for your answer! I didn't know about this, it's a nice feature of these fonts. Commented Apr 9, 2024 at 20:34
  • 2
    I've always asked myself why didn't Unicode managers ask some expert in mathematics before adding ridiculous code points for the same character. The difference between ≤ and ⩽ is purely a question of taste and preference, so the choice should be referred to character variants or stylistic sets. There's no way the two glyphs can represent different concepts. To the contrary, they refused to admit that Ş and Ș are different characters, until they eventually got convinced. Commented Apr 9, 2024 at 22:17
  • @egreg leqslant was added in unicode 3.2 as part of the stix submission spearheaded by elsevier and the ams:-) Commented Apr 10, 2024 at 23:00

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.