# How to align a Latex table that uses \multicolumn?

I want to align a Latex table the way it appears in the final document.

There are various Vim plugins for aligning tables (2, 3, 4), but none of them handle the spanning cell correctly. The code should be aligned like this:

\begin{tabular}{|c|c|c|}
\multicolumn{2}{|c|}{spanning cell} & cell3 \\
cell1 & cell2                       & cell3 \\
\end{tabular}


but ends up looking like this:

\begin{tabular}{|c|c|c|}
\multicolumn{2}{|c|}{spanning cell} & cell3 \\
cell1                               & cell2 & cell3 \\
\end{tabular}

• Can you give an example of the original text? You have given only those expected and not expected results. – SibiCoder Jun 6 '16 at 12:27
• Why? I don't think the actual text has any impact here? – Erik Jun 7 '16 at 23:06
• I will try to align the original code and check with the expected one. Only then I with be able to answer – SibiCoder Jun 8 '16 at 3:32