这是我的表格,我想更改行列,即列中写的所有标题,并将列划分为行。请帮帮我。
\begin{table*}
\centering
\setlength\extrarowheight{2pt}
\begin{tabular}{|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|p{1cm}|}
\hline
t&\multicolumn{3}{c}{SH}&\multicolumn{3}{|c|}{SH}&\multicolumn{3}{|c|}{MH }&\multicolumn{3}{|c|}{MH}\\ \cline{2-13}
&&&Difference&&Difference&&&Difference&&&Differences\\ \cline{2-13}
Unschedule &5.01 & --- &---& 5.01&--- &---&22.46&---&---& 24.54 &--- &\\
&4.31 &13.97\%&0.7&4.68&6.58\%&0.33&12.78 &43.09\%&11.78 &13.92&43.27\%&10.62\\
&3.24 &35.32\%&1.77&3.48&30.53\%&1.53&14.70&34.55\%&9.84&12.98&47.10\%&11.56\\
&3.73 &25.54\%&1.28&3.64 &27.34\%&1.37&12.70&43.45\%&11.48&14.01&42.66\%&10.53\\
&3.09 &38.32\%&1.92&3.13 &37.52\%& 1.88&11.73&47.77\%&12.78&12.01&50.08\%&12.53\\ \hline
\end{tabular}
\end{table*}
答案1
这是实现此目的的方法。我将大部分p{1cm}
列替换为S
列,以siunitx
确保小数点上的列对齐:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe, a4paper]{geometry}
\usepackage{array, booktabs, multirow, siunitx}
\begin{document}
\begin{table*}
\centering\sisetup{table-format=2.2, table-space-text-post = {\,\%}}
\setlength\extrarowheight{2pt}
\begin{tabular}{|c|c|*{5}{S|}}
\multicolumn{1}{c}{t} & \multicolumn{6}{c}{Unschedule}\\[2pt]
\hline
\multirow{3}{*}{SH} & & 5.01 &4.31 & 3.24 & 3.73 &3.09 \\
& & {—} &13.97 \,\% &35.32 \,\% &25.54 \,\% &38.32 \,\% \\
& Difference & {—} & 0.7 & 1.77 &1.28 &1.92 \\
\hline
\multirow{3}{*}{SH} & & 5.01 &4.68 & 3.48 &3.64 &3.13 \\
& & {—} & 6.58 \,\% & 30.53 \,\% &27.34 \,\% &37.52 \,\% \\
& Difference & {—} &0.33 &1.53 &1.37 & 1.88 \\
\hline
\multirow{3}{*}{MH} & &22.46 &12.78 &14.70 & 12.70 &11.73 \\
& & {—} & 43.09 \,\% & 34.55 \,\% & 43.45 \,\% & 47.77 \,\% \\
& Difference & {—} & 11.78 & 9.84 &11.48 &12.78 \\
\hline
\multirow{3}{*}{MH} & & 24.54 & 13.92 & 12.98 & 14.01 & 12.01 \\
& & {—} & 43.27 \,\% & 47.10 \,\% & 42.66\, \% & 50.08 \,\% \\
& Difference & & 10.62 & 11.56 & 10.53 & 12.53 \\ \hline
\end{tabular}
\end{table*}
\end{document}