表格出现“!未定义的控制序列。”错误

表格出现“!未定义的控制序列。”错误

我想用乳胶在我的文档中插入一个表格:

\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}%

但它总是返回错误:

! 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....

我不太明白。有人能给我解释一下吗?提前谢谢了!

答案1

似乎您不需要multirow,并且代码会更简单,而无需无休止地重复\bigstrutmakecell包定义了一个\makegapedcells,它在单元格的顶部和底部添加了一些自定义填充。此外,caption当标题位于表格上方时,包会在标题和表格之间产生更合理的间距:

\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} 

在此处输入图片描述

相关内容