Not an answer but I wanted to post some thoughts that a solution would need to consider, if someone wants to have a go...
- I downloaded all my posts from answer 1 and got a 3MB .csv file. I've never opened a 3MB TeX file before, does it work? If not then perhaps need to sort and batch.
- MathJax is not $\LaTeX$: There are certain constructs that are allowed in MathJax but not in $\LaTeX$. For example
$$ \begin{align} ... \end{align}$$
. Another is $\sum_{\text{newlines} \\ \text{in subscripts}}$
$\sum_{\text{newlines} \\ \text{in subscripts}}$ (this requires \substack
in LaTeX) and similarly $\text{new lines} \\ \text{in math mode}$, $$\text{even}\\\text{in display mode.}$$ Those throw errors in $\LaTeX$. Another one is that \color
works differently here: ${\color{red}red}$
${\color{red}red}$ works in $\LaTeX$. But $\color{red}{red}$
$\color{red}{red}$ works in both so I think this isn't an issue for the MathJax $\to \LaTeX$ direction.
- MathJax on Math.SE doesn't have an explicit list of packages; one will need to check what packages are needed in the $\LaTeX$ preamble.
\newcommand
, \renewcommand
and \let
across different questions/answers may conflict in the resulting .tex
so you will need to e.g. add some \let\...\relax
at the end of posts.
- Posts on Math.SE are not written with only MathJax: Links and images are written in Markdown. In particular images are not included in the csv file download. Markdown Tables might be a bother to format correctly.
- Actually, looking at the
.csv
file, it seems to not have exactly the source I wrote, but some HTML. An example from my .csv
file below. So that will also need to be parsed out.
<p><span class=""math-container"">$$C_1(1+||x||^2)^k \leq \sum_{|\alpha| \leq k} x^{2\alpha} \leq C_2 (1+||x||^2)^k,$$</span></p>
In addition some questions' comments are IMO vital to understanding the post, so that's a good nice-to-have.
I think the easiest would probably to make a script that visits each of the questions and just prints the page to PDF. (Don't do too many pages at once if you don't want to be banned from SE) This will give you PDF files but no .tex
file.
If you need a .tex
file you will probably want to go from the csv file, TexSoup looks like it might be useful.