[Tex/LaTex] Compiling problem

booktabsmath-modetables

I have had the problem of compiling my document with the following table in it:

\begin{table}[!h]
\centering\small
\caption{Thickness measurements on the two tubes.}
\label{tab:Thickness_measurement}
    \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lll}
        \toprule
        Tube & Avareage thickness (mm) & Standard deviation (mm) \\
        \midrule
        [89$^\circ$$_2$/12.7$^\circ$$_1$/89$^\circ$$_2$] & 2.08 & 0.034 \\
        \midrule
        [55$^\circ$$_n$] & 0.254 & 0.027 \\
        \bottomrule
    \end{tabular*}
\end{table}

I'm using MiKTeX and I don't get any error messages or anything peculiar in my log, I just click the compile button and it just starts working and keeps at it forever until I abort it.

I've managed to make it work by replacing [89$^\circ$$_2$/12.7$^\circ$$_1$/89$^\circ$$_2$] with some random text, say f as in this table:

\begin{table}[!h]
\centering\small
\caption{Thickness measurements on the two tubes.}
\label{tab:Thickness_measurement}
    \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lll}
        \toprule
        Tube & Avareage thickness (mm) & Standard deviation (mm) \\
        \midrule
        f & 2.08 & 0.034 \\
        \midrule
        [55$^\circ$$_n$] & 0.254 & 0.027 \\
        \bottomrule
    \end{tabular*}
\end{table}

This is probably rather vague, but does anyone know what can be wrong?

Best Answer

The problem you're encountering is caused by the fact that \midrule can take an optional argument which indicates the thickness of the line to be drawn. Thus, LaTeX scans the string [89$^\circ$$_2$/12.7$^\circ$$_1$/89$^\circ$$_2$] for a unit of measurement, and an error message is generated because no legal unit of measurement (such as pt, cm, etc) is found.

The easiest solution, I think, is to add a blank line after each \midrule instruction, i.e., to write

    \midrule % insert a blank line

    [89$^\circ$$_2$/12.7$^\circ$$_1$/89$^\circ$$_2$] & 2.08 & 0.034 \\
    \midrule % insert a blank line

    [55$^\circ$$_n$] & 0.254 & 0.027 \\

Instead of inserting a blank line, you could also insert \null or \relax immediately after \midrule. (See the posting What is the difference between \relax and {}? for a discussion of the differences between \relax and \null.) A separate solution, already proposed in the answer by @ChristianHupfer, is to exchange the order or [...] and $...$; that way, the first "item" that's scanned after \midrule is a $ rather than a \[ symbol, and no confusion arises.

Here's a full MWE that incorporates these thoughts:

enter image description here

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[!h]
%\centering\small  %% \centering has no effect because tabular* takes up the full text block
\caption{Thickness measurements on the two tubes.}
\label{tab:Thickness_measurement}
\smallskip % probably a good idea to have a bit of space between caption and tabular
\begin{tabular*}{\textwidth}{@{} l @{\extracolsep{\fill}} ll @{}}
\toprule
Tube & Average thickness (mm) & Standard deviation (mm) \\
\midrule\relax
[89$^\circ$$_2$/12.7$^\circ$$_1$/89$^\circ$$_2$] & 2.08 & 0.034 \\
\midrule\relax
[55$^\circ$$_n$] & 0.254 & 0.027 \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
Related Question