"! Undefined control sequence." errors with table

3,152

It seems you don't need multirow, and the code would be simpler without having tp repeat endlessly \bigstrut: the makecell package defines a \makegapedcells which adds some custom padding at the top and bottom of cells. Additionally, the caption package yields a more sensible spacing between captions and tables, when captions are above tables:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow, makecell, caption}

\begin{document}

\begin{table}[htbp]
  \centering\setcellgapes{4pt}\makegapedcells
  \caption{}
    \begin{tabular}{l|l|l|l|l|l|l}
    \hline
    \hline%
    \multicolumn{1}{r}{} & \multicolumn{2}{c|}{\textbf{S\&P500}} & \multicolumn{2}{c|}{\textbf{GS10}} & \multicolumn{2}{c}{\textbf{TWEXMMTH}} \\
\cline{2-7} \multicolumn{1}{r}{} & \multicolumn{1}{c|}{\textbf{p-value}} & \multicolumn{1}{c|}{\textbf{Yes/No}} & \multicolumn{1}{c|}{\textbf{p-value}} & \multicolumn{1}{c|}{\textbf{Yes/No}} & \multicolumn{1}{c|}{\textbf{p-value}} & \multicolumn{1}{c}{\textbf{Yes/No}} \\
    \hline
    \hline
    \textbf{PFANDB} & 0,000 & Yes & 0,193 & No & 0,487 & No \\
    \hline
    \textbf{PRAWM} & 0,001 & Yes & 0,287 & No & 0,601 & No \\
    \hline
    \textbf{PNRG} & 0,001 & Yes & 0,002 & Yes & 0,543 & No \\
    \hline
    \textbf{PMETA} & 0,014 & Yes & 0,052 & No & 0,537 & No \\
    \hline
    \textbf{GOLD} & 0,359 & No & 0,709 & No & 0,166 & No \\
    \hline
    \hline
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

\end{document} 

enter image description here

Share:
3,152
Ngoc Long
Author by

Ngoc Long

Updated on November 20, 2020

