所以我想弄清楚:
你能帮我设计一下布局吗?这些多行很难画。
目前正在研究 MWE:
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{multirow,tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\renewcommand{\arraystretch}{2}
\begin{document}\pagestyle{empty}
\begin{tabularx}{\textwidth}{|*{4}{Y|}}
\hline
\multirow{2}{*}{Similarity}
&\multicolumn{2}{c|}{Movielens 1M}&\\
\cline{2-4}
&KNNBasic &KNNBaseline & KNNMeans\\
\hline
MSD &0.9345 &0.9345 & 0.9345 \\
\hline
User based &0.9345 &0.9345 &0.9345 \\
\hline
Item based &0.9345 &0.9345 &0.9345 \\ \hline
\end{tabularx}
\end{document}
答案1
这是您的第一张表格的复制品,没有颜色,并且有一些垂直输入的条目,我认为这更好。
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{multirow,tabularx}
\renewcommand{\tabularxcolumn}[1]{m{#1}}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\renewcommand{\arraystretch}{2}
\begin{document}\pagestyle{empty}
\begin{tabularx}{\textwidth}{|*{5}{Y|}}
\hline
\multicolumn{2}{|c|}{\multirow{2}{*}{Similarity modules}}
& \multicolumn{3}{c|}{Mean RMSE for Movielens 1M dataset} \\
\cline{3-5}
\multicolumn{2}{|c|}{} & KNN Basic &KNN Baseline & KNN With Means\\
\hline
\multirow{2}{*}{MSD} & Item Based & 0.9144 & 0.8853 & 0.8854 \\
\cline{2-5}
& User Based & 0.9230 & 0.8953 & 0.9292 \\ \hline
\multirow{2}{*}{Cosine} & Item based & 0.9994 & 0.9840 & 0.8936 \\
\cline{2-5}
& User based & 0.9767 & 0.9011 & 0.9394 \\ \hline
\multirow{2}{*}{Pearson} & Item based & 0.9741 & 0.8825 & 0.8821 \\
\cline{2-5}
& User based & 0.9481 & 0.8879 & 0.9163 \\ \hline
\end{tabularx}
\end{document}
如果您希望表格有颜色,则必须从包中插入\rowcolor
、\cellcolor
和\arrayrulecolor
命令,并对某些文本colortbl
使用命令。\color
答案2
嗯,虽然不是最好的,但对我来说还是有用的。
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{multirow,tabularx}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\renewcommand{\arraystretch}{2}
\begin{document}\pagestyle{empty}
\begin{tabularx}{\textwidth}{|*{3}{Y|}}
\hline
\multirow{2 }{*}{\textbf{Similarity}}
& \multicolumn{2}{c|}{\textbf{RMSE}} \\
\cline{2-3}
& Movielens & Movielens \\
\hline
Cosine & 0.9345 &0.9345 \\
\hline
Pearson & 0.9345 &0.9345 \\ \hline
\end{tabularx}
\end{document}