Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- run: sudo apt install -y ghostscript fonts-freefont-ttf
- uses: julia-actions/setup-julia@v2
with:
version: 1
Expand Down
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
6 changes: 5 additions & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
InverseFunctions = "3587e190-3f89-42d0-90ee-14403ec27112"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
Latexify = "23fbe1c1-3f47-55db-b15f-69d7ec21a316"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it'd be always good to have compat bounds at least for non-stdlibs non-jll packages.

Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the package itself to the docs environment without something like 7682716 (from #794) is generally incorrect because you get the docs of the wrong version.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid. Rookie mistake on my part, I wasn't sure how to do this in a more robust way--thanks for pointing to an example.

tectonic_jll = "d7dd28d6-a5e6-559c-9131-7eb760cdacc5"

[compat]
Documenter = "1"
Latexify = "0.16"
Latexify = "0.16.9"
147 changes: 147 additions & 0 deletions docs/generate_latex_images.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
using LaTeXStrings, Unitful, Latexify, tectonic_jll

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, 2, 4) .* u"m"; fmt=SiunitxNumberFormatter())),
]
tab1 = map(commands) do command
LaTeXString.([
"\\verb+$(string(command))+",
"\\verb+$(eval(command))+",
"$(eval(command)) ",
])
end
ltab1 = latextabular(tab1, adjustment=:l, transpose=true, latex=false, booktabs=true,
head=["julia", "\\LaTeX", "Result"])
# Setting an explicit white background color results in transparent PDF, so go offwhite.
ltab1 = LaTeXString("\\definecolor{offwhite}{rgb}{0.999,0.999,0.999}\n\\pagecolor{offwhite}\n\\color{black}\n" * ltab1)

render(ltab1, MIME("image/png"); use_tectonic=true,
name=(@__DIR__)*"/src/assets/latex-examples",
packages=["booktabs", "color", "siunitx"],
documentclass=("standalone"))

functions = [
x -> "\\verb+$(string(x))+",
x -> latexify(x),
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", # No longer in siunitx
"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

tab2 = map(allunits) do unit
[LaTeXString(f(unit)) for f in functions]
end
ltab2 = latextabular(tab2, adjustment=:l, transpose=true, latex=false, booktabs=true,
head=["Name", "Default number formatter", "\\verb+SiunitxNumberFormatter()+", "\\verb+SiunitxNumberFormatter(;simple=true)+"])
# Set background to not-quite-white so it doesn't get treated as transparent
ltab2 = LaTeXString(
"""
\\setmainfont{FreeSerif}
\\setmonofont{FreeMono}
\\definecolor{offwhite}{rgb}{0.999,0.999,0.999}
\\pagecolor{offwhite}
\\color{black}
""" * ltab2)

render(ltab2, MIME("image/png"); use_tectonic=true,
tectonic_flags=`-Z continue-on-errors`,
name=(@__DIR__)*"/src/assets/latex-allunits",
packages=["booktabs", "color", "siunitx", "fontspec"],
documentclass=("standalone"))
4 changes: 4 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using Documenter, Unitful, Dates

@info "Generating latex images for documentation"
include("generate_latex_images.jl")

DocMeta.setdocmeta!(Unitful, :DocTestSetup, :(using Unitful))

makedocs(
Expand All @@ -19,6 +22,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
Loading
Loading