Inline SVG Output Styles?

30 views
Skip to first unread message

Adam Carlisle

unread,
Sep 22, 2021, 11:16:58 AM9/22/21
to MathJax Users
Hi,

I'm running into issues with Mathjax-full v3 mostly related to tables and the use of `\hline` when outputting SVGs. From reading similar issues I know that I need to include the CSS to get it to display properly in v3.


In my use case the SVG generated from user latex will be used in other places so just having the CSS on my site isn't viable. I know I can add a <style> element directly into the <svg>, but this seems quite wasteful since I would have to add all the styles to every SVG as I'd be unable to tell when it's needed or not.

Is there any configuration options to just inline these styles or any other ideas?

My settings:

```
const tex = new TeXWithErrorHandling({
    packages: AllPackages
});

const svgOutput = new SVG({ fontCache: "none" });

const html = mathjax.document("", {
    InputJax: tex,
    OutputJax: svgOutput,
});
```

Generating the output:
```
adaptor.innerHTML(html.convert(latex, { display: true }));
```

Thanks,
Adam


Volker Sorge

unread,
Sep 23, 2021, 10:59:24 AM9/23/21
to MathJax Users
Hi Adam, 

There is currently not option that allows you to inline the CSS. I currently there is no way around putting in a `style` elements, similar to  what we do in node scripts, e.g.:
https://github.com/mathjax/MathJax-demos-node/blob/master/jsdom/tex2svg

The styles are the lines given in the `const CSS` of the above script or the issue that you quote.

Volker
Reply all
Reply to author
Forward
0 new messages