3

I tried to create a table

\begin{tabular} {|l|l|l|l|l|l|}
    \hline
    \multicolumn{2}{|c}{1} &        \multicolumn{2}{|c}{1} &            \multicolumn{2}{|c|}{1} \\
    \hline
    1 & 1 & 1 & 1 & 1 & 1 \\
    \hline
\end{tabular}

the output is

enter image description here

What is wrong with spotted mismatch of vertical lines? How to align them?

1 Answer 1

6

Put the | after the c:

\documentclass{article}
\begin{document}
\begin{tabular}{|l|l|l|l|l|l|} 
\hline 
\multicolumn{2}{|c|}{1} & \multicolumn{2}{c|}{1} & \multicolumn{2}{c|}{1} \\ 
\hline 1 & 1 & 1 & 1 & 1 & 1 \\ 
\hline 
\end{tabular}
\end{document}

(but the advice is: don't use vertical rules at all!).

enter image description here

Edit: example of table without vertical rules:

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{*6{l}} 
\toprule
\multicolumn{2}{c}{1} & \multicolumn{2}{c}{1} & \multicolumn{2}{c}{1} \\ 
\cmidrule(lr){1-2} \cmidrule(lr){3-4} \cmidrule(lr){5-6}
1 & 1 & 1 & 1 & 1 & 1 \\ 
\bottomrule
\end{tabular}
\end{document}

enter image description here

3
  • Hi, @CarLaTeX. Thank you so much. It works. But I don't understand your last comment. don't use vertical rules at all! . What does it mean? Do you means I should not use \multicolumn? Then how could I merge cells?
    – user15964
    Nov 2, 2017 at 3:13
  • 1
    @user15964 Do use multicolum but not the vertical rules in all the table, I'll edit my answer to show what I mean.
    – CarLaTeX
    Nov 2, 2017 at 3:18
  • 1
    @user15964 See my edit. I've also used booktabs package, I recommend to you to read Section 2 of its documentation.
    – CarLaTeX
    Nov 2, 2017 at 3:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .