Skip to content

TeX-like mathbf (and similar commands) only works on identifiers #2322

@Omikhleia

Description

@Omikhleia

Issue found by @pekkavaa

Observed

The following math formula...

$`\mathbf{x_i}`

.... crashes with an error.

Workaround

One can use \mathbf{x}_\mathbf{i} i.e. mathxxx variant-changing commands only on identifiers.

Analysis

It is due to our interpretation of \mathbf (and other similar commands) as very simple macro definition, only working on final identifiers (i.e. as MathML <mi>), not around full expressions:

\def{mathbf}{\mi[mathvariant=bold]{#1}} % ---> so %1 here has to be a string/symbol identifier

For the record, MathJax supports it, but by propagating the property recursively down to the inner MathML identifiers and operators (if I understand well how it does it):

Image

This would require a higher-level hard-coded logic in the LPEG parser, probably, to get it right (e.g. perhaps not wrapping anything, but handling a stack for applying the math variant on inner <mi>'s and mo's (if they have none explicit) -- that's just a wild guess...)

Extracted from #2291

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSoftware bug issuemodules:packagesIssue relates to core or 3rd party packages

    Type

    Projects

    Status

    To do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions