hutchresearch / latex2speech

TeX2Speech is an application that turns LaTeX documents into spoken audio.
https://tex2speech-website.vercel.app/
MIT License
12 stars 5 forks source link

TODO - PreProcess #97

Closed willsower closed 3 years ago

willsower commented 3 years ago

2. This math equation inside the \footer{} errors

! In Progress
Example Document: cells.tex (removed \newcommand manually)

This is fine Line 449:
\footnote{The symmetric function notation for cycle-indexes has been used (see \cite{r0}). For example, we write $h_n[P]$ in place of.}

$Z(\Sg_n, P(x, t_1, t_2, \ldots))$

Not fine Line 449:
\footnote{The symmetric function notation for cycle-indexes has been used (see \cite{r0}). For example, we write $h_n[P]$ in place of $Z(\Sg_n, P(x, t_1, t_2, \ldots))$.}

Error: IndexError: AttributeError: 'TexMathModeEnv' object has no attribute 'find_all'

Solution: Need to discuss ? Remove matmode from footer??

Note: Math equations work fine within \caption tag (look at cells.tex at line 822-ish)

3. Line in \bibitem breaks

! In Progress
Example Document: zzz.tex

This line in 795 in \bibitem{TD}

\bibitem{TD} 
I. Tamm, 
J.\ Phys.\ (USSR), {\bf 9}, 449 (1945); 
S. M. Dancoff,
Phys.\ Rev. {\bf 78}, 382 (1950).

The J.\ Phys.\ (USSR), {\bf 9}, 449 (1945);  causes an error

Error: EOFError: [Line: 0, Offset: 5726] "math" env expecting \). Reached end of file.

Solution: Need to discuss ? Remove \ that have a white character before and after? When I removed the two \ after J. and After Phys. program ran just fine. However other liens with random \ work fine...

5. AssertionError Mathmode

! In Progress
Example Document: hyper.tex

This line in 679-682 

