# Handcalcs.jl - For more readable calculations

**URL:** <https://discourse.julialang.org/t/handcalcs-jl-for-more-readable-calculations/109891>\
**Category:** Package Announcements\
**Tags:** latex, math, engineering, latexstrings\
**Created:** [February 7, 2024, 5:38pm UTC](https://discourse.julialang.org/t/handcalcs-jl-for-more-readable-calculations/109891 "2024-02-07T17:38:08Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![agharezak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/agharezak/32/208958_2.png) [@agharezak](https://discourse.julialang.org/u/agharezak)\
**Post date:** [May 2, 2024, 4:01am UTC](https://discourse.julialang.org/t/handcalcs-jl-for-more-readable-calculations/109891/21 "2024-05-02T04:01:08Z")

</div>

My man!

---

<div class="post-metadata">

**Author:** ![mschauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mschauer/32/13946_2.png) [@mschauer](https://discourse.julialang.org/u/mschauer)\
**Post date:** [May 2, 2024, 7:49am UTC](https://discourse.julialang.org/t/handcalcs-jl-for-more-readable-calculations/109891/22 "2024-05-02T07:49:34Z")

</div>

Very nice! @co1emi11er : just letting you know about [GitHub - fkastner/NiceNumbers.jl: The nicest numbers in Julia.](https://github.com/fkastner/NiceNumbers.jl) in case that fits your interests.

---

<div class="post-metadata">

**Author:** ![co1emi11er](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/co1emi11er/32/206849_2.png) [@co1emi11er](https://discourse.julialang.org/u/co1emi11er)\
**Post date:** [July 3, 2024, 7:46pm UTC](https://discourse.julialang.org/t/handcalcs-jl-for-more-readable-calculations/109891/23 "2024-07-03T19:46:14Z")

</div>

# New Release: [Handcalcs.jl](https://co1emi11er2.github.io/Handcalcs.jl/stable/) v0.4.0

Hello all,

Here are a few updates to the latest release.

## Unitful Integration

I am excited to announce Handcalcs is now integrated with Unitful.jl!

## All Added Features

- Added ability to disable handcalcs when doing simulations. You can then turn it back on when you want to print results
- added a color option
- added ability to promote to certain unit using the `|>` operator (more info [here](https://co1emi11er2.github.io/Handcalcs.jl/stable/tutorial/#Using-Unitful-with-UnitfulLatexify))
- Unitful integration should be working with Latexify v0.16.4 and UnitfulLatexify v1.6.4

## Breaking Change

- now requires at least Latexify v0.16.4 and UnitfulLatexify v1.6.4

## Better Documentation Structure

I updated the structure of the docs to be a little better. Please see the [docs](https://co1emi11er2.github.io/Handcalcs.jl/stable/) for the updates!

---

<div class="post-metadata">

**Author:** ![tecosaur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tecosaur/32/23206_2.png) [@tecosaur](https://discourse.julialang.org/u/tecosaur)\
**Post date:** [July 4, 2024, 3:21am UTC](https://discourse.julialang.org/t/handcalcs-jl-for-more-readable-calculations/109891/24 "2024-07-04T03:21:43Z")

</div>

Very neat! If you’ve done the work to support unitful, might it be an easy step to also support DynamicQuantities.jl?

(One nit: in the docs I think `References` should maybe be `Reference`, is a one letter change that makes a big difference to interpretation 😆)

---

<div class="post-metadata">

**Author:** ![co1emi11er](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/co1emi11er/32/206849_2.png) [@co1emi11er](https://discourse.julialang.org/u/co1emi11er)\
**Post date:** [July 4, 2024, 1:24pm UTC](https://discourse.julialang.org/t/handcalcs-jl-for-more-readable-calculations/109891/25 "2024-07-04T13:24:51Z")

</div>

> [@tecosaur](#):
>
> Very neat! If you’ve done the work to support unitful, might it be an easy step to also support [DynamicQuantities.jl](https://juliahub.com/ui/Packages/General/DynamicQuantities)?

Does DynamicQuantities.jl have a package like UnitfulLatexify.jl? My package doesn’t really handle the latexifying (since that is already what Latexify.jl does). If DynamicQuantities.jl maintainers work to get it working with Latexify properly, then it will work for handcalcs as well.

@MilesCranmer Do you know the status of DynamicQuantities.jl integration with Latexify.jl?

The main issue before was this: [Issue when interpolating variables with units under an exponent](https://github.com/gustaphe/UnitfulLatexify.jl/issues/17). But this was fixed in Latexify v0.16.4 and UnitfulLatexify v1.6.4

---

<div class="post-metadata">

**Author:** ![tecosaur](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tecosaur/32/23206_2.png) [@tecosaur](https://discourse.julialang.org/u/tecosaur)\
**Post date:** [July 4, 2024, 3:08pm UTC](https://discourse.julialang.org/t/handcalcs-jl-for-more-readable-calculations/109891/26 "2024-07-04T15:08:45Z")

</div>

Is `Latexify` using package extensions yet? If not, this could be a good fit for it.

---

<div class="post-metadata">

**Author:** ![co1emi11er](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/co1emi11er/32/206849_2.png) [@co1emi11er](https://discourse.julialang.org/u/co1emi11er)\
**Post date:** [July 4, 2024, 3:31pm UTC](https://discourse.julialang.org/t/handcalcs-jl-for-more-readable-calculations/109891/27 "2024-07-04T15:31:53Z")

</div>

`Latexify` allows you to extend it for your types by creating recipes. It was just problematic for Unitful since the recipes didn’t allow for some things, but that is fixed now,. Basically any type you want to get working with latexify, you can through recipes, and as a result, it will work in `Handcalcs` as well.

---

<div class="post-metadata">

**Author:** ![MilesCranmer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/milescranmer/32/21070_2.png) [@MilesCranmer](https://discourse.julialang.org/u/MilesCranmer)\
**Post date:** [July 4, 2024, 4:23pm UTC](https://discourse.julialang.org/t/handcalcs-jl-for-more-readable-calculations/109891/28 "2024-07-04T16:23:34Z")

</div>

> [@co1emi11er](#):
>
> @MilesCranmer Do you know the status of [DynamicQuantities.jl](https://juliahub.com/ui/Packages/General/DynamicQuantities) integration with [Latexify.jl](https://juliahub.com/ui/Packages/General/Latexify)?

This would be good to have. I don’t think anybody has created something like this yet. But it should be pretty easy. The entire implementation of printing is:

```julia
function Base.show(io::IO, d::AbstractDimensions)
    tmp_io = IOBuffer()
    for k in filter(k -> !iszero(d[k]), keys(d))
        print(tmp_io, dimension_name(d, k))
        isone(d[k]) || pretty_print_exponent(tmp_io, d[k])
        print(tmp_io, " ")
    end
    s = String(take!(tmp_io))
    s = replace(s, r"^\s*" => "")
    s = replace(s, r"\s*$" => "")
    print(io, s)
end
Base.show(io::IO, q::UnionAbstractQuantity{<:Real}) = print(io, ustrip(q), " ", dimension(q))
Base.show(io::IO, q::UnionAbstractQuantity) = print(io, "(", ustrip(q), ") ", dimension(q))

function dimension_name(::AbstractDimensions, k::Symbol)
    default_dimensions = (length="m", mass="kg", time="s", current="A", temperature="K", luminosity="cd", amount="mol")
    return get(default_dimensions, k, string(k))
end

```

`dimension_name` is something that any `AbstractDimensions` can overload to map to a string representing the dimensions. (By default it just takes the string representation of the symbol (which are returned by `keys`))

Then the `pretty_print_exponent(tmp_io, d[k])` can be replaced with `print(tmp_io, "^{$(d[k])}")`.

[Previous page](https://discourse.julialang.org/t/handcalcs-jl-for-more-readable-calculations/109891.md?page=1)
