2

How do I make a table in LaTeX as shown below?

Table expected

  • 3
    Sorry, but this looks horrible. I bet there is a better way of representing the information, are you open for suggestions? – Johannes_B Oct 7 '15 at 16:39
  • 1
    Do you try to do anything regarding this table? Pleas show your effort! Retyping your table is not quit fun job ... – Zarko Oct 7 '15 at 16:41
  • The table is easy, but it does not look nice – user31729 Oct 7 '15 at 16:44
  • Any other ideas for a better format? @Zarko I am working on it and hope to provide some test soon – SimonB Oct 7 '15 at 16:47
  • Welcome to TeX SX, though :o) – Bernard Oct 7 '15 at 16:50
7

A suggestion: Merging the A,B,C,D identifiers with M/S respectively, deleting all vertical lines and removing almost any horizontal lines (the 'bad' layout' is below)

'Omitting' cells can be done with \multicolumn{1}{c}{}, i.e. empty multicolumn statements. Partial horizontal lines are done with \cline{startingcolumn-endcolumn} etc.

\documentclass[12pt]{article}
\usepackage{booktabs}


\begin{document}

{\bfseries
\begin{tabular}{*{9}{c}}
  \multicolumn{1}{c}{} & \multicolumn{8}{c}{Treatment 1} \tabularnewline
  \multicolumn{1}{c}{} &  MA & SA &  MB & SB &  MC & SC &  MD & SD\tabularnewline
\midrule[2pt]
F1 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline

F2 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline

F3 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline

F4 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline

\tabularnewline
\multicolumn{1}{c}{} & \multicolumn{8}{c}{Treatment 2} \tabularnewline
\multicolumn{1}{c}{} &  MA & SA &  MB & SB &  MC & SC &  MD & SD\tabularnewline
\midrule[2pt]
F1 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline

F2 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline

F3 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline

F4 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline

\end{tabular}
}

\end{document}

enter image description here

Just for comparision: The bad table layout -- Judge yourself...

\documentclass[12pt]{article}


\begin{document}

{\bfseries
\begin{tabular}{|*{9}{c|}}
  \cline{2-9}
  \multicolumn{1}{c|}{} & \multicolumn{8}{c|}{Treatment 1} \tabularnewline
  \cline{2-9}
  \multicolumn{1}{c|}{} &  \multicolumn{2}{c|}{A}&  \multicolumn{2}{c|}{B} & \multicolumn{2}{c|}{C} & \multicolumn{2}{c|}{D} \tabularnewline
  \cline{2-9}
  \multicolumn{1}{c|}{} &  M & S &  M & S &  M & S &  M & S\tabularnewline
\hline
F1 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline
\hline
F2 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline
\hline
F3 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline
\hline
F4 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline
\hline
  \multicolumn{1}{c|}{} & \multicolumn{8}{c|}{Treatment 2} \tabularnewline
  \cline{2-9}
  \multicolumn{1}{c|}{} &  \multicolumn{2}{c|}{A}&  \multicolumn{2}{c|}{B} & \multicolumn{2}{c|}{C} & \multicolumn{2}{c|}{D} \tabularnewline
  \cline{2-9}
  \multicolumn{1}{c|}{} &  M & S &  M & S &  M & S &  M & S\tabularnewline
\hline
F1 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline
\hline
F2 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline
\hline
F3 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline
\hline
F4 &   1 & 2 &  3 & 4 &  5 & 6 &  7 & 8\tabularnewline
\hline
\end{tabular}
}

\end{document}

enter image description here

  • Thanks a lot. Can I somehow change the font styles/size? – SimonB Oct 7 '15 at 17:22
  • @SimonB: Remove \bfseries, for example and replace it with \large etc. This depends on your choice, of course. For choosing a completely different font family use a font package – user31729 Oct 7 '15 at 17:24
  • Thanks. And if I want to add a title to the table. How can I proceed? – SimonB Oct 7 '15 at 17:26
  • @SimonB: You mean the caption? – user31729 Oct 7 '15 at 17:27
  • Yeah. I have tried \caption{} right after the \begin{tabular} but it does not work. – SimonB Oct 7 '15 at 17:30
2

Here is a variant:

    F1 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\
    F2 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\\
    F3 & 3 & 4 & 5 & 6 & 7 & 8\\
    F4 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11\\

Enter image description here

  • The left justification of Treatment disrupts the look, in my point of view, but that's perhaps only my opinion – user31729 Oct 7 '15 at 19:25
  • @Christian Hupfer: I did it on purpose, due to the F_i column, which itself disrupts symmetry in the layout, not to mention the use of boldface for ‘Treatment’. To my taste, it looks better than centred, especially if there is a centred caption. You can try modify it and tell me if you have some time, I'd be curious to have your opinion comparing both possibilities. – Bernard Oct 7 '15 at 19:33
  • No, it's just my opinion. I would not use it this way -- it's only a 'tiny' feature of your nice solution (+1) – user31729 Oct 7 '15 at 19:34

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.