1

I am trying to have a table in latex that spans two-column in my thesis paper. Actually, I want to have the following table:

enter image description here

Essentially I have come up with the following table:

enter image description here

The code table is as follows:

\begin{table*}
\begin{tabularx}{\textwidth}{ 
| >{\centering\arraybackslash}p{1cm} |   X | p{0.5cm} | 
  >{\centering\arraybackslash}X |   p{0.5cm}  | 
  > {\centering\arraybackslash}X |   p{0.5cm} | 
}
  \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{table*}

How can I get the my desired table in latex?

2 Answers 2

2

The following MWE replicate table as it is shown in the first image in your question:

enter image description here

\documentclass[twocolumn]{article}
\usepackage{makecell, multirow, tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X}

\begin{document}
    \begin{table*}
    \setcellgapes{3pt}
    \makegapedcells
\begin{tabularx}{\textwidth}{ | *{6}{C|} }
  \hline
\multirow{2.5}{=}{ - - - - }
    &   \multirow{2.5}{=}{ - - - - }
        &   \multicolumn{2}{c|}{ - - - - } 
            &   \multicolumn{2}{c|}{ - - - - }      \\
    \cline{3-6}
    &   & - - - -  & - - - - & - - - - & - - - -    \\ 
    \hline
    &   & - - - -  & - - - - & - - - - & - - - -    \\
    \hline
    &   & - - - -  & - - - - & - - - - & - - - -    \\
    \hline
\end{tabularx}
    \end{table*}
\end{document}

The second image show different table and can be reproduced by your code. So, it is not clear, what you are after.

1
  • Thank you. Your answer fits to my question. Commented Mar 1, 2021 at 7:46
2

Here is a solution with {NiceTabular} of nicematrix.

\documentclass[twocolumn]{article}
\usepackage{nicematrix}

\begin{document}

\begin{table*}

\renewcommand{\arraystretch}{1.5}
\begin{NiceTabular}{*{6}{X[c]}}[hvlines]
\Block{2-1}{ - - - - }
    &   \Block{2-1}{ - - - - }
        &   \Block{1-2}{ - - - - } 
            &&   \Block{1-2}{ - - - - } \\
    &   & - - - -  & - - - - & - - - - & - - - - \\ 
    &   & - - - -  & - - - - & - - - - & - - - - \\
    &   & - - - -  & - - - - & - - - - & - - - - \\
\end{NiceTabular}

\end{table*}

\end{document}

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .