react-hook-mathjax icon indicating copy to clipboard operation
react-hook-mathjax copied to clipboard

Adding delimiters to ignore non-math text

Open AnimeAllstar opened this issue 3 years ago • 1 comments

My goal is to render part of the text in latex. For example:

{The sum of $$n$$ numbers is $$n(n+1)/2$$} should render as {The sum of n numbers is n(n+1)/2}.

Only everything in $$...$$ should be turned into an svg.

I have been trying to use the delimiter option in Mathjax. I'm guessing that this regards text outside the delimiters as non-math and renders is normally. But it appears to be doing nothing. I used this as my options for the MathJaxProvider:

{
        tex: {
            inlineMath: [ 
                ['$$', '$$']
            ]
        }
}

I only want part of the text to be processed to latex. Is all text in the latex prop assumed to be latex, or is there a MathJax option that I can add to skip normal text? I could manually delimit and insert <Tex2SVG latex={latex}/> whenever I do find a $$...$$ but maybe there is an in-built option or maybe a feature request?

AnimeAllstar avatar May 17 '22 18:05 AnimeAllstar

Unless I am misunderstanding you- this should be quite simple to accomplish by using inline display. For example:

      The sum of <Tex2SVG display="inline" latex="n" /> numbers is{" "}
      <Tex2SVG display="inline" latex="\frac{n(n - 1)}{2}" />

will render: image

Hopefully this helps!

jpribyl avatar Nov 06 '22 21:11 jpribyl