我需要在表格中添加一列,并$L$
在旁边添加参数$n$
。我该如何添加?
母语:
\documentclass{article}
\usepackage{multirow}
\usepackage{amsmath}
\usepackage{setspace}
\begin{document}
\begin{table}[htbp]
\small
\begin{spacing}{1}
\begin{center}
\begin{tabular}{|*{8}{c|}} % <-- Alignments: 1st column left, 2nd middle and 3rd right, with vertical lines in between
\hline
& & & \multicolumn{2}{c|}{\textbf{ML }}
& \multicolumn{2}{c|}{\textbf{ML }} \\
\cline{3-7}
$\lambda$ & $\gamma$ & $n$& & Train & Test & Train & Test \\
\hline
0.01 & 0.006 & 30 & & 0.9133 & \textbf{0.9401} & & \\
\hline
0.01 & 0.002 & 50 & & & &0.8973 & \textbf{0.9080} \\
\hline
\end{tabular}
\caption{Values.}
\label{mejorrmsepredictorbase}
\end{center}
\end{spacing}
\end{table}
\end{document}
我得到了这样的结果,这太糟糕了:
我希望它保持原样
$\lambda$
,\gamma
也就是说,独自一人。
答案1
基本上,您只需要在每行(包括第一行)的适当位置添加额外的&
新内容。并且您需要更改的列号\crule
。我猜您想要\crule{5-8}
?
我会考虑设置没有垂直线的表格,我认为这样看起来更好。通常建议使用它\centering
来代替center
环境,请参阅我应该对图形和表格使用 center 还是 centering ?
\documentclass{article}
\usepackage{multirow}
\usepackage{amsmath}
\usepackage{setspace}
\usepackage{booktabs} % provides \toprule, \bottomrule,\midrule, \cmidrule
\begin{document}
\begin{table}[htbp]
\small
\centering
\begin{tabular}{|*{8}{c|}} % <-- Alignments: 1st column left, 2nd middle and 3rd right, with vertical lines in between
\hline
& & & & \multicolumn{2}{c|}{\textbf{ML }}
& \multicolumn{2}{c|}{\textbf{ML }} \\
\cline{5-8}
$\lambda$ & $\gamma$ & $n$& $L$ & Train & Test & Train & Test \\
\hline
0.01 & 0.006 & 30 & 1 & 0.9133 & \textbf{0.9401} & & \\
\hline
0.01 & 0.002 & 50 & 2 & & &0.8973 & \textbf{0.9080} \\
\hline
\end{tabular}
\caption{Values.}
\label{mejorrmsepredictorbase}
\end{table}
\begin{table}[htbp]
\small
\centering
\begin{tabular}{*{8}{c}}
\toprule
& & & & \multicolumn{2}{c}{\textbf{ML}}
& \multicolumn{2}{c}{\textbf{ML}} \\
\cmidrule(lr){5-6} \cmidrule(lr){7-8}
$\lambda$ & $\gamma$ & $n$& $L$ & Train & Test & Train & Test \\
\midrule
0.01 & 0.006 & 30 & 1 & 0.9133 & \textbf{0.9401} & & \\
0.01 & 0.002 & 50 & 2 & & &0.8973 & \textbf{0.9080} \\
\bottomrule
\end{tabular}
\caption{Values.}
\label{mejorrmsepredictorbase}
\end{table}
\end{document}