Print/Output only Equations/Math Formulas of a Given LaTeX or LyX Document

I have a LyX document filled with text and equations like in a scientific paper. To focus only on the math sometimes it can be really useful to only print/output the formulas and not the text around it. Is there any way to do this automatically in LyX? So far I manually copy all the equations but that is not convenient in the long run. All equations are numbered and centered in the math mode.

-

try with the following in the preamble:

``````\usepackage[
active,
generate=file,
extract-env={equation,align}
]{extract}
``````

then it generates a new file with the chosen contents.

-

It is with extreme reluctance that I suggest a perl script that I once wrote called `mathgrep` for this purpose. It was designed to mess with mathematics inside a LaTeX document, leaving non-mathematics environments alone. It is not particularly sophisticated in that if you mess with how you start and stop maths sections then you can easily confuse it, but on a regular document it ought to work (so long as you've used proper LaTeX `\( ... \)` and not TeX `\$ ... \$`).

You can get it from `mathgrep`. It needs Perl (plus a couple of perl libraries). If you've not used any weird maths environments, then:

``````mathgrep '/.*/' latex_file.tex
``````

should produce all of the mathematics (inline maths includes surrounding text, by the way). You'd need to include the preamble yourself.

-