# Tables with merged cells [duplicate]

I'm trying to create a table that has some merged columns. But after I compile the file, the borders for those merged cells doesn't appear. I don't know how can I fix this. Any suggestions?!

Here is the code :

\begin{table}[h]
\centering
\caption{Query Q1}
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{4}\textbf{Search Results} \\
\hline
1  & D7  & R  & \\
2  & D2  & R  & \\
3  & D3  & NR & \\
4  & D5  & R  & \\
5  & D1  & R  & \\
6  & D6  & NR & \\
7  & D12 & R  & \\
8  & D15 & NR & \\
9  & D21 & NR & \\
10 & D9  & R  & \\
\hline
\multicolumn{3}\textbf{Avg} & \\
\hline
\end{tabular}
\end{table}


Be careful to use correctly the multicolumn syntax: \multicolumn{num_cols}{alignment}{contents}.

\begin{table}[h]
\centering
\caption{Query Q1}
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{4}{|c|}{\textbf{Search Results}} \\
\hline
1  & D7  & R  & \\
2  & D2  & R  & \\
3  & D3  & NR & \\
4  & D5  & R  & \\
5  & D1  & R  & \\
6  & D6  & NR & \\
7  & D12 & R  & \\
8  & D15 & NR & \\
9  & D21 & NR & \\
10 & D9  & R  & \\
\hline
\multicolumn{3}{|c|}{\textbf{Avg}} & \\
\hline
\end{tabular}
\end{table}

• Jérôme, there is nothing wrong with \multicolumn. Your sentence "be careful with multicolumn sounds as if \multicolumn would be buggy, which it is not. You should explain, why there were no lines in the multicolumned row. I'd also suggest, removing the vertical and horizontal lines, using only the booktabs line.
– Jan
Jan 11 '17 at 9:50
• @Jan Thank's for the comment. You are right, the \multicolumn` command works perfectly when it is used with the correct syntax. That's what I meant. Concerning the vertical and horizontal lines, I took them from the original post. Jan 11 '17 at 9:55