Home

Awesome

GitHub (pre-)release Github All Releases Contributions welcome DOI


English | 中文


MaTeX

Create LaTeX labels in Mathematica.

See the blog post for a detailed introduction to MaTeX and up to date troubleshooting information.

Installation

In Mathematica 11.3 or later, simply evaluate ResourceFunction["MaTeXInstall"][] to install or upgrade MaTeX.

In older versions that do not support resource functions, follow the manual installation instructions:

Upgrading or uninstalling

A newer version can be safely installed when an older version is already present. <<MaTeX` will always load the latest installed MaTeX that is compatible with your version of Mathematica.

A list of all installed versions can be retrieved using

PacletFind["MaTeX"]

Any of the items in the list can be uninstalled by applying PacletUninstall to it. To uninstall all versions at once, use

PacletUninstall["MaTeX"]

To see more information about the version that gets loaded by Needs, use

PacletInformaton["MaTeX"]

Note: If you installed MaTeX before it started using the paclet distribution format (i.e. version 1.6.2), uninstall it by removing the MaTeX directory from the following location:

SystemOpen@FileNameJoin[{$UserBaseDirectory, "Applications"}]

The following function will automatically download the latest release of MaTeX and install it:

updateMaTeX[] :=
  Module[{json, download, target},
    Check[
      json = Import["https://api.github.com/repos/szhorvat/MaTeX/releases/latest", "JSON"];
      download = Lookup[First@Lookup[json, "assets"], "browser_download_url"];
      target = FileNameJoin[{CreateDirectory[], "MaTeX.paclet"}];
      If[$Notebooks,
        PrintTemporary@Labeled[ProgressIndicator[Appearance -> "Necklace"], "Downloading...", Right],
        Print["Downloading..."]
      ];
      URLSave[download, target]
      ,
      Return[$Failed]
    ];
    If[FileExistsQ[target], PacletManager`PacletInstall[target], $Failed]
  ]

After evaluating the function definition above, just run updateMaTeX[], then <<MaTeX` to load the updated version.

Usage

Use MaTeX[texcode] or MaTeX[expression] to typeset using LaTeX. The latter will automatically apply TeXForm to expression.

The LaTeX code is interpreted in math mode. Remember to escape backlashes (i.e. type two \ characters when you mean one) when writing LaTeX code in Mathematica strings, e.g.

MaTeX["\\sum_{k=1}^{\\infty} \\frac{1}{k}"]

Multiple expressions can also be processed in one go:

MaTeX[{
  "\\frac{x^2}{\\sqrt{3}}",
  HoldForm[Integrate[Sin[x], {x, 0, 2 Pi}]],
  Expand[(1 + x)^5]
}]

Processing a list of expressions together involves a single run of LaTeX, thus is much faster than processing each separately.

For many usage instructions, search for "MaTeX" in the documentation center.

Notes on performance

The limiting factor in the speed of MaTeX calls is running the pdflatex process, which might take as long as a second and cannot be sped up further. However, MaTeX caches results, making subsequent calls with the same TeX code near-instantaneous. MaTeX can also process a list of expressions using a single run of LaTeX, which is much faster than processing each separately.

Revision history

Version 1.7.10

Version 1.7.9

Version 1.7.8

Version 1.7.7

Version 1.7.6

Version 1.7.5

Version 1.7.4

Version 1.7.3

Version 1.7.2

Version 1.7.1

Version 1.7.0

Version 1.6.3

Version 1.6.2

Version 1.6.1

Version 1.6.0

Version 1.5.0

Version 1.4.0

Version 1.3.0

Version 1.2.0

Version 1.1.1

Version 1.1.0

Version 1.0.0

Version 0.3

Version 0.2

Version 0.1

Feedback

MaTeX was primarily created for my own needs. However, if you find it useful, feel free to drop me an email.

Send feedback or bug reports to szhorvat at gmail.com or open an issue in the tracker.