[Tex/LaTex] Remove all math for spelling and grammar checking

grammarmath-modespelling

I'm compiling a LaTeX file to pdf and then I use a pdf to text converter to convert the file to plain text. I then use LanguageTool to do grammar checking on that plain text file.
The LaTeX source has some customizations to improve the quality of the plain text file (e.g., I removed page headers, page number, multicolumn environments, and I'm using a huge paper size).

Unfortunately, LanguageTool finds a lot of the grammar errors in the math parts of the file, which clearly is not very useful. So I was wondering: is it possible to just remove all math from the pdf output? Clearly, I could just delete all math from the LaTeX source, but that is not an acceptable way. The math should just not be rendered in the pdf.

Best Answer

this really should be a comment, but it's a little too complicated.

if your math is either all in-line or displayed using the \[ ... \] notation, suppressing it is quite easy:

\documentclass{article}
\def\[#1\]{}
\def\(#1\){}
\catcode`\$=13
\def$#1${}
\begin{document}
some text $xyz$ with embedded \(abc\) math.
some display math as well:
\[ def \]
more text
\end{document}

things get trickier when you use \begin{xxx} ... \end{xxx} environments, and that doesn't even consider starred environments. i haven't licked that problem yet.

many of the amsmath environments ingest the entire content between the \begin and \end markers, so could be redefined to just ignore that instead of measuring and setting.

this sounds like an interesting project for a package. anyone who wants to can steal the ideas laid out above.