Skip to content

Animate a LaTeX solution

Paste a worked solution written as a LaTeX align* block, and Molkit turns it into a step-by-step animation. Each line of the block becomes one step. Molkit works out what each line does to the one before it (substitute, rearrange, evaluate, round, cancel) and checks the arithmetic before it animates the step. Matching terms move into place, struck-out terms are canceled, every pause has a caption naming the operation, and the final answer is boxed. You can preview, check, and export the result as an animated SVG or a video.

These animations are separate from the structure animations described in Set up animation states. You edit them in the LaTeX workspace instead of on the state strip.

This three-line calculation gives the mass of 2.50 mol of water:

\begin{align*}
m(\mathrm{H_2O}) &= n(\mathrm{H_2O}) ~ M(\mathrm{H_2O}) \\
&= 2.50~\mathrm{mol} \times \frac{18.02~\mathrm{g}}{1~\mathrm{mol}} \\
&= 45.1~\mathrm{g}
\end{align*}

Imported with the default options, it produces a three-step animation:

  1. The formula is on the page from the start.
  2. The values take the place of the symbols, one at a time, under a caption that names both quantities.
  3. The product is evaluated, checked against the numbers shown, and the result is boxed as the final answer.

To show the mol units canceling, strike them out in the source with \cancel{\mathrm{mol}}, or turn on Strike canceling units (off by default) and Molkit strikes them for you.

Each step pauses on a caption that names its operation. A step Molkit cannot check still plays, with a caption that only describes the change. For the details, including rearrangements, distribute and factor, and a second equation, see LaTeX workspace.

  1. Click Insert > Import LaTeX Solution…, or press Ctrl+Shift+L. The LaTeX editor opens with Animate derivation (step-by-step) already checked. You can also click Insert > LaTeX Equation… and check that box yourself.
  2. Paste your align* block into the input. A status line under the input shows how the source parses as you type. Amber items are warnings and do not block the import.
  3. Check the Options bar, which opens automatically in this mode (see Import options).
  4. Click Import Animation.

If the document already has content, a prompt titled “This document already has content” offers Open in new tab or Add to this document, which adds the solution as another animation (see Several animations in one document). Canceling the prompt returns you to the editor with your source intact. An empty document imports in place.

When the import finishes, the LaTeX workspace opens on the new animation.

The Options bar holds two settings, which are remembered for the next import:

Option Default Effect
Substitution Card flip How a symbol becomes its value. Card flip turns the symbol over in place; Lift and drop lifts the symbol out and drops the value in. You can change it later under Solution options in the workspace.
Strike canceling units Off Strikes out units that cancel when a step is evaluated, such as the mol above and below the bar in the example. Has no effect when the source strikes anything itself with \cancel. See Automatic unit cancellation.

To make one step fade in as a whole line, use Choreography in the inspector.

When you open the dialog to write a new equation, the font is STIX 2 unless you picked another one before.

The source of a solution follows the same command rules as any equation: some commands are refused, and a \newcommand, \renewcommand, or \def lasts for one equation only. See Commands Molkit refuses.

An animation keeps its own font. The preview, a re-parse of the source, and the export all draw in that font, whatever font you pick later for other equations.

  • A solution uses the font that was selected in the editor when you imported it, STIX 2 by default.
  • In a file from an older version of Molkit that does not record the animation’s font, Molkit uses the font the drawing was made in, or STIX 2 when that cannot be read, and shows a notice once for each animation.

The workspace opens after an import. To return to it later, click Edit solution… in the animation toolbar. LaTeX workspace describes its steps list, source pane, inspector, and Reader.

  1. Open the Export LaTeX Animation dialog in one of these ways:
    • Click File > Export LaTeX Animation…. The item appears only when the document has a LaTeX animation.
    • Click Export in the workspace header.
    • With the LaTeX animation active, click Export > Animated SVG in the animation toolbar.
  2. Set the options (see the table below).
  3. Click Export. The loop setting is remembered for the next export.
Option Effect
Filename Defaults to a name taken from the first step, ending in -animation, and is remembered for each animation. A line below it shows the file that will be written.
Loop continuously Off by default: the animation plays once and rests on the final step. The section also shows the total duration.

The exported file:

  • Draws the math in the text color of the page it is placed on, so it reads on a light or a dark page. Colors you set in the LaTeX with \color are kept.
  • Is drawn in the animation’s own font (see Fonts in an animation).
  • Is the same, byte for byte, each time you export an unchanged animation, so a website or version-control system sees a change only when the animation itself changed.
  • Prints as the finished derivation, every line at full strength, whatever frame the animation was on.
  • Carries a spoken version of each caption for screen readers, and a summary of the whole solution. Units are read as words, a bar over a digit is read as the number of significant figures it marks, and a formula that Molkit knows by name is read by that name (C2H6O as ethanol). Check what will be said in the Reader section before you export.

The file is driven by CSS keyframes, not SMIL, so you script it differently from a structure animation. See LaTeX solution exports in the developer guide.

To get an MP4 or WebM file, click Export > Video… in the animation toolbar while the LaTeX animation is active. The same Export Video dialog as for structure animations opens, and the video plays the same steps as the animated SVG, from the first line to the boxed answer. The math is drawn in dark ink, because a video has no page color to follow. The equation is centered on a 16:9 frame with a small margin, so Match SVG gives 1920 × 1080. See Video export for the dialog options.