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
    Commented Dec 18, 2020 at 22:39
  • maybe try tablesgenerator.com to get started.
    – davyjones
    Commented Dec 19, 2020 at 15:34

1 Answer 1

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
    Commented Dec 18, 2020 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
    Commented Dec 18, 2020 at 22:48
  • 4
    @jschnieder 1300 is perfectly aligned (on decimal separator). Commented Dec 18, 2020 at 23:21
  • @jschnieder The S column (from siunitx) aligns material on the decimal marker... Commented Dec 19, 2020 at 6:54

You must log in to answer this question.

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