# Table with merged cells

I would like to have a table to looks like this:

\documentclass{article}
\usepackage[english]{babel}

\begin{document}
\begin{center}
\begin{tabular}{ | p{5cm} | l | l | p{5cm} |}
\hline
& Taylor expansion &  & Power series \\ \hline
& $$f(x)=\sum_{k=0}^{n}a_k(x-1)^{k}+o((x-a)^{n})$$ &  & $$f(x)=\sum_{n\geq 0} a_k(x-1)^{k}$$     \\ \hline
Order  & $DL_{n}(0)$  &  $DL_{5}(0)$  &  \\ \hline
exp(x) & $$\sum_{k=0}^{n}\dfrac{x^k}{k!}+o(x^n)$$  & $$1+x+\drac{x^2}{2}+$$  & $$\sum_{k=0}^{n}\dfrac{x^k}{k!}$$ \\ \hline

\end{tabular}
\end{center}

\end{document}


Like this:

\documentclass{article}
\usepackage[english]{babel}
\usepackage{makecell}
\setcellgapes{5pt}
\usepackage{mathtools}

\begin{document}
\begin{center}
\makegapedcells
\begin{tabular}{ | l | *{4}{>{$\displaystyle}c<{$}|}}
\hline
&   \multicolumn{2}{c|}{Taylor expansion}    & Power series \\ \hline
&   \multicolumn{2}{c|}{$\displaystyle f(x)=\sum_{k=0}^{n}a_k(x-1)^{k}+o((x-a)^{n})$}
&   f(x)=\sum_{n\geq 0} a_k(x-1)^{k}    \\
\hline
Order   &   DL_{n}(0)   &   DL_{5}(0)           &                                       \\
\hline
$\exp(x)$   &   \sum_{k=0}^{n}\frac{x^k}{k!}+o(x^n)
&   1+x+\frac{x^2}{2}+  & \sum_{k=0}^{n}\frac{x^k}{k!}         \\
\hline
\end{tabular}
\end{center}
\end{document}


Note: Use of $$...$$ is in LaTeX deprecate. Instead it you should use $...$ or \begin{equation*} ... \end{equation*}. Since all this math environments don't work in column types c, l and r, instead them I use $\displaystyle ...$. For shorter code I modified columns type to >{$\displaystyle}c<{$} so the whoole column is in math mode (except \multicolumns). Therefore the text in header of the last column had to be in wrote as \text{Power series}.

More vertical space around cells content is obtained by macros \setcellgapes{5pt} and \makegapedcells from package makecell.

Would this work?

\documentclass{article}
\begin{document}
\begin{tabular}{|c|c|c|c|}
\hline
& \multicolumn{2}{c|}{Taylor expansion} & Power series \\ \hline
& \multicolumn{2}{c|}{ $f(x)=\sum_{k=0}^{n}a_k(x-1)^{k}+o((x-a)^{n})$} & $f(x)=\sum_{n\geq 0} a_k(x-1)^{k}$ \\ \hline
Order & $DL_{n}(0)$ & $DL_{5}(0)$ & \\ \hline
\end{tabular}
\end{document}


• Well, not really. ;-) When cells are merged, the excess goes on the last merged column. Dec 21, 2016 at 16:19
• @egreg I am not sure I understand what you mean by "excess". Do you refer to columns DLn and DL5 to be of unequal size? Dec 21, 2016 at 22:29

Here is how you can do that table with {NiceTabular} of nicematrix.

With that environment, which is similar to the classical {tabular} (of the package array), you merge cells both horizontally and vertically with the command \Block. Then the key hvlines draws all the rules, excepted in the blocks (created by \Block).

\documentclass{article}
\usepackage{mathtools}
\usepackage{nicematrix}

\begin{document}
\begin{center}
\begin{NiceTabular}{lccc}[hvlines,cell-space-limits=5pt]
& \Block{1-2}{Taylor expansion} && Power series \\
& \Block{1-2}{$\displaystyle f(x)=\sum_{k=0}^{n}a_k(x-1)^{k}+o((x-a)^{n})$} &&  $\displaystyle f(x)=\sum_{n\ge 0} a_k(x-1)^{k}$ \\
Order     & $\text{DL}_{n}(0)$ & $\text{DL}_{5}(0)$ \\
$\exp(x)$ & $\displaystyle\sum_{k=0}^{n}\frac{x^k}{k!}+o(x^n)$ & $\displaystyle 1+x+\cdots+\frac{x^5}{5!}+o(x^5)$
& $\displaystyle\sum_{k=0}^{n}\frac{x^k}{k!}$ \\
\end{NiceTabular}
\end{center}
\end{document}


You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).