jgm / texmath

A Haskell library for converting LaTeX math to MathML.
GNU General Public License v2.0
322 stars 67 forks source link

Feature request: color #225

Open corcoted opened 1 year ago

corcoted commented 1 year ago

It would be nice to be able to convert color attributes.

For example, from MathML

<math>
    <mi style="color: blue">m</mi>
    <mi>x</mi>
    <mo>+</mo>
    <mi style="color: red">c</mi>
</math>

to/from LaTeX (assuming the color or xcolor package is loaded...)

$$ {\color{blue}m}x+{\color{red}c} $$

which renders as

$$ {\color{blue}m}x+{\color{red}c} $$

Alternatively, (although MathJAX doesn't support this)

$$ \textcolor{blue}{m}x+\textcolor{red}{c} $$
d-morrison commented 2 months ago

+1; c.f. https://github.com/jgm/pandoc/issues/10222

jgm commented 1 month ago

Looks like in OMML color is added this way:

<m:r><w:rPr><w:color w:val="FF0000" w:themeColor="accent4"/></w:rPr><m:t>y</m:t></m:r>

(for red)

jgm commented 1 month ago

I added a branch color with a bit of work towards this.

One issue is how to store the colors. If we use strings, we'll need to convert them to RGB values for some formats. If we use RGB values, we'll need strings for some formats.