This package has been replaced by a (nearly-identical) extension directly in Unitful, so instead of installing this package, simply use
julia> using Unitful, Latexifyand all of this functionality will already be available. If you are updating code that used UnitfulLatexify, there are a few breaking changes to be aware of:
- The
unitformatkeyword argument tolatexifyis replaced by thefmtkeyword argument, which can be set toFancyNumberFormatter(),SiunitxNumberFormatter()., orStyledNumberFormatter(). - The
siunitxlegacykeyword argument is replaced by theversionkeyword argument ofSiunitxNumberFormatter(), where2is legacy and3is current. - The functions
latexslashunitlabel,latexroundunitlabel,latexsquareunitlabel, andlatexfracunitlabelno longer exist, and should be replaced as either:- First call
Latexify.set_default(labelformat=:slash), then uselatexifydirectly - Direct substitute:
(l,u) -> latexify(l, u; labelformat=:slash)with:slash,:round,:square, or:frac
- First call
Adds Latexify recipes for Unitful units and quantities.
] add UnitfulLatexifyjulia> using Unitful, Latexify, UnitfulLatexify;
julia> q = 612.2u"nm";
julia> u = u"kg*m/s^2";
julia> latexify(q)
L"$612.2\;\mathrm{nm}$"julia> latexify(u; unitformat=:mathrm) # explicit default
L"$\mathrm{kg}\,\mathrm{m}\,\mathrm{s}^{-2}$"julia> latexify(q; unitformat=:siunitx)
L"\qty{612.2}{\nano\meter}"
julia> latexify(u,unitformat=:siunitx)
L"\unit{\kilo\gram\meter\per\second\tothe{2}}"One use case is in Pluto notebooks, where my current favourite workflow is to write
Markdown.parse("""
The period is $(@latexrun T = $(2.5u"ms")), so the frequency is $(@latexdefine f = 1/T post=u"kHz").
"""), which renders as
The period is
$T = 2.5 \mathrm{ms}$ , so the frequency is$f = \frac{1}{T} = 0.4 \mathrm{kHz}$ .
Note that the quantity has to be interpolated (put inside a
dollar-parenthesis), or Latexify will interpret it as a multiplication between
a number and a call to @u_str.