\begin{equation}
{a}_b(z,\omega) = {a}_b(L,\omega)\text{e}^{-\frac{\alpha (L-z)}{2}} -
i\alpha \int^L_z dz' \text{e}^{-\frac{\alpha}{2}(z'-z)}D_b(z',0,\omega) 
\end{equation}

AssertionError

Solution: Read next one down for solution

6. AssertionError Mathmode READ (Similiar to #5 Above)

! In Progress
Example Document: dna.tex

This line in 215-221
Similiar problem 4x other times in this file

\begin{equation}
\cF=\cF_s \equiv
\frac{k_1}{2} \frac{d\Psi^{\dagger}}{ds}\frac{d\Psi}{ds} 
+   \frac{k_2}{2}
 \left|  \Psi^{\dagger}\frac{d\Psi}{ds} \right|^2. 
\label{Lrod}
\end{equation}

AssertionError

Solution: Replace \begin{equation} \end{equation} with $. For some reason, when I tried that, it worked! It also works for the issue in the assertion error above. I'm unsure if there may be other problems here though...

Example:
$
\cF=\cF_s \equiv
\frac{k_1}{2} \frac{d\Psi^{\dagger}}{ds}\frac{d\Psi}{ds} 
+   \frac{k_2}{2}
 \left|  \Psi^{\dagger}\frac{d\Psi}{ds} \right|^2. 
\label{Lrod}
$

7. Attribute Error: Mathmode

! In Progress
Example Document: generator.tex

This line in 1145-1149 

{\hspace{-0.3cm}\textbf{Lemma 4} (Main Lemma: Feasibility and equivalence of exit sequences).
\emph
{Given a starting state $s_\alpha$ and two collections of sequences $\Lambda=[\Lambda_1,\Lambda_2,...,\Lambda_n]$ and $\Gamma=[\Gamma_1,\Gamma_2,...,\Gamma_n]$
such that $\Lambda_i \tmu \Gamma_i$ (tail-fixed permutation) for all $1\leq i\leq n$. Then $(s_\alpha, \Lambda)$ is feasible if and only if $(s_\alpha, \Gamma)$ is feasible.}
}

If we take $\Lambda_i \tmu \Gamma_i$ command out of the above thing, it WORKS. This is the only command within that breaks it.

AttributeError: 'TexMathModeEnv' object has no attribute 'find_all'

Solution: I don't understand the problem really...

8. Def / Newcommand

! In Progress
Example Document: globalRev.tex

Def Example:
\def\be{\begin{equation}}
\def\ee{\end{equation}}

EOFError: [Line: 0, Offset: 113] "equation" env expecting \end{equation}. Reached end of file.

Newcommand Example:
\newcommand{\bq}{\begin{eqnarray}}
\newcommand{\eq}{\end{eqnarray}}

EOFError: [Line: 0, Offset: 140] "eqnarray" env expecting \end{eqnarray}. Reached end of file.

Solution: Need to discuss. This is 20% of the unique errors in our error log, they all are "reached end of file." Is it possible to do the def stuff before it reaches TexParser? I don't know how def works 100%

9. Need Newline

! In Progress
Example Document: globalRev.tex

This is not Okay
\def\t{\theta}\def\T{\Theta}
\def\l{\lambda}\def\L{\Lambda}

TypeError: [Line: 0, Offset 1272] Malformed argument. First and last elements must match a valid argument format. In this case, TexSoup could not find matching punctuation for: {.
Just finished parsing: ['{', '\\}', BraceGroup('L'), BraceGroup(TexCmd('Lambda')), '\n', '\n', '\n', '\n', TexCmd('end', [BraceGroup('document')]), '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n']

Solution (They cannot be side by side):
\def\t{\theta}
\def\T{\Theta}
\def\l{\lambda}
\def\L{\Lambda}

10. Index out of range

! In Progress
Example Document: globalRev.tex

Caused by 77-83:
\newcommand\lsim{\mathrel{\rlap{\lower4pt\hbox{\hskip1pt$\sim$}}
    \raise1pt\hbox{$<$}}}

IndexError: list index out of range

Solution: Need to discuss

Wolrab commented 3 years ago

1 is now fixed at least in cells.tex. Basically TexSoup wasn't expecting any [...] type arguments to be anywhere except the first argument, so I included a regex that now manually pushes all arguments together if they're separated by whitespace. I'll be interested to see if this causes different problems down the line, but I can't really think of a case where whitespace needs to be between args.

willsower commented 3 years ago

4. Line in \% breaks

+ Completed!
Example Document: hyper.tex

This line in 344 
Same problem happens in gameon.tex

This echo has a maximum efficiency of $54\%$

EOFError: [Line: 0, Offset: 2335] "$" env expecting $. Reached end of file.

Solution: Get rid of \% combo in both mathmode AND regular LaTeX. (I tested to see if \% would break outside of mathmode and it DOES)

4 is now fixed, tested in gameon.tex file. Essentially the fix was in the format_master_files.py when we are copying charachter by characther into the second file (we did this due to input file stuff), we check if there is \% occurence command. If so just replace this with percentage word.

willsower commented 3 years ago

1 is now fixed at least in cells.tex. Basically TexSoup wasn't expecting any [...] type arguments to be anywhere except the first argument, so I included a regex that now manually pushes all arguments together if they're separated by whitespace. I'll be interested to see if this causes different problems down the line, but I can't really think of a case where whitespace needs to be between args.

1. \newcommand makes errors when it has \newcommand{}[]{} instead of \newcommand{}{}

+ Completed!
Example Document: cells.tex

This is fine:
\newcommand{\con} {{\rm config}}
\newcommand{\Con} {{\rm Config}}
\newcommand{\Pj} {{\mathbb P}}    

Not fine:
\newcommand{\M}  [1] {\ensuremath{{\overline{\mathcal M}}{^{#1}_0(\R)}}}
\newcommand{\Cobnd} [2] {{\ensuremath{\Lambda^n(#1,#2)}}}
\newcommand{\Lc} [1] {{\mathcal {C}}(#1)}  

Error: IndexError: list index out of range

Solution: Currently pushing args seperated by whitespace together seems to fix this issue, FURTHER TESTING REQUIRED