Comments

  • Ngoc Long
    Ngoc Long almost 3 years

    I want to insert a table into my document with latex:

    \begin{table}[htbp]
      \centering
      \caption{}
        \begin{tabular}{l|l|l|l|l|l|l}
        \hline
        \hline
        \multicolumn{1}{r}{\multirow{}} & \multicolumn{2}{c|}{\textbf{S\&P500}} & \multicolumn{2}{c|}{\textbf{GS10}} & \multicolumn{2}{c}{\textbf{TWEXMMTH}} \bigstrut\\
    \cline{2-7}    \multicolumn{1}{r}{} & \multicolumn{1}{c|}{\textbf{p-value}} & \multicolumn{1}{c|}{\textbf{Yes/No}} & \multicolumn{1}{c|}{\textbf{p-value}} & \multicolumn{1}{c|}{\textbf{Yes/No}} & \multicolumn{1}{c|}{\textbf{p-value}} & \multicolumn{1}{c}{\textbf{Yes/No}} \bigstrut\\
        \hline
        \hline
        \textbf{PFANDB} & 0,000 & Yes   & 0,193 & No    & 0,487 & No \bigstrut\\
        \hline
        \textbf{PRAWM} & 0,001 & Yes   & 0,287 & No    & 0,601 & No \bigstrut\\
        \hline
        \textbf{PNRG} & 0,001 & Yes   & 0,002 & Yes   & 0,543 & No \bigstrut\\
        \hline
        \textbf{PMETA} & 0,014 & Yes   & 0,052 & No    & 0,537 & No \bigstrut\\
        \hline
        \textbf{GOLD} & 0,359 & No    & 0,709 & No    & 0,166 & No \bigstrut\\
        \hline
        \hline
        \end{tabular}%
      \label{tab:addlabel}%
    \end{table}%
    

    but it returns all the time the errors:

    ! Undefined control sequence.
    \@sharp ->\multirow
    {}
    l.58 \multicolumn{1}{r}{\multirow{}}
    & \multicolumn{2}{c|}{\textbf{S\&P5...
    The control sequence at the end of the top line
    of your error message was never \def'ed. If you have
    misspelled it (e.g., `\hobx'), type `I' and the correct
    spelling (e.g., `I\hbox'). Otherwise just continue,
    and I'll forget about whatever was undefined.
    LaTeX Font Info: Font shape `T1/ppl/bx/n' in size <10.95> not available
    (Font) Font shape `T1/ppl/b/n' tried instead on input line 58.
    ! Undefined control sequence.
    l.58 ...icolumn{2}{c}{\textbf{TWEXMMTH}} \bigstrut
    \\
    The control sequence at the end of the top line
    of your error message was never \def'ed. If you have
    misspelled it (e.g., `\hobx'), type `I' and the correct
    spelling (e.g., `I\hbox'). Otherwise just continue,
    and I'll forget about whatever was undefined.
    ! Undefined control sequence.
    l.59 ...column{1}{c}{\textbf{Contagion}} \bigstrut
    \\
    The control sequence at the end of the top line
    of your error message was never \def'ed. If you have
    misspelled it (e.g., `\hobx'), type `I' and the correct
    spelling (e.g., `I\hbox'). Otherwise just continue,
    and I'll forget about whatever was undefined.
    ! Undefined control sequence.
    l.62 ...s & 0,193 & No & 0,487 & No \bigstrut
    \\
    The control sequence at the end of the top line
    of your error message was never \def'ed. If you have
    misspelled it (e.g., `\hobx'), type `I' and the correct
    spelling (e.g., `I\hbox'). Otherwise just continue,
    and I'll forget about whatever was undefined.
    ! Undefined control sequence.
    l.64 ...s & 0,287 & No & 0,601 & No \bigstrut
    \\
    The control sequence at the end of the top line
    of your error message was never \def'ed. If you have
    misspelled it (e.g., `\hobx'), type `I' and the correct
    spelling (e.g., `I\hbox'). Otherwise just continue,
    and I'll forget about whatever was undefined.
    ! Undefined control sequence.
    l.66 ...s & 0,002 & Yes & 0,543 & No \bigstrut
    \\
    The control sequence at the end of the top line
    of your error message was never \def'ed. If you have
    misspelled it (e.g., `\hobx'), type `I' and the correct
    spelling (e.g., `I\hbox'). Otherwise just continue,
    and I'll forget about whatever was undefined.
    ! Undefined control sequence.
    l.68 ...s & 0,052 & No & 0,537 & No \bigstrut
    \\
    The control sequence at the end of the top line
    of your error message was never \def'ed. If you have
    misspelled it (e.g., `\hobx'), type `I' and the correct
    spelling (e.g., `I\hbox'). Otherwise just continue,
    and I'll forget about whatever was undefined.
    ! Undefined control sequence.
    l.70 ... & 0,709 & No & 0,166 & No \bigstrut
    \\
    The control sequence at the end of the top line
    of your error message was never \def'ed. If you have
    misspelled it (e.g., `\hobx'), type `I' and the correct
    spelling (e.g., `I\hbox'). Otherwise just continue,
    and I'll forget about whatever was undefined....
    

    I don't really understand. Can someone explain to me? Thank you in advance!

    • David Carlisle
      David Carlisle almost 6 years
      \multirow is not a standard command you need to define it. For example \usepackage{multirow} similarly \bigstrut needs to be defined.
    • David Carlisle
      David Carlisle almost 6 years
      however if you define \multrow as in the multirow package it needs values to know how many rows to span so your use here \multirow{} will give further errors. The best thing to do is simply delete all the \multirow and \bigstrut commands to get an error free table.
  • Bernard
    Bernard almost 6 years
    You're welcome. Glad to have been helpful!