next | previous | forward | backward | up | top | index | toc | Macaulay2 website
MergeTeX :: MergeTeX

MergeTeX -- Run Macaulay2 code inside a LaTeX file


This packages parses a LaTeX file, looking for Macaulay2 code. The latter must follow the syntax of the LaTeX package "listings", namely, if must be enclosed in \begin{lstlisting}[language=Macaulay2]...\end{lstlisting}, or must be taken from an external M2 file via \begin{lstinputlisting}[language=Macaulay2]{filename.m2}; one can also insert inline code with \lstinline[language=Macaulay2]!...!, but it is not parsed. See the example file ex.tex.

It then produces a new file where the output of the code has been inserted in place of the input. The LaTeX file should contain \usepackage{listings} and should include a definition of the Macaulay2 language; this can be found in the auxiliary file lst-Macaulay2.tex.

It also replaces automatically commands of the form \macoutput{n} with the nth output of Macaulay2.

mergeTeX takes as input the TeX source as a string and returns the output as a string, whereas mergeTeXFile takes as arguments the names of the source LaTeX file and of the target LaTeX file (the two can be identical; mergeTeXFile acts idempotently).



This documentation describes version 0.6 of MergeTeX.

Source code

The source code from which this documentation is derived is in the file MergeTeX.m2. The auxiliary files accompanying it are in the directory MergeTeX/.


  • Functions and commands
    • "mergeTeX"
    • "mergeTeXFile"
  • Symbols
    • "Path"
    • TeX (missing documentation)

For the programmer

The object MergeTeX is a package.