# Exporting Mathematica table to LaTeX

I have generated a code for a table using Mathematica using TeX as output. The code did not get compile. Kindly guide me.

%% AMS-LaTeX Created by Wolfram Mathematica 7.0 : www.wolfram.com

\documentclass{article}
\usepackage{amsmath, amssymb, graphics}

\newcommand{\mathsym}[1]{{}}
\newcommand{\unicode}{{}}

\begin{document}

$\begin{array}{ccccc} \text{Bounds on NP Parameter} & & \left.\text{Branching Fraction(\times }10^{-22}\right) & & \\ \theta & \left|\Sigma _{i=1}^3\lambda '_{\text{ik3}}^*\lambda '_{\text{ik1}}\text{|\backslash n \times }10^{-6}\right. & \text{NP} & \text{Interference} & \text{Combined} \\ 0 & 1.0164 & 3.325 & 0.269 & 3.6 \\ 30 & 1.0298 & 3.413 & 0.151 & 3.57 \\ 60 & 1.0506 & 3.552 & -0.23 & 3.328 \\ 90 & 1.0735 & 3.709 & -0.23 & 3.485 \\ 120 & 1.0923 & 3.84 & 0.168 & 4.014 \\ 150 & 1.1016 & 3.905 & 0.289 & 4.2 \\ 180 & 1.0987 & 3.885 & -0.08 & 3.811 \\ 210 & 1.0844 & 3.784 & -0.308 & 3.482 \\ 240 & 1.0629 & 3.636 & -0.016 & 3.626 \\ 270 & 1.0402 & 3.482 & 0.291 & 3.779 \\ 300 & 1.0223 & 3.363 & 0.104 & 3.473 \\ 330 & 1.0137 & 3.307 & -0.252 & 3.061 \\ 360 & 1.0164 & 3.325 & -0.181 & 3.15 \end{array}$

\end{document}


The problem was that the character ' is active in math mode, and it expands to ^\prime. When you say \lambda '_{\text{ik3}}^* you basically have \lambda^\prime_{\text{ik3}}^*, and this makes TeX throw a ! Double Superscript error.

Knowing this, you can group the \prime with the *:

\lambda _{\text{ik3}}^{\prime*}


Apparently Mathematica doesn't know it can't use superscripts like this...

Compilable code:

%% AMS-LaTeX Created by Wolfram Mathematica 7.0 : www.wolfram.com

\documentclass{article}
\usepackage{amsmath, amssymb, graphics}

\newcommand{\mathsym}[1]{{}}
\newcommand{\unicode}{{}}

\begin{document}

$\begin{array}{ccccc} \text{Bounds on NP Parameter} & & \left.\text{Branching Fraction(\times }10^{-22}\right) & & \\ \theta & \left|\Sigma _{i=1}^3\lambda _{\text{ik3}}^{\prime*}\lambda '_{\text{ik1}}\text{|\backslash n \times }10^{-6}\right. & \text{NP} & \text{Interference} & \text{Combined} \\ 0 & 1.0164 & 3.325 & 0.269 & 3.6 \\ 30 & 1.0298 & 3.413 & 0.151 & 3.57 \\ 60 & 1.0506 & 3.552 & -0.23 & 3.328 \\ 90 & 1.0735 & 3.709 & -0.23 & 3.485 \\ 120 & 1.0923 & 3.84 & 0.168 & 4.014 \\ 150 & 1.1016 & 3.905 & 0.289 & 4.2 \\ 180 & 1.0987 & 3.885 & -0.08 & 3.811 \\ 210 & 1.0844 & 3.784 & -0.308 & 3.482 \\ 240 & 1.0629 & 3.636 & -0.016 & 3.626 \\ 270 & 1.0402 & 3.482 & 0.291 & 3.779 \\ 300 & 1.0223 & 3.363 & 0.104 & 3.473 \\ 330 & 1.0137 & 3.307 & -0.252 & 3.061 \\ 360 & 1.0164 & 3.325 & -0.181 & 3.15 \end{array}$

\end{document}


I propose this neater and simpler code, based on siunitx for the alignment on the decimal dot, and makecell to allow for line breaks in cells. I was unsure of the details of the column heads, so I had to interpret the Mathematica code. Let me know if there's any problem.

\documentclass{article}
\usepackage{amsmath, amssymb, graphicx}
\usepackage{array, siunitx, makecell, booktabs}

\newcommand{\mathsym}[1]{{}}
\newcommand{\unicode}{{}}

\begin{document}

\sisetup{table-number-alignment=center} \begin{array}{cS[table-format = 1.4]*{3}{S[table-format=-1.3]}} \text{ \thead{Bounds on \\NP Parameter\\\theta}} &{\thead{\bigl|\Sigma _{i=1}^3{\lambda '}_{\text{ik3}}^*{\lambda '}_{\text{ik1}}\\ |\backslash\mathrm{n} \times \num{e-6}}} & {\text{\thead{Branching Fraction\\ ( \times\num{e-22} )\\NP}}} & {\text{Interference}} & \text{Combined} \\[-1ex] \midrule 0 & 1.0164 & 3.325 & 0.269 & 3.6 \\ 30 & 1.0298 & 3.413 & 0.151 & 3.57 \\ 60 & 1.0506 & 3.552 & -0.23 & 3.328 \\ 90 & 1.0735 & 3.709 & -0.23 & 3.485 \\ 120 & 1.0923 & 3.84 & 0.168 & 4.014 \\ 150 & 1.1016 & 3.905 & 0.289 & 4.2 \\ 180 & 1.0987 & 3.885 & -0.08 & 3.811 \\ 210 & 1.0844 & 3.784 & -0.308 & 3.482 \\ 240 & 1.0629 & 3.636 & -0.016 & 3.626 \\ 270 & 1.0402 & 3.482 & 0.291 & 3.779 \\ 300 & 1.0223 & 3.363 & 0.104 & 3.473 \\ 330 & 1.0137 & 3.307 & -0.252 & 3.061 \\ 360 & 1.0164 & 3.325 & -0.181 & 3.15 \end{array}

\end{document}


• Bernard, hi. can you edit your code. There is any code out of  :-) – Sebastiano Apr 23 '18 at 12:37
• Once again, I didn't check the result of my posting :o( Thanks! – Bernard Apr 23 '18 at 12:40
• As many times I wrote I do not correct the answers of the users much better than me. – Sebastiano Apr 23 '18 at 12:44