Atreyagaurav / litex-mode

LiTeX mode for emacs; A minor mode to convert valid lisp expressions to LaTeX
GNU General Public License v3.0
43 stars 4 forks source link

Numbers in fractions get concatenated when using SLIME #21

Closed Bu156 closed 2 years ago

Bu156 commented 2 years ago

For example the following

(setq a (/ 1 2))

Gets solved to

$$a = 12$$

When it should be

$$a = \frac{1}{2}$$

This is only an issue when using integers, and it seems to be because 1/2 gets returned by slime and Litex doesn't have code to handle it.

Atreyagaurav commented 2 years ago

Thank you for this, I hadn't done anything in litex during summer and I missed this one. Elisp didn't have fractional data type so I should do something about this if we're using clisp. Can you think of any other data types that might have similar results?

I'll write a function to parse the slime output for this one.

Atreyagaurav commented 2 years ago

Can you test and see if it's fixed in the linked pull req? Felt like a ducttape for now. turns out elisp didn't have ratio datatype so it was reading 1/2 as symbol so as a symbol it was formatted in the way symbols do (ignoring / as I used it to separate greek alphabets in symbol earlier), might need to fix that too... It'd have at least been 1/2 instead of 12 if that wasn't there.

If I tried to solve the expressions you gave in step by step format litex-solve-all-steps-align then we get this:

\begin{align*}
x& = \frac{1}{2}\\
& = \frac{1}{2}
\end{align*}

It looks repetitive because first one is values substitution and last one is the fractional value.

Considering other problems as well looks like overall I can't make litex automate everything but just help you generate the draft to fine tune.

Bu156 commented 2 years ago

The cases I've tried work great! And yeah, LiTeX is really useful for automating part of the note taking process for me. I write my maths and physics notes in lisp and it's a great time saver to be able to both evaluate and get TeX out of it. It isn't a big issue that there are a few manual steps as it does so much already.

Atreyagaurav commented 2 years ago

I've merged it, melpa should have the new version when it builds it next I guess. I do think I'll end up changing the greek letters' separate character from '/' to '.' because of this and other reasons (for eg, I'd like variables to be able to have names like "dx/dt").