4

I am fairly new to LaTeX. I learned how to make basic tables with LaTeX by using:

\begin{table}[t]
\centering
\begin{tabular}{ |c|c|c|c| }
...
\end{tabular}
\end{table} 

However, I am in a circumstance where I need to make a far more complicate table, which is shown below: enter image description here

The color of the line is irrelevent, I just decided to use the color red for some of the lines just to make it easier to read. These lines do not need to be red.

I searched over the internet for hours to learn how to make a table like this, but I could not make any progress. I know this is rather a daunting question, but can someone please help me with how to make a table like this on LaTeX?

I will make changes to this post if there is any request.

Thank you,

2
  • if showing the entire table is too daunting, could someone teach me how to write LaTeX code for making just the $C_1$ portion? Thank you.... – jschnieder Dec 18 '20 at 22:39
  • maybe try tablesgenerator.com to get started. – davyjones Dec 19 '20 at 15:34
6

An example:

\documentclass[margin=5mm]{standalone}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
\begin{document}
\begin{tabular}{crSSS}
 &        &             & \multicolumn{2}{c}{Avg min cost} \\
  \cmidrule{4-5}
 & {$t$}  & {$P_{win}$} & {random search} & {grid search}  \\
  \toprule
  \multirow{4}{*}{$C_1$}
 & $10$   & 0.34        & 100.2           & {N/A}          \\
 & $50$   & 1.34        & -0.00002        &                \\
 & $100$  & -7.3        & {---}           & 123.2          \\
 & $1000$ & 1300        & 14              & .34            \\
  \midrule
  \multirow{4}{*}{$C_2$}
 & $10$   &             &                 &                \\
 & $50$   &             &                 &                \\
 & $100$  &             &                 &                \\
 & $1000$ &             &                 &                \\
  \midrule
  \multirow{4}{*}{$C_3$}
 & $10$   &             &                 &                \\
 & $50$   &             &                 &                \\
 & $100$  &             &                 &                \\
 & $1000$ &             &                 &                \\
  \bottomrule
\end{tabular}
\end{document}

enter image description here

4
  • Thank you very much for your help, I really appreciate it. – jschnieder Dec 18 '20 at 22:42
  • Hello, sorry to bother you again, but is there any way that I can align the numbers nicely? like for example, the number 1300 is not aligned with 0.34 and -7.3... thank you again, – jschnieder Dec 18 '20 at 22:48
  • 4
    @jschnieder 1300 is perfectly aligned (on decimal separator). – Paul Gaborit Dec 18 '20 at 23:21
  • @jschnieder The S column (from siunitx) aligns material on the decimal marker... – Paul Gaborit Dec 19 '20 at 6:54

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.