SublimeText / LaTeXTools

LaTeX plugin for Sublime Text
https://latextools.readthedocs.io/
2.01k stars 365 forks source link

pdflatex in math preview hangs #1349

Open tobiasdiez opened 6 years ago

tobiasdiez commented 6 years ago

Since some time, I noticed the following problem when using the math preview: sometimes the background compilation freezes. This is not really reproducible but happens a lot. I suppose it happens when I start tying an equation and some problem prevents a successful compilation (like a single open bracket {). In these cases, the blocked pdflatex still run in the background and consume CPU power. I then have to kill these processes manually using the task manager. I hence suggest to add a timeout to the pdf compilation that automatically kills the process after some time (say 5 seconds, which should be enough for all equations).

r-stein commented 6 years ago

We are compiling with the flag -interaction=nonstopmode set and I hoped this is enough to prevent such issues. However I agree if don't get a better additional flag and it keeps hanging we should kill the process.

tobiasdiez commented 6 years ago

I just had again one of the freezes and looked at the resulting tex file used to generate the math preview. To my surprise it not only contained the equation but everything from this equation until the end of the document.

mathpreview.tex

\begin{document}
% set the foreground color
\IfFileExists{xcolor.sty}{\color[HTML]{5F842E}}{}%
\(
\label{eq:yangMillsHiggs:GWS:decompositionHiggsField}
    \varphi = \frac{\eta}{\sqrt{2}} \, \phi \cdot \Vector{0, \nu),
\end{equation}
where \( \phi \in \sSectionSpace(P \times_G G \slash K) \) and \( \eta \in \sFunctionSpace(M, \check{\FibreBundleModel{F}}_{(K)}) \), the latter seen as a \( G \)-invariant map on \( P \).
....

where as the actual tex file (after some further editing) contained

Accordingly, the decomposition~\eqref{eq:yangMillsHiggs:decompositionHiggsField} of \( \varphi \) simplifies here to
\begin{equation}
    \label{eq:yangMillsHiggs:GWS:decompositionHiggsField}
    \varphi = \frac{\eta}{\sqrt{2}} \, \phi \cdot \Vector{0 \\ \nu},
\end{equation}
where \( \phi \in \sSectionSpace(P \times_G G \slash K) \) and \( \eta \in \sFunctionSpace(M, \R_{> 0}) \).

Thus, I believe there is an error with the parsing logic which tries to extract the current equation. Note the open bracket in \Vector{ in mathpreview.tex which is not yet closed

r-stein commented 6 years ago

We don't have a separate parsing logic, but just take everything, which is highlighted as math by sublime text. I think the easiest way to solve that issue is to introduce a maximum text length for the compilation of the equations.