
の列を調整してtable
、見出しが中央揃えになり、残りの行が左揃えになるようにしたいのですが、これは自分で管理しました (図を参照)。これで、すべての行に追加の属性 (長さ) ができました。これを各セルの右端に押し出したいと思います。 を試してみました\hfil
が、スペースの中央揃えになってしまいました (右揃えではありません)。
どうやってやるの?
MWEは次のように付け加えた。
\documentclass{article}
\begin{document}
\begin{table}
\begin{tabular}{|c|l|} \hline
Item & \multicolumn{1}{c|}{Entries \hfil (length)} \\ \hline
1 & 1, 2, 3, 4, 5, 6, 7 \hfil (7) \\ \hline
2 & 1, 2, 3, 4, 5, 6, 7, 8, 9 \hfil (9) \\ \hline
3 & 1, 2, 3, 4 \hfil (4) \\ \hline
\end{tabular}
\end{table}
\end{document}
答え1
列を使用しないのはなぜですか3
? また、booktabs
パッケージを使用することもできます: 垂直方向の罫線がなく、行間の垂直方向の間隔が広くなります。両方の例を示します。
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}
\begin{tabular}[b]{|c|lc|} \hline
Item & \multicolumn{1}{c}{Entries} & (length) \\ \hline
1 & 1, 2, 3, 4, 5, 6, 7 & (7) \\ \hline
2 & 1, 2, 3, 4, 5, 6, 7, 8, 9 & (9) \\ \hline
3 & 1, 2, 3, 4 & (4) \\ \hline
\end{tabular}
\end{table}
\mbox{}%\vskip1cm%
\begin{table}[! h]
\begin{tabular}[b]{@{}clc@{}}
Item & \multicolumn{1}{c}{Entries} & (length) \\\addlinespace[0.5ex] \toprule
1 & 1, 2, 3, 4, 5, 6, 7 & (7) \\ \addlinespace
2 & 1, 2, 3, 4, 5, 6, 7, 8, 9 & (9) \\ \addlinespace
3 & 1, 2, 3, 4 & (4) \\ \bottomrule
\end{tabular}
\end{table}
\end{document}
答え2
私がそれをどのように行うかは次のとおりです:
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}
\centering
\begin{tabular}{clc}
\toprule
Item & \multicolumn{1}{c}{Entries} & (length) \\
\midrule
$1$ & $1,2,3,4,5,6,7$ & $(7)$ \\
$2$ & $1,2,3,4,5,6,7,8,9$ & $(9)$ \\
$3$ & $1,2,3,4$ & $(4)$ \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
\toprule
(Bernard の最後の解決策に似ていますが、表の上に があり、\midrule
テキストのすぐ下に があることがわかります。)