LaTeXML::Core(3pm)

πŸ’… LaTeXML::Core β€” the Perl doc bestie edition

okay so this is the LaTeXML::Core(3pm) page from the User Contributed Perl Documentation, and it's literally the main-character module that transforms TeX into XML. buckle up πŸŽ€


✨ NAME ✨

"LaTeXML" β€” transforms TeX into XML. that's it, that's the vibe. no cap.


🌸 SYNOPSIS 🌸

use LaTeXML::Core;
my $latexml = LaTeXML::Core->new();
$latexml->convertAndWrite("adocument");

But also β€” and this is the part where u breathe a sigh of relief β€” see the convenient command line script latexml, which suffices for most purposes. like genuinely, for most purposes u do not need to touch any of this. iykyk πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

πŸ’œ METHODS πŸ’œ

  • "my $latexml = LaTeXML::Core->new(%options);" β€” Creates a new LaTeXML object for transforming TeX files into XML. yes bestie, this is the constructor, this is where the whole journey begins ✨

Here are the options u can pass, and what each one does:

  • verbosity β€” Controls verbosity; higher is more verbose, smaller is quieter. 0 is the default.
  • strict β€” If true, undefined control sequences and invalid document constructs give fatal errors, instead of warnings. like, it stops playing games. πŸ™ˆ
  • includecomments β€” If false, comments will be excluded from the result document.
  • preload β€” an array of modules to preload
  • searchpath β€” an array of paths to be searched for Packages and style files.

(these generally set config variables in the LaTeXML::Core::State object) β€” so like, that's where the settings actually live, okurrr πŸ‘‘

  • "$latexml->convertAndWriteFile($file);" β€” Reads the TeX file $file.tex, digests and converts it to XML, and saves it in $file.xml. in goes .tex, out comes .xml, no notes. πŸ’–
  • "$doc = $latexml->convertFile($file);" β€” Reads the TeX file $file, digests and converts it to XML and returns the resulting XML::LibXML::Document.
  • "$doc = $latexml->convertString($string);" β€” OBSOLETE πŸ’€ Use "$latexml-"convertFile("literal:$string");> instead. (yes it's written exactly like that in the source, i don't make the rules.)
  • "$latexml->writeDOM($doc,$name);" β€” Writes the XML document to $name.xml.
  • "$box = $latexml->digestFile($file);" β€” Reads the TeX file $file, and digests it returning the LaTeXML::Core::Box representation.
  • "$box = $latexml->digestString($string);" β€” OBSOLETE 🫠 Use "$latexml-"digestFile("literal:$string");> instead.
  • "$doc = $latexml->convertDocument($digested);" β€” Converts $digested (the LaTeXML::Core::Box reprentation) into XML, returning the XML::LibXML::Document.

🧚 Customization 🧚

In the simplest case, LaTeXML will understand your source file and convert it automatically. iconic behaviour, honestly.

With more complicated (realistic) documents, you will likely need to make document specific declarations for it to understand local macros, your mathematical notations, and so forth. like yeah, when things get real, u gotta teach it ur ways 🌈

Before processing a file doc.tex, LaTeXML reads the file doc.latexml, if present. Likewise, the LaTeXML implementation of a TeX style file, say style.sty is provided by a file style.ltxml.

See LaTeXML::Package for documentation of these customization and implementation files. that's ur next stop, fr fr πŸŽ€


⭐ SEE ALSO ⭐

See latexml for a simple command line script. honestly the low-effort slay option.

See LaTeXML::Package for documentation of these customization and implementation files.

For cases when the high-level declarations described in LaTeXML::Package are not enough, or for understanding more of LaTeXML's internals, see:

  • LaTeXML::Core::State maintains the current state of processing, bindings or variables, definitions, etc.
  • LaTeXML::Core::Token, LaTeXML::Core::Mouth and LaTeXML::Core::Gullet deal with tokens, tokenization of strings and files, and basic TeX sequences such as arguments, dimensions and so forth.
  • LaTeXML::Core::Box and LaTeXML::Core::Stomach deal with digestion of tokens into boxes.
  • LaTeXML::Core::Document, LaTeXML::Common::Model, LaTeXML::Core::Rewrite dealing with conversion of the digested boxes into XML.
  • LaTeXML::Core::Definition and LaTeXML::Core::Parameters representation of LaTeX macros, primitives, registers and constructors.
  • LaTeXML::MathParser the math parser.
  • LaTeXML::Global, LaTeXML::Common::Error, LaTeXML::Common::Object other random modules.

πŸ‘‘ AUTHOR πŸ‘‘

Bruce Miller <bruce.miller@nist.gov> β€” thank u king 🫢


Public domain software, produced as part of work done by the United States Government & not subject to copyright in the US. periodt. πŸ’…


okay that's the whole page bestie, nothing skipped, nothing invented β€” go transform some TeX 🌸

✨ and that's a wrap ✨ β€” this was LaTeXML::Core(3pm) from perl v5.40.1, dated 2025-11-16. mwah πŸ’–

πŸ“¦ where this page comes from