References

Disclaimer

Note that there are 3 macros exported. It is recommended to use @handcalcs mainly. The singular @handcalc macro is used by the @handcalcs macro. You may find @handcalc useful on certain occasions where you don't define a variable. For example:

using Handcalcs
a = 2
b = 3
@handcalc a + b

\[a + b = 2 + 3 = 5\]

Besides this use case, @handcalcs macro can be used. The @handfunc macro should not be used anymore.

References

Handcalcs.get_handcalcsFunction
get_handcalcs()

Get a Dict with the user-specified default kwargs for handcalcs, set by set_handcalcs.

Kwargs

  • cols: sets the number of columns in the output
  • spa: sets the line spacing
  • len: can set to :long and it will split equation to multiple lines
  • h_env: Choose between "aligned" (default), "align" and other LaTeX options
  • not_funcs: Name the functions you do not want to "unroll"
  • parse_pipe: a boolean value (default=true) to remove pipe from equation. This is intended for unitful equations.
  • disable: disable handcalcs rendering to run simulations and turn it back on when needed.
source
Handcalcs.set_handcalcsMethod
set_default(; kwargs...)

Set default kwarg values for handcalcs.

This works for all keyword arguments. It is additive such that if you call it multiple times, defaults will be added or replaced, but not reset.

Kwargs

  • cols: sets the number of columns in the output
  • spa: sets the line spacing
  • len: can set to :long and it will split equation to multiple lines
  • color: change the color of the output (:blue, :red, etc)
  • h_env: choose between "aligned" (default), "align" and other LaTeX options
  • not_funcs: name the functions you do not want to "unroll"
  • parse_pipe: a boolean value (default=true) to remove pipe from equation. This is intended for unitful equations.
  • disable: disable handcalcs rendering to run simulations and turn it back on when needed.

Example:

set_handcalcs(cols = 2, spa = 5)

To reset the defaults that you have set, use reset_handcalcs. To see your specified defaults, use get_handcalcs.

source
Handcalcs.@handcalcMacro
@handcalc expression

Create LaTeXString representing expression. The expression being a vaiable followed by an equals sign and an algebraic equation. Any side effects of the expression, like assignments, are evaluated as well. The RHS can be formatted or otherwise transformed by supplying a function as kwarg post.

Examples

julia> a = 2
2
julia> b = 5
5
julia> @handcalc c = a + b
L"$c = a + b = 2 + 5 = 7$"

julia> c
7
source
Handcalcs.@handcalcsMacro
@handcalcs(expressions, kwargs)

Create LaTeXString representing expressions. The expressions representing a number of expressions. A single expression being a vaiable followed by an equals sign and an algebraic equation. Any side effects of the expression, like assignments, are evaluated as well. The RHS can be formatted or otherwise transformed by supplying a function as kwarg post. Can also add comments to the end of equations. See example below.

Kwargs

  • cols: sets the number of columns in the output
  • spa: sets the line spacing
  • len: can set to :long and it will split equation to multiple lines
  • color: change the color of the output (:blue, :red, etc)
  • h_env: choose between "aligned" (default), "align" and other LaTeX options
  • not_funcs: name the functions you do not want to "unroll"

Examples

julia> a = 2
2

julia> b = 5
5

julia> e = 7
7

julia> @handcalcs begin 
    c = a + b; "eq 1";
    d = a - c
    e
end
L"$\begin{aligned}
c &= a + b = 2 + 5 = 7\;\text{  }(\text{eq 1})
\\[10pt]
d &= a - c = 2 - 7 = -5
\\[10pt]
e &= 7
\end{aligned}$"

julia> c
7

julia> d
-5
source
Handcalcs.@handfuncMacro
@handfunc expression

Create LaTeXString representing expressions. These expressions represent a number of expressions that exist within the function that was called. A single expression being a variable followed by an equals sign and the function being called. The expression is evaluated as well (not the expressions within the function). The RHS can be formatted or otherwise transformed by supplying a function as kwarg post.

Examples

julia> @handfunc Iy = calc_Ix(5, 15)
L"$\begin{aligned}
Ix &= \frac{b \cdot h^{3}}{12} = \frac{5 \cdot 15^{3}}{12} = 1406.25
\end{aligned}$"

julia> Iy
1406.25

Note how Iy is evaluated but Ix is not.

source