unicode-math icon indicating copy to clipboard operation
unicode-math copied to clipboard

Allow to remap the mathematical hyphen ("2010) to the same glyph as the minus sign ("002D")

Open nagmat84 opened this issue 5 years ago • 5 comments

Description

The range option allows to remap certain unicode ranges to use glyph from an alternative range in the font, e.g. range={tt/{latin,Latin}->up} maps monospaced symbols to upright symbols. It would be nice to have this option as a generic feature or at least for some additional special symbols, at least the math hyphen.

Add info or delete as appropriate:

  • Relevant for XeTeX: yes
  • Relevant for LuaTeX: yes
  • Issue tracker has been searched for similar issues: yes
  • https://tex.stackexchange.com/q/528843/47156

Minimal example demonstrating the issue

\documentclass{article}

\usepackage{libertinus} % Set the same teletype font for text, \mathtt and \symtt \setmonofont{Inconsolatazi4-Regular.otf}[Scale=MatchLowercase] \setmathtt{Inconsolatazi4-Regular.otf}[Scale=MatchLowercase] \setmathfont{Inconsolatazi4-Regular.otf}[range={tt/{latin,Latin}->up},Scale=MatchLowercase]

% I hoped the following line would do the trick, but it only triggers a compilation error % \setmathfont{Inconsolatazi4-Regular.otf}[range={tt/{latin,Latin}->up,"2010->"002D},Scale=MatchLowercase]

\begin{document} \begin{tabular}{lcc}\hline & \texttt{\textbackslash mathhyphen} & normal \texttt{-} \\hline \texttt{\textbackslash mathrm} & $\mathrm{init\mathhyphen cmd}$ & $\mathrm{init-cmd}$ \ \texttt{\textbackslash mathsf} & $\mathsf{init\mathhyphen cmd}$ & $\mathsf{init-cmd}$ \ \texttt{\textbackslash mathit} & $\mathit{init\mathhyphen cmd}$ & $\mathit{init-cmd}$ \ \texttt{\textbackslash mathtt} & $\mathtt{init\mathhyphen cmd}$ & $\mathtt{init-cmd}$ \\hline \end{tabular} \end{document}

Further details

The problem occurs, if one maps a certain stylistic Unicode math range (tt, frak, bb, cal, scr) from the U+1D4xx range to an different font which has the required symbols but in their "normal" ASCII slots.

nagmat84 avatar Feb 19 '20 16:02 nagmat84

Sorry to be a bit out of topic, but I’ve never realized that U+2010 was used as a “mathematical hyphen”. Do you have an example of its use as such? (I’m interested in typography were U+2010 is quite important as inter‐word hyphen, and I’m curious about other uses)

ArchangeGabriel avatar Feb 19 '20 16:02 ArchangeGabriel

One uses a mathematical hyphen quite often in theoretical computer science, especially in the field of complexity theory and cryptography. So called reduction games very often use multi-word superscripts with words being separated by hyphens. For example $\symcal{O}^{\mathsf{ind\mathhyphen cca\mathhyphen 2}}$, for an oracle (in the sense of complexity theory) which answers an IND-CCA-2 challenge.

Opposed to mathematicians, computer science theorists tend not to use single letter variables, but "telling" names and there the mathematical hyphens comes in very handy.

nagmat84 avatar Feb 19 '20 20:02 nagmat84

Thanks for the suggestion. I agree it should be a good feature to introduce “arbitrary” remappings like this. Of course it wouldn’t be very useful to the vast majority of possibilities, but there are a few cases where the glyph you want is in another slot than the input character.

Sorry, I won’t be able to implement this quickly...

wspr avatar Feb 20 '20 01:02 wspr

OK, thanks for considering the idea. I understand that this feature request might have low priority and take its time. However, are you aware of a quick (and dirty) workaround?

With traditional LaTeX I did not had the problem (\mathhyphen worked as expeced), but then I had to switch to LuaLaTeX and unicode-math for some other reason. Hence, this problem is some kind of personal regression for me and there is a paper deadline. :(

I already tried to define some own special-purpose macro like \mathhyphenforconsolate using \DeclareMathSymb which simply maps to "002D but uses math class \mathord. But I failed. In order not to clutter this thread, might I ask you to post your answer at the referred TeX StackExchange question (see above)?

nagmat84 avatar Feb 20 '20 06:02 nagmat84

For a quick fix, could you make a personal copy of unicode-math-table.tex and add/change another entry in it?

wspr avatar Feb 20 '20 10:02 wspr