\documentclass{article}
\begin{document}
\begin{tabular}{r|r@{\,}l|}
1&2&300\\
10&-2&X\\
\multicolumn{2}{r@{\,}}{2}&\multicolumn{1}{l}{X}
\end{tabular}
\end{document}
According to Lamport, the columns formatting consists of three parts:
r| + r@{\,} + l|
hence I would expect the two X's to be in the same position. But the X in the third line is shifted to the right (compared to the X in the second line).
By trial and error I found a solution by replacing \multicolumn{1}{l}{X} with \multicolumn{1}{@{}l}{X}. What is the reason behind this behaviour?
@{...}in a multicolumn argument acts like a final@{...]in a tabular argument and acts as if there is nothing to follow. – David Carlisle Aug 10 '23 at 15:32