如何旋转列中的文本?
\documentclass{article}
\usepackage{rotating}
\usepackage{colortbl}
\usepackage{multirow}
\usepackage[table]{xcolor}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{l|l|llll|llll|l}
\multicolumn{11}{c}{{\cellcolor[HTML]{EFEFEF}}Dataset} \\
\multicolumn{1}{l}{} & \begin{sideways}\end{sideways} & \multicolumn{2}{c}{training} & \multicolumn{2}{c|}{validation} & \multirow{2}{*}{\rotatebox[origin=c]{90}{BatchSize}} & \multirow{2}{*}{\rotatebox[origin=c]{90}{RandBat}} & \multirow{2}{*}{\rotatebox[origin=c]{90}{Loss$\mathcal{L}$}} & \multirow{2}{*}{\rotatebox[origin=c]{90}{\#Params}} &
\multirow{2}{*}{\rotatebox[origin=c]{90}{ Runtime}} \\
\multicolumn{2}{l|}{Methods} & acc & auc & acc & auc & & & & & \\
\hline
Ours & Direct & 94.17 & 98 & 84.86 & 72 & 1 & & CE & & \\
& Corr+Conv & 86.13 & 50 & 88.20 & 50 & 1 & & CE & & \\
& Corr+Convd & 73.30 & 85 & 82.33 & 89 & 4 &x & CE & & \\
& Corr+Conv3d+$\mathcal{H}$& 27.19 & 71 & 83.61 & 73 & 4 & x & HL & & \\ \hline
Others & Net & & & & 88 & 16 & x & CE & 5 Mio. &
\end{tabular}
\caption{Experiments}
\end{table}
\end{document}
当前结果如下:
答案1
一个具有makecell
和 可选参数的命题\raisebox
:
\documentclass{article}
\usepackage{rotating}
\usepackage{colortbl}
\usepackage{multirow}
\usepackage[table]{xcolor}
\usepackage{makecell}
\newcommand{\myrotcell}[1]{\rotcell{\makebox[0pt][l]{#1}}}
\begin{document}
\begin{table}[h]
\centering\settowidth{\rotheadsize}{Batchs}
\begin{tabular}{l|l|*{2}{llll|}l}
\multicolumn{11}{c}{{\cellcolor[HTML]{EFEFEF}}Dataset} \\
\multicolumn{1}{l}{} & \begin{sideways}\end{sideways} & \multicolumn{2}{c}{\raisebox{-3ex}[0pt][0pt] {training}} & \multicolumn{2}{c|}{\raisebox{-3ex}[0pt][0pt] {validation}}& & & & & \\
\multicolumn{2}{l|}{Methods} & acc & auc & acc & auc & \myrotcell{BatchSize} & \myrotcell{RandBat} & \myrotcell{Loss$\mathcal{L}$} & \myrotcell{\#Params} & \myrotcell{ Runtime} \\[-1ex]
\hline
Ours & Direct & 94.17 & 98 & 84.86 & 72 & 1 & & CE & & \\
& Corr+Conv & 86.13 & 50 & 88.20 & 50 & 1 & & CE & & \\
& Corr+Convd & 73.30 & 85 & 82.33 & 89 & 4 &x & CE & & \\
& Corr+Conv3d+$\mathcal{H}$& 27.19 & 71 & 83.61 & 73 & 4 & x & HL & & \\ \hline
Others & Net & & & & 88 & 16 & x & CE & 5 Mio. &
\end{tabular}
\caption{Experiments}
\end{table}
\end{document}%
\multirow{2}{*}
答案2
我的尝试:
\begin{table}[h]
\centering
\begin{tabular}{l|l|llll|llll|l}
\multicolumn{11}{c}{{\cellcolor[HTML]{EFEFEF}}Dataset} \\
\multicolumn{1}{l}{} & & \multicolumn{2}{c}{} & \multicolumn{2}{c|}{}& & & & & \\
\multicolumn{1}{l}{} & & \multicolumn{2}{c}{training} & \multicolumn{2}{c|}{validation}& \vbox{\hbox{\multirow{2}{0pt}{\rotatebox{90}{BatchSize}}}\vspace{20pt}}
& \vbox{\hbox{\multirow{2}{*}{\rotatebox[origin=c]{90}{RandBat}}}\vspace{16pt}} & \vbox{\hbox{\multirow{2}{*}{\rotatebox[origin=c]{90}{Loss$\mathcal{L}$}}}\vspace{3pt}} & \vbox{\hbox{\multirow{2}{*}{\rotatebox[origin=c]{90}{\#Params}}}\vspace{17pt}} & \vbox{\hbox{\multirow{2}{*}{\rotatebox[origin=c]{90}{ Runtime}}}\vspace{15pt}} \\
\multicolumn{2}{l|}{Methods} & acc & auc & acc & auc & & & & & \\
\hline
Ours & Direct & 94.17 & 98 & 84.86 & 72 & 1 & & CE & & \\
& Corr+Conv & 86.13 & 50 & 88.20 & 50 & 1 & & CE & & \\
& Corr+Convd & 73.30 & 85 & 82.33 & 89 & 4 &x & CE & & \\
& Corr+Conv3d+$\mathcal{H}$& 27.19 & 71 & 83.61 & 73 & 4 & x & HL & & \\ \hline
Others & Net & & & & 88 & 16 & x & CE & 5 Mio. &
\end{tabular}
\caption{Experiments}
\end{table}