表格中帶有 \multicolumn 的虛假領先水平空間

表格中帶有 \multicolumn 的虛假領先水平空間

當我\multicolumn在 a tabular(或) 中使用 a 時,即使為 指定了 eft 對齊,tabularx似乎也會在列的開頭添加額外的水平間距。該表中的最後一行顯示了此問題:l\multicolumn

在此輸入影像描述

為什麼會有間距,如何消除它?

代碼:

\documentclass{article}
\usepackage{tabularx}
\usepackage[showframe,textwidth=7.0cm]{geometry}

\begin{document}
\noindent
\begin{tabularx}{\linewidth}{@{}X l l@{}}
Sub Item 1 & 3,000 \\
Sub Item 2 & 4,000 \\
Total      &       & 7,000 \\
\multicolumn{3}{l}{$\leftarrow$ Why is there space to the left of this?} \\
\end{tabularx}
\bigskip
\par\noindent
\begin{tabular}{@{}l l l@{}}
Sub Item 1 & 3,000 \\
Sub Item 2 & 4,000 \\
Total      &       & 7,000 \\
\multicolumn{3}{l}{$\leftarrow$ Why is there space to the left of this?} \\
\end{tabular}
\end{document}

答案1

由參數決定\arraycolsep。如果您的問題是“如何避免這種跳過”,解決方案很簡單:

\documentclass{article}
\usepackage{tabularx}
\usepackage[showframe,textwidth=7.0cm]{geometry}

\begin{document}
\noindent
\begin{tabularx}{\linewidth}{@{}X l l@{}}
Sub Item 1 & 3,000 \\
Sub Item 2 & 4,000 \\
Total      &       & 7,000 \\
%\multicolumn{3}{l}{$\leftarrow$ Why is there space to the left of this?} \\
\multicolumn{3}{@{}l}{$\leftarrow$ Why is there space to the left of this?} \\
\end{tabularx}
\end{document}

相關內容