# [NTG-context] Changing font for math function

Maggyero maggyero at gmail.com
Sat May 16 01:34:50 CEST 2015

> Aditya Mahajan:
> The default should be \mathupright (as is the case in amstex
and latex, and probably also plaintex).

> Hans Hagen:
> next beta: when one of the stylealternatives text mode else mathmode
> (default nothing == math upright)

> Hans Hagen:
>> Because like in \mtext, the \text command is ESSENTIAL (for the function
names to have the mathcodes, kerning and ligatures of the text mode instead
of the ones of the math mode).
>that is not needed because if you use a style known as text style a text
font is used

Alright, but why not ALWAYS use your text style (or my \text), why talking
about \mathupright then? \mathupright should never be used to display a
name in text style in my opinion. I don't get it, is there something that I
missed with that \mathupright? (And I'm not managing to download the new
beta of yesterday so I don't have access to the new code yet).

Appart from that story of \text or not \text, what do you think about the
suggestion that I gave in the conclusion of my previous post? Do you plan
to still use version 1 or to implement version 2 after the freeze for
TeXLive 2015? My conclusion was:

CONCLUSION. — It all comes down to the choice of the best user interface
for math functions and math texts (usually used as subscripts of
variables). Their styles and colors is handled with \setupmathematics.
There are two choices of user interface:
1. $\normalmathop{\mfunction{Arsinh}}\nolimits x\ \text{and}\ n_{\mtext{air}}$.
2. $\mfunction{Arsinh} x\ \text{and}\ n_{\mtext{air}}$.

First, the default functionstyle and textstyle in \setupmathematics should
be \rm\tf (the text mode equivalent of \mathupright, as we are always in
text mode thanks to the \text hardcoded in \mfunction and \mtext).

Then, in the 1st solution \normalmathop is used instead of \mathop because
the latter is modified by ConTeXt to convert \rm to \mf, which makes
\setupmathematics[functionstyle=\rm] without effect.

The 2nd solution is obviously way cleaner, that is why I think it should be
preferred. The implementation is given in my '2nd DEFINITION of \mfunction'
for replacing the existing definition in math-ini.mkiv:
———————————————————————
\unexpanded\def\mfunction{\dosingleempty\domfunction}
\def\domfunction[#1]#2%
{\iffirstargument

\doifelse{#1}{op}{\normalmathop{\text{\usemathematicsstyleandcolor\c!functionstyle\c!functioncolor#2}}}{\doifelse{#1}{limop}{\normalmathop{\text{\usemathematicsstyleandcolor\c!functionstyle\c!functioncolor#2}}}{\normalmathop{\text{\usemathematicsstyleandcolor\c!functionstyle\c!functioncolor#2}}\nolimits}}
\else

\normalmathop{\text{\usemathematicsstyleandcolor\c!functionstyle\c!functioncolor#2}}\nolimits
\fi}
———————————————————————

We also saw that \mfunctionlabeltext is inconsistent with ConTeXt
\labeltext because the former has a style attached to it, so
\mfunctionlabeltext should be removed from math-ini.mkiv and
\mfunction{\mathlabeltext } should be used instead when needed.

To go even further in userfriendlyness, we the new macro \definemathcommand
———————————————————————
\unexpanded\def\definemathfunction{\dodoubleempty\dodefinemathfunction}
\def\dodefinemathfunction[#1][#2]#3%
{\ifsecondargument
\definemathcommand[#1]{\mfunction[#2]{#3}}
\else
\definemathcommand[#1]{\mfunction{#3}}
\fi}
———————————————————————

Finally, with this new \mfunction definition and the removal of the
misleading \mfunctionlabeltext, the functions defined in math-def.mkiv
should be rewrite as:
———————————————————————
\definemathcommand[cos]{\mfunction{\mathlabeltext{cos}}} % Or
\definemathcommand[cos]{\mfunction[nolop]{\mathlabeltext{cos}}}, it is the
same.
\definemathcommand[det]{\mfunction[limop]{\mathlabeltext{det}}}
\definemathcommand[diff]{\normalmathop{\text{\mathfunctionstyle
d}}\mathopen{}}
%etc.
———————————————————————

or
———————————————————————
\definemathfunction[cos]{\mathlabeltext{cos}} % Or
\definemathfunction[cos][nolop]{\mathlabeltext{cos}}, it is the same.
\definemathfunction[det][limop]{\mathlabeltext{det}}
\definemathcommand[diff]{\normalmathop{\text{\mathfunctionstyle
d}}\mathopen{}} % It is a special function so it should still be treated
with the more general \definemathcommand.
%etc.
———————————————————————

ConTeXt users are now provided, if Hans agrees to implement the code given
in this conclusion, with three extremely useful macros:
— \mtext (that should be used for all math texts such as subscripts of
variables):
$n_{\mtext{air}}$;
— \mfunction (the equivalent of LaTeX \operatorname macro of the amsopn
package):
$\mfunction{Arsinh} x$
$\mfunction[op]{Arsinh} x$ or equivalently $\mfunction[limop]{Arsinh} x$;
— \definemathfunction (the equivalent of LaTeX \DeclareMathOperator macro
of the amsopn package):
\definemathfunction[arsinh]{Arsinh} $\arsinh x$
\definemathfunction[arsinh][op]{Arsinh} $\arsinh x$ or equivalently
\definemathfunction[arsinh][limop]{Arsinh} $\arsinh x$.

Maggyero
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20150516/62d728e9/attachment-0001.html>