4

I'm trying to make a table, but some vertical lines are missing. Could someone help me to see the mistake?

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{dsfont}
\parindent0em
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{multirow}


\begin{document}

\begin{tabular}{c|c|c|c|c|c|c|c|} 
\cline{2-8} & \multicolumn{1}{c|}{Generacion} & Nombre & Simbolo & Masa(eV) & Espin & Carga($e$) & Color \\ \cline{1-8} 

\multicolumn{1}{ |c| }{\multirow{3}{*}{Quarks} } & \multirow{2}{*}{1a} & UP & 2 & 0 & 1 &5& 5\\
& \multicolumn{1}{ |c| }{} & UP & 2 & 0 & 1 &5& 5\\ \cline{2-8}
\multicolumn{1}{ |c| }{}& \multirow{2}{*}{2a} & UP & 2 & 0 & 1 &5& 5\\  
&\multicolumn{1}{ |c| }{} & UP & 2 & 0 & 1 &5& 5\\ \cline{2-8} 
\multicolumn{1}{ |c| }{} & \multirow{2}{*}{3a} & UP & 2 & 0 & 1 &5& 5\\  
&\multicolumn{1}{ |c| }{} & UP & 2 & 0 & 1 &5& 5\\ \cline{1-8} 
\cline{1-8} 

\multicolumn{1}{ |c| }{\multirow{3}{*}{Leptones} } & \multirow{2}{*}{1a} & UP & 2 & 0 & 1 &5& 5\\
& & UP & 2 & 0 & 1 &5& 5\\ \cline{2-8}
\multicolumn{1}{ |c| }{} & \multirow{2}{*}{2a} & UP & 2 & 0 & 1 &5& 5\\  
& & UP & 2 & 0 & 1 &5& 5\\ \cline{2-8} 
\multicolumn{1}{ |c| }{} & \multirow{2}{*}{3a} & UP & 2 & 0 & 1 &5& 5\\  
& & UP & 2 & 0 & 1 &5& 5\\ \cline{1-8} 
\cline{1-8} 


\multicolumn{2}{|c|}{\multirow{5}{*}{Bosones}} & UP & 2 & 0 & 1 &5& 5\\ 
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\          
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\ 
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\ \cline{3-8}
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\ \cline{3-8}
\cline{1-8} 

\end{tabular}

\end{document}

This is how the table looks

Thanks

2

An important issue not mentioned in your posting is that the table is too wide to fit inside the text block. This may be remedied by (i) placing the units in two of the header cells in a separate row and (ii) reducing the value of \tabcolsep, the parameter that governs the amount of intercolumn whitespace, by a third (from 6pt to 4pt.

The table code is, I hope you don't mind the criticism, rather cluttered. It may be simplified considerably by (a) setting the structure via

\begin{tabular}{|*{8}{c|}}

and (b) getting rid of the multitude of \multicolumn{1}{ |c| }{} directives. Do also replace all \cline{1-8} directives with \hline and drop the three redundant \cline instructions.

enter image description here

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{dsfont}
\parindent0em
\usepackage{multirow,array}
\begin{document}

\setlength\tabcolsep{4pt} % default value: 6pt

\begin{tabular}{|*{8}{c|}} 
\cline{2-8} 
\multicolumn{1}{c|}{}& Generacion & Nombre & Simbolo & Masa & Espin & Carga  & Color \\ 
\multicolumn{1}{c|}{}& & & & (eV) & ($e$) &  & \\
\hline 
\multirow{3}{*}{Quarks} & \multirow{2}{*}{1a} 
                       & UP & 2 & 0 & 1 &5& 5\\
&                      & UP & 2 & 0 & 1 &5& 5\\ 
\cline{2-8}
& \multirow{2}{*}{2a}  & UP & 2 & 0 & 1 &5& 5\\  
&                      & UP & 2 & 0 & 1 &5& 5\\ 
\cline{2-8} 
& \multirow{2}{*}{3a}  & UP & 2 & 0 & 1 &5& 5\\  
&                      & UP & 2 & 0 & 1 &5& 5\\ 
\hline 
\multirow{3}{*}{Leptones} & \multirow{2}{*}{1a} 
                       & UP & 2 & 0 & 1 &5& 5\\
&                      & UP & 2 & 0 & 1 &5& 5\\ 
\cline{2-8}
& \multirow{2}{*}{2a}  & UP & 2 & 0 & 1 &5& 5\\  
&                      & UP & 2 & 0 & 1 &5& 5\\ 
\cline{2-8} 
& \multirow{2}{*}{3a}  & UP & 2 & 0 & 1 &5& 5\\  
&                      & UP & 2 & 0 & 1 &5& 5\\ 
\hline  
\multicolumn{2}{|c|}{\multirow{5}{*}{Bosones}} 
                       & UP & 2 & 0 & 1 &5& 5\\ 
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\          
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\ 
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\ 
\cline{3-8}
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\ 
\hline 

\end{tabular}
\end{document}

Optional: All these vertical and horizontal lines do not contribute to the table's legibility and intelligibility; I would assume that these two criteria are important to your work. Dropping all vertical lines, replacing the \cline instructions with a bit of (vertical) whitespace, and using the rule-drawing macros (\toprule, \midrule, and \bottomrule) of the booktabs package gives you the following look -- I hope you will agree that it looks at least as good as the table above:

enter image description here

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{dsfont}
\parindent0em
\usepackage{multirow,array,booktabs}
\begin{document}
\setlength\tabcolsep{4pt}

\begin{tabular}{@{}l*{7}{c}@{}} 
\toprule 
& Generacion & Nombre & Simbolo & Masa & Espin & Carga  & Color \\ 
& & & & (eV) & ($e$) &  & \\
\midrule 
\multirow{3}{*}{Quarks}  & \multirow{2}{*}{1a} & UP & 2 & 0 & 1 &5& 5\\
& & UP & 2 & 0 & 1 &5& 5\\ \addlinespace
& \multirow{2}{*}{2a} & UP & 2 & 0 & 1 &5& 5\\  
& & UP & 2 & 0 & 1 &5& 5\\ \addlinespace 
& \multirow{2}{*}{3a} & UP & 2 & 0 & 1 &5& 5\\  
&{} & UP & 2 & 0 & 1 &5& 5\\ 
\midrule 
\multirow{3}{*}{Leptones}  & \multirow{2}{*}{1a} & UP & 2 & 0 & 1 &5& 5\\
& & UP & 2 & 0 & 1 &5& 5\\ 
\addlinespace
& \multirow{2}{*}{2a} & UP & 2 & 0 & 1 &5& 5\\  
& & UP & 2 & 0 & 1 &5& 5\\ 
\addlinespace 
 & \multirow{2}{*}{3a} & UP & 2 & 0 & 1 &5& 5\\  
& & UP & 2 & 0 & 1 &5& 5\\ 
\midrule  
\multicolumn{2}{c}{\multirow{5}{*}{Bosones}} & UP & 2 & 0 & 1 &5& 5\\ 
&  & UP & 2 & 0 & 1 &5& 5\\          
&  & UP & 2 & 0 & 1 &5& 5\\ 
&  & UP & 2 & 0 & 1 &5& 5\\ 
\addlinespace
&  & UP & 2 & 0 & 1 &5& 5\\ 
\bottomrule 
\end{tabular}

\end{document}
5

Use

\begin{tabular}{|c|c|c|c|c|c|c|c|} 

if you really want vertical lines - it is not recommended - and get rid of the unneeded \multicolumn{1}{|c|}{}s.

lines

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{parskip}

\begin{document}

\begin{tabular}{|c|c|c|c|c|c|c|c|}
  \cline{2-8} \multicolumn{1}{c}{}& \multicolumn{1}{|c|}{Generacion} & Nombre & Simbolo & Masa(eV) & Espin & Carga($e$) & Color \\ \cline{1-8}

\multirow{3}{*}{Quarks}  & \multirow{2}{*}{1a} & UP & 2 & 0 & 1 &5& 5\\
&  & UP & 2 & 0 & 1 &5& 5\\ \cline{2-8}
& \multirow{2}{*}{2a} & UP & 2 & 0 & 1 &5& 5\\
& & UP & 2 & 0 & 1 &5& 5\\ \cline{2-8}
 & \multirow{2}{*}{3a} & UP & 2 & 0 & 1 &5& 5\\
& & UP & 2 & 0 & 1 &5& 5\\ \cline{1-8}

\multirow{3}{*}{Leptones}  & \multirow{2}{*}{1a} & UP & 2 & 0 & 1 &5& 5\\
& & UP & 2 & 0 & 1 &5& 5\\ \cline{2-8}
 & \multirow{2}{*}{2a} & UP & 2 & 0 & 1 &5& 5\\
& & UP & 2 & 0 & 1 &5& 5\\ \cline{2-8}
 & \multirow{2}{*}{3a} & UP & 2 & 0 & 1 &5& 5\\
& & UP & 2 & 0 & 1 &5& 5\\ \cline{1-8}


\multicolumn{2}{|c|}{\multirow{5}{*}{Bosones}} & UP & 2 & 0 & 1 &5& 5\\
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\ \cline{3-8}
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\ \cline{3-8}

\end{tabular}

\end{document}

I would, however, urge you to reconsider your presentation. I highly recommend taking a look at booktabs documentation on creating professional quality tables.

A quick makeover:

made-over table

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow,booktabs}
\usepackage{parskip}

\begin{document}

  \begin{tabular}{*{8}{c}}
  \toprule & Generacion & Nombre & Simbolo & Masa(eV) & Espin & Carga($e$) & Color \\\midrule

  \multirow{3}{*}{Quarks}  & \multirow{2}{*}{1a} & UP & 2 & 0 & 1 &5& 5\\
  &  & UP & 2 & 0 & 1 &5& 5\\ \cmidrule{2-8}
  & \multirow{2}{*}{2a} & UP & 2 & 0 & 1 &5& 5\\
  & & UP & 2 & 0 & 1 &5& 5\\ \cmidrule{2-8}
  & \multirow{2}{*}{3a} & UP & 2 & 0 & 1 &5& 5\\
  & & UP & 2 & 0 & 1 &5& 5\\
  \midrule

  \multirow{3}{*}{Leptones}  & \multirow{2}{*}{1a} & UP & 2 & 0 & 1 &5& 5\\
  & & UP & 2 & 0 & 1 &5& 5\\ \cmidrule{2-8}
  & \multirow{2}{*}{2a} & UP & 2 & 0 & 1 &5& 5\\
  & & UP & 2 & 0 & 1 &5& 5\\ \cmidrule{2-8}
  & \multirow{2}{*}{3a} & UP & 2 & 0 & 1 &5& 5\\
  & & UP & 2 & 0 & 1 &5& 5\\
  \midrule

  \multicolumn{2}{c}{\multirow{5}{*}{Bosones}} & UP & 2 & 0 & 1 &5& 5\\
  & & UP & 2 & 0 & 1 &5& 5\\
  & & UP & 2 & 0 & 1 &5& 5\\
  & & UP & 2 & 0 & 1 &5& 5\\ \cmidrule{3-8}
  & & UP & 2 & 0 & 1 &5& 5\\
  \bottomrule

\end{tabular}
  • 1
    In the version with the vertical rules, I'd also get rid of the redundant \cline{1-8} and \cline{3-8} directives (three in all) and replace the remaining \cline{1-8} statements with \hline. – Mico Jul 11 '15 at 1:27
  • @Mico Thanks. I meant to do that and must have forgotten to go back. – cfr Jul 11 '15 at 2:51
  • Thank you everyone for your advice. It was very helpful! – isk27 Jul 11 '15 at 18:58
2

Here you are. The following code proposes two versions for this table.

– First, a table with horizontal and all vertical rules, slightly improved (cells in the first column are vertically centred).

– Then a solution without vertical rules, and much fewer horizontal rules, based on booktabs, resulting in a simpler code, and much better looking, in my opinion:

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\parindent0em
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{multirow, makecell}
\usepackage{cellspace, booktabs}
\setlength\cellspacetoplimit{5pt}
%\setlength\cellspacebottomlimit{4pt}

\begin{document}

