3

I've used the code below which doesn't seem to be working for my Latex table. I think it might be because I'm using the iopart document class. It gives me the following error.

<inserted text> 
                $
l.456 ...ngth L ($\mu$ m) & Density of PDMS (Kg/m^
                                                  3) \nonumber\\
I've inserted a begin-math/end-math symbol since I think
you left one out. Proceed, with fingers crossed.

! Missing $ inserted.
<inserted text> 
                $
l.457 \mr
\begin{table}
\caption{\label{TableOfValues}Dimensions of example to be solved}
\begin{indented}
\item[]\begin{tabular}{p{0.15in}p{0.3in}p{0.3in}p{0.6in}p{0.2in}p{0.25in}p{0.3in}}
\br
Sr. no & Breadth b ($\mu$ m) & Height h ($\mu$ m) & Young's Modulus E of PDMS (GPa) & Gap g ($\mu$ m) & Length L ($\mu$ m) & Density of PDMS (Kg/m^3) \nonumber\\
\mr
1&300&10&0.750&5&800&970\\
2&300&8&0.750&5&800&970\\
3&300&9&0.750&5&800&970\\
4&300&11&0.750&5&800&970\\
5&300&12&0.750&5&800&970\\
6&300&10&0.750&5&600&970\\
7&300&10&0.750&5&700&970\\
8&300&10&0.750&5&900&970\\
9&300&10&0.750&5&1000&970\\
10&300&10&0.750&3&800&970\\
11&300&10&0.750&4&800&970\\
12&300&10&0.750&6&800&970\\
13&300&10&0.750&7&800&970\\
\br
\end{tabular}
\end{indented}
\end{table}
4

2 Answers 2

3
  • Please always provide MWE (Minimal Working Example, a small complete document, which can be compile as it is and which demonstrate your problem.
  • Since the preamble of your document is unknown, some commands in your table is not defined.
  • For units of variable is very sensible to use the siunitx package. Using it, your problem is avoided.
  • column headers are very long, so the table probably spill out of right text border. A solution is break column headers by use makcell command (defined in the package of the same name) into two lines and use shortens for very long text with explanation at bottom of table:
\documentclass{article}
\usepackage{booktabs, makecell}
\usepackage{siunitx} % package for dummy text

\begin{document}
    \begin{table}
    \sisetup{per-mode=symbol}
\caption{Dimensions of example to be solved}
\label{TableOfValues}
\begin{tabular}{@{}S[table-format=2.0]
                S[table-format=3.0]
                S[table-format=2.0]
                S[table-format=1.3]
                S[table-format=1.0]
                S[table-format=4.0]
                S[table-format=3.0]
                @{}}
    \toprule
{\makecell{Sr.\\ no}} 
    & {\makecell{Breadth\\ b (\si{\micro\metre})}} 
            & {\makecell{Height\\ h (\si{\micro\metre})}}
                & {\makecell{Modulus*\\ E (GPa)}}
                        & {\makecell{Gap\\g (\si{\micro\metre})}}
                            & {\makecell{Length\\ L (\si{\micro\metre})}} 
                                    & {\makecell{Density of\\ PDMS (\si{\kilogram\per\cubic\metre})}} \\
    \midrule
1   &300    &10 &0.750  &5  &800    &970    \\
2   &300    &8  &0.750  &5  &800    &970    \\
3   &300    &9  &0.750  &5  &800    &970    \\
4   &300    &11 &0.750  &5  &800    &970    \\
5   &300    &12 &0.750  &5  &800    &970    \\
6   &300    &10 &0.750  &5  &600    &970    \\
7   &300    &10 &0.750  &5  &700    &970    \\
8   &300    &10 &0.750  &5  &900    &970    \\
9   &300    &10 &0.750  &5  &1000   &970    \\
10  &300    &10 &0.750  &3  &800    &970    \\
11  &300    &10 &0.750  &4  &800    &970    \\
12  &300    &10 &0.750  &6  &800    &970    \\
13  &300    &10 &0.750  &7  &800    &970    \\
    \bottomrule
\multicolumn{7}{l}{\small
*: Young's Modulus E of PDMS (GPa)}
\end{tabular}
    \end{table}
\end{document}

enter image description here

3

Some suggestions and comments:

  • Load the siunitx package and use its \si macro to typeset scientific units. E.g., \si{\micro\meter} and \si{\kilo\gram\per\meter\cubed}.

  • Still using the capabilities of the siunitx package, use its S column type to align the numbers in all 7 columns on their (explicit or implicit) decimal markers.

  • Employ a tabularx environment and use its X column type to typeset the header cells while allowing automatic line breaking. In the example below, I utilize a variable-width and centered version of the X column types. Note that the sum of the variable widths is 7, i.e., the number of columns of type X. (Aside: The relative widths were obtained in part by trial-and-error; the objective was to make the content of all header cells to fit in just two lines.)

enter image description here

\documentclass{article}
\usepackage{tabularx,siunitx,booktabs}
\newcolumntype{T}[1]{S[table-format=#1]}
\newcolumntype{C}[1]{>{\centering\arraybackslash%
    \hsize=#1\hsize\linewidth=\hsize}X}
\sisetup{per-mode=symbol}
\newcommand\mc[2]{\multicolumn{1}{#1}{#2}} % handy shortcut macro
\begin{document}
\begin{table}
\caption{Dimensions of example to be solved} \label{TableOfValues}
\setlength\tabcolsep{4pt}
\begin{tabularx}{\textwidth}{@{} 
  T{2.0}T{3.0}T{2.0}T{1.3}T{1.0}T{4.0}T{3.0} 
  @{}}
\toprule
  \mc{@{}C{0.3}}{Sr.\ no}
& \mc{C{0.75}}{Breadth $b$ (\si{\micro\meter})} 
& \mc{C{0.75}}{Height $h$ (\si{\micro\meter})} 
& \mc{C{2.1}}{Young's Modulus $E$ of PDMS (\si{\giga\pascal})} 
& \mc{C{0.65}}{Gap $g$~(\si{\micro\meter})}
& \mc{C{0.75}}{Length $L$ (\si{\micro\meter})}
& \mc{C{1.7}@{}}{Density of PDMS (\si{\kilo\gram\per\meter\cubed})} \\
\midrule
 1 & 300 & 10 & 0.750 & 5 & 800 & 970\\
 2 & 300 &  8 & 0.750 & 5 & 800 & 970\\
 3 & 300 &  9 & 0.750 & 5 & 800 & 970\\
 4 & 300 & 11 & 0.750 & 5 & 800 & 970\\
 5 & 300 & 12 & 0.750 & 5 & 800 & 970\\
 6 & 300 & 10 & 0.750 & 5 & 600 & 970\\
 7 & 300 & 10 & 0.750 & 5 & 700 & 970\\
 8 & 300 & 10 & 0.750 & 5 & 900 & 970\\
 9 & 300 & 10 & 0.750 & 5 &1000 & 970\\
10 & 300 & 10 & 0.750 & 3 & 800 & 970\\
11 & 300 & 10 & 0.750 & 4 & 800 & 970\\
12 & 300 & 10 & 0.750 & 6 & 800 & 970\\
13 & 300 & 10 & 0.750 & 7 & 800 & 970\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .