Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\begin{equation}...\end{equation} (numbered equations) #15

Open
HuidaeCho opened this issue Aug 7, 2020 · 1 comment
Open

\begin{equation}...\end{equation} (numbered equations) #15

HuidaeCho opened this issue Aug 7, 2020 · 1 comment

Comments

@HuidaeCho
Copy link

HuidaeCho commented Aug 7, 2020

Numbered equations

Thanks for the great plugin. I've tried \begin{equation}...\end{equation} syntax with little success. If there are \{ and '}`, I had to escape backslashes because of the Markdown syntax(?). For example,

\begin{equation}
\left\{\sin(x)\right\}
\end{equation}

doesn't work while

\begin{equation}
\left\\{\sin(x)\right\\}
\end{equation}

does.

I think you're escaping them if they're between the default delimiters. I could add \begin{} and \end{} as delimiters, but then, my auto-numbering setting (TeX: {equationNumbers: {autoNumber: "AMS"}} in mathjax.js) wouldn't work anymore. For this setting, I directly modified the JS file in the plugin, which I don't link (see below for more details). Please support \begin{} and \end{} syntax as well.

Custom JS file

Also, since I wanted to add the auto-numbering setting, I tried to follow your instructions to create a custom JS file. I'm using my inherited Quark theme, so I copied mathjax.js to themes/my-quark/js and added {% do assets.addJs('theme://js/mathjax.js') %} to themes/my-quark//templates/partials/base.html.twig. Then, disabled the build-in JS. Now, in the developer console of my Firefox, I'm getting these errors (Undefined MathJax.Hub.. Full error message below). Do you have any idea why this is happening? One thing I can think of is.. in my other non-Grav site, I'm using the text/x-mathjax-config type, not the script type as in

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
  TeX: {equationNumbers: {autoNumber: "AMS"}},
  tex2jax: {inlineMath: [['$','$'], ['\\\\(','\\\\)']], processEscapes: true}});
</script>

<script>
// here load MathJax.js?config=TeX-AMS_CHTML
</script>

Thank you,
Huidae

Full error message

Uncaught TypeError: can't access property "Startup", MathJax.Hub is undefined
    onload https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    execute https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    cb https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    onLoad https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    <anonymous> https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    <anonymous> https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
MathJax.js:19:49644
Uncaught TypeError: can't access property "Config", MathJax.Hub is undefined
    <anonymous> https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/config/TeX-AMS-MML_HTMLorMML.js?V=2.7.0:15
TeX-AMS-MML_HTMLorMML.js:15:1
Uncaught TypeError: can't access property "isArray", MathJax.Object is undefined
    Set https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    loadError https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    loadTimeout https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    execute https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    cb https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    setTimeout handler*JS https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    Load https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    Require https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    execute https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    cb https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    Process https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    Push https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    Config https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    execute https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    cb https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    Process https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    Push https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    <anonymous> https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
    <anonymous> https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML:19
MathJax.js:19:28828
@talbertsutah
Copy link

I'm not sure if this is relevant to your specific problem, but here is how I got equation numbering to work with the Grav Mathjax plugin. In short, the issue was that Grav was loading my configuration file after loading from the MathJax CDN, and so the CDN wasn't taking my configuration options into account.

Here is a more detailed list of what I did:

  • After copying the mathjax.yaml file into my user/config/plugins directory I left most of the configuration options the same except for these two:
built_in_js: false
CDN:
  enabled: true
  url: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js
  • Then I totally replaced the mathjax.js file (the one in the js folder of my theme) with
MathJax = {
	tex: {
				tags: 'ams',
				inlineMath: [['$', '$'],['\\(', '\\)']],
				displayMath: [['$$', '$$'],['\\[', '\\]']]
			}
};

The tags: 'ams' is what should tell MathJax to turn on equation numbering

  • Then in the base.html.twig file of my theme I added the line
{% do assets.addJs('theme://js/mathjax.js', {position: 'before'}) %}

The {position: 'before'} seemed to be the key addition, as it made Grav load my mathjax.js config before calling the CDN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants