先前的答案指示,\multicolumn
在表格中使用时,表格列规范中添加的后续列间空间应在列规范中重复\multicolumn
。然而,这对我来说并不总是有效:
\documentclass{article}
\begin{document}
\begin{tabular}{@{}lr@{~~}r@{~~}r@{\hspace{10pt}}r@{\hspace{10pt}}r@{}}
\hline
configuration & \multicolumn{1}{c@{~~}}{$M$} & \multicolumn{1}{c@{~~}}{$w$} & \multicolumn{1}{c@{\hspace{10pt}}}{$x$} & \multicolumn{1}{c@{\hspace{10pt}}}{$y$} & \multicolumn{1}{c}{H} \\
base model & 5 & \multicolumn{1}{c@{~~}}{$w$} & 00000 & $y$ & 00000 \\
\hline
\end{tabular}
\end{document}
请注意X不太居中。有什么建议吗?
答案1
将列间距作为细胞内容,而不是列规范:
\documentclass{article}
\begin{document}
Original table:
\begin{tabular}{@{}lr@{~~}r@{~~}r@{\hspace{10pt}}r@{\hspace{10pt}}r@{}}
\hline
configuration & \multicolumn{1}{c@{~~}}{$M$} & \multicolumn{1}{c@{~~}}{$w$} & \multicolumn{1}{c@{\hspace{10pt}}}{$x$} & \multicolumn{1}{c@{\hspace{10pt}}}{$y$} & \multicolumn{1}{c}{H} \\
base model & 5 & \multicolumn{1}{c@{~~}}{$w$} & 00000 & $y$ & 00000 \\
\hline
\end{tabular}
\bigskip
Modified table:
\begin{tabular}{@{}lr@{~~}c@{~~}r@{\hspace{10pt}}r@{\hspace{10pt}}r@{}}
\hline
configuration & \multicolumn{1}{c}{$M$} & $w$ & \multicolumn{1}{c}{$x$\hspace*{10pt}} & \multicolumn{1}{c}{$y$\hspace*{10pt}} & \multicolumn{1}{c}{H} \\
base model & 5 & $w$ & 00000 & 11111 & 00000 \\
\hline
\end{tabular}
\end{document}