Skip to content

CianLM/reveal-animated-latex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

reveal.js

Reveal.js with Animated LaTeX


Setup

Assuming you have reveal.js setup, clone this repository and place the latex-animation directory at the root of the project.

Then place the following scripts after reveal has initialized (Reveal.initialize()) in your HTML file

<link rel="stylesheet" href="latex-animation/animate_latex.css" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/svg-path-properties.min.js"></script>
<script src="latex-animation/SVGProcessing.js"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>
<script src="latex-animation/Animate_SVGs.js"></script>

Note. Do not import MathJax before these scripts as it will process your equations before they can be animated.

Usage

To add animated LaTeX, use the <eq> tag and place LaTeX inside it. For example,

  <eq>
    \mathcal{L}=F_{\mu\nu}F^{\mu\nu}+\gamma\sqrt{(F_{\mu \nu}F^{\mu \nu})^2+(F_{\mu\nu}\tilde{F}^{\mu\nu})^2}
  </eq>
Standard.Animation.mp4

or for more advanced usage (and using fragments),

  <eq class="fragment" data-gradient='["red", "gold"]' data-color-precess="true">
    \mathcal{L}=F_{\mu\nu}F^{\mu\nu}+\gamma\sqrt{(F_{\mu \nu}F^{\mu \nu})^2+(F_{\mu\nu}\tilde{F}^{\mu\nu})^2}
  </eq>
Red.to.Gold.Gradient.mp4

align environments are also supported. For example,

<eq>
  \begin{align*}
      \nabla \cdot \mathbf{E} &= 0 \\
      \nabla \cdot \mathbf{B} &= 0
  \end{align*}
</eq>

Options

If you want to customize the animation, there are a number of parameters in the form of data- attributes.

Animation Speed (data-speed)

The increment of time (in seconds) between each stroke.

<eq data-speed="0.3">
  ...
</eq>

Color/Color Gradient (data-gradient)

Any number of colors $n \geq 1$ is accepted (as well as rgb/hex values).

<eq data-gradient='["red", "gold"]'>
  ...
</eq>
Red.to.Gold.Gradient.mp4

Color Precession (Experimental)

The gradient precesses in a loop.

<eq data-gradient='["red", "gold"]' data-color-precess="true">
  ...
</eq>
Colour.Precession.mp4

Animation Delay

Add a delay (in seconds) to the start of the animation.

<eq data-delay='1'>
  ...
</eq>

About

Animated LaTeX in a reveal.js Presentation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published