Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Support solving within latex expressions #37

Open
Explosion-Scratch opened this issue Nov 20, 2023 · 7 comments
Open
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@Explosion-Scratch
Copy link

I have lots of notes which have something like:

  • 2.00 L of water is at 20.0 °C. If you raise its temperature to 90.0 °C, by how much will its volume expand?
    • $\triangle V = (2.14e-5)270$

It would be amazing if this plugin would solve things within the '$'s, evaluating that as '(2.14*e-5)270' =114.40

Also this would solve issues like * being used as italic formatting in obsidian

@Explosion-Scratch Explosion-Scratch added the enhancement New feature or request label Nov 20, 2023
@LiamRiddell LiamRiddell added the help wanted Extra attention is needed label Nov 27, 2023
@LiamRiddell
Copy link
Owner

LiamRiddell commented Nov 27, 2023

Thanks a lot for this cool idea 🌟. I totally get where you're coming from, wanting to solve equations right inside your notes. It sounds super convenient!

However, after giving it some thought, I realized that integrating this feature is quite a handful. The thing with TeX/LaTeX is that it's awesome for showing off math equations in a neat format, but it's not really built for crunching numbers. Parsing and computing LaTeX directly in the plugin would be like opening a whole new can of worms, given how complex LaTeX syntax can get. Also, there's this tricky part where LaTeX uses symbols like '*' for its formatting magic, which could get misread as something else if we start doing math with them.

So, while I love the idea, I think it's a bit out of reach for this plugin. That said, I'm all ears for other suggestions to make the plugin better within its main goals. Keep those ideas coming!


On a side note, I've implemented a fix for *, you can escape it using \* or you can use letter x or the word multiply.

@LiamRiddell LiamRiddell added wontfix This will not be worked on and removed help wanted Extra attention is needed labels Nov 27, 2023
@Explosion-Scratch
Copy link
Author

@LiamRiddell Not parsing and evaluating LaTeX per se, but just ignoring the $ and splitting on =. In the example above this would split by equals to get (2.14*e-5)270$, then remove the trailing $, then evaluate that.

@LiamRiddell LiamRiddell reopened this Nov 27, 2023
@LiamRiddell
Copy link
Owner

LiamRiddell commented Nov 27, 2023

@LiamRiddell Not parsing and evaluating LaTeX per se, but just ignoring the $ and splitting on =. In the example above this would split by equals to get (2.14*e-5)270$, then remove the trailing $, then evaluate that.

Damn, my apologies! I'll reopen the issue. I can take a look at this and see what I can do. Thank you for correcting me 😃

@Explosion-Scratch
Copy link
Author

All good! A cool thing that I might PR in the future would be to convert LaTeX to ASCIIMath then solve that

@LiamRiddell
Copy link
Owner

LiamRiddell commented Nov 27, 2023

That sounds interesting. I do have an initial draft of the community providers in the code which allows another Obsidian Plugin to define custom providers. It's currently un-documented in early stages. It could also be a good project for that too!

@LiamRiddell
Copy link
Owner

LiamRiddell commented Nov 27, 2023

@Explosion-Scratch The only issue I initially see in the example $\triangle V = (2.14e-5)270$ is that the multiplication is implicit. However, Solve would require this to be an explicit definition with the symbol e.g. $\triangle V = (2.14e-5)*270$. This would probably be a pain for you use case?

Implicit:
image

Explicit:
image

@Explosion-Scratch
Copy link
Author

@LiamRiddell You could use https://github.com/Crownie/latex-to-js/blob/e878ba070936388988eb245a4d031125df68e788/latex-to-js.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants