Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to create similar table using LaTeX:

enter image description here

I have tried to use \tabular and \multicolumn, but every time I get something wrong.

Could someone help me?

  \documentclass{article}
  \begin{document}

\begin{tabular}{ | l | l | l | l | l | l | l | l | l | l | l | l | l | l | l | l | l | l | l | l | l | l | }
 \hline
\  & \  & \  & \  & \  & \  & \  & \  & \  & \  & \  & \  & \  & \  & \  & \  & \    & \  & \  & \  & \  & \  \\ \hline
\  & \  & \  & \  & \  & \  & \  & \  & \  & \  & \  & \  & \  & \  & \  & \  & \     & \  & \  & \  & \  & \  \\ \hline
 &  & No 0 &  &  &  &  & No  1 &  &  &  &  & No  2 &  &  &  &  & No 3 &  &  &  &      \\ \hline
      &  & TT & FF & P & R & F & TT & FF & P & R & F & TT & FF & P & R & F & TP & FP & P & R & F \\ \hline


     A & A1 & 2 & 3 & 0.4 & 0.4 & 0.4 & 3 & 7 & 0.3 & 0.6 & 0.54 & 5 & 12 & 0.28 & 1 & 0.79 & 5 & 0 & 1 & 1 & 1 \\ \hline
      & A2 & 1 & 12 & 0.08 & 0.5 & 0.31 & 2 & 14 & 0.13 & 1 & 0.56 & 2 & 4 & 0.33 & 1 & 0.82 & 2 & 0 & 1 & 1 & 1 \\ \hline
      & A3 & 0 & 0 & na & na & 0 & 0 & 4 & 0 & na & 0 & 0 & 0 & na & na & na & 0 & 0 & na & na & na \\ \hline

     B & B1 & 2 & 9 & 0.18 & 0.5 & 0.42 & 3 & 26 & 0.12 & 0.75 & 0.47 & 4 & 30 & 0.12 & 1 & 0.54 & 4 & 0 & 1 & 1 & 1 \\ \hline
     & B2 & 0 & 3 & 0 & 0 & na & 1 & 3 & 0.25 & 0.5 & 0.45 & 2 & 2 & 0.5 & 1 & 0.9 & 2 & 0 & 1 & 1 & 1 \\ \hline
     & B3 & 0 & 1 & 0 & 0 & na & 1 & 3 & 0.25 & 1 & 0.75 & 1 & 2 & 0.33 & 1 & 0.82 & 1 & 0 & 1 & 1 & 1 \\ \hline

      C & C1 & 1 & 56 & 0.02 & 1 & 0.14 & 1 & 38 & 0.03 & 1 & 0.19 & 1 & 11 & 0.08 & 1 & 0.45 & 1 & 0 & 1 & 1 & 1 \\ \hline
    & C2 & 0 & 8 & 0 & 0 & na & 1 & 1 & 0.5 & 1 & 0.9 & 1 & 1 & 0.5 & 1 & 0.9 & 1 & 0 & 1 & 1 & 1 \\ \hline
    & C3 & 0 & 2 & 0 & 0 & na & 0 & 7 & 0 & 0 & na & 1 & 4 & 0.2 & 1 & 0.69 & 1 & 0 & 1 & 1 & 1 \\ \hline

      D & D1 & 0 & 37 & 0 & 0 & na & 2 & 16 & 0.11 & 0.33 & 0.27 & 3 & 18 & 0.14 & 0.5 & 0.39 & 3 & 0 & 1 & 1 & 0.53 \\ \hline
   & D2 & 0 & 2 & 0 & 0 & na & 3 & 2 & 0.4 & 0.5 & 0.49 & 4 & 2 & 0.67 & 1 & 0.95 & 4 & 0 & 1 & 1 & 1 \\ \hline
    & D3 & 0 & 0 & na & na & 0 & 0 & 6 & 0 & na & 0 & 0 & 1 & 0 & na & na & 0 & 0  & na & na & na \\ \hline
    \end{tabular}
    \end{document}
share|improve this question

2 Answers 2

This takes inspiration from an answer given by Bernard using makecell. I used this because it seems that the use of vertical rules is essential to the look desired for this question and that excludes use of booktabs. Like booktabs, makecell adds some extra spacing to LaTeX's rather squashed default tabular layout, and supports the use of variable width rules.

Caveat emptor... The code may suffer from the fact that I've never used this package before.

The tabular will not fit horizontally without reducing its size (whatever package is used) so it is typeset in landscape orientation instead:

\documentclass{article}
\usepackage{multirow,makecell}
\renewcommand{\theadfont}{\bfseries}
\usepackage{pdflscape}
\begin{document}
\begin{landscape}
  \noindent\begin{tabular}{ !{\vrule width1.2pt}c!{\vrule width1.2pt}c!{\vrule width1.2pt}*{5}{c}!{\vrule width1.2pt}*{5}{c}!{\vrule width1.2pt}*{5}{c}!{\vrule width1.2pt}*{5}{c}!{\vrule width1.2pt} }
 \Xcline{3-22}{1.2pt}
   \multicolumn{2}{c!{\vrule width1.2pt}}{}  & \multicolumn{5}{c!{\vrule width1.2pt}}{\thead{No 0}}  & \multicolumn{5}{c!{\vrule width1.2pt}}{\thead{No 1}}  & \multicolumn{5}{c!{\vrule width1.2pt}}{\thead{No 2}}  & \multicolumn{5}{c!{\vrule width1.2pt}}{\thead{No 3}}     \\\Xcline{3-22}{1.2pt}
   \multicolumn{2}{c!{\vrule width1.2pt}}{}  & \thead{TT} & \thead{FF} & \thead{P} & \thead{R} & \thead{F} & \thead{TT} & \thead{FF} & \thead{P} & \thead{R} & \thead{F} & \thead{TT} & \thead{FF} & \thead{P} & \thead{R} & \thead{F} & \thead{TP} & \thead{FP} & \thead{P} & \thead{R} & \thead{F} \\\Xhline{1.2pt}
     \multirowthead{3}{A} & \thead{A1} & 2 & 3 & 0.4 & 0.4 & 0.4 & 3 & 7 & 0.3 & 0.6 & 0.54 & 5 & 12 & 0.28 & 1 & 0.79 & 5 & 0 & 1 & 1 & 1 \\\Xcline{2-2}{1.2pt}
      & \thead{A2} & 1 & 12 & 0.08 & 0.5 & 0.31 & 2 & 14 & 0.13 & 1 & 0.56 & 2 & 4 & 0.33 & 1 & 0.82 & 2 & 0 & 1 & 1 & 1 \\\Xcline{2-2}{1.2pt}
      & \thead{A3} & 0 & 0 & na & na & 0 & 0 & 4 & 0 & na & 0 & 0 & 0 & na & na & na & 0 & 0 & na & na & na \\\Xhline{1.2pt}
     \multirowthead{3}{B} & \thead{B1} & 2 & 9 & 0.18 & 0.5 & 0.42 & 3 & 26 & 0.12 & 0.75 & 0.47 & 4 & 30 & 0.12 & 1 & 0.54 & 4 & 0 & 1 & 1 & 1 \\\Xcline{2-2}{1.2pt}
     & \thead{B2} & 0 & 3 & 0 & 0 & na & 1 & 3 & 0.25 & 0.5 & 0.45 & 2 & 2 & 0.5 & 1 & 0.9 & 2 & 0 & 1 & 1 & 1 \\\Xcline{2-2}{1.2pt}
     & \thead{B3} & 0 & 1 & 0 & 0 & na & 1 & 3 & 0.25 & 1 & 0.75 & 1 & 2 & 0.33 & 1 & 0.82 & 1 & 0 & 1 & 1 & 1 \\\Xhline{1.2pt}
    \multirowthead{3}{C} & \thead{C1} & 1 & 56 & 0.02 & 1 & 0.14 & 1 & 38 & 0.03 & 1 & 0.19 & 1 & 11 & 0.08 & 1 & 0.45 & 1 & 0 & 1 & 1 & 1 \\\Xcline{2-2}{1.2pt}
    & \thead{C2} & 0 & 8 & 0 & 0 & na & 1 & 1 & 0.5 & 1 & 0.9 & 1 & 1 & 0.5 & 1 & 0.9 & 1 & 0 & 1 & 1 & 1 \\\Xcline{2-2}{1.2pt}
    & \thead{C3} & 0 & 2 & 0 & 0 & na & 0 & 7 & 0 & 0 & na & 1 & 4 & 0.2 & 1 & 0.69 & 1 & 0 & 1 & 1 & 1 \\\Xhline{1.2pt}
   \multirowthead{3}{D}& \thead{D1} & 0 & 37 & 0 & 0 & na & 2 & 16 & 0.11 & 0.33 & 0.27 & 3 & 18 & 0.14 & 0.5 & 0.39 & 3 & 0 & 1 & 1 & 0.53 \\\Xcline{2-2}{1.2pt}
   & \thead{D2} & 0 & 2 & 0 & 0 & na & 3 & 2 & 0.4 & 0.5 & 0.49 & 4 & 2 & 0.67 & 1 & 0.95 & 4 & 0 & 1 & 1 & 1 \\\Xcline{2-2}{1.2pt}
    & \thead{D3} & 0 & 0 & na & na & 0 & 0 & 6 & 0 & na & 0 & 0 & 1 & 0 & na & na & 0 & 0  & na & na & na \\\Xhline{1.2pt}
  \end{tabular}
\end{landscape}
\end{document}

Tabular in landscape orientation

share|improve this answer

