Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
aad1161
Move UnitfulLatexify into extension, along with tests, following #668
Ickaser Jul 4, 2025
8a9704e
Add UnitfulLatexify docs
Ickaser Jul 4, 2025
87e95ea
Remove actual plotting command from docs
Ickaser Jul 4, 2025
d13a51e
Remove ranges from docs
Ickaser Jul 7, 2025
329190d
Swap range example for list example in docs
Ickaser Jul 7, 2025
fe8f81a
Add extension to README
Ickaser Jul 7, 2025
33d778c
Merge branch 'PainterQubits:master' into latexify-ext
Ickaser Jul 31, 2025
dc8b71c
Move UnitfulLatexify into extension, along with tests, following #668
Ickaser Jul 4, 2025
6d461a7
Add UnitfulLatexify docs
Ickaser Jul 4, 2025
e8ea39c
Remove actual plotting command from docs
Ickaser Jul 4, 2025
cf8b7db
Remove ranges from docs
Ickaser Jul 7, 2025
5458be2
Swap range example for list example in docs
Ickaser Jul 7, 2025
dc754da
Add extension to README
Ickaser Jul 7, 2025
210cbee
Try letting runner generate the example images for docs
Ickaser Aug 4, 2025
0b7b03d
Merge branch 'latexify-ext' of https://github.com/Ickaser/Unitful.jl …
Ickaser Aug 4, 2025
887800f
Try out Latexify.render
Ickaser Aug 8, 2025
8944f77
Use Latexify.render with new command line options to render images
Ickaser Aug 13, 2025
35316ac
Merge branch 'master' into latexify-ext
Ickaser Aug 13, 2025
d5ad57c
Try to improve LaTeX behavior on GitHub runner
Ickaser Aug 13, 2025
a654560
try again on fonts for allunits.png
Ickaser Aug 13, 2025
da11483
Redo headers and go back to FreeFont
Ickaser Aug 20, 2025
c4939c9
Remove latex-generated images from checkin
Ickaser Aug 20, 2025
4288e15
Improve docs output
Ickaser Aug 28, 2025
e80cbbb
Match spacing in docs to current code status
Ickaser Aug 29, 2025
443daf0
Note the default permode
Ickaser Aug 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[extensions]
ConstructionBaseUnitfulExt = "ConstructionBase"
ForwardDiffExt = "ForwardDiff"
InverseFunctionsUnitfulExt = "InverseFunctions"
LatexifyExt = ["Latexify", "LaTeXStrings"]
PrintfExt = "Printf"

[compat]
Expand All @@ -27,6 +30,8 @@ ConstructionBase = "1"
Dates = "<0.0.1, 1"
ForwardDiff = "0.10, 1"
InverseFunctions = "0.1"
LaTeXStrings = "1.2.0"
Latexify = "0.16.8"
LinearAlgebra = "<0.0.1, 1"
Printf = "<0.0.1, 1"
REPL = "<0.0.1, 1"
Expand All @@ -39,11 +44,13 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
ConstructionBase = "187b0558-2788-49d3-abe0-74a17ed4e7c9"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "ConstructionBase", "ForwardDiff", "InverseFunctions", "LinearAlgebra", "Test", "Random", "REPL", "Printf"]
test = ["Aqua", "ConstructionBase", "ForwardDiff", "InverseFunctions", "Latexify", "LaTeXStrings", "LinearAlgebra", "Test", "Random", "REPL", "Printf"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ mathematical operations and collections that are found in Julia base.
### Feature additions

- [UnitfulEquivalences.jl](https://github.com/sostock/UnitfulEquivalences.jl): Enables conversion between equivalent quantities of different dimensions, e.g. between energy and wavelength of a photon.
- [UnitfulLatexify.jl](https://github.com/gustaphe/UnitfulLatexify.jl): Pretty print units and quantities in LaTeX format.
- [UnitfulParsableString.jl](https://github.com/michikawa07/UnitfulParsableString.jl): Add a `Base.string` method that converts quantities and units to parsable strings.
- [UnitfulBuckinghamPi.jl](https://github.com/rmsrosa/UnitfulBuckinghamPi.jl): Solves for the adimensional Pi groups in a list of Unitful parameters, according to the Buckingham-Pi Theorem.
- [NaturallyUnitful.jl](https://github.com/MasonProtter/NaturallyUnitful.jl): Convert to and from natural units in physics.
- [UnitfulChainRules.jl](https://github.com/SBuercklin/UnitfulChainRules.jl): Enables use of Unitful quantities with [ChainRules.jl](https://github.com/JuliaDiff/ChainRules.jl)-compatible autodifferentiation systems.
- [DimensionfulAngles.jl](https://github.com/cmichelenstrofer/DimensionfulAngles.jl): Adds angle as a dimension. This allows dispatching on angles and derived quantities.
- [Dimensionless.jl](https://github.com/martinkosch/Dimensionless.jl): Contains tools to switch between dimensional bases, conduct dimensional analysis and solve similitude problems.
- [UnitfulRecipes.jl](https://github.com/jw3126/UnitfulRecipes.jl) (deprecated): Adds automatic labels and supports plot axes with units for [Plots.jl](https://github.com/JuliaPlots/Plots.jl). (UnitfulRecipes.jl is now included in Plots.jl.)
- [UnitfulLatexify.jl](https://github.com/gustaphe/UnitfulLatexify.jl) (deprecated): Pretty print units and quantities in LaTeX format. (This package is now an extension to Unitful, so that loading both Unitful and [Latexify.jl](https://github.com/korsbo/Latexify.jl) loads this functionality.)


## Related packages
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"

[compat]
Documenter = "1"
Latexify = "0.16"
Latexify = "0.16.8"
199 changes: 199 additions & 0 deletions docs/generate_latex_images.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
#!/bin/julia

# generate_latex_images.jl
# Run locally (rarely) to generate a couple of figures needed by the
# documentation

using LaTeXStrings, Unitful, Latexify, UnitfulLatexify

mktempdir() do dir
commands = [
:(latexify(612.2u"nm")),
:(latexify(u"kg*m/s^2")),
:(latexify(612.2u"nm"; fmt=SiunitxNumberFormatter())),
:(latexify(u"kg*m/s^2"; fmt=SiunitxNumberFormatter())),
:(latexify(612.2u"nm"; fmt=SiunitxNumberFormatter(; simple=true))),
:(latexify(u"kg*m/s^2"; fmt=SiunitxNumberFormatter(; simple=true))),
:(latexify((1:5)u"m"; fmt=SiunitxNumberFormatter())),
:(latexify((1, 2, 4) .* u"m"; fmt=SiunitxNumberFormatter())),
]

open(joinpath(dir, "examples.tex"), "w") do f
print(
f,
raw"""
\documentclass{standalone}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{tabular}{lll}\toprule\\
\textt{julia} & \LaTeX & Result \\\midrule
""",
)
for command in commands
print(
f,
raw"\verb+",
string(command),
raw"+",
raw"& \verb+",
eval(command),
raw"+",
raw"& ",
eval(command),
" \\\\\n",
)
end
print(
f,
raw"""
\bottomrule
\end{tabular}
\end{document}
""",
)
end

# List manually imported from Unitful/src/pkgdefaults.jl
# Could be automated by temporarily redefining @unit, @affineunit ... and include()ing this file.
functions = [
x -> "\\verb+$(string(x))+",
x -> latexify(x; fmt=SiunitxNumberFormatter()),
x -> latexify(x; fmt=SiunitxNumberFormatter()),
x -> latexify(x; fmt=SiunitxNumberFormatter(; simple=true)),
]
allunits = begin
uparse.([
"nH*m/Hz",
"m",
"s",
"A",
"K",
"cd",
"g",
"mol",
"sr",
"rad",
"°",
"Hz",
"N",
"Pa",
"J",
"W",
"C",
"V",
"S",
"F",
"H",
"T",
"Wb",
"lm",
"lx",
"Bq",
"Gy",
"Sv",
"kat",
#"percent", # Messes with comments
"permille", # Undefined in all formats
"pertenthousand", # Undefined in all formats (butchered)
"°C",
"°F",
"minute",
"hr",
"d",
"wk", # Undefined in siunitx
"yr", # Undefined in siunitx
"rps", # Undefined in siunitx
"rpm", # Undefined in siunitx
"a", # Undefined in siunitx
"b",
"L",
"M", # Undefined in siunitx
"eV",
"Hz2π", # Butchered by encoding
"bar",
"atm", # Undefined in siunitx
"Torr", # Undefined in siunitx
"c", # Undefined in siunitx
"u", # Undefined in siunitx
"ge", # Undefined in siunitx
"Gal", # Undefined in siunitx
"dyn", # Undefined in siunitx
"erg", # Undefined in siunitx
"Ba", # Undefined in siunitx
"P", # Undefined in siunitx
"St", # Undefined in siunitx
#"Gauss", # errors in testing, maybe from Unitful.jl's dev branch?
#"Oe", # errors in testing, maybe from Unitful.jl's dev branch?
#"Mx", # errors in testing, maybe from Unitful.jl's dev branch?
"inch", # Undefined in siunitx
"mil", # Undefined in siunitx
"ft", # Undefined in siunitx
"yd", # Undefined in siunitx
"mi", # Undefined in siunitx
"angstrom", # Undefined in mathrm,siunitxsimple
"ac", # Undefined in siunitx
"Ra", # Undefined in siunitx
"lb", # Undefined in siunitx
"oz", # Undefined in siunitx
"slug", # Undefined in siunitx
"dr", # Undefined in siunitx
"gr", # Undefined in siunitx
"lbf", # Undefined in siunitx
"cal", # Undefined in siunitx
"btu", # Undefined in siunitx
"psi", # Undefined in siunitx
#"dBHz", # Cannot *yet* be latexified.
#"dBm", # Cannot *yet* be latexified.
#"dBV", # Cannot *yet* be latexified.
#"dBu", # Cannot *yet* be latexified.
#"dBμV", # Cannot *yet* be latexified.
#"dBSPL", # Cannot *yet* be latexified.
#"dBFS", # Cannot *yet* be latexified.
#"dBΩ", # Cannot *yet* be latexified.
#"dBS", # Cannot *yet* be latexified.
])
end

open(joinpath(dir, "allunits.tex"), "w") do f
print(
f,
raw"""
\documentclass{standalone}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{tabular}{llll}\toprule\\
Name & \texttt{mathrm} & \texttt{siunitx} & \texttt{siunitx+simple} \\\midrule
""",
)
for unit in allunits
join(f, [fun(unit) for fun in functions], " & ")
print(f, " \\\\\n")
end
print(
f,
raw"""
\bottomrule
\end{tabular}
\end{document}
""",
)
end

for s in ["examples", "allunits"]
try
run(
`xelatex -interaction=nonstopmode -output-directory $dir $(joinpath(dir,s*".tex"))`,
)
catch
end

try
run(
`magick -fill white -opaque none -density 600 -quality 90 $(joinpath(dir,s*".pdf")) $(joinpath(pkgdir(UnitfulLatexify),"docs","src","assets",s*".png"))`,
)
catch
end
end
end
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ makedocs(
"Logarithmic scales" => "logarithm.md"
"Temperature scales" => "temperature.md"
"Interoperability with `Dates`" => "dates.md"
"Latexifying units" => "latexify.md"
"Extending Unitful" => "extending.md"
"Troubleshooting" => "trouble.md"
"Pre-defined units and constants" => "defaultunits.md"
Expand Down
Binary file added docs/src/assets/latex-allunits.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/assets/latex-examples.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading