An alignment problem in table environment in LaTeX using array & multirow packages

multicolumnmultirowtables

Using the array and multirow packages, I was successfully able to run LaTeX and getting a table environment I desired. (I changed some column names and data values for asking query.) My problem is that I am not getting a horizontal line (within the columns of the table) below the multicolumn for Constants and System values. How to do it using the LaTeX packages? Kindly help me on this! I have enclosed the LaTeX code.. Thanks a lot !!

Best wishes
Sundar

LaTeX program :

\documentclass{article}
\usepackage{array,multirow}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of "X" type
\setlength{\extrarowheight}{1pt}
\begin{document}

\begin{table*}
 \caption{System, Constants, Spectral Values and $D_L$}
\label{my-label}
\begin{center}
\begin{tabular}{|c|c|c|c|c|p{1.2cm}|c|c|c|c|c|c|} \hline
\multirow{2}{*}{System} & \multicolumn{4}{c|}{Constants} & $XYZ $& \multicolumn{4}{c|}{Spectral Values} & \multirow{2}{*}{$D_{L}$}& \multirow{2}{*}{Figure} \\
  & $\alpha$ & $\beta$ & $\gamma$ & $\delta$ &   & $z_1$ & $z_2$ & $z_3$ & $z_4$ &  &  \\[2mm] \hline
Ergodic & $6$ & $3$ & $2$ & $4$ & $\alpha = 2$ & $0$ & $1$ & $2$ & $3$ & $0$ & 5 (a) \\[2mm]
  \hline
\end{tabular}
\end{center}
\end{table*}
\end{document}

Best Answer

With {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage{caption}
\usepackage{nicematrix}

\begin{document}

\begin{table*}
\caption{System, Constants, Spectral Values and $D_L$}
\label{my-label}
\centering
\begin{NiceTabular}[hvlines]{*{12}{c}}
\Block{2-1}{System}  & \Block{1-4}{Constants} & & & & \Block{2-1}{} $XYZ$ & \Block{1-4}{Spectral Values} & & & & \Block{2-1}{$D_{L}$} & \Block{2-1}{Figure} \\
 & $\alpha$  & $\beta$ & $\gamma$ & $\delta$ & & $z_1$ & $z_2$ & $z_3$ & $z_4$ & & \\
Ergodic & $6$ & $3$ & $2$ & $4$ & $\alpha=2$ & $0$ & $1$ & $2$ & $3$ & $0$ & 5 (a)  \\
\end{NiceTabular}
\end{table*}

\end{document}

Output of the above code

Related Question