我使用以下命令\multirow{5}{*}{\parbox[t]{2cm}{\raggedright$a1=0.12$; $a2=-0.14$; $a3=0.2$}}
在单元格顶部显示文本。
不幸的是,它不起作用。
如何纠正?我发布了以下代码供您参考:
\documentclass[[preprint,11pt,authoryear]{elsarticle}
\usepackage{multirow}
\usepackage{rotating,array,booktabs}
\usepackage[skip=0.333\baselineskip]{caption}
\begin{sidewaystable}[h]
\captionsetup{font=footnotesize}
\caption{Comparsion of Methods}\label{tab:LPer}
\footnotesize
\setlength\tabcolsep{0pt} % let LaTeX determine intercol. whitespace
\setlength\extrarowheight{1pt}
% \begin{tabular*}{\textwidth}{>{\raggedright}p{2cm}
\begin{tabular*}{\textwidth}{p{2cm}
@{\extracolsep{\fill}} cc*{6}{ccc}} % 21 [!] columns in all
\toprule
Model \& Parameters & Input 1 & Input 2
&\multicolumn{3}{c}{M0} &\multicolumn{3}{c}{M1}
&\multicolumn{3}{c}{M2} &\multicolumn{3}{c}{M3}
&\multicolumn{3}{c}{M4} &\multicolumn{3}{c}{M5}\\
\cmidrule{4-6} \cmidrule{7-9}
\cmidrule{10-12} \cmidrule{13-15}
\cmidrule{16-18} \cmidrule{19-21}
&&
& $N$ & error& Time & $N$ & error & Time & $N$ & error& Time & $N$ & error& Time & $N$ & error & Time & $N$ & error& Time \\
\midrule
\multirow{5}{*}{\parbox[t]{2cm}{\raggedright$a3=0.12$; $a2=-0.14$; $a1=0.2$}} & $\theta$ & 1--100& $N$ & error& Time & $N$ & error & Time & $N$ & error& Time& $N$ & error& Time & $N$ & error & Time & $N$ & error& Time \\
&&&$N$ & error& Time & $N$ & error & Time & $N$ & error& Time& $N$ & error& Time & $N$ & error & Time & $N$ & error& Time \\
&&&$N$ & error& Time & $N$ & error & Time & $N$ & error& Time & $N$ & error& Time & $N$ & error & Time & $N$ & error& Time \\
&&&$N$ & error& Time & $N$ & error & Time & $N$ & error& Time& $N$ & error& Time & $N$ & error & Time & $N$ & error& Time \\
&&&$N$ & error& Time & $N$ & error & Time & $N$ & error& Time& $N$ & error& Time & $N$ & error & Time & $N$ & error& Time \\
\bottomrule
\end{tabular*}
\end{sidewaystable}
\end{document}
答案1
当您输入 时\multirow{5}{*}{..}
,里面的文本将相对于下一five
行垂直居中。但是,里面的文本multirow
只值几three
行,因此只需删除5
并输入3
即可。我还改进了第一个单元格。不过,我建议您重新考虑以正常方向设计整个表格,我稍后可能会给您一些建议。
\documentclass[preprint,11pt,authoryear]{elsarticle}
\usepackage{multirow}
\usepackage{rotating,array,booktabs}
\usepackage[skip=0.333\baselineskip]{caption}
\begin{document}
\begin{sidewaystable}
\captionsetup{font=footnotesize}
\caption{Comparsion of Methods}\label{tab:LPer}
\footnotesize
\setlength\tabcolsep{0pt} % let LaTeX determine intercol. whitespace
\setlength\extrarowheight{1pt}
% \begin{tabular*}{\textwidth}{>{\raggedright}p{2cm}
\begin{tabular*}{\textwidth}{l
@{\extracolsep{\fill}} cc*{6}{ccc}} % 21 [!] columns in all
\toprule
Model \& & Input 1 & Input 2
&\multicolumn{3}{c}{M0} &\multicolumn{3}{c}{M1}
&\multicolumn{3}{c}{M2} &\multicolumn{3}{c}{M3}
&\multicolumn{3}{c}{M4} &\multicolumn{3}{c}{M5}\\
Parameters & & & & & \\
\cmidrule{4-6} \cmidrule{7-9}
\cmidrule{10-12} \cmidrule{13-15}
\cmidrule{16-18} \cmidrule{19-21}
&&
& $N$ & error& Time & $N$ & error & Time & $N$ & error& Time & $N$ & error& Time & $N$ & error & Time & $N$ & error& Time \\
\midrule
\multirow{3}{*}{\begin{tabular}{l}$a3=0.12$;\\$a2=-0.14$;\\$a1=0.2$\end{tabular}} & $\theta$ & 1--100& $N$ & error& Time & $N$ & error & Time & $N$ & error& Time& $N$ & error& Time & $N$ & error & Time & $N$ & error& Time \\
&&&$N$ & error& Time & $N$ & error & Time & $N$ & error& Time& $N$ & error& Time & $N$ & error & Time & $N$ & error& Time \\
&&&$N$ & error& Time & $N$ & error & Time & $N$ & error& Time & $N$ & error& Time & $N$ & error & Time & $N$ & error& Time \\
&&&$N$ & error& Time & $N$ & error & Time & $N$ & error& Time& $N$ & error& Time & $N$ & error & Time & $N$ & error& Time \\
&&&$N$ & error& Time & $N$ & error & Time & $N$ & error& Time& $N$ & error& Time & $N$ & error & Time & $N$ & error& Time \\
\bottomrule
\end{tabular*}
\end{sidewaystable}
\end{document}
现在,请看以下设计(只有 7 列,节省了读者抬头的力气):
\begin{table}
\centering
\caption{Comparsion of Methods}\label{tab:LPer}
\begin{tabular}{@{}ll *5{c}@{}}
\toprule
Parameters
& Model & Input 1 & Input 2 & $N$ & Error & Time \\ \midrule
& & & & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\
& $M_0$ & $\theta$ & 1--100 & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\ \cmidrule{2-7}
& & & & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\
& $M_1$ & $\theta$ & 1--100 & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\ \cmidrule{2-7}
& & & & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\
& $M_2$ & $\theta$ & 1--100 & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\
\multirow{3}{*}[5pt]{\begin{tabular}{l}$a3=0.12$;\\$a2=-0.14$;\\$a1=0.2$\end{tabular}}
& & & & $N$ & Error & Time \\ \cmidrule{2-7}
& & & & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\
& $M_3$ & $\theta$ & 1--100 & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\ \cmidrule{2-7}
& & & & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\
& $M_4$ & $\theta$ & 1--100 & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\ \cmidrule{2-7}
& & & & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\
& $M_5$ & $\theta$ & 1--100 & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\
& & & & $N$ & Error & Time \\ \bottomrule
\end{tabular}
\end{table}
有了这个“漂亮”的输出(您可能还想将$M_n$ \theta 1--100
行向上移动两行):