Here again (and offering an alternative to @cfr 's solution —and also copying part of it :P—). With tap. Far from okay, but tap offers some flexibility.

enter image description here

\documentclass{scrartcl}

\input{tap}
\usepackage{pdflscape}

\begin{document}

\deftable\tmptable
\begintable
    \begintableformat
        & \center
    \endtableformat
    \B"- @2                       ! @20 \=                                                                                                                                                                                                                            \E!
    \B": @2                       ! @5 \textbf{No 1}                                       ! @5 \textbf{No 2}                                       ! @5 \textbf{No 3}                                       ! @5 \textbf{No 4}                                       \E!
    \B"- @2                       ! @20 \=                                                                                                                                                                                                                            \E!
    \B": @2                       ! \emph{TT} " \emph{FF} " \emph{P} " \emph{R} " \emph{F} ! \emph{TT} " \emph{FF} " \emph{P} " \emph{R} " \emph{F} ! \emph{TT} " \emph{FF} " \emph{P} " \emph{R} " \emph{F} ! \emph{TT} " \emph{FF} " \emph{P} " \emph{R} " \emph{F} \E!
    \=
    \B!: \textbf{A} ! \textbf{A1} ! 2         " 3         " 0.4      " 0.4      " 0.4      ! 3         " 7         " 0.3      " 0.6      " 0.54     ! 5         " 12        " 0.28     " 1        " 0.79     ! 5         " 0         " 1        " 1        " 1        \E!
    \B!-            ! \=          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          \E!
    \B!:            ! \textbf{A2} ! 1         " 12        " 0.08     " 0.5      " 0.31     ! 2         " 14        " 0.13     " 1        " 0.56     ! 2         " 4         " 0.33     " 1        " 0.82     ! 2         " 0         " 1        " 1        " 1        \E!
    \B!-            ! \=          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          \E!
    \B!:            ! \textbf{A3} ! 0         " 0         " na       " na       " 0        ! 0         " 4         " 0        " na       " 0        ! 0         " 0         " na       " na       " na       ! 0         " 0         " na       " na       " na       \E!
    \=
    \B!: \textbf{B} ! \textbf{B1} ! 2         " 9         " 0.18     " 0.5      " 0.42     ! 3         " 26        " 0.12     " 0.75     " 0.47     ! 4         " 30        " 0.12     " 1        " 0.54     ! 4         " 0         " 1        " 1        " 1        \E!
    \B!-            ! \=          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          \E!
    \B!:            ! \textbf{B2} ! 0         " 3         " 0        " 0        " na       ! 1         " 3         " 0.25     " 0.5      " 0.45     ! 2         " 2         " 0.5      " 1        " 0.9      ! 2         " 0         " 1        " 1        " 1        \E!
    \B!-            ! \=          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          \E!
    \B!:            ! \textbf{B3} ! 0         " 1         " 0        " 0        " na       ! 1         " 3         " 0.25     " 1        " 0.75     ! 1         " 2         " 0.33     " 1        " 0.82     ! 1         " 0         " 1        " 1        " 1        \E!
    \=
    \B!: \textbf{C} ! \textbf{C1} ! 1         " 56        " 0.02     " 1        " 0.14     ! 1         " 38        " 0.03     " 1        " 0.19     ! 1         " 11        " 0.08     " 1        " 0.45     ! 1         " 0         " 1        " 1        " 1        \E!
    \B!-            ! \=          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          \E!
    \B!:            ! \textbf{C2} ! 0         " 8         " 0        " 0        " na       ! 1         " 1         " 0.5      " 1        " 0.9      ! 1         " 1         " 0.5      " 1        " 0.9      ! 1         " 0         " 1        " 1        " 1        \E!
    \B!-            ! \=          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          \E!
    \B!:            ! \textbf{C3} ! 0         " 2         " 0        " 0        " na       ! 0         " 7         " 0        " 0        " na       ! 1         " 4         " 0.2      " 1        " 0.69     ! 1         " 0         " 1        " 1        " 1        \E!
    \=
    \B!: \textbf{D} ! \textbf{D1} ! 0         " 37        " 0        " 0        " na       ! 2         " 16        " 0.11     " 0.33     " 0.27     ! 3         " 18        " 0.14     " 0.5      " 0.39     ! 3         " 0         " 1        " 1        " 0.53     \E!
    \B!-            ! \=          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          \E!
    \B!:            ! \textbf{D2} ! 0         " 2         " 0        " 0        " na       ! 3         " 2         " 0.4      " 0.5      " 0.49     ! 4         " 2         " 0.67     " 1        " 0.95     ! 4         " 0         " 1        " 1        " 1        \E!
    \B!-            ! \=          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          !           "           "          "          "          \E!
    \B!:            ! \textbf{D3} ! 0         " 0         " na       " na       " 0        ! 0         " 6         " 0        " na       " 0        ! 0         " 1         " 0        " na       " na       ! 0         " 0         " na       " na       " na       \E!
    \=
\endtable

\begin{landscape}
    \mbox{\begintable\tmptable\endtable}
\end{landscape}

\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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