latexalign

This function converts its input to $\LaTeX$ align environments. One way of using the function is to pass it two vectors, one which holds the left-hand-side of the equations and the other which holds the right. For example:

lhs = ["dx/dt", "dy/dt"]
rhs = ["y^2 - x", "x/y - y"]
print(latexalign(lhs, rhs))

outputs:

\begin{align}
\frac{dx}{dt} &= y^{2} - x \\
\frac{dy}{dt} &= \frac{x}{y} - y \\
\end{align}

In Jupyter, this can be rendered by:

display( latexalign(lhs, rhs))

\begin{align*} \frac{dx}{dt} &= y^{2} - x \\ \frac{dy}{dt} &= \frac{x}{y} - y \\ \end{align*}

Using DifferentialEquations.jl

The motivation for creating this function was mainly to be able to render ODEs. In my own work, I tend to use DifferentialEquations.jl to define ODEs as ParameterizedFunctions. Therefore, I found it useful to create a method which simply takes the ParameterizedFunction as input:

using Latexify
using DifferentialEquations
ode = @ode_def positiveFeedback begin
    dx = y/(k_y + y) - x
    dy = x^n_x/(k_x^n_x + x^n_x) - y
end k_y k_x n_x

latexalign(ode)

\begin{align} \frac{dx}{dt} &= \frac{y}{k{y} + y} - x \\ \frac{dy}{dt} &= \frac{x^{n{x}}}{k{x}^{n{x}} + x^{n_{x}}} - y \\ \end{align}