我的并排表格重叠了,我无法调整它们的大小。任何建议都非常感谢!
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{table}[htbp]
\caption{filter window size}
\label{tab:config_filternum}
\begin{minipage}{.4\textwidth}
\begin{tabular}{| m{3cm} | m{4.3cm} | c |}
\hline
number of entity filter (size 1) & number of context filters (size 2, size 3,
size 4) & Accuracy\\ [2ex]
\hline
32 & 32 , 32 , 32 & 0.835 \\[0.5ex]
\hline
32 & 64 , 64 , 64 & 0.821 \\[0.5ex]
\hline
\hline
\end{tabular}
\end{minipage}%
\quad
\begin{minipage}{.4\textwidth}
\begin{tabular}{| m{3cm} | m{4.3cm} | c |}
\hline
number of entity filter (size 1) & number of context filters (size 2, size 3,
size4) & Accuracy\\ [2ex]
\hline
512 & 32 , 32 , 32 & 0.910 \\[0.5ex]
\hline
512 & 64 , 64 , 64 & 0.922 \\[0.5ex]
\hline
\hline
\end{tabular}
\end{minipage}
\end{table}
\end{document}
答案1
我认为您不需要minipage
,解决方案的示例如下,其中还包含我的一个建议,以改善表格的外观(并且我认为列标题还有更多需要改进的地方)。
我还修改了标题设置,在其后面添加了一些空格。
编辑:根据建议,我修改了我的代码以添加 raggedright 对齐(即使 Bernard 已经给出了最佳解决方案)。
\documentclass{article}
\usepackage{array}
\usepackage{booktabs, tabularx}
\usepackage{caption}
\captionsetup[table]{position=above, belowskip=4pt}
\usepackage{ragged2e}
\begin{document}
\begin{table}[htbp]
\caption{filter window size}
\label{tab:config_filternum}
\begin{tabularx}{.5\textwidth}{| X | X | c |}
\hline
number of entity filter (size 1) & number of context filters (size 2, size 3,
size 4) & Accuracy\\ [2ex]
\hline
32 & 32 , 32 , 32 & 0.835 \\ [0.5ex]
\hline
32 & 64 , 64 , 64 & 0.821 \\ [0.5ex]
\hline
\hline
\end{tabularx}
\quad
\begin{tabularx}{.5\textwidth}{| X | X | c |}
\hline
number of entity filter (size 1) & number of context filters (size 2, size 3,
size 4) & Accuracy\\ [2ex]
\hline
512 & 32 , 32 , 32 & 0.910 \\[0.5ex]
\hline
512 & 64 , 64 , 64 & 0.922 \\[0.5ex]
\hline
\hline
\end{tabularx}
\end{table}
but this is my suggestion:
\newcolumntype{R}{>{\RaggedRight\arraybackslash}X}
\begin{table}[htbp]
\caption{filter window size }
\label{tab:2filternum}
\small
\begin{tabularx}{.5\textwidth}{RRc}
\toprule
Number of entity filter (size 1) & Number of context filters (size 2, size 3,
size 4) & Accuracy\\
\midrule
32 & 32 , 32 , 32 & 0.835 \\
32 & 64 , 64 , 64 & 0.821 \\
\bottomrule
\end{tabularx}
\quad
\begin{tabularx}{.5\textwidth}{RRc}
\toprule
Number of entity filter (size 1) & Number of context filters (size 2, size 3,
size 4) & Accuracy\\
\midrule
512 & 32 , 32 , 32 & 0.910 \\
512 & 64 , 64 , 64 & 0.922 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
答案2
这里还有其他 3 种解决方案,其中一种tabular
基于makecell
软件包,很简单,可以在列标题中换行:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{geometry}%
\usepackage{xspace, array}
\usepackage{booktabs, tabularx, makecell, cellspace}
\usepackage{caption}
\renewcommand\theadfont{\small}
\renewcommand\theadalign{lc}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{3pt}
\newcommand\No{N\textsuperscript{o}\xspace}
\begin{document}
\begin{table}[htbp]
\setlength\tabcolsep{4pt}\small
\caption{filter window size}
\label{tab:config_filternum}
\begin{tabular}{|*{3}{Sc|}}
\hline
\thead{\No of entity \\ filter (size 1)} &\thead{\No of context filters\\ (size 2, size 3, size 4)} &\thead{Accuracy}\\
\hline
32 & 32 , 32 , 32 & 0.835 \\
\hline
32 & 64 , 64 , 64 & 0.821 \\
\hline
\hline
\end{tabular}
\hfill
\begin{tabular}{|*{3}{Sc|}}
\hline
\thead{\No of entity \\ filter (size 1)} &\thead{\No of context filters\\ (size 2, size 3, size 4)} & \thead{Accuracy}\\
\hline
512 & 32 , 32 , 32 & 0.910 \\
\hline
512 & 64 , 64 , 64 & 0.922 \\
\hline
\hline
\end{tabular}
\end{table}
\begin{table}[htbp]
\setlength\tabcolsep{4pt}\small
\caption{filter window size}
\label{tab:config_filternum}
\begin{tabular}{*{3}{c}}
\toprule
\thead{\No of entity \\ filter (size 1)} &\thead{\No of context filters\\ (size 2, size 3, size 4)} &\thead{Accuracy}\\
\cmidrule(lr){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3}
32 & 32 , 32 , 32 & 0.835 \\
\addlinespace
32 & 64 , 64 , 64 & 0.821 \\
\bottomrule
\end{tabular}
\hfill
\begin{tabular}{*{3}{c}}
\toprule
\thead{\No of entity \\ filter (size 1)} &\thead{\No of context filters\\ (size 2, size 3, size 4)} & \thead{Accuracy}\\
\cmidrule(lr){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3}
512 & 32 , 32 , 32 & 0.910 \\
\addlinespace
512 & 64 , 64 , 64 & 0.922 \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}[htbp]
\setlength\tabcolsep{4pt}\small
\caption{filter window size}
\label{tab:config_filternum}
\begin{tabular}{*{3}{c}}
\toprule
\addlinespace[0pt]
\cmidrule{1-3}
\thead{\No of entity \\ filter (size 1)} &\thead{\No of context filters\\ (size 2, size 3, size 4)} &\thead{Accuracy}\\
\cmidrule(lr){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3}
32 & 32 , 32 , 32 & 0.835 \\
\addlinespace
32 & 64 , 64 , 64 & 0.821 \\
\cmidrule{1-3}
\addlinespace[-2.7pt]
\bottomrule
\end{tabular}
\hfill
\begin{tabular}{*{3}{c}}
\toprule
\addlinespace[0pt]
\cmidrule{1-3}
\thead{\No of entity \\ filter (size 1)} &\thead{\No of context filters\\ (size 2, size 3, size 4)} & \thead{Accuracy}\\
\cmidrule(lr){1-1} \cmidrule(lr){2-2} \cmidrule(lr){3-3}
512 & 32 , 32 , 32 & 0.910 \\
\addlinespace
512 & 64 , 64 , 64 & 0.922 \\
\cmidrule{1-3}
\addlinespace[-2.7pt]
\bottomrule
\end{tabular}
\end{table}
\end{document}