因写论文的需要,想要做一个这样的表格:
使用Excel2Latex(github上有下载)将做的Excel转为latex代码,发现使用texstudio编译运行后得到的是:
其中highAA和low这两列的宽度不同,试了好多网上的方法,发现这一个满足要求,便记录下来。
得到的效果如下:
原latex代码:
\begin{table*}[htbp]
\centering
\caption{Add caption}
\begin{tabular}{|c|c|c|c|c|c|c|c|}
\hline
& & \multicolumn{2}{c|}{A} & \multicolumn{2}{c|}{B} & \multicolumn{2}{c|}{C} \bigstrut\\
\hline
& & highAA & low & highAA & low & highAA & low \bigstrut\\
\hline
\multirow{3}[6]{*}{\begin{sideways}V1\end{sideways}} & m1 & 1 & 1 & 1 & 1 & 1 & 1 \bigstrut\\
\cline{2-8} & m2 & 2 & 2 & 2 & 2 & 2 & 2 \bigstrut\\
\cline{2-8} & m3 & 3 & 3 & 3 & 3 & 3 & 3 \bigstrut\\
\hline
\multirow{3}[6]{*}{\begin{sideways}V2\end{sideways}} & m1 & 4 & 4 & 4 & 4 & 4 & 4 \bigstrut\\
\cline{2-8} & m2 & 5 & 5 & 5 & 5 & 5 & 5 \bigstrut\\
\cline{2-8} & m3 & 6 & 6 & 6 & 6 & 6 & 6 \bigstrut\\
\hline
\multirow{3}[6]{*}{\begin{sideways}V3\end{sideways}} & m1 & 7 & 7 & 7 & 7 & 7 & 7 \bigstrut\\
\cline{2-8} & m2 & 8 & 8 & 8 & 8 & 8 & 8 \bigstrut\\
\cline{2-8} & m3 & 9 & 9 & 9 & 9 & 9 & 9 \bigstrut\\
\hline
\end{tabular}%
\label{tab:addlabel}%
\end{table*}%
修改后的:
\begin{table*}[htbp]
\centering
\caption{Add caption}
\begin{tabularx}{.5\textwidth}{|c|c|*{6}{Y|}} %可以调整宽度
\hline
& & \multicolumn{2}{c|}{A} & \multicolumn{2}{c|}{B} & \multicolumn{2}{c|}{C} \bigstrut\\
\hline
& & highAA & low & highAA & low & highAA & low \bigstrut\\
\hline
\multirow{3}[6]{*}{\begin{sideways}V1\end{sideways}} & m1 & 1 & 1 & 1 & 1 & 1 & 1 \bigstrut\\
\cline{2-8} & m2 & 2 & 2 & 2 & 2 & 2 & 2 \bigstrut\\
\cline{2-8} & m3 & 3 & 3 & 3 & 3 & 3 & 3 \bigstrut\\
\hline
\multirow{3}[6]{*}{\begin{sideways}V2\end{sideways}} & m1 & 4 & 4 & 4 & 4 & 4 & 4 \bigstrut\\
\cline{2-8} & m2 & 5 & 5 & 5 & 5 & 5 & 5 \bigstrut\\
\cline{2-8} & m3 & 6 & 6 & 6 & 6 & 6 & 6 \bigstrut\\
\hline
\multirow{3}[6]{*}{\begin{sideways}V3\end{sideways}} & m1 & 7 & 7 & 7 & 7 & 7 & 7 \bigstrut\\
\cline{2-8} & m2 & 8 & 8 & 8 & 8 & 8 & 8 \bigstrut\\
\cline{2-8} & m3 & 9 & 9 & 9 & 9 & 9 & 9 \bigstrut\\
\hline
\end{tabularx}%
\label{tab:addlabel}%
\end{table*}%
标签:bigstrut,latex,begin,end,表格,--,sideways,hline,cline
From: https://www.cnblogs.com/cowei/p/16796811.html