Re: [NTG-context] define math function with \, inside

2023-05-01 Thread Stefan Haller via ntg-context
Hi Mikael,

On Mon, May 01, 2023 at 05:48:40PM +0200, Mikael Sundqvist via ntg-context 
wrote:
> [...]
> This works here (but maybe there should be a simpler way):
> 
> \definemathfunction
>   [argmax]
>   [mathlimits=auto]
> 
> \setupmathlabeltext
>   [en]
>   [argmax=arg\sixperemspace max]
> [...]

That was exactly what I was looking for. It is working perfectly. Thanks
a lot!

With this knowledge finding additional information in the wiki is much
easier: :)

1. https://wiki.contextgarden.net/Command/_setuplabeltext
2. https://wiki.contextgarden.net/Command/_labeltext

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] define math function with \, inside

2023-05-01 Thread Stefan Haller via ntg-context
Hi all,

I wanted to define a custom math function (similar to log etc.) for
argmax. However, I wanted to have a small space between "arg" and "max"
and limits should work properly. I am using a up-to-date LMTX installation.

Without the first constraint it's easy:

> % old way:
> \definemathcommand[argmax][limop]{\mfunction[argmax]}
> % new way, discoverd by looking into math-def.mkxl
> \definemathfunction[argmax]

However, both methods do not work if I want to have "arg\,max" printed
(error about \endcsname missing). With mkiv the first method works and
can also be found in the wiki[1].

What's the current way to define such a custom math function?

Thanks!
Stefan

[1]: https://wiki.contextgarden.net/Math/functions
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


Re: [NTG-context] \nolimits no effect in LMTX

2022-08-16 Thread Stefan Haller via ntg-context
On Tue, Aug 16, 2022 at 05:47:06PM +0200, Hans Hagen via ntg-context wrote:
> \definemathoperator[nosum][sum][method=nolimits]
> 
> \startformula
>   \sum [method=nolimits]_{i=1}^{n} a_i +
>   \sum _{i=1}^{n} a_i +
>   \sum [bottom={n},top={i=1},topcolor=red] a_i +
>   \nosum _{i=1}^{n} a_i
>   \nosum[method=auto] _{i=1}^{n} a_i
> \stopformula
> 
> \stoptext

Thanks for the response and also for your efforts creating and
maintaining ConTeXt! The proposed alternative work well. This also
solves the confusion due to never being able to to remember that I have to
put the \limits / \nolimits directive *after* the symbol I want to
modify.

If somebody else stumbled across this: The code for the *mathoperators
macros sits in `mkxl/math-lop.mkxl`.

Best regards,
Stefan
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] \nolimits no effect in LMTX

2022-08-16 Thread Stefan Haller via ntg-context
Hello,

The \nolimits macro has no effect in LMTX, but works fine in the context
mkiv version of my texlive installation.

Small example:

\starttext
\startformula
  \sum\nolimits_{i=1}^{n} a_i
\stopformula
\stoptext

In LMTX the sub- and superscripts are incorrectly placed below and above
the sum operator. Can someone have a look what's going wrong? Thanks in
advance!

Best regards,
Stefan Haller
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Bug in startalign

2022-07-21 Thread Stefan Haller via ntg-context
Hi!

I (presumably) found a bug in the recent math changes of the latest
upload. If a cell of the startalign environment is empty, something
internally to the macro seems to be breaking.

Minimal example:

\starttext

\startformula
  \startalign
\NC   \NC a \NR
\NC b \NC c \NR
  \stopalign
\stopformula

\stoptext

Error: 
> tex error > tex error on line 5 in file ./test.tex: Missing number, treated 
> as zero
> 
> \23C>1
> 
> \math_next_in_eqalign \math_left_of_eqalign \mathbeginclass \csname 
> \??mathendclass \the \numexpr \c_math_eqalign_column -\plusone \relax 
> \endcsname
> \startforceddisplaymath \everycr \emptytoks
> 
> a
> 

Filling the empty cell with e.g. "d" makes it work. Using "\strut" or
"\quad" or similar also leads to the same error.

Best regards,
Stefan Haller
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___


[NTG-context] Problems with MetaFun Transparency Groups

2022-06-13 Thread Stefan Haller via ntg-context
Hi everyone!

I have a question regarding transparency groups in MetaFun. As a toy example, I
want to draw a grid of lines where the whole grid should have an opacity of 25%.

If I draw intersecting lines individually with `withtransparency(1, .25)` the
overlapping parts will have a total opacity of 50%. However, I want to draw the
whole grid as one group and then blend it as a whole so that the whole grid is
evenly colored when blended. According to the MetaFun manual we should be able
to get the desired effect with the `asgroup` operator applied to a picture.
(Actually, the manual says the operator is called `grouped` but the source code
of the graphics above uses the `asgroup` operator [1].)

The `asgroup` does in fact insert a transparency group into the PDF output:

> << /Type /XObject /Subtype /Form /FormType 1 /Group << /S /Transparency /I 
> false /K false

However, the group does not seem to be blended as one group and we can still
see that the overlapping parts are darker than the other parts of the line.
Something seems to be off. Looking at the compiled manual also shows that the
transparency groups are not working (both parts of the arrow, the head and the
tail, are blended independently and not as a group).

When I recreate the graphics in Tikz/PGF everything works. The resulting PDF
output looks similar, at least with my limited understanding of PDF format I am
unable to understand the differences.

The full example is attached below the text of my mail. The Tikz example on the
fifth page shows the desired result.

Do I misunderstand the syntax of transparency groups in MetaFun? Or is there
some other problem? Maybe someone can point me in the right direction.

Thanks in advance!
Stefan Haller

[1]: 
https://source.contextgarden.net/doc/context/sources/general/manuals/metafun/metafun-effects.tex?search=asgroup=yes#l2543



\nopdfcompression
\usemodule[tikz]

\starttext
\startMPdefinitions
  vardef draw_grid =
def withmycolor = withcolor red withtransparency(normaltransparent, .25) 
enddef;
linecap := butt;
u := 10mm;
n := 20;
pickup pencircle scaled 7mm;
for i = 1 upto n:
  draw (0, i) * u -- (n+1, i) * u withmycolor;
  draw (i, 0) * u -- (i, n+1) * u withmycolor;
endfor;
  enddef;
\stopMPdefinitions
\startMPpage
  draw image( draw_grid ) asgroup "";
  addbackground withcolor yellow;
\stopMPpage
\startMPpage
  draw image( draw_grid ) asgroup "isolated";
  addbackground withcolor yellow;
\stopMPpage
\startMPpage
  draw image( draw_grid ) asgroup "knockout";
  addbackground withcolor yellow;
\stopMPpage
\startMPpage
  draw image( draw_grid ) asgroup "isolated,knockout";
  addbackground withcolor yellow;
\stopMPpage
\startTEXpage
\starttikzpicture
  \fill[yellow] (-0.35cm, -0.35cm) rectangle (21.35cm, 21.35cm);
  \startscope[opacity=.25, transparency group]
\startscope[x=10mm, y=10mm, every path/.style={line width=7mm}]
  \foreach \i in {1,...,20}{
\draw[red] (0, \i) -- (21, \i);
\draw[red] (\i, 0) -- (\i, 21);
  };
\stopscope
  \stopscope
\stoptikzpicture
\stopTEXpage
___
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___