Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PGML algebra mode doesn't respect number display format set in the Context #810

Open
dlglin opened this issue Apr 14, 2023 · 1 comment
Open
Labels
MathObject issue Issue involving MathObects code

Comments

@dlglin
Copy link
Member

dlglin commented Apr 14, 2023

Algebra mode in PGML seems to be hard-coded to use "%g" as the display format for numbers, which leads to some counterintuitive behaviour with MathObjects, particularly when a custom number format is set in the context.

Consider the following MWE:

DOCUMENT();

loadMacros("PGstandard.pl","MathObjects.pl","PGML.pl");

Context()->{format}{number} = "%d";
$x = Real(1234567);

BEGIN_PGML
[`[$x]`]

[:[$x]:]
END_PGML

ENDDOCUMENT();

In LaTeX mode it displays 1234567, but in algebra mode it converts to scientific notation. This doesn't seem like the desired behaviour if the author has explicitly set a number format for the MathObject.

Does it make sense to have PGML inherit the number format from the context? Is that even possible?

@dpvc dpvc added the MathObject issue Issue involving MathObects code label Apr 14, 2023
@dpvc
Copy link
Member

dpvc commented Apr 14, 2023

This is by design. The algebra math notation is processed in a special Typeset context, which includes more operations and functions than the usual contexts. You can cause the algebra notation to use the current context by adding a star after the notation, as in

[:[$x]:]*

or provide a context in several other ways. See the wiki documentation for details.

You could probably also do something like

$context{Typeset} = Context("Typeset");
$context{Typeset}->{format}{number} = "%d";
Context("Numeric");

...

BEGIN_PGML
[:[$x]:]
END_PGML

though I haven't tried it to see. That should make PGML use your copy of the Typeset context, which you have altered to have the changed number format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MathObject issue Issue involving MathObects code
Projects
None yet
Development

No branches or pull requests

2 participants