Handcalcs
Introduction
This is a package for generating LaTeX maths and designed to improve documentation for your calculations. This package was designed to work in both jupyter and pluto.
This package supplies macros to generate \LaTeX
formatted strings from mathmatical formulas. This package takes inspiration from handcalcs.py which is a python package that works best in jupyter notebooks. The goal is to get the functionalities of that package and bring them to Julia. The current version of Handcalcs.jl is working for typical algebraic formulas. Future plans are to integrate the package with Unitful.jl, be able to render the algebraic expressions within a function, and many other things. This package is an extension of Latexify.jl. The @latexdefine
macro is similar to the main @handcalc
macro, but instead of only a symbolic rendering it also renders the numeric substitution.
Basic Demo
Will add gif soon!
Basic example:
@handcalc macro
using Handcalcs
a = 3
b = 4
@handcalc c = sqrt(a^2 + b^2)
This generates a LaTeXString (from LaTeXStrings.jl) which, when printed looks like:
$c = \sqrt{a^{2} + b^{2}} = \sqrt{3^{2} + 4^{2}} = 5.0$
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:
@handcalcs macro
This macro is the same as @handcalc but for multiple expressions. You can add comments to the side of the expression by adding a string beside the expression. Note: the variables being assigned in the expressions are evaluated (see docs for more details). See example below.
a = 2
b = 5
@handcalcs begin
c = a + b; "eq 1"
d = a - c
end
$\begin{align}
\\c = a + b = 2 + 5 = 7\text{ }(\text{eq 1})
\\d = a - c = 2 - 7 = -5
\end{align}\$"
Note: Need to fix alignment of equations
Installation
This package is registered in the Julia registry, so to install it you can just run:
Pkg.add("Handcalcs")
Further information
For further information see the docs - Note: docs link not working. Will fix soon!