-
-
Notifications
You must be signed in to change notification settings - Fork 16.6k
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
Fragments in MathJax #1365
Comments
@hakimel opinions? This seems fine to me. |
Looks like a useful addition. Happy to add this but we'll need to mention it in the readme too. |
Note: with this solution, the fragment indices are relative to the slide's current fragment index. This can be tested with this: <section>
<ul>
<li>Dummy text</li>
<li class="fragment" data-fragment-index="1">Some math:
$$
\begin{align*}
\fragment{1}{x_1} \\
\fragment{3}{x_3} \\
\fragment{4}{x_4} \\
\end{align*}
$$
</li>
<li class="fragment" data-fragment-index="2">x_1</li>
<li class="fragment" data-fragment-index="3">nop</li>
<li class="fragment" data-fragment-index="4">x_3</li>
<li class="fragment" data-fragment-index="5">x_4</li>
</ul>
</section> |
useful addition, thanks @mungerd! |
It's not only that the indices are relative like @bchretien said: I think the fragment-parsing code renumbers the fragment indices before the math is parsed. So this doesn't work as expected: <section>
<ul>
<li>Dummy text</li>
<li class="fragment" data-fragment-index="1">Some math:
$$
\begin{align*}
\fragment{1}{x_1} \\
\fragment{3}{x_3} \\
\fragment{4}{x_4} \\
\end{align*}
$$
</li>
<li class="fragment" data-fragment-index="5">wanted x_4, actually x_1</li>
</ul>
</section> I worked around it by adding some empty |
I've recently started pre-rendering my mathjax into SVG with mathjax-node. This avoids occasional layout problems with Reveal, reduces the client-side load of rendering, and as a happy side effect fixes the issue with fragment indices I mentioned above (since the If others are curious how to set this up, here is my current base code for a talk, using grunt. (I might switch to webpack or something in the future.) |
what is the current state of this - is it currently possible to fragment equations? |
I am interested as well |
@dakling @cxkoda you can add fragments to LaTeX equations by tweaking the |
@gcalmettes thank you very much for sharing. I checked it out some hours ago and it looks quite nice. however, from time to time the equations are not rendered correctly and i have to manually refresh the page to trigger the process again. are you experiencing this too? should we move this discussion over to your repo? |
@cxkoda I never had a problem with this. Note however that I usually use |
I took the old code from @gcalmettes (for Mathjax V2, as I need automatic linebreaks) and modified The file and the compiled
|
The issue might resolve itself soon. This can be tested now already: Reveal.initialize({
hash: true,
plugins: [ ..., RevealMath.MathJax3 ],
mathjax3: {
mathjax: "https://cdn.jsdelivr.net/npm/mathjax@4.0.0-alpha.1/es5/tex-mml-chtml.js",
loader: {load: ['[tex]/html']},
tex: {packages: {'[+]': ['html']},
}
});
... I also recommend setting |
I wanted to be able to use fragments (with specific indices) inside MathJax contents.
I added the following lines to
plugin/math/math.js
:So now I can type in equations like
\[ x \fragment{2}{+ y} \fragment{1}{= z} \]
, where "x" appears first, followed by "x = z" and then "x + y = z".Would it make sense to include something like this in
math.js
?The text was updated successfully, but these errors were encountered: