colinc86 / MathJaxSwift

Converts and renders math expressions in Swift using MathJax and the JavaScriptCore framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TeX Extension Options

colinc86 opened this issue · comments

Hi @colinc86!

Great work in the library. Could you guide me on how I can help with this? I would like to add support for some AMSmath labels like \binom

Hey thanks, @juancazalla, and sorry for not getting around to this sooner!

You can load different extensions through the TexInputProcessorOptions' loadPackages property. Only the base extension is loaded by default, so this will error:

let output = try await mathjax.tex2svg("\\binom{n}{k}")

But this will render:

let texOptions = TeXInputProcessorOptions(loadPackages: [TeXInputProcessorOptions.Packages.ams])
let output = try await mathjax.tex2svg("\\binom{n}{k}", inputOptions: texOptions)

If you want all of the extensions available to MathJax loaded you can use TeXInputProcessorOptions.Packages.all as the input array.