我使用 tabu 包来生成表格。tabu 包提供了一些很棒的功能,例如固定表格列宽,但我碰巧在较窄的页面列中有一些丑陋的表格。
\documentclass[10pt, twocolumn]{article}
\usepackage{tabu}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}
\begin{table}[hbtp]
\caption{Strategies and tradeoff factors}\label{tab:factors}
\begin{tabu} to \linewidth{X[c] | X[c]X[c]X[c]X[c]X[c]}
\toprule
{\bf Strategy} & {\bf Size} & {\bf Energy} & {\bf Expressiveness} & {\bf Flexibility} & {\bf Data Quality} \\
\hline
HCHQ & $-$ & $-$ & + & + & + \\
LCLF & + & + & $-$ & $-$ & + \\
Tunable & + & + & + & + & $-$\\
Tunable with hints & + & + & + & + & + \\
\bottomrule
\end{tabu}
\end{table}
\end{document}
我尝试了第二个版本:
\begin{table}[hbtp]
\caption{Strategies and tradeoff factors (E1 = Energy, E2 = Expressiveness, F = Flexibility, D = Data Quality)}\label{tab:factors}
\begin{tabu} to \linewidth{c | X[c]X[c]X[c]X[c]X[c]}
\toprule
{\bf Strategy} & {\bf Size} & {\bf E1} & {\bf E2} & {\bf F} & {\bf D} \\
\hline
HCHQ & $-$ & $-$ & + & + & + \\
LCLF & + & + & $-$ & $-$ & + \\
Tunable & + & + & + & + & $-$\\
Tunable with hints & + & + & + & + & + \\
\bottomrule
\end{tabu}
\end{table}
不过我觉得这个标签太长了,而且不好看。
有没有更好的方法可以让禁忌表看起来更好(使第一列稍微长一点,自动连字,通过连字在多行中居中等等)?
答案1
那么转置表格怎么样?
注意,我tabu
用替换了 ,只是因为我根本tabularx
不熟悉。tabu
\documentclass[10pt, twocolumn]{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}
\begin{table}[hbtp]
\caption{Strategies and tradeoff factors}\label{tab:factors}
\begin{tabularx}{\linewidth}{@{}l *4{>{\centering\arraybackslash}X}@{}}
\toprule
& \textbf{HCHQ} & \textbf{LCLF} & \multicolumn{2}{c}{\textbf{Tunable}} \\
& & & w/o hints & with hints \\ \midrule
Size & - & + & + & + \\
Energy & - & + & + & + \\
Expressiveness & + & - & + & + \\
Flexibility & + & - & + & + \\
Data Quality & + & + & - & + \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
答案2
无需人为地放大表格。
\documentclass{article}
\usepackage{booktabs,caption,makecell}
\begin{document}
\begin{table}[hbtp]
\centering
\caption
[Strategies and tradeoff factors]% for the list of figures
{Strategies and tradeoff factors
(E1:~Energy; E2:~Expressiveness,
F:~Flexibility, D:~Data Quality)}
\label{tab:factors}
\begin{tabular} {@{}*{6}{c}@{}}
\toprule
\bfseries Strategy &
\bfseries Size &
\bfseries E1 &
\bfseries E2 &
\bfseries F &
\bfseries D \\
\midrule
HCHQ & $-$ & $-$ & + & + & + \\
\addlinespace
LCLF & + & + & $-$ & $-$ & + \\
\addlinespace
Tunable & + & + & + & + & $-$\\
\addlinespace
\makecell{Tunable \\ with hints} & + & + & + & + & + \\
\bottomrule
\end{tabular}
\end{table}
\begin{table}[hbtp]
\centering
\caption
[Strategies and tradeoff factors]% for the list of figures
{Strategies and tradeoff factors
(E1:~Energy; E2:~Expressiveness,
F:~Flexibility, D:~Data Quality)}
\label{tab:factors-2}
\begin{tabular} {@{}l*{5}{c}@{}}
\toprule
\multicolumn{1}{c}\bfseries Strategy} &
\bfseries Size &
\bfseries E1 &
\bfseries E2 &
\bfseries F &
\bfseries D \\
\midrule
HCHQ & $-$ & $-$ & + & + & + \\
LCLF & + & + & $-$ & $-$ & + \\
Tunable & + & + & + & + & $-$\\
Tunable with hints & + & + & + & + & + \\
\bottomrule
\end{tabular}
\end{table}
\end{document}