1

I want to reproduce this kind of table: 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

4
  • 3
    {\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
0

Here's a code which works and looks better:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tabularx, booktabs, makecell, multirow, caption}
\renewcommand{\theadfont}{\normalsize\bfseries\boldmath}
\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
\multirow{3.5}{*}{\thead{Reference machine:\\ R == Tomita15}} & \multicolumn{2}{c}{\thead{Subject machine:\\
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} 

enter image description here

0
2

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy