Graphics, Figures & TablesEquation inside a table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
palmuser
Posts: 2
Joined: Thu Sep 24, 2009 10:28 pm

Equation inside a table

Post by palmuser »

Hi All,

I have a problem of creating an equation inside a table. An error message "! Missing $ inserted" is shown at line

Code: Select all

\alpha = 10
from the example below:

Code: Select all

\begin{table}[h]
\caption{Example of Equation inside Table}
\begin{center}
\begin{tabular}{|l|}
\hline
This table has 1 row and 1 column\\
\begin{equation}
\alpha = 10
\end{equation}
\hline
\end{tabular}
\end{center}
\end{table}
Please help me to point out the problem
Thank you,

Palmuser

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Equation inside a table

Post by Stefan Kottwitz »

Hi Palmuser,

welcome to the board!
  • the equation would be accepted if it's set in a \parbox or a p-column,
  • put a \\ (\tabularnewline) after \end{equation} and before \hline,
  • I would not use \begin{center}...\end{center} inside a table environment because it's causing additional vertical space, use \centering instead, see center vs. \centering,
  • h is not much as a positioning option, I would use at least ht.
The code could look like this:

Code: Select all

\begin{table}[ht]
\caption{Example of Equation inside Table}
\centering
\begin{tabular}{|p{4cm}|}
\hline
This table has 1 row and 1 column\\
\begin{equation}
\alpha = 10
\end{equation}\\
\hline
\end{tabular}
\end{table}
Stefan
LaTeX.org admin
palmuser
Posts: 2
Joined: Thu Sep 24, 2009 10:28 pm

Re: Equation inside a table

Post by palmuser »

Thanks Stefan!

It works perfectly. The major problem comes from using center instead of centering.
Post Reply