答案1
\documentclass[11pt]{article}
\usepackage{graphicx}
\begin{document}
This a multirow and multicolumn table
\begin{tabular}{|c|c|c|}
\hline
a & b & g\\
\hline
b & c & h\\
\hline
g & v & a\\
\hline
\end{tabular}
\end{document}
代表|
分隔单元格每个元素的垂直线,并且c
是将单元格内容居中的选项(还有其他的,如r
->右和l
->左)。
最后\hline
代表水平线。我希望我说得够清楚了。
答案2
您必须对百分比(最后一列)的每次更改至少编译两次(因为它使用eqparbox
以获得适当的对齐)。
\documentclass{book}
\usepackage[
margin=1in,
landscape
]{geometry} % Just for this example
\usepackage{booktabs,collcell,eqparbox,makecell}
\begin{document}
\begin{table}
\centering
\newcommand{\pa}[1]{\eqmakebox[CFNetvsNeuMF][r]{#1}}% Percentage alignment
\newcommand{\hlc}{\textbf}% Highlight cell
\caption{Comparison results of different methods in terms of NDCG@10 and HR@10.}
\begin{tabular}{ *{9}{c} >{\collectcell\pa}c<{\endcollectcell} }
\toprule
&
&
\multicolumn{4}{c}{Existing methods} &
\multicolumn{3}{c}{CFNet} &
\\
\cmidrule(lr){3-6}\cmidrule(lr){7-9}
Dataset & % \raisebox{.7\normalbaselineskip}[0pt][0pt]{Dataset}
Measures & % \raisebox{.7\normalbaselineskip}[0pt][0pt]{Measures}
ItemPop & eALS & DMF & NeuMF &
CFNet-rl & CFNet-ml & CFNet &
\multicolumn{1}{c}{\smash{\makecell[b]{Improvement of \\ CFNet \emph{vs.} NeuMF}}} \\
\midrule
ml-1m & HR & 0.4535 & 0.7018 & 0.6565 & \hlc{0.7210} &
0.7127 & 0.7073 & \hlc{0.7253} &
0.6\% \\
& NDCG & 0.2542 & 0.4280 & 0.3761 & \hlc{0.4387} &
0.4336 & 0.4264 & \hlc{0.4416} &
0.7\% \\
\addlinespace
lastfm & HR & 0.6628 & 0.8265 & 0.8840 & \hlc{0.8868} &
0.8840 & 0.8834 & \hlc{0.8995} &
1.4\% \\
& NDCG & 0.3862 & 0.5162 & 0.5804 & \hlc{0.6007} &
0.6001 & 0.5919 & \hlc{0.6186} &
3.0\% \\
\addlinespace
AMusic & HR & 0.2483 & 0.3711 & 0.3744 & 0.3891 &
0.3947 & \hlc{0.4071} & \hlc{0.4116} &
5.8\% \\
& NDCG & 0.1304 & 0.2352 & 0.2149 & 0.2391 &
\hlc{0.2504} & 0.2420 & \hlc{0.2601} &
8.8\% \\
\addlinespace
AToy & HR & 0.2840 & 0.3717 & 0.3535 & 0.3650 &
0.3746 & \hlc{0.3931} & \hlc{0.4150} &
13.7\% \\
& NDCG & 0.1518 & \hlc{0.2434} & 0.2016 & 0.2155 &
0.2271 & 0.2293 & \hlc{0.2513} &
16.6\% \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案3
使用该siunitx
包:
\documentclass{book}
\usepackage[landscape]{geometry}
\usepackage{booktabs, makecell, multirow}
% new
\usepackage{siunitx}
\usepackage{etoolbox}
\newrobustcmd\B{\DeclareFontSeriesDefault[rm]{bf}{b}\bfseries}
\usepackage{xparse}
\NewExpandableDocumentCommand\mcc{O{1}m}
{\multicolumn{#1}{c}{#2}}
\begin{document}
\begin{table}
\centering
\sisetup{detect-weight,
mode=text,
table-format=1.4}
\setlength\tabcolsep{0pt}
\caption{Comparison results of different methods in terms of NDCG@10 and HR@10.}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
l c
*{7}{S}
S[table-format=2.1,
table-space-text-post=\%]<{\%} }
\toprule
& & \mcc[4]{Existing methods}
& \mcc[3]{CFNet}
& \mcc{\multirow{2}{*}{\makecell{Improvement of \\
CFNet \emph{vs.} NeuMF}}} \\
\cmidrule(lr){3-6}\cmidrule(lr){7-9}
Dataset & Measures
& {ItemPop} & {eALS} & {DMF} & {NeuMF}
& {CFNet-rl}& {CFNet-ml}& {CFNet} & \mcc{} \\
\midrule
ml-1m & HR
& 0.4535 & 0.7018 & 0.6565 &\B 0.7210
& 0.7127 & 0.7073 &\B 0.7253 & 0.6 \cr
& NDCG
& 0.2542 & 0.4280 & 0.3761 &\B 0.4387
& 0.4336 & 0.4264 &\B 0.4416 & 0.7 \cr
\addlinespace
lastfm & HR
& 0.6628 & 0.8265 & 0.8840 &\B 0.8868
& 0.8840 & 0.8834 &\B 0.8995 & 1.4 \cr
& NDCG
& 0.3862 & 0.5162 & 0.5804 &\B 0.6007
& 0.6001 & 0.5919 &\B 0.6186 & 3.0 \cr
\addlinespace
AMusic & HR
& 0.2483 & 0.3711 & 0.3744 & 0.3891
& 0.3947 &\B 0.4071 &\B 0.4116 & 5.8 \cr
& NDCG
& 0.1304 & 0.2352 & 0.2149 & 0.2391
&\B 0.2504 & 0.2420 &\B 0.2601 & 8.8 \cr
\addlinespace
AToy & HR
& 0.2840 & 0.3717 & 0.3535 & 0.3650
& 0.3746 &\B 0.3931 &\B 0.4150 & 13.7 \cr
& NDCG
& 0.1518 &\B 0.2434 & 0.2016 & 0.2155
& 0.2271 & 0.2293 &\B 0.2513 & 16.6 \cr
\bottomrule
\end{tabular*}
\end{table}
\end{document}