我有一张长表格,看起来像这样,该表格有几行,不能只放在一页中:
我创建了下表代码:
% \usepackage{multirow}
\begin{table}
\centering
\begin{tabular}{|c|c|l|l|l|cl|}
\hline
Test function & Study domain & \multicolumn{2}{c|}{initial obtained solution (Algorithm 2 )} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}} Obtained hybrid optimizer solution\\ ( Algorithm\textasciitilde{} 3 ) \end{tabular}} & \multicolumn{1}{l}{\begin{tabular}[c]{@{}l@{}} Objective function value \\ of the solution \end{tabular}} & \multicolumn{1}{c|}{} \\
\hline
\multirow{2}{*}{\begin{tabular}[c]{@{}c@{}} \textasciitilde{} Sphere \\\textasciitilde{}\textasciitilde{}\textasciitilde{} ( dim = 14 ) \textasciitilde{} \end{tabular}} & \multirow{2}{*}{$ [-5,5]^{14} $ } & $N_ter=6 N=22 P=5 ~ $ & \multirow{2}{*}{$X1=1 X2=-0.1 X3=1.0 X4=-1 X5=-1 X6=0.90 X7=0.8 X8=-0.9 X9=0.16 X10=0.14 X11=-0.2 X12=0.6 X13=0.33 ~ $ } & \multirow{2}{*}{$X1=-0.03 X2=-0.05 X3=-0.04 X4=-0.03 X5=0.005 X6=-0.07 X7=0.04 X8=-0.05 X9=0.05 X10=0.05 X11=-0.04 X12=-0.05 X13=0.05 ~ $ } & \multirow{2}{*}{$~0.03~ $ } & \\
\cline{3-3}
& & \begin{tabular}[c]{@{}l@{}}\\ $~Iter =10 $\\$\alpha=0.1$\\$\gama=0.3$\textasciitilde{}\textasciitilde{}\textasciitilde{} \end{tabular} & & & & \\
\hline
\end{tabular}
\end{table}
不幸的是,编译后表格无法正确显示:
问题的 MWE:
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{table}
\centering
\begin{tabular}{|c|c|l|l|l|cl|}
\hline
Test function & Study domain & \multicolumn{2}{c|}{initial obtained solution (Algorithm 2 )} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}} Obtained hybrid optimizer solution\\ ( Algorithm\textasciitilde{} 3 ) \end{tabular}} & \multicolumn{1}{l}{\begin{tabular}[c]{@{}l@{}} Objective function value \\ of the solution \end{tabular}} & \multicolumn{1}{c|}{} \\
\hline
\multirow{2}{*}{\begin{tabular}[c]{@{}c@{}} \textasciitilde{} Sphere \\\textasciitilde{}\textasciitilde{}\textasciitilde{} ( dim = 14 ) \textasciitilde{} \end{tabular}} & \multirow{2}{*}{$ [-5,5]^{14} $ } & $N_ter=6 N=22 P=5 ~ $ & \multirow{2}{*}{$X1=1 X2=-0.1 X3=1.0 X4=-1 X5=-1 X6=0.90 X7=0.8 X8=-0.9 X9=0.16 X10=0.14 X11=-0.2 X12=0.6 X13=0.33 ~ $ } & \multirow{2}{*}{$X1=-0.03 X2=-0.05 X3=-0.04 X4=-0.03 X5=0.005 X6=-0.07 X7=0.04 X8=-0.05 X9=0.05 X10=0.05 X11=-0.04 X12=-0.05 X13=0.05 ~ $ } & \multirow{2}{*}{$~0.03~ $ } & \\
\cline{3-3}
& & \begin{tabular}[c]{@{}l@{}}\\ $~Iter =10 $\\$\alpha=0.1$\\$\gama=0.3$\textasciitilde{}\textasciitilde{}\textasciitilde{} \end{tabular} & & & & \\
\hline
\end{tabular}
\end{table}
\end{document}
希望您能解决问题!非常感谢您的帮助!
答案1
以下可以作为起点。根据具体要求,可能仍需要进一步修改/改进。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pdflscape}
\usepackage[longtable]{multirow}
\usepackage{longtable}
\usepackage{amsmath}
\begin{document}
\begin{landscape}
\begin{longtable}{|c|c|l|l|l|cl|}
\hline
Test function
& Study domain
& \multicolumn{2}{c|}{\begin{tabular}[c]{@{}c@{}}
initial obtained solution (Algorithm 2 )
\end{tabular}}
& \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}
Obtained hybrid\\
optimizer solution\\
(Algorithm 3 )
\end{tabular}}
& \multicolumn{1}{l}{\begin{tabular}[c]{@{}c@{}}
Objective\\
function\\
value of the\\
solution
\end{tabular}}
& \multicolumn{1}{c|}{} \\*
\hline
\multirow{13}{*}{\begin{tabular}[c]{@{}c@{}} Sphere \\ ( dim = 13 ) \end{tabular}}
& \multirow{13}{*}{$ [-6,6]^{13} $ }
& $N_ter=5 N=20 P=4 $
& \multirow{13}{*}{\begin{tabular}[c]{@{}l@{}}
$X1=1$ \\
$X2=-0.15$\\
$X3=1.07$ \\
$X4=-1.08$ \\
$X5=-1.1$ \\
$X6=0.6$ \\
$X7=0.5$ \\
$X8=-0.17$ \\
$X9=0.12$ \\
$X10=0.12$ \\
$X11=-0.28$ \\
$X12=0.55$ \\
$X13=0.39 $ \end{tabular} }
& \multirow{13}{*}{\begin{tabular}[c]{@{}l@{}}
$X1=-0.035$ \\
$X2=-0.09$ \\
$X3=-0.0$ \\
$X4=-0.01$ \\
$X5=0.05$ \\
$X6=-0.09$ \\
$X7=0.05$ \\
$X8=-0.02$ \\
$X9=0.3$ \\
$X10=0.04$ \\
$X11=-0.07$ \\
$X12=-0.8$ \\
$X13=0.4 $ \end{tabular}}
& \multirow{13}{*}{$ 0.33 $ } & \\*
\cline{3-3}
&
& \begin{tabular}[t]{@{}l@{}}
$ \text{Iter} =52 $\\
$\alpha=0.1$\\
$\gamma=0.9$
\end{tabular}
& & & & \\
&&&&&& \\
&&&&&& \\
&&&&&& \\
&&&&&& \\
&&&&&& \\
&&&&&& \\
&&&&&& \\
&&&&&& \\
&&&&&& \\
\hline
\end{longtable}
\end{landscape}
\end{document}
答案2
aligned
使用数学环境和longtable
宽度等于的可能性\linewidth
:
\documentclass{article}
\usepackage{longtable,
makecell,
multirow}
\usepackage{pdflscape}
\usepackage{amsmath}
\begin{document}
\begin{landscape}
\setcellgapes{2pt}
\makegapedcells
\begin{longtable}{|>{\centering}p{\dimexpr0.11\linewidth-2\tabcolsep-\arrayrulewidth}|
>{\centering}p{\dimexpr0.09\linewidth-2\tabcolsep-\arrayrulewidth}|
p{\dimexpr0.23\linewidth-2\tabcolsep-\arrayrulewidth}|
p{\dimexpr0.19\linewidth-2\tabcolsep-\arrayrulewidth}|
p{\dimexpr0.19\linewidth-2\tabcolsep-\arrayrulewidth}|
>{\centering\arraybackslash}p{\dimexpr0.19\linewidth-2\tabcolsep-\arrayrulewidth}|
}
\hline
\multirow{3}{=}{\centering Test function}
& \multirow{3}{=}{\centering Study domain}
& \multicolumn{2}{c|}{\multirow{3}{*}{initial obtained solution (Algorithm 2)}}
& \centering Obtained hybrid optimizer solution (Algorithm 3)
& \multirow{3}{=}{Objective function value of the solution} \\
\hline
\endfirsthead
\hline
\multirow{3}{=}{\centering Test function}
& \multirow{3}{=}{\centering Study domain}
& \multicolumn{2}{c|}{\multirow{3}{*}{initial obtained solution (Algorithm 2)}}
& \centering Obtained hybrid optimizer solution (Algorithm 3)
& \multirow{3}{=}{Objective function value of the solution} \\
\hline
\endhead
\multicolumn{6}{r}{\footnotesize Continue on the next page}
\endfoot
\endlastfoot
\multirow{15}{=}{Sphere \\ (dim = 13)}
& \multirow{15}{=}{$[-6,6]^{13}$}
& $N_{\mathrm{te}r}=5,\; N=20,\; P=4$
& & & \\
\cline{3-3}
& & $\begin{aligned}
\text{Iter} & = 50 \\
\alpha & = 0.1 \\
\gamma & = 0.9 \\[9\baselineskip]
\end{aligned}$
& \multirow[t]{-1.5}{=}{$\begin{aligned}
X1 & = 1.0077534 \\
X2 & = -0.1104975 \\
X3 & = 1.0014137 \\
X4 & = -1.0036138 \\
X5 & = -1.9578661 \\
X6 & = 0.9005066 \\
X7 & = 0.7631584 \\
X8 & = -0.1421437 \\
X9 & = 0.1663432 \\
X10 & = 0.1404722 \\
X11 & = -0.233138 \\
X12 & = 0.5286155 \\
X13 & = 0.3286869
\end{aligned}$}
& \multirow[t]{-1.5}{=}{$\begin{aligned}
X1 & = -0.03192925 \\
X2 & = -0.05026519 \\
X3 & = -0.04528505 \\
X4 & = -0.0326411 \\
X5 & = 0.00547415 \\
X6 & = -0.0716279 \\
X7 & = 0.04580095 \\
X8 & = -0.050372 \\
X9 & = 0.0503053 \\
X10 & = 0.05034414 \\
X11 & = -0.0472667 \\
X12 & = -0.0584998 \\
X13 & = 0.0519024
\end{aligned}$}
& \multirow{-4}{*}{$0.029873$} \\*
\hline
\end{longtable}
\end{landscape}
\end{document}