ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Maggyero <maggyero@gmail.com>
To: ntg-context@ntg.nl
Subject: Changing font for math function
Date: Tue, 12 May 2015 16:19:38 +0200	[thread overview]
Message-ID: <CAJ2CwZ1mjJhOMwS03ndt20xPimVAtsMRrZQtPYpZx2qGR29xMA@mail.gmail.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 10087 bytes --]

>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.

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{}}

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]

>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}

\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

[-- Attachment #1.2: Type: text/html, Size: 12326 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
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	other threads:[~2015-05-12 14:19 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-12 14:19 Maggyero [this message]
2015-05-12 16:03 ` Hans Hagen
2015-05-12 18:05 ` Aditya Mahajan
2015-05-12 18:29   ` Mikael P. Sundqvist
2015-05-12 20:23 ` Aditya Mahajan
  -- strict thread matches above, loose matches on Subject: below --
2015-05-16 14:23 Maggyero
2015-05-16 15:35 ` Hans Hagen
2015-05-15 23:34 Maggyero
2015-05-16  0:24 ` Aditya Mahajan
2015-05-16  8:23   ` Hans Hagen
2015-05-13 15:51 Maggyero
2015-05-13 16:13 ` Hans Hagen
2015-05-12 15:18 Maggyero
2015-05-09  0:03 Aditya Mahajan
2015-05-09 10:14 ` Hans Hagen
2015-05-09 11:02 ` Wolfgang Schuster
2015-05-09 11:46 ` Hans Hagen
2015-05-09 11:56   ` Wolfgang Schuster
2015-05-09 13:00     ` Hans Hagen
2015-05-09 16:28       ` Wolfgang Schuster
2015-05-09 13:50   ` Aditya Mahajan
2015-05-09 14:16     ` Aditya Mahajan
2015-05-09 23:30       ` Hans Hagen
2015-05-10 12:19         ` Aditya Mahajan
2015-05-10 17:22           ` Hans Hagen
2015-05-11 16:16             ` Aditya Mahajan
2015-05-11 16:44               ` Hans Hagen
2015-05-11 17:08                 ` Aditya Mahajan
2015-05-11 19:28                   ` Hans Hagen
2015-05-10 16:16         ` Otared Kavian
2015-05-11  2:47           ` Aditya Mahajan
2015-05-11  7:07             ` Otared Kavian
2015-05-11  8:05               ` Hans Hagen
2015-05-11  8:33                 ` Otared Kavian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAJ2CwZ1mjJhOMwS03ndt20xPimVAtsMRrZQtPYpZx2qGR29xMA@mail.gmail.com \
    --to=maggyero@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).