[Tex/LaTex] How to use Nested multicolumn and multirows

multicolumnmultirowtables

I want to make a good table on table but I am not an expert. Below is my code for the label

\documentclass{article}
\usepackage{times}
\usepackage{multirow}
\begin{document}

% Article top matter
\begin{table*}[!t]
  \centering
  \caption{Vehicle Info}
  \begin{tabular}{|c|c|c|c|c|c|c|c|c|}
    \hline
    % \multirow{2}{*}{Object} & \multicolumn{1}{c|}{\multirow{2}{*}{\textbf{Action}}} &  \multicolumn{6}{c|}{\textbf{RMS Errors}} & \textbf{Leave/Off} & \multirow{2}{*}{\textbf{Total}} \\
    \multirow{2}{*}{Object} & \multirow{2}{*}{Action}  & \multirow{2}{*}{Part}  & \multicolumn{6}{c|}{\textbf{Values}} \\
    \cline{4-9}
     & \multicolumn{1}{c|}{} &  & \textbf{X}(mm) & \textbf{Y}(mm) & \textbf{Z}(mm) & \textbf{Roll}(deg)  & \textbf{Pitch}(deg) & \textbf{Yaw}(deg)  \\
    \hline
    car & Drive & Wheel & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    car & Drive & Gear & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    \hline

    car & Park & Wheel & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    car & Park & Gear & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    \hline

    car & Uphill & Wheel & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    car & Uphill & Gear & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    \hline


    truck & Drive & Wheel & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    truck & Drive & Gear & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    \hline

    truck & Park & Wheel & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    truck & Park & Gear & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    \hline

    truck & Uphill & Wheel & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    truck & Uphill & Gear & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    \hline
    \hline
  \end{tabular}
  \label{tab:pro_pro}
\end{table*}

The picture of my table is attached below. However I want to make the table so that instead of writing the car, truck 6 times i want to just write it once in the column. Likewise for the Action column where I have to write it 2 time. Can I get some help or some modification to my code below. Thanks
\end{document}  %End of document.

Best Answer

You don't need \multirow; when a table cell in the body is blank, it is understood that the value above it is repeated.

Removing the vertical rules and the unnecessary horizontal ones will help in better reading the table.

\documentclass{article}
\usepackage{newtxtext,newtxmath}
\usepackage{booktabs}

\usepackage{geometry} % just not to bother with the table width

\begin{document}

% Article top matter
\begin{table}
\centering

\caption{Vehicle Info}\label{tab:pro_pro}

\begin{tabular}{lllcccccc}
\toprule
\textbf{Object} & \textbf{Action}  & \textbf{Part}  & \multicolumn{6}{c}{\textbf{Values}} \\
\cmidrule{4-9}
 & & & $X$ (mm) & $Y$ (mm) & $Z$ (mm) & Roll (deg)  & Pitch (deg) & Yaw (deg) \\
\midrule
car & Drive & Wheel & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    &       & Gear & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\
\addlinespace
    & Park & Wheel & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    &      & Gear & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
\addlinespace
    & Uphill & Wheel & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
    &        & Gear & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
\midrule
truck & Drive & Wheel & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
      &       & Gear & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
\addlinespace
      & Park & Wheel & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
      &      & Gear & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
\addlinespace
      & Uphill & Wheel & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
      &        & Gear & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ 
\bottomrule
\end{tabular}

\end{table}

\end{document}

enter image description here

Related Question