LaTeX setup
The latex feature of fframes-kit (MathTex, Tex, ChemEq, see
components.md) typesets MathTex formulas with Typst, built into
the kit, so most videos need nothing installed. TeX is needed only for:
Tex(text mode) and TikZ pictures;ChemEqand the chemistry kit’s reactions (mhchem);- templates with a preamble, compiler or wrapper of your own;
- formulas that fail with
TexError::NeedsTexand are switched to TeX with.backend(TexBackend::Tex), or every formula afterTexEngine::with_backend(TexBackend::Tex).
For those the kit runs the TeX installed on your machine. It needs:
latex(orxelatex/lualatexforTexCompiler::XeLatex/LuaLatex);dvisvgm.
MiKTeX and TeX Live both ship them. Formulas that are already in a video’s cache render without TeX, so only the person who adds or changes such a formula needs it.
Windows: MiKTeX
Section titled “Windows: MiKTeX”- Install MiKTeX from https://miktex.org/download, or run
choco install miktex. - Enable automatic package installation, so a missing package installs itself instead of opening a dialog that stalls the render until the timeout:
initexmf --set-config-value "[MPM]AutoInstall=1"- Check it in a new terminal:
latex --versiondvisvgm --versionIf the terminal does not find latex, the kit still looks in the default MiKTeX folders:
%LOCALAPPDATA%\Programs\MiKTeX\miktex\bin\x64(an install for the current user);C:\Program Files\MiKTeX\miktex\bin\x64.
Without a working installer
Section titled “Without a working installer”If the installer cannot download (proxies, a broken Chocolatey package), MiKTeX’s
command-line setup works offline in two steps. Get miktexsetup_standalone.exe from the
same download page, then:
miktexsetup_standalone --remote-package-repository=https://mirrors.mit.edu/CTAN/systems/win32/miktex/tm/packages/ --local-package-repository=C:\miktex-repo --package-set=basic downloadmiktexsetup_standalone --local-package-repository=C:\miktex-repo --package-set=basic --shared=no install- Any mirror listed on https://ctan.org/mirrors works for
--remote-package-repository. MiKTeX only accepts mirrors that are registered, so pick one from that list. --shared=noinstalls for the current user.- The first formula that uses a package outside the basic set installs it. This takes 20 to 30 s once, for example for mhchem and chemfig.
Ubuntu: TeX Live (or MiKTeX)
Section titled “Ubuntu: TeX Live (or MiKTeX)”sudo apt install texlive-latex-extra texlive-science texlive-pictures dvisvgmlatex --version && dvisvgm --versiontexlive-science brings mhchem, siunitx and physics, texlive-pictures circuitikz. Add
texlive-xetex or texlive-luatex for the other compilers. MiKTeX for Linux works too
(https://miktex.org/download). Enable its automatic installation as on Windows.
macOS: MacTeX
Section titled “macOS: MacTeX”brew install --cask mactex-no-guieval "$(/usr/libexec/path_helper)" # or open a new terminallatex --version && dvisvgm --versionPointing the kit at a TeX folder
Section titled “Pointing the kit at a TeX folder”FFRAMES_TEX_BIN=<folder> makes the kit look for the tools only in that folder. This is
useful when PATH is not refreshed yet, or to pick one of several installations.
Pointing it at an empty folder hides TeX. Use that to check that a video renders from its committed cache alone.
The cache
Section titled “The cache”TexEngine::new(dir)writes one small.svgper formula intodir, for both backends.- The file name of a TeX formula is a hash of the compiler, the preamble and the source. A Typst formula’s is a hash of the template’s definitions, the source and the Typst and mitex versions the kit pins. A changed formula gets a new file.
- Old files stay until you delete them. To start over, empty the directory and render the video once.
- Commit the directory. Then CI and other machines render without TeX.
- The web editor has no file system.
TexEngine::with_embedded(tex_cache!("tex-cache"))compiles the directory’s files into the build, and the engine reads them before the directory. The gallery does this; itsbuild.rsrebuilds the crate when a file is added. - The same TeX and dvisvgm versions reproduce the files byte for byte on any system, and
so does the same kit version for Typst: the kit writes
\nline ends. - With
core.autocrlfon (the Git for Windows default), put a.gitattributeswith*.svg -textinto the cache directory. Otherwise git reports the files as changed after every regeneration (seegallery/tex-cache). - When TeX is missing and a formula is not in the cache,
typesetreturnsTexError::NotInstalled. The error names the formula and says how to install TeX for the current system.
Errors
Section titled “Errors”TexError::Compile: the TeX log from the first!line, and the whole.texfile the kit wrote, for an error in the formula.TexError::Timeout: a run took longer than the timeout (120 s,TexEngine::with_timeout). With MiKTeX this usually means a package dialog is waiting. Enable automatic installation (step 2 above).TexError::Convert:dvisvgmfailed. Its output is in the error.TexError::NeedsTex: the formula uses a command the Typst backend cannot typeset (\ce,\begin{tikzpicture}, an unknown macro, physics’\div,\qty(x)). The error names the command. Typeset that formula withMathTex::new(..).backend(TexBackend::Tex); the kit never switches by itself.TexError::Typst: mitex or Typst rejected the formula (\frac{a}, an unbalanced brace). The message and the formula are in the error.TexError::NotInstalledin the web editor (any tool): the editor cannot typeset and the embedded cache has no SVG for the formula. Render natively once, then rebuild the editor with the cache embedded (TexEngine::with_embedded(tex_cache!("tex-cache"))), and drawFormula::unset(source)for what is still missing (see components.md).
The kit runs TeX with -interaction=nonstopmode -halt-on-error and never with
--shell-escape, so a formula cannot run commands.
