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

Macro insertion differs from definition (extra mathrm) #2573

Open
ChristopherChudzicki opened this issue Dec 27, 2024 · 1 comment
Open

Macro insertion differs from definition (extra mathrm) #2573

ChristopherChudzicki opened this issue Dec 27, 2024 · 1 comment

Comments

@ChristopherChudzicki
Copy link

Description

The LaTeX inserted by a virtual keyboard macro is different from the macro definition, beyond the placeholders. In particular, my macro uses \operatorname{unitT}, but \operatorname{\mathrm{unitT}} was inserted.This seems to have changed between 0.98.6 and 0.99.0.

Steps to Reproduce

See https://gist.github.com/ChristopherChudzicki/9e96df7d04504e29817dc646a29bcf6d, where this virtual keyboard macro

const demoLayout = {
    label: "Macro",
        rows: [
            [
                {
                    latex: "\\operatorname{unitT}(\\vec{r},t)",
                    insert: "\\operatorname{unitT}(#0, #1)",
                    width: 1.0,
                    class: "small",
                },
            ]
        ]
    }

produces LaTeX values with \operatorname{\mathrm{unitT}}(\placeholder{},\placeholder{})

Actual Behavior

The macro produces \mathrm output even though \mathrm is not included in its definition.

Expected Behavior

My expectation is that the output would have been

`\operatorname{unitT}(\placeholder{},\placeholder{})`

Environment

MathLive version This behavior seems to have started in 0.99.0.

Is this a regression: did it use to work in a previous version?

This behavior seems to have started in 0.99.0.

Operating System MacOS 14.3.1

Browser Chrome Version 131.0.6778.140 (Official Build) (arm64)

@ChristopherChudzicki
Copy link
Author

ChristopherChudzicki commented Dec 27, 2024

As some explanation: For https://next.math3d.org/ I parse (rather heuristically) the latex output into objects parseable by https://github.com/josdejong/mathjs. 1 The change from \operatorname{...} to \operatorname{\mathrm{...}} broke one of those heuristics. I can certainly work around it if this is the new behavior I have improved the heuristics to account for this, but it seemed like a possible bug.

The extra mathrm seemed surprising to me, but if it's desirable for some reason, please feel free to close this. And, as always, thanks for the great library!

Footnotes

  1. (I'm aware of MathJSON, which is an interesting alternative to MathJS for evaluating expressions, but the application I've been working on has used MathJS for ~8 years, and I'm a bit worried about backward compatibility if I ditch MathJS entirely. Not out of the question, but seems like a pretty big change.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant