TexSoup icon indicating copy to clipboard operation
TexSoup copied to clipboard

Problem with \right) and }

Open SengerM opened this issue 4 years ago • 3 comments

I found out that if I have file.tex with this content:

\begin{equation}
    \frac{\left(a+b\right)}{a}
\end{equation}

\begin{itemize}
    \item Lalala.
\end{itemize}

and I run

import TexSoup
with open('file.tex', 'r') as ifile: 
    latex_soup = TexSoup.TexSoup(ifile.read()) 
print(latex_soup)

I get AssertionError: Command \item invalid in math mode.. I have noted that if I change \frac{\left(a+b\right)}{a} to \frac{\left(a+b\right) }{a} this works as expected. I suppose this is not the expected behavior so I am reporting this issue here.

SengerM avatar Jul 26 '21 10:07 SengerM

I just encountered a related error. If I run TexSoup(r'What is \[\left(2\right)\]') I get EOFError: [Line: 0, Offset: 21] "displaymath" env expecting \].

Inserting a space after \right leads to correct behaviour: TexSoup(r'What is \[\left(2\right) \]') I expect this is related to #115, see @equaeghe's comment.

tschmah avatar Jul 29 '21 18:07 tschmah

I get simular problem, but what is intersting:

  • $f_I(z)=V_0 \left\{1-\beta + \beta\frac{z^2}{z_0^2}\right\} $ parsing correctly, while
  • $f_I(z)=V_0 \left\{1-\beta + \beta\frac{z^2}{z_0^2}\right\}$ is not. So, as long as the problem not fixed, maybe you'll try to get a space after the \right) command?

Lavton avatar Jan 27 '22 09:01 Lavton

I think this issue was actually fixed in https://github.com/alvinwan/TexSoup/commit/71d4c0624141bce6686f45c755465278d0ead0e3 (committed on Oct 19, 2020).

A new release on PyPI would be useful :slightly_smiling_face:

paugier avatar Apr 15 '23 20:04 paugier