0

I need a table with this format:

enter image description here

I need to use tabularx. I already tried something but it doesn't work... I keep getting the error message '! Missing number, treated as zero.'

\documentclass{scrartcl}
\usepackage{tabularx}
\begin{document}

\begin{tabularx}{\textwidth}{ >{\centering\arraybackslash}p{1cm} | X | p{0.5cm} | >{\centering\arraybackslash}X | p{0.5cm}  > {\centering\arraybackslash}X | p{0.5cm} }
\multirow{2}{*}{\textbf{Code}} & \multicolumn{2}{c}{\multirow{2}{}{\textbf{Richtige Bewertung}}} & \multicolumn{4}{c}{\textbf{Falsche Bewertung}} \\ \cline{4-7}
& & \multicolumn{2}{c}{\textbf{False Negatives}} & \multicolumn{2}{c}{\textbf{False Positives}} \\ \hline\hline
$\boldsymbol{A_1}$ & \StrokeFive\StrokeFive\StrokeTwo (12) & & & & & \\ \hline
$\boldsymbol{A_2}$ & & & & & & \\ \hline
$\boldsymbol{B_1}$ & & & & & & \\ \hline
$\boldsymbol{B_2}$ & & & & & & \\ \hline
$\boldsymbol{C_1}$ & & & & & & \\ \hline
$\boldsymbol{C_2}$ & & & & & & \\ \hline
$\boldsymbol{D_1}$ & & & & & & \\ \hline
$\boldsymbol{D_2}$ & & & & & & \\
\end{tabularx}

\end{document}

Can anyone help me with this? Thank you very much in advance. Daniel

0

You have forgotten a lot of vertical bars | in the declaration of your table.

Also, you must remember, that if you use \multicolumn, you are redefining the look of the column, including the vertical bars. You have to repeat the definition of vertical bars in that case.

Next, you were missing some important packages, for example multirow, to get the \multirow-command working. Package ifsym with option [misc] to make the command \StrokeFive working.

You should think about using the >{$}...<{$} magic, to save from repeatedly inserting the $ in the first column.

I was not able to find a package for the command \boldsymbol. I replaced it by \mathbf which might be the same.

First example:

\documentclass{scrartcl}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage[misc]{ifsym}        % for \StrokeFive

\begin{document}

\begin{tabularx}{\textwidth}{ |% <-- was missing!
  >{\centering\arraybackslash}p{1cm} | 
  X | 
  p{0.5cm} | 
  >{\centering\arraybackslash}X | 
  p{0.5cm}  | % <-- bar missing
  > {\centering\arraybackslash}X | 
  p{0.5cm} | % <--- bar missing
}
  \hline
  \textbf{Code}
  & \multicolumn{2}{c|}{\textbf{Richtige Bewertung}}
%  & \multicolumn{2}{c}{ \multirow{2}{}{\textbf{Richtige Bewertung}}}
  & \multicolumn{4}{c|}{\textbf{Falsche Bewertung}} \\ 
  \cline{4-7}
  & \multicolumn{2}{c|}{}
  & \multicolumn{2}{c|}{\textbf{False Negatives}} 
  & \multicolumn{2}{c|}{\textbf{False Positives}} \\ 
  \hline  %% in your example was only one line!
$\mathbf{A_1}$ & \StrokeFive\StrokeFive\StrokeTwo (12) & & & & & \\ \hline
$\mathbf{A_2}$ & & & & & & \\ \hline
$\mathbf{B_1}$ & & & & & & \\ \hline
$\mathbf{B_2}$ & & & & & & \\ \hline
$\mathbf{C_1}$ & & & & & & \\ \hline
$\mathbf{C_2}$ & & & & & & \\ \hline
$\mathbf{D_1}$ & & & & & & \\ \hline
$\mathbf{D_2}$ & & & & & & \\ \hline
\end{tabularx}

\end{document}

Second example, using >{$}...<{$} to save typing:

\documentclass{scrartcl}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage[misc]{ifsym}        % for \StrokeFive

\begin{document}

\begin{tabularx}{\textwidth}{ |% <-- was missing!
  >{\centering\arraybackslash $}p{1cm} <{$} | % <---- added math mode
                                % magic here! 
  X | 
  p{0.5cm} | 
  >{\centering\arraybackslash}X | 
  p{0.5cm}  | % <-- bar missing
  > {\centering\arraybackslash}X | 
  p{0.5cm} | % <--- bar missing
}
  \hline
  \multicolumn{1}{|c}{\textbf{Code}} % \multicolumn gets rid of math
                                % mode here!
  & \multicolumn{2}{c|}{\textbf{Richtige Bewertung}}
%  & \multicolumn{2}{c}{ \multirow{2}{}{\textbf{Richtige Bewertung}}}
  & \multicolumn{4}{c|}{\textbf{Falsche Bewertung}} \\ 
  \cline{4-7}
  & \multicolumn{2}{c|}{}
  & \multicolumn{2}{c|}{\textbf{False Negatives}} 
  & \multicolumn{2}{c|}{\textbf{False Positives}} \\ 
  \hline %% in your example was only one line!
\mathbf{A_1} & \StrokeFive\StrokeFive\StrokeTwo (12) & & & & & \\ \hline
\mathbf{A_2} & & & & & & \\ \hline
\mathbf{B_1} & & & & & & \\ \hline
\mathbf{B_2} & & & & & & \\ \hline
\mathbf{C_1} & & & & & & \\ \hline
\mathbf{C_2} & & & & & & \\ \hline
\mathbf{D_1} & & & & & & \\ \hline
\mathbf{D_2} & & & & & & \\ \hline
\end{tabularx}

\end{document}

Result for both examples:

enter image description here

  • Thank you very much :) That was really helpfull, especially the >{$}...<{$} part is really nice. I did not know that. – Daniel Wehner Jan 12 '17 at 8:00
  • My pleasure if it helped. – Jan Jan 12 '17 at 11:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.