\begin{tabular}{|c|c|Sc|c|c|c|c|c|}
  \cline{2-8}
  \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{Generacion} & Nombre & Simbolo & Masa(eV) & Espin & Carga($e$) & Color \\ \cline{1-8}
  \multicolumn{1}{|c|}{\multirowcell{6}[-5pt]{Quarks}} & \multirow{2}{*}{1a} & UP & 2 & 0 & 1 & 5 & 5 \\
                                                           & \multicolumn{1}{ c| }{} & UP & 2 & 0 & 1 & 5 & 5 \\ \cline{2-8}
  & \multirow{2}{*}{2a} & UP & 2 & 0 & 1 & 5 & 5 \\
                                                           & \multicolumn{1}{c |}{} & UP & 2 & 0 & 1 & 5 & 5 \\ \cline{2-8}
  & \multirow{2}{*}{3a} & UP & 2 & 0 & 1 & 5 & 5 \\
                                                           & \multicolumn{1}{c| }{} & UP & 2 & 0 & 1 & 5 & 5 \\ \cline{1-8}
  \cline{1-8}

  \multicolumn{1}{ |c| }{\multirow{6}{*}[-5pt]{Leptones} } & \multirow{2}{*}{1a} & UP & 2 & 0 & 1 & 5 & 5 \\
                                                           & & UP & 2 & 0 & 1 & 5 & 5 \\ \cline{2-8}
   & \multirow{2}{*}{2a} & UP & 2 & 0 & 1 & 5 & 5 \\
                                                           & & UP & 2 & 0 & 1 & 5 & 5 \\ \cline{2-8}
  & \multirow{2}{*}{3a} & UP & 2 & 0 & 1 & 5 & 5 \\
                                                           & & UP & 2 & 0 & 1 & 5 & 5 \\ \cline{1-8}
  \cline{1-8}

  \multicolumn{2}{|c|}{\multirow{5}{*}[-5pt]{Bosones}} & UP & 2 & 0 & 1 &5& 5\\
  \multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\
  \multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\
  \multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\ \cline{3-8}
  \multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\ \cline{3-8}
  \cline{1-8}
\end{tabular}

\begin{tabular}{l*{7}{c}}
  \cmidrule[\heavyrulewidth]{2-8}
  \multicolumn{1}{c}{} & \multicolumn{1}{c}{Generacion} & Nombre & Simbolo & Masa(eV) & Espin & Carga($e$) & Color \\
  \cmidrule(lr){2-8}
  \multicolumn{1}{c}{\multirowcell{6}[-5pt]{Quarks}} & \multirow{2}{*}{1a} & UP & 2 & 0 & 1 & 5 & 5 \\
                                                      & & UP & 2 & 0 & 1 & 5 & 5 \\
  \addlinespace
                                                      & \multirow{2}{*}{2a} & UP & 2 & 0 & 1 & 5 & 5 \\
                                                      & & UP & 2 & 0 & 1 & 5 & 5 \\
  \addlinespace
                                                      & \multirow{2}{*}{3a} & UP & 2 & 0 & 1 & 5 & 5 \\
                                                      & & UP & 2 & 0 & 1 & 5 & 5 \\
  \cmidrule(lr){2-8}

  %
  \multicolumn{1}{c}{\multirow{6}{*}[-5pt]{Leptones}} & \multirow{2}{*}{1a} & UP & 2 & 0 & 1 & 5 & 5 \\
                                                      & & UP & 2 & 0 & 1 & 5 & 5 \\
  \addlinespace
                                                      & \multirow{2}{*}{2a} & UP & 2 & 0 & 1 & 5 & 5 \\
                                                      & & UP & 2 & 0 & 1 & 5 & 5 \\
  \addlinespace
                                                      & \multirow{2}{*}{3a} & UP & 2 & 0 & 1 & 5 & 5 \\
                                                      & & UP & 2 & 0 & 1 & 5 & 5 \\
  \cmidrule(lr){2-8}
  %
  \multicolumn{2}{c}{\multirow{5}{*}[-5pt]{Bosones}} & UP & 2 & 0 & 1 &5& 5\\
                                                      & & UP & 2 & 0 & 1 & 5 & 5 \\
                                                      & & UP & 2 & 0 & 1 & 5 & 5 \\
                                                      & & UP & 2 & 0 & 1 & 5 & 5 \\
  \cmidrule(lr){3-8}
                                                      & & UP & 2 & 0 & 1 & 5 & 5 \\
  \cmidrule[\heavyrulewidth]{3-8}
