1

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?!

Table

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}

marked as duplicate by Schweinebacke, Zarko, Maarten Dhondt, ebosi, user13907 Jan 11 '17 at 9:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4

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}
  • 1
    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
  • 1
    @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. – Jérôme Dequeker Jan 11 '17 at 9:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.