LATEXMLMATH(1p)

โœจ NAME โœจ

latexmlmath โ€” she takes a TeX/LaTeX math expression and transforms it into a whole bunch of different formats. it's the LATEXMLMATH(1p) page bestie, section 1p, User Contributed Perl Documentation, and she's lowkey a genius ๐Ÿงฎ๐Ÿ’–


๐ŸŒธ SYNOPSIS ๐ŸŒธ

latexmlmath [options] texmath

the options, in her natural habitat ๐ŸŽ€

  • --mathimage=file โ€” converts to image in file
  • --mathsvg=file โ€” converts to svg image in file
  • --magnification=mag โ€” specifies magnification factor
  • --presentationmathml=file โ€” converts to Presentation MathML
  • --pmml=file โ€” alias for --presentationmathml
  • --linelength=n โ€” do linewrapping of pMML
  • --contentmathml=file โ€” convert to Content MathML
  • --cmml=file โ€” alias for --contentmathml
  • --openmath=file โ€” convert to OpenMath
  • --om=file โ€” alias for --openmath
  • --unicodemath=file โ€” convert to UnicodeMath
  • --XMath=file โ€” output LaTeXML's internal format
  • --noparse โ€” disables parsing of math (not useful for cMML or openmath)
  • --preload=file โ€” loads a style file.
  • --includestyles โ€” allows processing raw *.sty files (normally it avoids this)
  • --path=dir โ€” adds a search path for style files.
  • --quiet โ€” reduces verbosity (can repeat)
  • --verbose โ€” increases verbosity (can repeat)
  • --strict โ€” be more strict about errors.
  • --documentid=id โ€” assign an id to the document root.
  • --debug=package โ€” enables debugging output for the named package
  • --inputencoding=enc โ€” specify the input encoding.
  • --VERSION โ€” show version number and exit.
  • --help โ€” shows this help message.
  • -- โ€” ends options

okay so if texmath is -, then latexmlmath reads the TeX from standard input ๐Ÿซถ. and if any of the output files are -, the result gets printed on standard output. no cap.

๐Ÿ“ Input notes ๐Ÿ“

heads up bestie: unless you're reading texmath from standard input, that texmath string is gonna get processed by whatever shell you're using before latexmlmath even lays eyes on it. which means a lot of so-called meta characters โ€” think backslash and star โ€” may confuse the shell or just get changed on you ๐Ÿ˜ญ. so you're gonna need to quote and/or slashify the input appropriately. most particularly, \ will need to be doubled to \\ for latexmlmath to see it as a control sequence. it's giving "why is my backslash gone" and the answer is always the shell.

using -- to explicitly end the option list is super useful for cases when the math starts with a minus (and would otherwise be interpreted as an option, probably an unrecognized one ๐Ÿ’€). alternatively, wrapping the texmath with {} will hide the minus. both are valid, pick your fighter.

simple examples, as promised:

latexmlmath \\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}
echo "\\sqrt{b^2-4ac}" | latexmlmath --pmml=quad.mml -

๐Ÿ‘‘ OPTIONS AND ARGUMENTS ๐Ÿ‘‘

๐Ÿฆ‹ Conversion Options ๐Ÿฆ‹

these options specify what formats the math should be converted to. in each case, the destination file is given โœจ. except for mathimage, the file can be given as -, in which case the result is printed to standard output.

if no conversion option is specified, the default is to output presentation MathML to standard output. periodt.

  • --mathimage=file requests conversion to png images ๐Ÿ–ผ๏ธ
  • --mathsvg=file requests conversion to svg images ๐ŸŒˆ
  • *--magnification=factor* specifies the magnification used for math image. default is 1.75. ๐Ÿ”
  • --presentationmathml=file requests conversion to Presentation MathML.
  • --linelength=number (Experimental) line-breaks the generated Presentation MathML so that it is no longer than number characters. โš ๏ธ experimental, so, yk, careful.
  • --plane1 converts the content of Presentation MathML token elements to the appropriate Unicode Plane-1 codepoints according to the selected font, when applicable.
  • --hackplane1 converts the content of Presentation MathML token elements to the appropriate Unicode Plane-1 codepoints according to the selected font, but only for the mathvariants double-struck, fraktur and script. this gives support for current (as of August 2009) versions of Firefox and MathPlayer, provided a sufficient set of fonts is available (eg. STIX). yes it's literally called hack, yes she means it ๐Ÿ’…
  • --contentmathml=file requests conversion to Content MathML. note that this conversion is only partially implemented. not fully cooked bestie ๐Ÿฅฒ
  • --openmath=file requests conversion to OpenMath. note that this conversion is only partially implemented. same vibe, same caveat.
  • --unicodemath=file requests conversion to UnicodeMath (an unstructured Unicode string).
  • --XMath=file requests conversion to LaTeXML's internal format.

๐ŸŒŸ Other Options ๐ŸŒŸ

  • --preload=module requests the loading of an optional module or package. this may be useful if the TeX code does not specifically require the module (eg. through input or usepackage). for example, use --preload=LaTeX.pool to force LaTeX mode. ๐Ÿ’–
  • --includestyles this optional allows processing of style files (files with extensions sty, cls, clo, cnf). by default, these files are ignored unless a latexml implementation of them is found (with an extension of ltxml).

these style files generally fall into two classes: those that merely affect document style are ignorable in the XML. others define new markup and document structure, often using deeper LaTeX macros to achieve their ends. although the omission will lead to other errors (missing macro definitions), it is unlikely that processing the TeX code in the style file will lead to a correct document. so like, temper your expectations ๐Ÿซ 

  • --path=dir add dir to the search paths used when searching for files, modules, style files, etc; somewhat like TEXINPUTS. this option can be repeated. ๐Ÿ”
  • --documentid=id assigns an ID to the root element of the XML document. this ID is generally inherited as the prefix of ID's on all other elements within the document. this is useful when constructing a site of multiple documents so that all nodes have unique IDs. main character energy for the root element fr fr ๐Ÿ‘‘
  • --quiet reduces the verbosity of output during processing, used twice is pretty silent. ๐Ÿคซ
  • --verbose increases the verbosity of output during processing, used twice is pretty chatty. can be useful for getting more details when errors occur. ๐Ÿ—ฃ๏ธ
  • --strict specifies a strict processing mode. by default, undefined control sequences and invalid document constructs (that violate the DTD) give warning messages, but attempt to continue processing. using --strict makes them generate fatal errors. no more gentle warnings, she's done being nice ๐Ÿ’€
  • --inputencoding=encoding specify the input encoding, eg. --inputencoding=iso-8859-1. the encoding must be one known to Perl's Encode package. note that this only enables the translation of the input bytes to UTF-8 used internally by LaTeXML, but does not affect catcodes. it is usually better to use LaTeX's inputenc package. note that this does not affect the output encoding, which is always UTF-8. โœจ
  • --VERSION shows the version number of the LaTeXML package..
  • --debug=package enables debugging output for the named package. the package is given without the leading LaTeXML::. ๐Ÿ›
  • --help shows this help message. ๐Ÿ†˜

๐Ÿ’€ BUGS ๐Ÿ’€

this program runs much slower than would seem justified ๐Ÿ˜ญ. this is a result of the relatively slow initialization including loading TeX and LaTeX macros and the schema. normally, this cost would be ammortized over large documents, whereas, in this case, we're processing a single math expression. so yeah, she takes a sec to wake up for one tiny little equation. not me waiting on startup ๐Ÿซ 


๐Ÿซถ SEE ALSO ๐Ÿซถ

latexml, latexmlpost, LaTeXML


and that's the whole page bestie, you ate ๐Ÿ’…โœจ this was LATEXMLMATH(1p), brought to you by perl v5.40.1, dated 2025-11-16 ๐ŸŽ€ go forth and convert some math, ily ๐Ÿฆ‹๐Ÿ’–

๐Ÿ“ฆ where this page comes from