# Multicolumn/multirow inside align

Is there a way to use \multicolumn or \multirow inside an array environment which is inside align environment? For instance, the following piece of code gives me an error. What is the way around this? I want $4$ to span the first two columns.

\documentclass{minimal}

\usepackage{amsmath,amssymb}

\begin{document}

\begin{align}
\begin{array}{ccccc}
1 & 1 & 3 & \cdots & \multicolumn{2}{*}{4}\\
1 & 1 & 3 & \cdots &\\
1 & 1 & 3 & \cdots &\\
1 & 1 & 3 & \cdots &\\
1 & 1 & 3 & \cdots &\\
\end{array}
\end{align}

\end{document}


You used the argument syntax of \multirow but wrote \multicolumn (and didn't include the multirow package):

\documentclass{minimal}
\usepackage{multirow}
\usepackage{amsmath,amssymb}

\begin{document}

\begin{align}
\begin{array}{ccccc}
1 & 1 & 3 & \cdots & \multirow{2}{*}{4}\\
1 & 1 & 3 & \cdots &\\
1 & 1 & 3 & \cdots &\\
1 & 1 & 3 & \cdots &\\
1 & 1 & 3 & \cdots &\\
\end{array}
\end{align}

\end{document}

• Oops. Sorry. Does the same work for multicolumn as well, if we want an element to occupy two columns? – user1876 May 8 '13 at 20:29
• @user17762 yes neither multicolumn nor multirow is at all affected by an outer align. – David Carlisle May 8 '13 at 20:30
• I found that the entry inside the multirow is not in math mode, i.e., \multirow{2}{*}{U_1} doesn't work, I need to have \multirow{2}{*}{$U_1$}, even though the entire thing is inside the align environment. – user1876 May 8 '13 at 20:37
• @user17762 multirow's * form is affectively a p column and p columns in array are not in math mode (the outer align will not affect this) – David Carlisle May 8 '13 at 20:41

To get "multicolumn" in align (as asked in the title), I've found that using \omit\rlap{} gives the desired result.

\documentclass{minimal}
\usepackage{amsmath}
\begin{document}

\begin{align*}
\omit\rlap{Formula} && \text{Description} \\
y &= x + 14 & \text{A linear formula} \\
\end{align*}

\end{document}


Output:

• It took me a minute to catch this, so I'll point it out for everyone: the argument to \omit\rlap{} is parsed in text mode, not math mode. Use \omit\rlap{$contents$} if your "contents" is an equation – user1476176 Mar 26 '17 at 19:39

Instead of using \rlap, you can use \multispan2{$\displaystyle contents$\hfil}

\omit and \multispan are the plain Tex equivalents of \multicolumn. \omit just removes all of the formatting that {align} puts in and lets you format the table cell as you wish. Multispan gives you a true two-column cell (so if your two-column cell is the widest thing in the table it will set the column width properly) but you have to tell TeX how to format the cell contents afterwards.

The \hfil moves the cell contents over to the left. The \$s make it in math mode. The \displaystyle puts it in display math mode--if you have a \sum or \int in your contents, it will be in inline text style (too small) unless you remind TeX that you are in a displayed math environment.