Graphics, Figures & TablesProblem with equation in table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
mexxwel
Posts: 1
Joined: Mon Nov 16, 2015 10:54 am

Problem with equation in table

Post by mexxwel »

Hey there!

I'd like to create a table with two parameters and the corresponding equation.
Somehow Latex gives me the error: '! Missing $ inserted.' and I don't know what that means...

Code: Select all

\begin{table}[H]
\centering
\caption{XXX}
\label{tab:XXX}
\begin{adjustbox}{max width=\textwidth}
	\begin{tabular}{c c}
	\hline\hline
	\vspace{0.25cm}
	Parameter & Mathematical Equation \\	\hline 
	\vspace{0.25cm}
	Standard Deviation & \sigma=\sqrt{\frac{\sum(X-\mu)$^2$}{N}} \\
	\vspace{0.25cm}
	Variance & \sigma^2=\frac{\sum(X-\mu)$^2$}}{N} \\
	\\ \hline
	\end{tabular}
\end{adjustbox}
\end{table}
Thanks for your help!

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Problem with equation in table

Post by Johannes_B »

Welcome,

you put only the superscript in mathmode, but the whole equation needs to be in mathmode. Below, an example that sets the second column in math mode as a whole.

Code: Select all

\documentclass{article}
\usepackage{mathtools}
\usepackage{booktabs}
\usepackage{array}
\setlength{\defaultaddspace}{.75em}
\begin{document}
\begin{tabular}{c >{$\displaystyle}c<{$}}
			\toprule
			Parameter          & $Mathematical Equation$ \\
			\midrule
			Standard Deviation & \sigma=\sqrt{\frac{\sum(X-\mu)^2}{N}} \\\addlinespace
			Variance           & \sigma^2=\frac{\sum(X-\mu)^2}{N} \\
			\bottomrule
		\end{tabular}
\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply