On 5/12/2015 4:19 PM, Maggyero wrote:
 >Hans Hagen wrote:
 >for functions one can now use:
 >\setupmathematics
 >   [functionstyle=\rm]

Fantastic! Thank you Hans, it is way better than the old mechanism
\setmathfunctionstyle. Now I have a few suggestions to improve the
consistency of this new mechanism. First, I think this functionstyle key
a) should be better called 'mathlabelstyle';
b) be default to \tf to make the FONT ALTERNATIVE always upright;
c) be linked to this following new definition in math-ini.mkiv:

+ \unexpanded\def\mathlabel#1{\text{\mathlabelstyle #1}}

so that \mathlabel can be used for labeling math objects like functions
but ALSO for labeling variables with subscripts (e.g.,
\rho_{\mathlabel{air}}). The hardcoded \text in the definition of
\mathlabel is used here for these 5 reasons:
1. It CAN make the FONT STYLE adaptative to the surrounding style (if
the \mathlabelstyle inside—defined by the user in
\setupmathematics[mathlabelstyle=]—does not specify another FONT STYLE
like \rm, \ss or \tt).
2. It uses proper mathcodes (hyphens are not converted to minus binary
operators—useful if one wants to call its function or subscript
'low-frequency' for instance—, apostrophes are not converted to
primes—useful if one wants to call its function 'Riemann's function' for
instance).
3. It uses proper kerning (if one wants to call its function or
subscript 'WALL' for instance).
4. It uses proper ligatures (if one wants to call its function or
subscript 'efficiency' for instance).
5. It avoids the user having to add \kern\zeropoint to prevent vertical
alignment to the middle of the fraction bar when used inside \mathop for
one-character function names (if one wants to call its function 'd' for
instance).

That \mathlabel should replace \mfunction which should be removed, and
\mfunctionlabeltext should be removed as well and one should directly
use the already defined \mathlabeltext instead, for these 3 reasons:
1. Every command containing the word 'labeltext' should not have a style
attached to it.
2. The word 'function' is misleading because \mfunction and
\mfunctionlabeltext do not create a \mathop atom and it makes the user
believe its usage is restricted for labeling functions while the command
should also be used for labeling variable with subscripts (e.g.,
\rho_{\mathlabel{air}} is far better than \rho_\mfunction{air}).
3. Using only \mathlabeltext with \setuplabeltext is also more
consistent with the current \labeltext that works with \setuplabeltext.

