Re: [mathjax-users] version 3 How to define a Macro

101 views
Skip to first unread message
Message has been deleted

David Farmer

unread,
Jul 25, 2021, 7:32:45 PM7/25/21
to MathJax Users

Did you load the newcommand extension?

https://docs.mathjax.org/en/latest/input/tex/extensions/newcommand.html



On Sun, 25 Jul 2021, Rafael Rández García wrote:

> Hi, 
>   I have changed fro v2 to v3 but I can't define macros. 
>
>   I have used the MathJax Configuration converter 
>
> https://mathjax.github.io/MathJax-demos-web/convert-configuration/convert-configuration.html
>
>   And it's impossible for me to define macros with MathJax version3. 
>   
>    The generated code is: 
>
> <script> window.MathJax = { tex: { macros: { sen: [&quot;\\operatorname\{sen\}&quot;], arcsen:
> [&quot;\\operatorname\{arcsen\}&quot;], tg: [&quot;\\operatorname\{tg\}&quot;], cotg:
> [&quot;\\operatorname\{cotg\}&quot;], cosec: [&quot;\\operatorname\{cosec\}&quot;], arctg:
> [&quot;\\operatorname\{arctg\}&quot;] } } }; </script> <script
> src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/startup.js" id="MathJax-script"></script>
>
> Where do I have to put this code? 
>
> If I write this code the webpage doesn't render the TeX code. 
>
> Any idea? 
>
> Thanks in advance. 
>
> Regards. Rafa.
>  
>   
>
> --
> You received this message because you are subscribed to the Google Groups "MathJax Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> mathjax-user...@googlegroups.com.
> To view this discussion on the web visithttps://groups.google.com/d/msgid/mathjax-users/a9c6642a-f426-47ac-b33a-93a6068201b2n%40googleg
> roups.com.
>
>

Davide Cervone

unread,
Jul 26, 2021, 7:02:12 AM7/26/21
to mathja...@googlegroups.com
It looks like you may not have given your complete configuration (including the `config=...` that you used) to the configuration conversion tool, as the configuration you give below does not include any input or output jax, so MathJax will run, but not process anything.  Also, the block you included as &quot; where there should be a quotation mark (") and \{ and \} where there should just be braces.  I'm not sure if your email software added that, or if that is actually in your configuration in your web page, but these will cause the configuration to fail.

Try

<script>
window.MathJax = {
  tex: {
    macros: {
      sen: ["\\operatorname{sen}"],
      arcsen: ["\\operatorname{arcsen}"],
      tg: ["\\operatorname{tg}"],
      cotg: ["\\operatorname{cotg}"],
      cosec: ["\\operatorname{cosec}"],
      arctg: ["\\operatorname{arctg}"]
    }
  }
};
</script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js" id="MathJax-script"></script>

instead, and check the final page (using your browser's "View page source" menu item) to see that the quotation marks and braces are coming through properly.

Davide

Rafael Rández García

unread,
Jul 26, 2021, 5:31:07 PM7/26/21
to MathJax Users

HI dpvc, 
 
     Finally I got it. I use it on blogger «https://mostrandomisexperiencias.blogspot.com/», the code is 

<script>
window.MathJax = {
  tex: {
    inlineMath: [[&#39;$&#39;, &#39;$&#39;], [&#39;\\(&#39;, &#39;\\)&#39;]]
    ,macros: {
       sen: &#39;\\operatorname\{sen\}&#39;
      ,arcsen: [&#39;\\operatorname\{arcsen\}&#39;]
      ,tg: [&#39;\\operatorname\{tg\}&#39;]
      ,cotg: [&#39;\\operatorname\{cotg\}&#39;]
      ,cosec: [&#39;\\operatorname\{cosec\}&#39;]
      ,arctg: [&#39;\\operatorname\{arctg\}&#39;]  
    }
  },  
  svg: {
    fontCache: &#39;global&#39;
  }
};
</script> 
<script async='async' id='MathJax-script' src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js'/>

I had to put the code in bold in order to get a good rendering of latex. Is it correct?

     Thanks a lot. 

Davide Cervone

unread,
Jul 27, 2021, 7:10:31 AM7/27/21
to mathja...@googlegroups.com
Yes, since the math in your blog is delimited using single dollar signs, you do need to enable those as you have done.  Without that, dollar signs will not be considered to be math delimiters.

Davide


Reply all
Reply to author
Forward
0 new messages