# missing $error when creating a table I am going to create a table using the following commands. I use the xepersian package. \begin{latin} \begin{table}[h!] \centering \begin{tabular}{|c c c|} \hline p & q & \varphi_q^p(x)\\ [0.5ex] \hline p & -1 & ‎\vert‎ x \vert^p \\ 2 & 0 & ln(x^2+1) \\ 2 & -0.5 & 2 ‎\sqrt{x^2+1}-2‎ \\ 2 & 1 & ‎\frac{x^2}{x^2+1}‎ \\ 1 & 1 & ‎\frac{‎\vert‎ x ‎\vert‎}{\vert x \vert +1}‎ \\ [1ex] \hline \end{tabular} \label{table:1} \end{table} \end{latin}  Although I used the latin environment I got the error of missing $. How can I solve this problem?

Using the amsmath package for formulas and enclosing them properly, ie $formula$, will remove the error.

\documentclass[12pt]{article}
\usepackage{amsmath}

\begin{latin}
\begin{table}[h!]
\centering
\begin{tabular}{|c c c|}
\hline
p & q & $\varphi_q^p(x)$ \\ [0.5ex]
\hline
p & -1 & ‎$\vert‎ x \vert^p$ \\
2 & 0 & $\ln(x^2+1)$ \\
2 & -0.5 & $2 ‎\sqrt{x^2+1}-2‎$ \\
2 & 1 & ‎$\frac{x^2}{x^2+1}‎$ \\
1 & 1 & ‎$\frac{‎\vert‎ x ‎\vert‎}{\vert x \vert +1}‎$ \\ [1ex]
\hline
\end{tabular}
\label{table:1}
\end{table}
\end{latin}

\end{document}


As Leucippus implies, subscripts (_{}), superscripts (^{}), \frac, \sqrt, \ln, \vert are commands that can only be used in math mode, so you need to enclose them in dollar signs or $$...$$. As such he has answered your question, this answer is just a suggestion for an alternative way of typesetting that table.

Changes:

• I've added the array package, and used *{3}{>{$}c<{$}} as the column specification for the table. This will create three c columns (*{3}) where a $ is inserted at the start (>{$}) and end (<{$}) of each cell, effectively setting all cells in math mode. • I've loaded booktabs and used \toprule, \midrule and \bottomrule instead of \hline, while removing vertical rules. A lot of people prefer this style of tables, see for example the manual of booktabs. • mathtools provides \DeclarePairedDelimiter, with which I've defined the \abs macro to set the absolute values. Additional note: • Often when using [h!] as a float specifier, you will get a warning saying h' specifier changed to ht'. This is because there is no room for the table exactly where you put it, so h is not an option. Therefore it is recommend to use at least ht as float specifiers, thereby giving LaTeX some more freedom as to where the float should be placed. See for example h' float specifier changed to ht' warning when not attempting to specify a float \documentclass[12pt]{article} \usepackage{array,booktabs,mathtools} \DeclarePairedDelimiter\abs{\lvert}{\rvert} \begin{document} \begin{tabular}{*{3}{>{$}c<{\$}}}
\toprule
p & q & \varphi_q^p(x) \\ [0.5ex]
\midrule
p & -1 & ‎\abs{x}^p \\
2 & 0 & \ln(x^2+1) \\
2 & -0.5 & 2 ‎\sqrt{x^2+1}-2‎ \\
2 & 1 & ‎\frac{x^2}{x^2+1}‎ \\
1 & 1 & ‎\frac{‎\abs{x}}{\abs{x}+1}‎ \\
\bottomrule
\end{tabular}
\end{document}