Unable to setup "textmacros" MathJax extension for HTML rendering

How can I configure my R Markdown document to use the textmacros MathJax extension for HTML rendering (knitting)? I was unsuccessful in trying to apply the instructions provided at https://docs.mathjax.org/en/latest/input/tex/extensions/textmacros.html in a include: in_header: file specified in my YAML header.

I'm using RStudio 2022.12.0 Build 353 (version available in my workplace).

Context
My goal is to get similar rendering with LaTeX text commands (e.g., \text{} or \texttt{}) whether I Knit to PDF or Knit to HTML with MathJax. E.g., while $\texttt{my\_var}$ renders to my_var in PDF, it renders to my\_var in HTML with MathJax by default. Using the textmacros extension would (supposedly) render it to my_var.

Note: HTML rendering with webtex works fine in this case, but I'd like to have the option to use mathjax as well.

Thanks for your help.

I believe the answer to the question https://stackoverflow.com/questions/74816183/mathjax-text-with-greek-letters-inside/74825914#74825914 on Stack Overflow applies to my issue as well. My version of RStudio (2022.12.0 Build 353) uses MathJax 2.7.2 while the textmacros extension was introduced in MathJax 3.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.