MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

Support for more text types in math preview, e.g. \textsc{}

Open gandalfsaxe opened this issue 7 years ago • 6 comments

Hi,

Could you consider supporting more text styles in the math block preview? See this:

image

This is how it looks after converting to PDF via pandoc latexpdf:

image

PS: (The image above shows the preview in Typora. I made an issue with them, but since they use Mathjax for the math preview, they referred me to you https://github.com/typora/typora-issues/issues/1269#event-1495901133)

gandalfsaxe avatar Mar 01 '18 11:03 gandalfsaxe

We are unlikely to support \textsc in general, but you can use a work-around for this situation such as the following:

\def\textsc#1{\dosc#1\csod}
\def\dosc#1#2\csod{\text{#1}\small\style{text-transform: uppercase}{\text{#2}}}

This is not perfect, but should work for this situation.

dpvc avatar Mar 01 '18 14:03 dpvc

Thanks for the suggestion. It doesn't really make a difference though because the issue is the live preview in Typora. As soon as I convert it to PDF via pandoc, everything displays correctly. I don't think the suggestion above helps with this situation?

gandalfsaxe avatar Mar 05 '18 10:03 gandalfsaxe

If you could configure the MathJax used by Typora to include the definition above, then it would make the preview work without interfering with the pandoc output, so yes, it could help. But if it is just a preview issue, then you might not want to bother to do that.

dpvc avatar Mar 05 '18 10:03 dpvc

Thanks.

gandalfsaxe avatar Mar 05 '18 10:03 gandalfsaxe

If I use your suggestion:

\def\textsc#1{\dosc#1\csod}
\def\dosc#1#2\csod{\text{#1}\small\style{text-transform: uppercase}{\text{#2}}}

in the same math block, and try to convert with pandoc with command pandoc file.md -o file.pdfI get the following error:

Error producing PDF.
! Undefined control sequence.
l.102 \{\text{#1}\small\style

It doesn't matter if the two lines are inside $ or not btw. For some reason it works if I put it in a separate math block, but not in the same as the content where I use the \textsc. Any suggestions?

gandalfsaxe avatar Mar 09 '18 19:03 gandalfsaxe

If I use your suggestion ... in the same math block, and try to convert with panic ... I get [an error].

Yes, you can not use this command within the document itself, as it relies on MathJax-specific macros (\style) and CSS properties (text-transform), which make no sense in actual TeX.

What I suggested was not to put these commands into the document, but to configure MathJax so that they are defined in MathJax (only). I don't know pandoc myself, so I can't tell you how that is done there, but you would have to modify the MathJax configuration that it uses (or produces) in order to get these macro defined in the HTML pages that you create, but not included in the LaTeX files that you create.

dpvc avatar Apr 25 '18 00:04 dpvc