# Undefined control sequence in tabularx

I want to add a table to my latex file in which the text is shown on 2 columns and I get the following error:

Undefined control sequence. <inserted text> {@{}lYYYYYY@{}} \toprule &\multicolumn {2}{c}{\bfseries Sour... l.221 \end{tabularx}


Here is the table:

\begin{table}
\caption{caption).}\label{table:mr}
\begin{tabularx}{\textwidth}{@{}lYYYYYY@{}}
\toprule
&\multicolumn{2}{c}{\bfseries Source}
&\multicolumn{2}{c}{\bfseries Target}
&\multicolumn{2}{c}{\bfseries Target with GANs} \\
\cmidrule(lr){2-3} \cmidrule(l){4-5} \cmidrule(l){6-7}
&Frames
&Score
&Frames
&Score
&Frames
&Score
\\
\midrule
A Constant Rectangle & 43M & 302 & 122 & 0 & \textbf{260K} & \textbf{362} \\
A Moving Square & 43M & 302 & 100 & 0 & \textbf{384K} & \textbf{300} \\
Green Lines & 43M & 302 & 186 & 2 & \textbf{288K} & \textbf{300} \\
Diagonals & 43M & 302 & 100 & 0 & \textbf{383K} & \textbf{330} \\
\bottomrule
\end{tabularx}
\end{table}


This table worked on another document where there was only one column. If the problem is the size of the table then I don't mind if it spreads on both columns but unfortunately adding * didn't work as well.

 \usepackage{booktabs}


is missing. It is needed for \toprule et al

• your table code is fine (but result not looks beautiful).
• what you have (and miss) in preamble, we don't know since you not provide mwe (minimal working example), a complete small document with necessary preamble and your table (however Herbert find it from your error)
• off-topic, see if you might like the following redesign of table:

\documentclass{article}
\usepackage{booktabs, makecell, tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\usepackage{lipsum}

\begin{document}
\lipsum[11]
\begin{table}[htb]
\caption{caption).}\label{table:mr}
\begin{tabularx}{\textwidth}{@{}l *{6}{Y} @{}}
\toprule
\cmidrule(r){2-3} \cmidrule(r){4-5} \cmidrule{6-7}
&Frames
&Score
&Frames
&Score
&Frames
&Score
\\
\midrule
A Constant Rectangle & 43M & 302 & 122 & 0 & \textbf{260K} & \textbf{362} \\
A Moving Square & 43M & 302 & 100 & 0 & \textbf{384K} & \textbf{300} \\
Green Lines & 43M & 302 & 186 & 2 & \textbf{288K} & \textbf{300} \\
Diagonals & 43M & 302 & 100 & 0 & \textbf{383K} & \textbf{330} \\
\bottomrule
\end{tabularx}
\end{table}
\lipsum
\end{document}


which gives

• from text in your question can be concluded that you have twoo column document. in this case your table due to its width had to be spread over two columns, i.e. instead figure you should use figure*.