[Tex/LaTex] Creating a table with maths symbols

math-modetables

I have a problem with the table below. I tried to fix it but it still gives the same error. I get this error:

! Missing $ inserted.<inserted text>$ \textbf{\rho (kg/m^{3})} and !
Extra }, or forgotten $.<recently read> \egroup \textbf{\rho
(kg/m^{3})}

Table:

 \begin{center} \textbf{Table4-1: Parameters used}
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\textbf{\rho (kg/m^{3})} & \textbf{W (m)}  & \textbf{H (m)} & \textbf{L (m)} & \textbf{E (N/m^{2})} & \textbf{m (kg/m)} \\ \hline
2500 & 0.3 & 0.3 & 4 & 30x10^{9} & 225  \\ \hline

\end{tabular}
\end{center}

Best Answer

A solution with makecell and siunitx. The former allows for a common formatting of column heads anf gives tools for some vertical padding of rows. The latter has macros for a conistent formatting of numbers (num command) and units (\sicommand):

\documentclass[a4paper,11pt,twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{makecell, caption, chngcntr} %
\renewcommand\theadfont{\normalsize\bfseries\boldmath}

\captionsetup{font=bf}
\usepackage{siunitx} %
\sisetup{detect-all}
\counterwithin{table}{section}
\renewcommand\thetable{\thesection-\arabic{table}}

\begin{document}%

\setcounter{section}{4}

\begin{table}
  \caption{Parameters used}\setcellgapes{5pt}\makegapedcells
  \centering%
  \begin{tabular}{|*{6}{c|}}
    \hline
    \thead{$\rho$ (\si{\kg/m^{3}}) }& \thead{W (m)} & \thead{H (m}) & \thead{L (m)} & \thead{E (\si{\N/\m²}}) & \thead{m (\si{kg/m})} \\
    \hline
    2500 & 0.3 & 0.3 & 4 & \num{30e9} & 225 \\ %
    \hline
  \end{tabular}
\end{table}

\end{document} 

enter image description here

Related Question