# TeXForm output in a tabular environment

As far as I can see TeXForm of a matrix produces LaTeX arrays, which assume LaTeX is in math mode. However, Mathematica can be used to produce whole tables programmatically. Therefore I was wondering if there is a way to tell TeXForm to spit out LaTeX in a tabular environment, including the annoying dollar-signs needed for each cell that is in math mode. I cannot see any option for TeXForm to do this.

Of course one could program this, but that would be tedious, because one has to figure out what is math and what is not. And one also has to do the necessary substitutions. So I was wondering if this wheel has already been invented, or do I have to be the inventor? In any case, I invite suggestions.

• I haven't tried it myself, but the Cells to TeX package might do a better job. (I found it by looking at the LaTeX tag on packagedata.net) – C. E. Apr 4 '16 at 13:52

Have a look at TeXTableForm.m: Converting Mathematica Lists to LaTeX Tables it is working quite well:

t = Table[i, {i, 1, 22}]


{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, \ 20, 21, 22}

TeXTableForm[t, 5, "tab1.tab"]


"tab1.tab"

Import[".../tab1.tab"]