# Epigrafica font and mathastext incompatible for minus sign

I like the looks of the Optima font for my figure notations, which often include mathematical notations. I also prefer pdflatex. So I have found the Epigrafica font to be a nice Optima clone, which runs in pdflatex. However, the native epigrafica package switches to pxfonts for its math support.

Since I prefer the native epigrafica italic for my figure's math notations, I chose to combine the package with mathastext, with the [italic] option chosen. Everything works great except for one thing: the minus sign - in math appears as a non-italic left brace {. Other operators seem to translate just fine, such as +, =, >, <, etc. Only the - seems affected.

I have a workaround, in which I use \mathchardef to define a symbol \minus that gives me the desired glyph. However, it would be so much simpler if I could redefine things in a way such that a - in math mode produces the proper glyph directly.

In practice, I use a setup like this with the standalone document class and tikz to create my graphics images, and then I simply use \includegraphics to insert them into a report that uses a different text font altogether. Here, the MWE dispenses with most of that.

\documentclass{article}
\usepackage[greek,english]{babel}
\usepackage[iso-8859-7]{inputenc}
\usepackage{epigrafica}
\usepackage[italic]{mathastext}
\mathchardef\minus="2200
\begin{document}
Epigrafica

-a-b

$-a-b$

$\minus a\minus b$
\end{document}


I realize that one approach would be to make - "math"-active, fixing the issue in the MWE with the following preamble addition:

{\catcode-=\active \gdef-{\minus}}
\AtBeginDocument{\mathcode-="8000 }


However, unless I am mistaken, there could not be a worse character to apply that sort of "fix" to, as an active hyphen would break all kinds of dimensional and integer arithmetic. So I don't really consider an active hyphen as a viable solution, unless you convince me that this has no negative side effects.

• \usepackage[italic,nominus]{mathastext} Apr 15, 2020 at 6:14
• With that code the hyphen is not active. Apr 15, 2020 at 7:46
• @egreg I know you have explained to me in the past that the "8000 approach is not a true "active". So the question remains...will this "8000 fix have any adverse side effects? Is there a more official way to resolve this? Apr 15, 2020 at 9:20
• Thank you @UlrikeFischer for the proper fix. I accepted egreg's answer nonetheless, because he provided a much needed (for me) discussion of \mathcode. Apr 15, 2020 at 9:49

If a character is assigned \mathcode 32768 (that is, "8000 in TeX hexadecimal notation), the following happens when the character is found:

• nothing at all when TeX is not typesetting (for instance when looking for arguments of every kind, even of primitives);

• the character is printed when TeX is in horizontal mode;

• the current definition of the character as active when TeX is in math mode and examines the character for adding it to the math list under construction.

In the last case above, the character is replaced by the meaning of its active character version.

Suppose you have

{\catcode-=\active \gdef-{\minus}}
\AtBeginDocument{\mathcode-="8000 }


So if you have $-a\mkern-1mu b$ (just to make a silly example), the first - will be transformed into \minus, but the second one won't, because, when TeX encounters it, it is looking for the argument to \mkern, which should be a number followed by mu (or something else, not relevant here).

Just try it!

\documentclass{article}
\usepackage[greek,english]{babel}
\usepackage{epigrafica}
\usepackage[italic]{mathastext}

\mathchardef\minus=\mathcode-

{\catcode-=\active \gdef-{\minus}}
\AtBeginDocument{\mathcode-="8000 }

\begin{document}
Epigrafica

-a-b

$-a\mkern-1mu b$

$-a-b$

$\minus a\minus b$
\end{document}


(I removed the reference to the legacy ISO encoding.)

Of course, passing the nominus option to mathastext` is easier.