使用数组和多行包,我成功运行了 LaTeX 并获得了我想要的表格环境。(我更改了一些列名和数据值以进行查询。)我的问题是,在常量和系统值的多列下方,我没有得到一条水平线(在表格的列内)。如何使用 LaTeX 包做到这一点?请帮助我!我附上了 LaTeX 代码。非常感谢!!
最良好的祝愿 Sundar
LaTeX 程序:
\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}
答案1
与。{NiceTabular}
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}
答案2
tblr
新 LaTeX3 包环境中的可能解决方案tabularray
:
\documentclass{article}
\usepackage{caption}
\usepackage{tabularray}
\begin{document}
\begin{table*}
\caption{System, Constants, Spectral Values and $D_L$}
\label{my-label}
\centering
\begin{tblr}{
colspec = {|c|c|c|c|c|c|c|c|c|c|c|c|},
cell{1}{1,Y,Z} = {r=2}{m}, % multirow
cell{1}{6} = {r=2}{h}, % multirow
cell{1}{2,7} = {c=4}{c}, % multicolumn
hlines,
}
System & Constants & & & & $XYZ$ & Spectral Values & & & & $D_{L}$ & 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{tblr}
\end{table*}
\end{document}
答案3
从狭义上讲,你所面临的问题可以通过插入说明来解决
\cline{2-5} \cline{7-10}
在第一个标题行之后。
不过,我鼓励您重新排列表格,使其看起来更加开放、更具吸引力,主要方法是(a)省略所有垂直条和(b)使用包的画线宏booktabs
而不是\hline
和\cline
。
\documentclass{article}
\usepackage{booktabs,array,multirow}
\begin{document}
\begin{table}[ht] % original form, with two \cline directives
\setlength{\extrarowheight}{1pt}
\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} \\
\cline{2-5} \cline{7-10}
& $\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}
\begin{table}[h] % modified for a more open "look"
\caption{Same table, but with a more open and less busy ``look''\strut}
\label{my-label}
\centering
\begin{tabular}{@{} l *{4}{c} p{1.2cm} *{6}{c} @{}}
\toprule
System
& \multicolumn{4}{c}{Constants}
& $XYZ$
& \multicolumn{4}{c}{Spectral Values}
& $D_{L}$
& Figure \\
\cmidrule(lr){2-5} \cmidrule(lr){7-10}
& $\alpha$ & $\beta$ & $\gamma$ & $\delta$ & & $z_1$ & $z_2$ & $z_3$ & $z_4$ \\
\midrule
Ergodic & $6$ & $3$ & $2$ & $4$ & $\alpha = 2$ & $0$ & $1$ & $2$ & $3$ & $0$ & 5(a) \\
\bottomrule
\end{tabular}
\end{table}
\end{document}