# Runaway argument constructing a tabularx simple table

I want to reproduce this kind of table:

I tried writing down this code:

\documentclass{article}
\usepackage{tabularx,booktabs}
\begin{document}

\newcolumntype{Y}{>{\centering\arraybackslash}X}
\medskip\noindent
\begin{tabularx}{0.75\textwidth}{c *{4}{Y}}
\toprule
& & \multicolumn{2}{c}{\textbf{Subject machine: S
==Tomita15modified}\\
\cmidrule(lr){3-4}
\multicolumn{2}{c}{\textbf{Reference machine: R == Tomita15} & in
$L(S)$ & in $L(S)^C$\\
\midrule
\multicolumn{2}{c|}{\textbf{in $L(R)$}} &  $|TP|=3$ & $|FN|=3$\\
\hline
\multicolumn{2}{c|}{\textbf{in $L(R)^C$}}  & $|FP|=0$ &
$|TN|=125$\\
\bottomrule
\end{tabularx}
\end{document}


I can't see why it returns me the error:

   Runaway argument?
{c *{4}{Y}} \toprule & & \multicolumn {2}{c}{\textbf {Subject machine\ETC.
! File ended while scanning use of \TX@get@body. <inserted text>


How can I fix this? Is there an easier way to get that table? Thank you for the attention

• {\textbf{Reference machine: R == Tomita15} has two { and one } Dec 20 '17 at 23:14
• I happened to spot that by eye but please in future always post complete documents to make it easy to run the example and debug the problem, a fragment as above can not be tested unless we guess a preamble Dec 20 '17 at 23:15
• You' re right! Thank you! But the outcome is not as I expected: !outcome Do you see where my errors are?
– user151080
Dec 20 '17 at 23:17
• Yes, I admit it's a bit confusing, I'm so sorry
– user151080
Dec 20 '17 at 23:21

Here's a code which works and looks better:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tabularx, booktabs, makecell, multirow, caption}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{document}
\medskip\noindent
\begin{tabularx}{0.75\linewidth}{>{\hsize = 1.4\hsize }Y*{2}{>{\hsize = 0.8\hsize }Y}}
\toprule
S ==Tomita15 modified}}\\
\cmidrule(lr){2-3}
& in
$L(S)$ & in $L(S)^C$\\
\midrule
\thead{in $L(R)$} & $|TP|=3$ & $|FN|=3$\\
\hline
\thead{in $L(R)^C$} & $|FP|=0$ &
$|TN|=125$\\
\bottomrule
\end{tabularx}

\end{document}


You had two missing } in the multicolumn but I also fixed a couple of other things, you don't need/want tabularx for such a table as there is no linebreaking within the cells, so a simple tabular is better. And it is best not to use vertical lines with booktabs (see the booktabs package documentation)

\documentclass{article}
\usepackage{tabularx,booktabs}
\newcommand\hd[1]{\bfseries\begin{tabular}{@{}c@{}}#1\end{tabular}}
\begin{document}

\newcolumntype{Y}{>{\centering\arraybackslash}X}
\medskip\noindent
\begin{tabular}{cccc}
\toprule
\multicolumn{2}{c}{\hd{Reference machine:\\ R == Tomita15}}&
\multicolumn{2}{c}{\hd{Subject machine:\\
S  ==Tomita15modified}}\\
\cmidrule(lr){3-4}
&& in  $L(S)$ & in $L(S)^C$\\
\midrule
\multicolumn{2}{c}{\textbf{in $L(R)$}} &  $|TP|=3$ & $|FN|=3$\\
\midrule
\multicolumn{2}{c}{\textbf{in $L(R)^C$}}  & $|FP|=0$ &
$|TN|=125$\\
\bottomrule
\end{tabular}
\end{document}