The LaTeX math round trip, at the string level
Two printers, as for Typst: printLatex
writes an expression (an == at its top is a
comparison and prints as any expression does), printLatexEqn
an equation’s expression,
in its defining form when it has one (Math.print
).
def printLatex (S : Sym) (e : Json) : String
The LaTeX math spelling of an expression under the symbol table S.
def printLatexEqn (S : Sym) (e : Json) : String
The LaTeX math spelling of an equation’s expression (==(lhs, rhs)) under the symbol
table S: in its defining form when it has one.
def parseLatex (S : Sym) (s : String) : Option Json
Read LaTeX math under the symbol table S.
theorem parseLatex_printLatex (S : Sym) (e : Json) (he : isE e = true) :
parseLatex S (printLatex S e) = some e
The LaTeX round trip: every well-formed expression reads back from its LaTeX spelling, under every symbol table (collisions included: the printer switches the names involved to the explicit form).
theorem parseLatex_printLatexEqn (S : Sym) (e : Json) (he : isE e = true) :
parseLatex S (printLatexEqn S e) = some e
The LaTeX round trip of an equation’s expression, its defining form included.
A template body
A template’s body prints in the defining form when it is a faq with output indices that
has one (_s \coloneqq …, s ∈ S after the template’s head), otherwise as any expression; the
printer writes the defining form only when the reader gives the body back.
def defLatexText (S : Sym) (b : Json) : Option (List Char)
The Latex text of a template body in its defining form: the defining form of the
stand-in equation y = b (defEq
), without the y, with \coloneqq for =.
def parseLatexBody (S : Sym) (s : String) : Option Json
Read a template body: an expression, or the defining form (_s \coloneqq …, s ∈ S).
def printLatexBody (S : Sym) (b : Json) : String
The Latex text of a template body: in the defining form when it has one that reads back, otherwise as any expression.
theorem parseLatexBody_printLatexBody (S : Sym) (b : Json) (hb : isE b = true) :
parseLatexBody S (printLatexBody S b) = some b
The round trip of a template body.