\end{tabular}

\end{document} 

enter image description here

enter image description here

  • 1
    I find this a bit confusing. You start by saying you are proposing a solution with features X and Y but then immediately provide a solution which has neither of them. Then you provide a second solution which does, indeed, have both X and Y. Wondered if you might want to include some more sign-posting. – cfr Jul 11 '15 at 2:53
  • @cfr: ??? For me, I first solved the problem as posed by the O.P., then suggested (like all of us) a better solution based on booktabs. Anyway, I added some explanations to make that clearer. Is it less confusing now? – Bernard Jul 11 '15 at 9:31
  • Yes, I find that much clearer. (+1) but I think you mean 'fewer horizontal rules' ;). – cfr Jul 11 '15 at 12:21
  • 1
    @cfr: Apparently I forgot some subtleties of English grammar…;o( Corrected, thank you. – Bernard Jul 11 '15 at 12:35
  • It is a pet peeve. However, it will probably count as correct soon because the BBC now says things like 'less people' but they probably don't mean an equal number of smaller or lighter people. – cfr Jul 11 '15 at 12:41
0

you need \multicolumn{2}{|c|}{} in first column

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{dsfont}
\parindent0em
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{multirow}


\begin{document}

\begin{tabular}{c|c|c|c|c|c|c|c|} 
\cline{2-8} & \multicolumn{1}{c|}{Generacion} & Nombre & Simbolo & Masa(eV) & Espin & Carga($e$) & Color \\ \cline{1-8} 

\multicolumn{1}{ |c| }{\multirow{3}{*}{Quarks} } & \multirow{2}{*}{1a} & UP & 2 & 0 & 1 &5& 5\\
\multicolumn{1}{ |c| }{}& \multicolumn{1}{ |c| }{} & UP & 2 & 0 & 1 &5& 5\\ \cline{2-8}
\multicolumn{1}{ |c| }{}& \multirow{2}{*}{2a} & UP & 2 & 0 & 1 &5& 5\\  
\multicolumn{1}{ |c| }{}&\multicolumn{1}{ |c| }{} & UP & 2 & 0 & 1 &5& 5\\ \cline{2-8} 
\multicolumn{1}{ |c| }{} & \multirow{2}{*}{3a} & UP & 2 & 0 & 1 &5& 5\\  
\multicolumn{1}{ |c| }{}&\multicolumn{1}{ |c| }{} & UP & 2 & 0 & 1 &5& 5\\ \cline{1-8} 
\cline{1-8} 

\multicolumn{1}{ |c| }{\multirow{3}{*}{Leptones} } & \multirow{2}{*}{1a} & UP & 2 & 0 & 1 &5& 5\\
\multicolumn{1}{ |c| }{}& & UP & 2 & 0 & 1 &5& 5\\ \cline{2-8}
\multicolumn{1}{ |c| }{} & \multirow{2}{*}{2a} & UP & 2 & 0 & 1 &5& 5\\  
\multicolumn{1}{ |c| }{}& & UP & 2 & 0 & 1 &5& 5\\ \cline{2-8} 
\multicolumn{1}{ |c| }{} & \multirow{2}{*}{3a} & UP & 2 & 0 & 1 &5& 5\\  
\multicolumn{1}{ |c| }{}& & UP & 2 & 0 & 1 &5& 5\\ \cline{1-8} 
\cline{1-8} 


\multicolumn{2}{|c|}{\multirow{5}{*}{Bosones}} & UP & 2 & 0 & 1 &5& 5\\ 
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\          
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\ 
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\ \cline{3-8}
\multicolumn{2}{|c|}{} & UP & 2 & 0 & 1 &5& 5\\ \cline{3-8}
\cline{1-8} 

\end{tabular}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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