我想用 LaTeX 制作一个表格,我编写了以下程序:
\documentclass[]{article}
\usepackage{graphicx}
\usepackage{color}
\begin{document}
\begin {center}
\begin {tabular}{| l | l | l | l | l | l |}
\cline{2-6}
& \multicolumn{5}{ |c| }{$\eta_{\infty}$} \\ \cline{2-6}
& i=1,f=6 & i=1,f=3 & i=3,f=5& i=4,f=2& i=6,f=3 \\ \hline
$k,l=0,0$ & \textcolor{blue}{0.1811} & \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811} \\ \hline
$k,l=1,2$ &0.3788 &0.3788 &0.2898 &0.2220 &0.2898 \\ \hline
$k,l=1,3$ &0.3788 &\textcolor{red}{0.9393} &0.2898 &0.2898 &0.2220 \\ \hline
$k,l=1,4$ &0.3788 &0.3788 &0.2898 &0.3788 &0.2898 \\ \hline
$k,l=1,5$ &0.3788 &0.3788 &0.2220 &0.2898 &0.2898 \\ \hline
$k,l=1,6$ &\textcolor{red}{0.9393} &0.3788 &0.2898 &0.2898 &0.3788 \\ \hline
$k,l=2,3$ &0.2898 &0.2220 &0.3788 &0.2220 &0.2220 \\ \hline
$k,l=2,4$ &0.2898 &0.2898 &0.2898 &\textcolor{red}{0.9393} &0.2898 \\ \hline
$k,l=2,5$ &0.2898 &0.2898 &0.2220 &0.2220 &0.2898 \\ \hline
$k,l=2,6$ &0.2220 &0.2898 &0.2898 &0.2220 &0.3788\\ \hline
$k,l=3,4$ &0.2898 &0.2220 &0.3788 &0.3788 &0.2220 \\ \hline
$k,l=3,5$ &0.2898 &0.2220 &\textcolor{red}{0.9393} &0.2898 &0.2220 \\ \hline
$k,l=3,6$ &0.2220 &0.2220 &0.3788 &0.2898 &\textcolor{red}{0.9393} \\ \hline
$k,l=4,5$ &0.2898 &0.2898 &0.2220 &0.3788 &0.2898 \\ \hline
$k,l=4,6$ &0.2220 &0.2898 &0.2898 &0.3788 &0.3788 \\ \hline
$k,l=5,6$ &0.2220 &0.2898 &0.2220 &0.2898 &0.3788 \\ \hline
\end {tabular}\\
Table 2: System efficiency for different k,l and i,f.
\end {center}
\end{document}
有些单元格的第一列有一条多余的垂直线,我该如何省略它?感谢您尽快回复!
答案1
\documentclass[]{article}
\usepackage{graphicx}
\usepackage{color}
\begin{document}
\begin {table}\centering
\begin {tabular}{| l | l | l | l | l | l |}
\cline{2-6}
\multicolumn{1}{c|}{}&\multicolumn{5}{c| }{$\eta_{\infty}$} \\ \cline{2-6}
\multicolumn{1}{c|}{}& i=1,f=6 & i=1,f=3 & i=3,f=5& i=4,f=2& i=6,f=3 \\ \hline
$k,l=0,0$ & \textcolor{blue}{0.1811} & \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811} \\ \hline
$k,l=1,2$ &0.3788 &0.3788 &0.2898 &0.2220 &0.2898 \\ \hline
$k,l=1,3$ &0.3788 &\textcolor{red}{0.9393} &0.2898 &0.2898 &0.2220 \\ \hline
$k,l=1,4$ &0.3788 &0.3788 &0.2898 &0.3788 &0.2898 \\ \hline
$k,l=1,5$ &0.3788 &0.3788 &0.2220 &0.2898 &0.2898 \\ \hline
$k,l=1,6$ &\textcolor{red}{0.9393} &0.3788 &0.2898 &0.2898 &0.3788 \\ \hline
$k,l=2,3$ &0.2898 &0.2220 &0.3788 &0.2220 &0.2220 \\ \hline
$k,l=2,4$ &0.2898 &0.2898 &0.2898 &\textcolor{red}{0.9393} &0.2898 \\ \hline
$k,l=2,5$ &0.2898 &0.2898 &0.2220 &0.2220 &0.2898 \\ \hline
$k,l=2,6$ &0.2220 &0.2898 &0.2898 &0.2220 &0.3788\\ \hline
$k,l=3,4$ &0.2898 &0.2220 &0.3788 &0.3788 &0.2220 \\ \hline
$k,l=3,5$ &0.2898 &0.2220 &\textcolor{red}{0.9393} &0.2898 &0.2220 \\ \hline
$k,l=3,6$ &0.2220 &0.2220 &0.3788 &0.2898 &\textcolor{red}{0.9393} \\ \hline
$k,l=4,5$ &0.2898 &0.2898 &0.2220 &0.3788 &0.2898 \\ \hline
$k,l=4,6$ &0.2220 &0.2898 &0.2898 &0.3788 &0.3788 \\ \hline
$k,l=5,6$ &0.2220 &0.2898 &0.2220 &0.2898 &0.3788 \\ \hline
\end {tabular}
\caption{System efficiency for different $k,l$ and $i,f$.}
\end {table}
\end{document}
答案2
除了 David Carlisle 的解决方案之外,我宁愿取消所有垂直线,并使用booktabs
andcellspace
包。此包确保在带有前缀说明符的列中单元格顶部和底部的垂直间距最小S
。我还使用了table environment, and a
\caption` 命令,以便您可以交叉引用此表:
\documentclass[]{article}
\usepackage{graphicx}
\usepackage{array}
\usepackage{color}
\usepackage{cellspace, booktabs}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}
\begin{document}
\begin{table}
\centering
\begin {tabular}{Sl*{5}{Sc}}
& \multicolumn{5}{Sc }{$\eta_{\infty}$} \\
\cmidrule[\heavyrulewidth]{2-6}
& i=1,f=6 & i=1,f=3 & i=3,f=5& i=4,f=2& i=6,f=3 \\
\midrule
$k,l=0,0$ & \textcolor{blue}{0.1811} & \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811}& \textcolor{blue}{0.1811} \\
$k,l=1,2$ &0.3788 &0.3788 &0.2898 &0.2220 &0.2898 \\
$k,l=1,3$ &0.3788 &\textcolor{red}{0.9393} &0.2898 &0.2898 &0.2220 \\
$k,l=1,4$ &0.3788 &0.3788 &0.2898 &0.3788 &0.2898 \\
$k,l=1,5$ &0.3788 &0.3788 &0.2220 &0.2898 &0.2898 \\
$k,l=1,6$ &\textcolor{red}{0.9393} &0.3788 &0.2898 &0.2898 &0.3788 \\
$k,l=2,3$ &0.2898 &0.2220 &0.3788 &0.2220 &0.2220 \\
$k,l=2,4$ &0.2898 &0.2898 &0.2898 &\textcolor{red}{0.9393} &0.2898 \\
$k,l=2,5$ &0.2898 &0.2898 &0.2220 &0.2220 &0.2898 \\
$k,l=2,6$ &0.2220 &0.2898 &0.2898 &0.2220 &0.3788\\
$k,l=3,4$ &0.2898 &0.2220 &0.3788 &0.3788 &0.2220 \\
$k,l=3,5$ &0.2898 &0.2220 &\textcolor{red}{0.9393} &0.2898 &0.2220 \\
$k,l=3,6$ &0.2220 &0.2220 &0.3788 &0.2898 &\textcolor{red}{0.9393} \\
$k,l=4,5$ &0.2898 &0.2898 &0.2220 &0.3788 &0.2898 \\
$k,l=4,6$ &0.2220 &0.2898 &0.2898 &0.3788 &0.3788 \\
$k,l=5,6$ &0.2220 &0.2898 &0.2220 &0.2898 &0.3788 \\
\bottomrule
\end {tabular}
\caption{System efficiency for different $ k,l $ and i,f.}\label{effi}
\end {table}
答案3
这是一个解决方案,它重新组织了第二个标题行中的材料,使其符合第一列的形式。它还使用S
(包的siunitx
)列类型将第 2 至第 6 列中的数字数据点对齐到小数点标记上。(我更改了一些数字,使它们在小数点标记后有两位或三位数字,以突出显示此设置的效果。)我进一步建议删除所有垂直规则和大多数水平规则;相信我,它们不会被错过。
\documentclass{article}
\usepackage{color,siunitx,booktabs}
\begin{document}
\begin{table}
\begin{tabular*}{\textwidth}{ @{} @{\extracolsep{\fill}} l *{5}{S[table-format=1.4]} @{} }
\toprule
& \multicolumn{5}{ c@{} }{$\eta_{\infty}$} \\
\cmidrule(l){2-6}
& {$i,f=1,6$}& {$i,f=1,3$}& {$i,f=3,5$}& {$i,f=4,2$}& {$i,f=6,3$} \\
\midrule
$k,l=0,0$ & \color{blue}0.1811& \color{blue}0.1811& \color{blue}0.1811& \color{blue}0.1811& \color{blue}0.1811 \\
$k,l=1,2$ &0.38 &0.38 &0.2898 &0.222 &0.2898 \\
$k,l=1,3$ &0.38 &\color{red}0.9393&0.2898 &0.2898 &0.222 \\
$k,l=1,4$ &0.38 &0.38 &0.2898 &0.38 &0.2898 \\
$k,l=1,5$ &0.38 &0.38 &0.222 &0.2898 &0.2898 \\
$k,l=1,6$ &\color{red}0.9393&0.38 &0.2898 &0.2898 &0.38 \\
$k,l=2,3$ &0.2898 &0.222 &0.38 &0.222 &0.222 \\
$k,l=2,4$ &0.2898 &0.2898 &0.2898 &\color{red}0.9393&0.2898 \\
$k,l=2,5$ &0.2898 &0.2898 &0.222 &0.222 &0.2898 \\
$k,l=2,6$ &0.222 &0.2898 &0.2898 &0.222 &0.38\\
$k,l=3,4$ &0.2898 &0.222 &0.38 &0.38 &0.222 \\
$k,l=3,5$ &0.2898 &0.222 &\color{red}0.9393&0.2898 &0.222 \\
$k,l=3,6$ &0.222 &0.222 &0.38 &0.2898 &\color{red}0.9393 \\
$k,l=4,5$ &0.2898 &0.2898 &0.222 &0.38 &0.2898 \\
$k,l=4,6$ &0.222 &0.2898 &0.2898 &0.38 &0.38 \\
$k,l=5,6$ &0.222 &0.2898 &0.222 &0.2898 &0.38 \\
\bottomrule
\end{tabular*}
\caption{System efficiency for various combinations of $k,l$ and $i,f$.}
\end{table}
\end{document}