-
Notifications
You must be signed in to change notification settings - Fork 444
Description
Hi Connor,
First of all, thank you for creating handcalcs — since I discovered it, I haven't stopped using it! I'm from Peru, and I'm planning to run a small workshop to introduce this amazing tool to people who are just starting with Python.
I'm currently facing an issue when using custom_symbols with the square root function.
Here's my setup:
handcalcs.set_option("custom_symbols", {
"fcmag": "\\left( f'_{c} \\right)",
"fymag": "f_y",
"rhobal": "\\overline{ \\rho_b }",
"fraccion": r"\frac{k_x \text{Holaj}x}{r_x} "
})I use Pint for units:
f_prime_c = 210 * kgf/cm**2
fcmag = f_prime_c.magnitude # This is a floatThe issue occurs with the square root:
%%render
As_min_1 = max(0.80*sqrt(fcmag)/fymag*b*d_1, 14/fymag*b*d_1)Expected LaTeX Output:
\sqrt{f'_{c}}
Actual Output (from %%tex):
\mathrm{sqrt} f'_{c}
This incorrect rendering only happens when using fcmag (a custom_symbol). If I use f_prime_c directly in the formula, it renders correctly as \sqrt{210}.
It seems the symbolic substitution breaks proper detection of sqrt() and falls back to rendering it as \mathrm{sqrt} instead of \sqrt{}.
Would love to hear your thoughts or guidance on how to patch this. I’ve been customizing the library, so I’d also be happy to contribute a fix or test one if you have suggestions.
Thanks again for your work!
Best regards