gitit icon indicating copy to clipboard operation
gitit copied to clipboard

How to configure mathjax?

Open Edenharder opened this issue 10 years ago • 7 comments

I want to configure the mathjax with the following scripts:

        <script type="text/x-mathjax-config">
        MathJax.Hub.Config({"HTML-CSS": { preferredFont: "TeX", availableFonts: ["STIX","TeX"], linebreaks: { automatic:true }, EqnChunk: (MathJax.Hub.Browser.isMobile ? 10 : 50) },tex2jax: { inlineMath: [ ["$", "$"], ["\\(","\\)"] ], displayMath: [ ["$$","$$"], ["\\[", "\\]"] ], processEscapes: true, ignoreClass: "tex2jax_ignore|dno",skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']},TeX: {  noUndefined: { attributes: { mathcolor: "red", mathbackground: "#FFEEEE", mathsize: "90%" } }, Macros: { href: "{}" } },messageStyle: "none"}); </script>
        <script type="text/x-mathjax-config">
        MathJax.Hub.Queue(function() {
            var all = MathJax.Hub.getAllJax(), i;
            for(i=0; i < all.length; i += 1) {
                all[i].SourceElement().parentNode.className += ' has-jax';
            }});
        </script>

Where to do this configuration? I add this configuration to page.st, but it seems to be not correct.

Edenharder avatar Dec 18 '15 09:12 Edenharder

You could put this in one of the page templates (see the manual). Or you could adjust mathjax-script in your config file to point to a local installation of MathJax with these settings.

jgm avatar Dec 19 '15 16:12 jgm

I put the following script in page.st

<script type="text/x-mathjax-config">
        MathJax.Hub.Config({
            tex2jax: {
                inlineMath: [ ['$','$'], ["\\(","\\)"]  ], displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
                processEscapes: true,
                skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
            }
        }); 
 </script>

When I gitit in the terminal and view the source of a page, the above script is interpreted into

<script type="text/x-mathjax-config">
        MathJax.Hub.Config({
            tex2jax: {
                inlineMath: [ [','], ["\(","\)"]  ], displayMath: [ ['',''], ["\[","\]"] ],
                processEscapes: true,
                skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
            }
        });
</script>

That is, some $ and \ are missing.

Edenharder avatar Dec 21 '15 08:12 Edenharder

You need to escape $ and \ as $ and \ in page templates. (At least, that's my recollection - see the documentation.)

+++ Edenharder [Dec 21 15 00:40 ]:

I put the following script in page.st

When I gitit in the terminal and view the source of a page, the above script is interpreted into

That is, some $ and \ are missing.

— Reply to this email directly or [1]view it on GitHub.

References

  1. https://github.com/jgm/gitit/issues/524#issuecomment-166233559

jgm avatar Dec 21 '15 21:12 jgm

I have tried to escape $ and \ as \$ and \\ in page templates, and one also need to escape \ as \\ in each page (markdown files). Even so, there is some error.

\\[
A+\alpha
\\]

will output A+ and the corresponding code in source file is <p>\[ A+\]</p>. That is, every tex command following \ will be eaten by the interpreter.

Edenharder avatar Dec 22 '15 01:12 Edenharder

If your page format is Markdown, then use $$ for display math.

+++ Edenharder [Dec 21 15 17:11 ]:

I have tried to escape $ and \ as $ and \ in page templates, and one also need to escape \ as \ in each page (markdown files). Even so, there is some error. [ A+\alpha ]

will output A+ and the corresponding code in source file is

[ A+]

. That is, every tex command following \ will be eaten by the interpreter.

— Reply to this email directly or [1]view it on GitHub.

References

  1. https://github.com/jgm/gitit/issues/524#issuecomment-166471146

jgm avatar Dec 22 '15 01:12 jgm

Thanks. I know $$ will work, but I'd like to use \[ and \].

Edenharder avatar Dec 22 '15 04:12 Edenharder

[ and ] have other meanings in Markdown; they are escaped square brackets, and we need to keep this meaning.

+++ Edenharder [Dec 21 15 20:00 ]:

Thanks. I know $$ will work, but I'd like to use [ and ].

— Reply to this email directly or [1]view it on GitHub.

References

  1. https://github.com/jgm/gitit/issues/524#issuecomment-166499954

jgm avatar Dec 22 '15 05:12 jgm