Graphics, Figures & Tables ⇒ why the table I made has missing border lines
why the table I made has missing border lines
I made a table. (not all the cells have data, I left the cell blank when there is no input). Thank you for any suggestions in advance.
My question is, 1, the table does not have the complete border line on the right. some part of the right border are missing. I don't know why.
2, The first title "Special First Group" is longer than the 2nd one, so the 2nd column of the table is wider than the 3rd column. Besides moving the word 'Group' into the 2nd line, is there a way to adjust the columns to make each column have equal width?
thank you very much.
\begin{document}
\begin{table}
\centering
\begin{tabular} {|l|c c c c|c c c c |c c c l|}
\hline
&\multicolumn{4}{c|}{Special First Group} &\multicolumn{4}{c|}{First Group} &\multicolumn{4}{c}{ Second Group}\\
& & & & & & & & &\multicolumn{4}{c} { with different n}\\
\hline
& $z_1$ & $z_2$ & $z_3$ & $z_4$& $z_1$ & $z_2$ & $z_3$ & $z_4$& $z_1$ & $z_2$ & $z_3$ & $z_4$ \\
\hline
all in one &0&0&0&0&0 &0 &1 &1 &1 & 1&1 &1\\[-1ex]
all in three&1&1&1&1& 5& 5& 5&\\
\hline
& 1 & 0 & 0 & 0 & 7& 7&7 &7 &7 & 3& 3&\\ [-1ex]
3 in one &0&1&0&0 &9 &9 1&5 &0 & 4&4 & 4&4\\[-1ex]
1 in three&0&0&1&0&0 &0 &1 & 5&0 &0 &0 &0\\[-1ex]
&0&0&0&1& & & & & & & &\\
\hline
&0&1&1&1& & 1&1 &1 & 1& 1& 1&1\\[-1ex]
1 in two &1&0&1&1& &3 & 3&3 &3 & 3& 0&\\[-1ex]
3 in three &1&1&0&1& & & & & 1&1 & &\\[-1ex]
&1&1&1&0& & & & &1 & 1& 1&\\
\hline
\end{tabular}
\end{table}
\end{document}
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
why the table I made has missing border lines
Because your code is not complete. Try this (in the corresponding parts of your code):gcheer3 wrote:...1, the table does not have the complete border line on the right. some part of the right border are missing. I don't know why...
Code: Select all
&\multicolumn{4}{c|}{Special First Group} &\multicolumn{4}{c|}{First Group} &\multicolumn{4}{c|}{ Second Group}\\
Code: Select all
all in three&1&1&1&1& 5& 5& 5&&&&&\\
One possibility would be to initially declare a four column table with column format , for example, lp{3cm}p{3cm}p{3cm} . Now, each of the last three columns will have equal width and will contain a tabular with four columns.gcheer3 wrote:...2, The first title "Special First Group" is longer than the 2nd one, so the 2nd column of the table is wider than the 3rd column. Besides moving the word 'Group' into the 2nd line, is there a way to adjust the columns to make each column have equal width?..
The following code illustrates this approach:
Code: Select all
\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\newcommand\zhead{%
\begin{tabular}{cccc}
$z_1$ & $z_2$ & $z_3$ & $z_4$
\end{tabular}}
\newcommand\mytabular[4]{%
\begin{tabular}{*{3}{c@{\hspace{16.5pt}}}c}
#1 & #2 & #3 & #4
\end{tabular}}
\begin{document}
\begin{table}[!ht]
\centering
\begin{tabular} {lp{3cm}p{3cm}p{3cm}}
\toprule
&\multicolumn{1}{c}{Special First Group} &\multicolumn{1}{c}{First Group}
&\multicolumn{1}{c}{ Second Group}\\
\midrule
& \zhead & \zhead & \zhead\\
\midrule
all in one & \mytabular{0}{0}{0}{0} & \mytabular{0}{0}{1}{1} &
\mytabular{1}{1}{1}{1}\\
all in three & \mytabular{1}{1}{1}{1} & \mytabular{5}{5}{5}{} & \\
\midrule
& \mytabular{1}{0}{0}{0} & \mytabular{7}{7}{7}{7} & \mytabular{7}{3}{3}{}\\
three in one & \mytabular{0}{1}{0}{0} & \mytabular{9}{\hspace*{-4pt}91}
{\hspace*{-1pt}5}{0} & \mytabular{4}{4}{4}{4}\\
1 in three & \mytabular{0}{0}{1}{0} & \mytabular{0}{0}{1}{5} &
\mytabular{0}{0}{0}{0} \\
& \mytabular{0}{0}{0}{1} & & \\
\midrule
& \mytabular{0}{1}{1}{1} & \mytabular{\hphantom{0}}{1}{1}{1} &
\mytabular{1}{1}{1}{1} \\
1 in two & \mytabular{1}{0}{1}{1} & \mytabular{\hphantom{0}}{3}{3}{3} &
\mytabular{3}{3}{0}{} \\
3 in three & \mytabular{1}{1}{0}{1} & & \mytabular{1}{1}{}{} \\
& \mytabular{1}{1}{1}{0} & & \mytabular{1}{1}{1}{} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}2) Feel free to adapt my example according to your needs.
Re: why the table I made has missing border lines
Thanks a lot for your help. I really appreciate you pointed out my mistake in the table. The border line shows up now:-)
I will read the code with booktabs package carefully. It does make the table looks better. Thanks for the suggestion!
gcheer3