I'm currently writing a Python program that can automate detection of whether a certain command is permitted in math mode without using any packages.
For the purpose of testing I add \documentclass{article}
\begin{document}$
before a command to be tested and $\end{document}
after it. Then I save it to a file using a randomly generated filename and use latex <filename>+'.tex'
to TeX the file.
If the command is actually permitted the process ends and I can obtain a return code of 0. On the other hand when TeXing doesn't work instead of returning an error code the process simply doesn't end.
Is there a way to run LaTeX so that the process always return even if there is an error?
-halt-on-error
. Problem solved! – Ying Zhou May 5 at 19:55