# Merging Various Rows

I am trying to merge the first three rows of the table, but unable to do. Example is given below.

\documentclass{article}
\usepackage[dvipsnames,table]{xcolor}
\usepackage{array}
\usepackage{environ}
\usepackage{tikz}

\usepackage{caption}

\newsavebox{\tablebox}
\definecolor{tablecolor}{named}{cyan}

\NewEnviron{rndtable}[1]{%
\rowcolors{2}{tablecolor!20}{tablecolor!40}%
\sffamily%
\multicolumn{1}{c}{%
\cellcolor{tablecolor}\color{white}\bfseries##1}}
\savebox{\tablebox}{%
\begin{tabular}{#1}%
\BODY%
\end{tabular}}%
\begin{tikzpicture}
\clip[rounded corners=1ex] (0,-\dp\tablebox) -- (\wd\tablebox,-\dp\tablebox) -- (\wd\tablebox,\ht\tablebox) -- (0,\ht\tablebox) -- cycle;
\node at (0,-\dp\tablebox) [anchor=south west,inner sep=0pt]{\usebox{\tablebox}};
\draw[tablecolor,very thick,rounded corners=1ex] (0,-\dp\tablebox) -- (\wd\tablebox,-\dp\tablebox) -- (\wd\tablebox,\ht\tablebox) -- (0,\ht\tablebox) -- cycle;
\end{tikzpicture}
}

\begin{document}
\noindent
\begin{center}
\captionof{table}{Caption}
\footnotesize{
\begin{rndtable}{lp{3cm}p{5cm} ll} %

\textbf{A} & C & G & A\\
\textbf{B} & B  & M & A\\
\textbf{B} & E & 1B & I \\
\textbf{I} & M & N & A \\
\textbf{M} & E & 12 & I \\
\textbf{N} & E & NA    & NA \\
\textbf{P} & I & P  & An \\
\textbf{S} & B & C  & A \\
\multicolumn{4}{l} {\footnotesize \textcolor{red} {Source: Central banks
\end{rndtable}}

\end{center}

\end{document}

• A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). May 1 '14 at 5:39

It is not clear to me, what you mean with "merging the first three rows", but the example lets several issues to fix and improve, e.g.:

• Unmatched/wrongly matched curly braces, e.g. after Central banks are two closing braces missing.
• \\ is missing after the header line.
• Only four columns are used, but five specified.
• Clipping should probably apply to the table, not the border line.
• The horizontal centered headers looked a little odd, thus I have changed it to left-aligned as the rest of the columns.
• Paths with the form of a rectangle can be defined using rectangle. Thus only two pairs of coordinates need to be specified, the lower left and upper right corner.

Example:

\documentclass{article}
\usepackage[dvipsnames,table]{xcolor}
\usepackage{array}
\usepackage{environ}
\usepackage{tikz}

\usepackage{caption}

\newsavebox{\tablebox}
\definecolor{tablecolor}{named}{cyan}

\NewEnviron{rndtable}[1]{%
\rowcolors{2}{tablecolor!20}{tablecolor!40}%
\sffamily
\multicolumn{1}{l}{%
\cellcolor{tablecolor}%
\color{white}%
\bfseries##1%
}%
}%
\savebox{\tablebox}{%
\begin{tabular}{#1}%
\BODY
\end{tabular}%
}%
\begin{tikzpicture}
\begin{scope}
\clip[rounded corners=1ex]
(0,-\dp\tablebox) rectangle (\wd\tablebox,\ht\tablebox);
\node at (0,-\dp\tablebox) [anchor=south west,inner sep=0pt]
{\usebox{\tablebox}};
\end{scope}
\draw[tablecolor,very thick,rounded corners=1ex]
(0,-\dp\tablebox) rectangle (\wd\tablebox,\ht\tablebox);
\end{tikzpicture}%
}

\begin{document}
\begin{center}
\captionof{table}{Caption}
\footnotesize
\begin{rndtable}{lp{3cm}p{5cm} l} %
\textbf{A} & C & G & A\\
\textbf{B} & B  & M & A\\
\textbf{B} & E & 1B & I \\
\textbf{I} & M & N & A \\
\textbf{M} & E & 12 & I \\
\textbf{N} & E & NA    & NA \\
\textbf{P} & I & P  & An \\
\textbf{S} & B & C  & A \\
\multicolumn{4}{l} {\footnotesize \textcolor{red} {Source: Central banks}}
\end{rndtable}
\end{center}

\end{document}