mfunction will stay as it is also needed for tagged pdf and exporting (basically it's an apply math function thing) so if something else is needed another name/mechanism have to be made (with appropriate tagging)

the label itself is a special case as it's optional (and is just there for cultural differences as not all countries use the english names)

so, \rho_{\mathlabel{air}} is something different then, some kind of multi-character variable?

Thus the function definitions in math-def.mkiv should be changed:

- \definemathcommand [arccos]  [nolop] {\mfunctionlabeltext{arccos}}
+ \definemathcommand [arccos]  [nolop] {\mathlabel{\mathlabeltext{arccos}}}
etc.

And I think you should add in this file the definition of the
differential operator which is so widely used in mathematics, so that
users have at their disposal once for all a proper implementation of
this operator and don't have to make their own hack:

+ \definemathcommand[diff]{\mathop{\mathlabel{d}}\mathopen{}}

i can add a 'diff'

With this new \mathlabel command, the user now have a convenient and
consistent way to label its math objets (functions and variables with
subscripts):

\definemathcommand[arsinh][nolop]{\mathlabel{arsinh}}

\starttext
$\arsinh z = \ln\bigl(z + \sqrt{z^2 + 1}\bigr)$\par
$\rho_{\mathlabel{air}} = \frac{p}{R_{\mathlabel{specific}}T}$\par
\stoptext

 >Hans Hagen wrote:
 >\unprotect
 >\def\v!sansnormal {sansnormal}
 >%def\v!sansbold   {sansbold}
 >\def\v!serifnormal{serifnormal}
 >\def\v!serifbold  {serifbold}
 >\definealternativestyle [\v!sansnormal]  [\ss\tf]
 >%definealternativestyle [\v!sansbold]    [\ss\bf]
 >\definealternativestyle [\v!serifnormal] [\rm\tf]
 >\definealternativestyle [\v!serifbold]   [\rm\bf]
 >\protect

In this case, for completeness, I would also add the definitions for the
remaining style \tt:

\def\v!mononormal {mononormal}
\def\v!monobold {monobold}
\definealternativestyle [\v!mononormal]  [\tt\tf]
\definealternativestyle [\v!monobold]    [\tt\bf]

ok

 >Aditya Mahajan wrote:
 >\sin etc should not behave like \text{...}. \text should adapt to the
surrounding style while \mathoptext should not. In particular, in the
following
 >   {\ss $\sin x$}
 >   {\bf $\sin x$}
 >\sin should be in normal text upright font and not adapted to the
surrounded text.
 >Is it possible to set a value of functionstyle so that the surrounding
text font styles are ignored (but the font size is not).

You should try \mathop{\text{\rm\tf sin}} or \mathoptext{\rm\tf sin}
(Hans defined this \mathoptext in math-ini.mkiv as equal to
\mathop#1{\text{1#}}), or equivalently but better:
\mathop{\mathlabel{sin}} with \setupmathematics[mathlabelstyle=\rm\tf]
with the new command \mathlabel that I have defined above.

And in my opinion, names for operators and subscripts should all be
upright, that is adaptative to the surrounding TEXT STYLE (\rm, \ss and
\tt) BUT not adaptative to the surrounding TEXT ALTERNATIVE or MATH
ALTERNATIVE (\it, \bi, \sl, \bs) and stay in the normal alternative \tf
(upright). So for your case it becomes simply \mathop{\text{\tf sin}} or
equivalently  but better: \mathop{\mathlabel{sin}} with
\setupmathematics[mathlabelstyle=\tf].

About \mathupright: it is just a wrapper for \rm\tf. Better use
\text{\rm\tf} or equivalently \mathop{\mathlabel{}} with
\setupmathematics[mathlabelstyle=\rm\tf].

Here is a little example showing the behaviour of the new command
\mathlabel defined above:


\define\mathlabelstyle{\tf} % I don't have access to the last beta yet
so let's assume that the key 'mathlabelstyle' (called by Hans
'functionstyle' so far) of \setupmathematics is implemented this way,
with the default value \tf (Aditya prefers \rm\tf as the default value
so it is just a matter of taste).
\define[1]\mathlabel{\text{\mathlabelstyle #1}}

\define\function{\dosingleempty\dofunction}
\def\dofunction[#1]#2{%
     \iffirstargument

\doifelse{#1}{limop}{\mathlimop{\mathlabel{#2}}}{\mathop{\mathlabel{#2}}}
     \else
         \mathop{\mathlabel{#2}}
     \fi}

changing anything to the definition of mfunction around tl code freeze is asking for problems .. i'll added

\unexpanded\def\mtext#1%
  {\text{\usemathematicsstyleandcolor\c!textstyle\c!textcolor#1}}

which can be used as:

$x^{\mtext{effe}}$

and obeys

\setupmathematics[textstyle=bold,textcolor=darkgreen]

\definemathcommand[arsinh][op]{\mathlabel{arsinh}}

\startbuffer
     $\arsinh x\ \text{and}\ n_{\mathlabel{red}}$
\stopbuffer

\starttext
\defineparagraphs[myparagraphs][n=5, rule=on]
\setupparagraphs[myparagraphs][1][width=\dimexpr 0.3\textwidth\relax]
\setupparagraphs[myparagraphs][2][width=\dimexpr 0.3\textwidth\relax]
\setupparagraphs[myparagraphs][3][width=\dimexpr 0.3\textwidth\relax]

\section{{\tt \backslash setupmathematics[mathlabelstyle=\backslash tf]}
(default)}

\startmyparagraphs
\switchtobodyfont[rm]
{\tt \backslash switchtobodyfont[rm]}\crlf
{\tt \backslash tf}: {\tf \getbuffer}\par
{\tt \backslash bf}: {\bf \getbuffer}\par
{\tt \backslash it}: {\it \getbuffer}\par
{\tt \backslash bi}: {\bi \getbuffer}\par
{\tt \backslash sl}: {\sl \getbuffer}\par
{\tt \backslash bs}: {\bs \getbuffer}\par
\nextmyparagraphs

\switchtobodyfont[ss]
{\tt \backslash switchtobodyfont[ss]}\crlf
{\tt \backslash tf}: {\tf \getbuffer}\par
{\tt \backslash bf}: {\bf \getbuffer}\par
{\tt \backslash it}: {\it \getbuffer}\par
{\tt \backslash bi}: {\bi \getbuffer}\par
{\tt \backslash sl}: {\sl \getbuffer}\par
{\tt \backslash bs}: {\bs \getbuffer}\par
\nextmyparagraphs

\switchtobodyfont[tt]
{\tt \backslash switchtobodyfont[tt]}\crlf
{\tt \backslash tf}: {\tf \getbuffer}\par
{\tt \backslash bf}: {\bf \getbuffer}\par
{\tt \backslash it}: {\it \getbuffer}\par
{\tt \backslash bi}: {\bi \getbuffer}\par
{\tt \backslash sl}: {\sl \getbuffer}\par
{\tt \backslash bs}: {\bs \getbuffer}\par
\stopmyparagraphs

\section{{\tt \backslash setupmathematics[mathlabelstyle=\backslash
rm\backslash tf]} (Aditya's setup)}
\define\mathlabelstyle{\rm\tf}

\startmyparagraphs
\switchtobodyfont[rm]
{\tt \backslash switchtobodyfont[rm]}\crlf
{\tt \backslash tf}: {\tf \getbuffer}\par
{\tt \backslash bf}: {\bf \getbuffer}\par
{\tt \backslash it}: {\it \getbuffer}\par
{\tt \backslash bi}: {\bi \getbuffer}\par
{\tt \backslash sl}: {\sl \getbuffer}\par
{\tt \backslash bs}: {\bs \getbuffer}\par
\nextmyparagraphs

\switchtobodyfont[ss]
{\tt \backslash switchtobodyfont[ss]}\crlf
{\tt \backslash tf}: {\tf \getbuffer}\par
{\tt \backslash bf}: {\bf \getbuffer}\par
{\tt \backslash it}: {\it \getbuffer}\par
{\tt \backslash bi}: {\bi \getbuffer}\par
{\tt \backslash sl}: {\sl \getbuffer}\par
{\tt \backslash bs}: {\bs \getbuffer}\par
\nextmyparagraphs

\switchtobodyfont[tt]
{\tt \backslash switchtobodyfont[tt]}\crlf
{\tt \backslash tf}: {\tf \getbuffer}\par
{\tt \backslash bf}: {\bf \getbuffer}\par
{\tt \backslash it}: {\it \getbuffer}\par
{\tt \backslash bi}: {\bi \getbuffer}\par
{\tt \backslash sl}: {\sl \getbuffer}\par
{\tt \backslash bs}: {\bs \getbuffer}\par
\stopmyparagraphs

\section{{\tt \backslash setupmathematics[mathlabelstyle=\backslash bf]}}
\define\mathlabelstyle{\bf}

\startmyparagraphs
\switchtobodyfont[rm]
{\tt \backslash switchtobodyfont[rm]}\crlf
{\tt \backslash tf}: {\tf \getbuffer}\par
{\tt \backslash bf}: {\bf \getbuffer}\par
{\tt \backslash it}: {\it \getbuffer}\par
{\tt \backslash bi}: {\bi \getbuffer}\par
{\tt \backslash sl}: {\sl \getbuffer}\par
{\tt \backslash bs}: {\bs \getbuffer}\par
\nextmyparagraphs

\switchtobodyfont[ss]
{\tt \backslash switchtobodyfont[ss]}\crlf
{\tt \backslash tf}: {\tf \getbuffer}\par
{\tt \backslash bf}: {\bf \getbuffer}\par
{\tt \backslash it}: {\it \getbuffer}\par
{\tt \backslash bi}: {\bi \getbuffer}\par
{\tt \backslash sl}: {\sl \getbuffer}\par
{\tt \backslash bs}: {\bs \getbuffer}\par
\nextmyparagraphs

\switchtobodyfont[tt]
{\tt \backslash switchtobodyfont[tt]}\crlf
{\tt \backslash tf}: {\tf \getbuffer}\par
{\tt \backslash bf}: {\bf \getbuffer}\par
{\tt \backslash it}: {\it \getbuffer}\par
{\tt \backslash bi}: {\bi \getbuffer}\par
{\tt \backslash sl}: {\sl \getbuffer}\par
{\tt \backslash bs}: {\bs \getbuffer}\par
\stopmyparagraphs
\stoptext


Maggyero


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________



--

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
    tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to