这是我的 Latex 代码:
\documentclass[a4paper,oneside,11pt]{report}
\documentclass{standalone}
\usepackage{standalone}
\usepackage{multirow}
\usepackage{multicol}
\begin{document}
\begin{table}[h!]
\begin{center}
\caption{Algorithm Performance Evaluation Utilizing Different Features with 10-fold CV}
\label{tab:table2}
\begin{tabular}{|c|c|c|c|c|}
\hline
\multicolumn{2}{|cc|}{} & \multicolumn{3}{c|}{\textbf{Feature Sets}}\\
\hline
\textbf{Classifiers } & \textbf{Evaluation Metrics} & \textbf{TF-IDF} & \textbf{Unigram + Bigram} & \textbf{Bag of words}\\
\hline
& Accuracy & 0.540 & 0.672 & 0.528\\ \cline{2-5}
\multirow{Na\"{\i}ve Bayes} & Precision & 0.755 & 0.750 & 0.747\\ \cline{2-5}
& Recall & 0.188 & 0.565 & 0.157\\ \cline{2-5}
& F1 score & 0.300 & 0.644 & 0.258\\
\hline
& Accuracy & 0.687 & 0.728 & 0.686\\ \cline{2-5}
\multirow{SVM} & Precision & 0.692 & 0.769 & 0.719\\ \cline{2-5}
& Recall & 0.732 & 0.694 & 0.665\\ \cline{2-5}
& F1 score & 0.711 & 0.729 & 0.690\\
\hline
& Accuracy & 0.689 & 0.684 & 0.686\\ \cline{2-5}
\multirow{Random Forest} & Precision & 0.728 & 0.747 & 0.737\\ \cline{2-5}
& Recall & 0.655 & 0.609 & 0.629\\ \cline{2-5}
& F1 score & 0.689 & 0.669 & 0.678\\
\hline
& Accuracy & 0.646 & 0.660 & 0.654\\ \cline{2-5}
\multirow{Decision Tree} & Precision & 0.675 & 0.700 & 0.686\\ \cline{2-5}
& Recall & 0.635 & 0.622 & 0.635\\ \cline{2-5}
& F1 score & 0.654 & 0.659 & 0.659\\
\hline
& Accuracy & 0.639 & 0.644 & 0.645\\ \cline{2-5}
\multirow{Adaboost} & Precision & 0.641 & 0.664 & 0.664\\ \cline{2-5}
& Recall & 0.741 & 0.658 & 0.661\\ \cline{2-5}
& F1 score & 0.683 & 0.661 & 0.662\\
\hline
& Accuracy & 0.684 & 0.686 & 0.681\\ \cline{2-5}
\multirow{Gradient Boosting} & Precision & 0.696 & 0.702 & 0.706\\ \cline{2-5}
& Recall & 0.718 & 0.690 & 0.679\\ \cline{2-5}
& F1 score & 0.706 & 0.698 & 0.688\\
\hline
\end{tabular}\\
\end{center}
\end{table}
\end{document}
输出显示完美,但为什么 overleaf 显示此错误
未定义的控制序列。
代码行用红色突出显示。我不明白为什么会这样,是否缺少任何必需的包?我是乳胶新手。
有几个语法错误:
你只能有一个文档类。
\multicolumn
生成单个单元格,您只能在参数中使用一个对齐说明符,而不是 |cc|
应该是 |c|
\multirow
的语法是\multirow[⟨vpos⟩]{⟨nrows⟩}[⟨bigstruts⟩]{⟨width⟩}[⟨vmove⟩]{⟨text⟩}
。至少,您需要指定所有强制参数,例如\multirow{4}{*}{some text here}
如果您希望单元格跨越 4 行。将其放在要合并的第一个单元格中,而不是中间的单元格中。
其他一些评论:
你不需要
multicolumn
表包。包的目的是设置文档多栏
而不是
center
环境,您应该使用 \centering
来避免额外的垂直空间
您的表格对于您的页面几何形状来说太宽了。
\documentclass[a4paper,oneside,11pt]{report}
%\documentclass{standalone}
\usepackage{standalone}
\usepackage{multirow}
\usepackage{multicol}
\begin{document}
\begin{table}[h!]
% \begin{center}
\centering
\caption{Algorithm Performance Evaluation Utilizing Different Features with 10-fold CV}
\label{tab:table2}
\begin{tabular}{|c|c|c|c|c|}
\hline
\multicolumn{2}{|c|}{} & \multicolumn{3}{c|}{\textbf{Feature Sets}}\\
\hline
\textbf{Classifiers } & \textbf{Evaluation Metrics} & \textbf{TF-IDF} & \textbf{Unigram + Bigram} & \textbf{Bag of words}\\
\hline
\multirow{4}{*}{Na\"{\i}ve Bayes} & Accuracy & 0.540 & 0.672 & 0.528\\ \cline{2-5}
& Precision & 0.755 & 0.750 & 0.747\\ \cline{2-5}
& Recall & 0.188 & 0.565 & 0.157\\ \cline{2-5}
& F1 score & 0.300 & 0.644 & 0.258\\
\hline
\end{tabular}%\\
% \end{center}
\end{table}
\end{document}