# How to create a complicated table in latex

I am trying to create a table in LateX that looks like the following:

Could anyone plz tell me what the corresponding LateX code would be? Thank you in advance.

• Welcome to TeX.SX! This table is typographically ill-designed – user31729 Nov 9 '14 at 10:19
• Can you please show us what you have tried so far? It is fun to help you but not to write the numbers for you ... BTW: Welcome to TeX.SE! – Mensch Nov 9 '14 at 10:22
• Please help us to help you and add a full minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. Show us how are you trying to create that table, come on. – Aradnix Nov 9 '14 at 10:33
• I think it would have been better if you said please instead of plz. – Joel Reyes Noche Nov 9 '14 at 10:42

I suggest you aim for a table with an open, easily-accessible look. To that effect, get rid of all vertical rules and most horizontal rules. (Whatever you do, try to avoid creating tables with random-looking widths for horizontal and/or vertical rules.) Use the macros of the booktabs package to draw the remaining few rules with good spacing.

There's a lot of math material in the table. One can specify the column type as >{$}c<{$} to get center-set columns whose contents are in math mode automatically; this'll save you a lot of typing of $ symbols. People also usually do not like to have to crane their necks to read material that's been rotated by 90 degrees. In your case, the table works just as well (and maybe even better...) if you place the word "Subject" in the top line of the table's header. To color in (or gray) various cells, use the \cellcolor{<color>} macro of the colortbl package. For available color names, consult the user guide of the xcolor package. I'll leave it you to fill in the remaining 32 cells. \documentclass{article} \usepackage{booktabs,multirow,array} \usepackage[table]{xcolor} % load both xcolor and colortbl \begin{document} \begin{table} \centering \begin{tabular}{@{} l*{5}{>{$}c<{$}} @{}} \toprule Subject & \multicolumn{5}{c@{}}{$N_{\textnormal{trials}}\$}\\
\cmidrule(l){2-6}
& 20 & 60 & 100 & 140 & 180 \\
\midrule
\multirow{2}{*}{AD} & 50.5\pm 3.2 & 50.3\pm4.5 & 52.6\pm4.7 & 51.7\pm5.3 & 51.5\pm 8.4\\
& \cellcolor{lightgray} 74.8\pm4.9 & \\[1ex]
\multirow{2}{*}{AS} & 50.4\pm3.6 & & & \\
& 74.9\pm6.8 & & & & \\
\multirow{2}{*}{NR} & 50.3\pm2.7 & & & \\
& 75.2\pm6.5 & & & & \\
\multirow{2}{*}{RA} & 49.9\pm2.7& & &\\
& 74.8\pm6.6& & & &\\
\midrule
\multirow{2}{*}{Average} & 50.3\pm3.0& & &\\
& 74.9\pm6.2& & & &\\
\bottomrule
\end{tabular}
\end{table}
\end{document}

• Thanks for the snippet. Just one last question: how do I change the color of the second rows of each subject value? For instance, suppose for AD, I want to highlight 74.8\pm4.9 ... to gray. Thank you in advance. – user65876 Nov 10 '14 at 4:53
• @user65876 - I've added a paragraph about using the \cellcolor macro (of the colortbl package), and I've updated the MWE and screenshot. – Mico Nov 10 '14 at 6:21