Hi, I was perusing an update to https://wiki.contextgarden.net/index.php?title=Framed&diff=next&oldid=35583 and noticed that the grey math was not properly aligned on the wiki page. But then I tried it on my system, and, worse yet, I found out that \setuppapersize[A5] \setupcolors[state=start] \def\graymath{\mframed[frame=off, background=color, backgroundcolor=gray, backgroundoffset=3pt]} \starttext \startformula {x^3\over3} - 2 \stopformula \stoptext creates a fraction that I would expect from {x^3\over3 - 2} Is this just my (newly updated) context, or has the year 2025 started off with a \over problem? Thanks. Jim
On 1/3/2025 1:56 AM, Jim wrote:
Hi,
I was perusing an update to https://wiki.contextgarden.net/index.php?title=Framed&diff=next&oldid=35583 and noticed that the grey math was not properly aligned on the wiki page.
But then I tried it on my system, and, worse yet, I found out that
\setuppapersize[A5] \setupcolors[state=start] \def\graymath{\mframed[frame=off, background=color, backgroundcolor=gray, backgroundoffset=3pt]}
\starttext \startformula {x^3\over3} - 2 \stopformula \stoptext
creates a fraction that I would expect from
{x^3\over3 - 2}
Is this just my (newly updated) context, or has the year 2025 started off with a \over problem?
It's been so for a while. In fact, using \over was never advocated For various reasons you should use: \frac{x^3}{3} - 2 Here are some: - in lmtx we configure {} to as anywhere else in tex: grouping or argument delimiters; if not it will always create atoms - \over is a special but confusing case of parsing where, when it is seen, tex will take the previous atom and pair that with an upcoming only case of such parsing - just try to predict what {x} \over {y} {x+1} \over {y} x + {1} \over {y} x + 1\over y {x + {1} \over {y}} {x + 1\over y} etc etc are supposed to do especially when you also mix in \scriptstyle, \red, \bf or alike in different places in or ourside these { } - this means that when one wants to control rendering rather dirty tricks have to be used to might not always work - for that reason \frac is there (afaik not only in context): we can control how the numerator and denominator are handled in more detail - in lmtx (see the extended math manual) we've spend a lot (!) of time on improving math rendering and spacing especially, so in our case fractions are native classes I'm sure Mikael can add some more arguments ... like different kind of fractions, skrewed fraction etc, but maybe best read the quite extensive mathincontext manual first. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Hi Hans, On Fri, Jan 3, 2025 at 09:13 (+0100), Hans Hagen wrote:
On 1/3/2025 1:56 AM, Jim wrote:
Hi,
I was perusing an update to https://wiki.contextgarden.net/index.php?title=Framed&diff=next&oldid=35583 and noticed that the grey math was not properly aligned on the wiki page.
But then I tried it on my system, and, worse yet, I found out that
\setuppapersize[A5] \setupcolors[state=start] \def\graymath{\mframed[frame=off, background=color, backgroundcolor=gray, backgroundoffset=3pt]}
\starttext \startformula {x^3\over3} - 2 \stopformula \stoptext
creates a fraction that I would expect from
{x^3\over3 - 2}
Is this just my (newly updated) context, or has the year 2025 started off with a \over problem?
It's been so for a while. In fact, using \over was never advocated
OK, I'm not entirely surprised by that. But... as mentioned, I see it used in the wiki. And I know that the wiki isn't the same sort of official documentation as the manual, but (a) there it is, and (b) in the wiki it works. I know little about the wiki, is it using some other/older version of ConTeXt (e.g., Mk II or Mk IV) to generate the examples? If the answer is "yes", is that something that should be reconsidered?
For various reasons you should use:
\frac{x^3}{3} - 2
Here are some:
- in lmtx we configure {} to as anywhere else in tex: grouping or argument delimiters; if not it will always create atoms
- \over is a special but confusing case of parsing where, when it is seen, tex will take the previous atom and pair that with an upcoming only case of such parsing
- just try to predict what
{x} \over {y} {x+1} \over {y} x + {1} \over {y} x + 1\over y {x + {1} \over {y}} {x + 1\over y}
etc etc are supposed to do especially when you also mix in \scriptstyle, \red, \bf or alike in different places in or ourside these { }
I will admit in my plain TeX documents I always used {<numer> \over <denom>} to let TeX know the extent of the numerator and denominator, and it always (?!) did The Right Thing (i.e., typeset a fraction with "numer" over "denom"), but I don't tend to use hugely complicated fractions, so maybe I could have run into problems if I tried trickier things.
- this means that when one wants to control rendering rather dirty tricks have to be used to might not always work
- for that reason \frac is there (afaik not only in context): we can control how the numerator and denominator are handled in more detail
- in lmtx (see the extended math manual) we've spend a lot (!) of time on improving math rendering and spacing especially, so in our case fractions are native classes
I'm sure Mikael can add some more arguments ... like different kind of fractions, skrewed fraction etc, but maybe best read the quite extensive mathincontext manual first.
Thanks for your comments and the pointer to the manual. Back to the wiki: I have made some edits to the wiki here and there when I got (more or less) definitive statements from someone who I assumed is a ConTeXt "guru" (or higher), or when I was correcting some typo or grammar error, or when I added an example I thought was enlightening. In this case, the edit is major, and I would not want anyone to feel I was stepping on anyone's toes by rewriting the examples in the framed page. Has anyone who has read this far care to comment on the wiki questions: (1) Why does \over work correctly in the \framed wiki example, and (2) Should the example there be re-written to use preferred ConTeXt syntax? Cheers. Jim
On Fri, Jan 3, 2025 at 12:29 (-0500), Aditya Mahajan wrote:
On Fri, 3 Jan 2025, Jim wrote:
Has anyone who has read this far care to comment on the wiki questions: (2) Should the example there be re-written to use preferred ConTeXt syntax?
Definitely, yes to (2)!
I changed \over usage to \frac on the wiki page known, as of very recently, as "Text blocks/Environments/Frames" (i.e., https://wiki.contextgarden.net/Text_blocks/Environments/Frames ) However, the greyed math (see "Shaded background for part of a displayed equation" about 1/4 the way down the page) is too high. I changed \mframed to \inmframed which made it less bad, but I am at a loss as to The Right Way to get good horizontal alignment here. Does anyone here who knows The Right Way have the time to either (a) fix the wiki, or (b) tell me The Right Way (and then I'll cheerfully fix the wiki)? I am confident that I could kludge it to the correct height with a little box lowering trickery, but surely there is a better way. Thanks. Jim
On Sun, 5 Jan 2025, Jim wrote:
On Fri, Jan 3, 2025 at 12:29 (-0500), Aditya Mahajan wrote:
On Fri, 3 Jan 2025, Jim wrote:
Has anyone who has read this far care to comment on the wiki questions: (2) Should the example there be re-written to use preferred ConTeXt syntax?
Definitely, yes to (2)!
I changed \over usage to \frac on the wiki page known, as of very recently, as "Text blocks/Environments/Frames" (i.e., https://wiki.contextgarden.net/Text_blocks/Environments/Frames )
However, the greyed math (see "Shaded background for part of a displayed equation" about 1/4 the way down the page) is too high. I changed \mframed to \inmframed which made it less bad, but I am at a loss as to The Right Way to get good horizontal alignment here.
Does anyone here who knows The Right Way have the time to either (a) fix the wiki, or (b) tell me The Right Way (and then I'll cheerfully fix the wiki)?
I am confident that I could kludge it to the correct height with a little box lowering trickery, but surely there is a better way.
This is how I'd do it: \definemathframed [graymath] [frame=off, location=mathematics, background=color, backgroundcolor=gray, backgroundoffset=3pt] \starttext \startformula \ln (1+x) =\, \graymath{x - \frac{x^2}{2}} \,+ \frac{x^3}{3}-\cdots. \stopformula \stoptext The key part is location=mathematics (or \mcframed .. short for math-centered). However, there appears to be a bug as the \frac is shown in text style instead of display style. Here is a minimal example illustrating the bug: \startformula \mcframed[mathstyle=display]{\frac{1}{x}} + \frac {1}{x} + \mcframed{\displaystyle \frac{1}{x}} \stopformula Aditya
Am 03.01.25 um 18:07 schrieb Jim:
I have made some edits to the wiki here and there when I got (more or less) definitive statements from someone who I assumed is a ConTeXt "guru" (or higher), or when I was correcting some typo or grammar error, or when I added an example I thought was enlightening. In this case, the edit is major, and I would not want anyone to feel I was stepping on anyone's toes by rewriting the examples in the framed page.
Has anyone who has read this far care to comment on the wiki questions: (1) Why does \over work correctly in the \framed wiki example, and (2) Should the example there be re-written to use preferred ConTeXt syntax?
As you can see on its start page, the ConTeXt installation of the wiki is 2024.01.08, i.e. one year old. Since then, most of the math rewrite happened. (If Taco finds the time, it would make sense to update.) There’s a lot of outdated code in the wiki, since it started in MkII times, and it’s not always obvious that something is outdated. Besides, users have different styles of coding… But yes, please, if you see something outdated/oldfashioned/overly convoluted, change it if you know how! And if not, please ask to make those who know aware. Hraban
On Fri, Jan 3, 2025 at 19:06 (+0100), Henning Hraban Ramm wrote:
Am 03.01.25 um 18:07 schrieb Jim:
I have made some edits to the wiki here and there when I got (more or less) definitive statements from someone who I assumed is a ConTeXt "guru" (or higher), or when I was correcting some typo or grammar error, or when I added an example I thought was enlightening. In this case, the edit is major, and I would not want anyone to feel I was stepping on anyone's toes by rewriting the examples in the framed page.
Has anyone who has read this far care to comment on the wiki questions: (1) Why does \over work correctly in the \framed wiki example, and (2) Should the example there be re-written to use preferred ConTeXt syntax?
As you can see on its start page,
Had I only known or thought to look! Thanks for the pointer.
the ConTeXt installation of the wiki is 2024.01.08, i.e. one year old. Since then, most of the math rewrite happened. (If Taco finds the time, it would make sense to update.)
There’s a lot of outdated code in the wiki, since it started in MkII times, and it’s not always obvious that something is outdated.
Quite true.
Besides, users have different styles of coding…
There is that. But style is one thing, and wondering why something in the wiki won't work at all is yet another.
But yes, please, if you see something outdated/oldfashioned/overly convoluted, change it if you know how! And if not, please ask to make those who know aware.
See my next message... Cheers. Jim
participants (4)
-
Aditya Mahajan
-
Hans Hagen
-
Henning Hraban Ramm
-
Jim