Skip to content

Latest commit

 

History

History
201 lines (153 loc) · 6.19 KB

README.md

File metadata and controls

201 lines (153 loc) · 6.19 KB

codecov Coverage Status Downloads

Latexify.jl

This is a package for generating LaTeX maths from julia objects.

This package utilises Julias homoiconicity to convert expressions to LaTeX-formatted strings. Latexify.jl supplies functionalities for converting a range of different Julia objects, including:

  • Expressions,
  • Strings,
  • Numbers (including rationals and complex),
  • Symbolic expressions from SymEngine.jl,
  • ParameterizedFunctions and ReactionNetworks from DifferentialEquations.jl,
  • Other types for which a user recipe has been defined

as well as arrays or dicts of supported types.

Recipes

To extend Latexify to work with your own type, you define a recipe using the @latexrecipe macro. See the documentation.

Examples

latexifying expressions

using Latexify
ex = :(x/(y+x)^2)
latexify(ex)

This generates a LaTeXString (from LaTeXStrings.jl) which, when printed looks like:

$\frac{x}{\left( y + x \right)^{2}}$

And when this LaTeXString is displayed in an environment which supports the tex/latex MIME type (Jupyter and Pluto notebooks, Jupyterlab and Hydrogen for Atom) it will automatically render as:

fraction

latexifying other things

Latexify.jl is equipped to convert a whole range of types to latex formatted maths. This includes primitive types such as Symbols and Complex, but also of containers such as Arrays and Dicts.

using Latexify
print(latexify("x+y/(b-2)^2"))

outputs:

$x + \frac{y}{\left( b - 2 \right)^{2}}$
arr = ["x/y" 3//7 2+3im; 1 :P_x :(gamma(3))]
latexify(arr)

matrix

The GitHub website does not really support rendering of equations in the README file, so I th