I am a beginner. I am trying to build a table using math Jax but it can't compile. how can I add a table?
\begin{center}
\begin{tabular}{ | m{7em} | m{5em}| m{9em} | }
\hline
Set & operation & Identity \\
\hline
\(\mathbb{Z}\) & \(+\) & \(0\) \\
\hline
\(\mathbb{Q}\) & \(+\) & \(0\) \\
\hline
\(\mathbb{R}\) & \(+\) & \(0\) \\
\hline
\(\mathbb{Z}\) & \(\times \) & \(0\) \\
\hline
\(\mathbb{Q}\) & \(\times\) & \(0\) \\
\hline
\(\mathbb{R}\) & \(\times\) & \(0\) \\
\hline
\end{tabular}
\end{center}
MathJax only implements the macros used for math layout, not text layout, so things like \begin{tabular}
and \begin{center}
are not supported. Instead, you can use an array
environment, like:
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS_CHTML-full"></script>
\[
\begin{array}{|c|c|c|}
\hline
\text{Set} & \text{Operation} & \text{Identity} \\
\hline
\mathbb{Z} & + & 0 \\
\hline
\mathbb{Q} & + & 0 \\
\hline
\mathbb{R} & + & 0 \\
\hline
\mathbb{Z} & \times & 1 \\
\hline
\mathbb{Q} & \times & 1 \\
\hline
\mathbb{R} & \times & 1 \\
\hline
\end{array}
\]
On the other hand, it may be better to use an HTML table with math inside it rather than trying to use MathJax to do the entire table.
I made a table generator for MathJax using MathJax's array : https://isaurssaurav.github.io/mathjax-table-generator/
Usage:
Repo Link :https://github.com/isaurssaurav/mathjax-table-generator ( Any changes are welcome )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With