Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following code:

\begin{table}[H]  
\begin{center}  
\caption{Quarks and leptons of the Standard Model.}  
\label{TablaQuarks}  
\begin{tabu}{|m{2cm}|m{2cm}|m{4cm}|[2pt]} \hline  
\multicolumn{3}{|c|[2pt]}{Quarks} \\ \hline  
Flavour & Charge & Mass \\ \hline  
u & 2/3 $e$ & 2.3$_{-0.5}^{+0.7}$ MeV/c$^2$ \\[1.0ex]  
d & -1/3 $e$ & 4.8$_{-0.3}^{+0.7}$ MeV/c$^2$ \\[1.0ex]\hline  
c & 2/3 $e$ & 1.275 $\pm$ 0.025 GeV/c$^2$ \\  
s &  -1/3 $e$ & 95 $\pm$ 5 MeV/c$^2$ \\ \hline  
t & 2/3 $e$ & 173.5 $\pm$ 0.6 GeV/c$^2$ \\  
b &  - 1/3 $e$ & 4.18 $\pm$ 0.03 GeV/c$^2$ \\ \hline  
\end{tabu}
\end{center}  
\end{table}

The problem is that I cannot center (vertically) the text in the last column, it always remains at the top. Moreover the first two that are vertically aligned cannot be centered horizontally.

In order to use the previous code you need the tabu and array packages.

share|improve this question

2 Answers 2

It's best not to use \\[length] if the last column is a multi-line entry. This version opens out the table so that isn't needed, and applies \centering to the cells. I left in the [H] from your MWE but that shouldn't ever really be needed.

enter image description here

\documentclass{article}
\usepackage{tabu,float}
\begin{document}
\begin{table}[H]  
\begin{center}  
\caption{Quarks and leptons of the Standard Model.} 
\smallskip
\label{TablaQuarks}  
\setlength\extrarowheight{5pt}
\begin{tabu}{
|>{\centering}m{2cm}|
>{\centering}m{2cm}|
>{\centering\arraybackslash}m{4cm}|[2pt]} \hline  
\multicolumn{3}{|c|[2pt]}{Quarks} \\ \hline  
Flavour & Charge & Mass \\ \hline  
u & 2/3 $e$ & 2.3$_{-0.5}^{+0.7}$ MeV/c$^2$ \\
d & -1/3 $e$ & 4.8$_{-0.3}^{+0.7}$ MeV/c$^2$ \\\hline  
c & 2/3 $e$ & 1.275 $\pm$ 0.025 GeV/c$^2$ \\  
s &  -1/3 $e$ & 95 $\pm$ 5 MeV/c$^2$ \\ \hline  
t & 2/3 $e$ & 173.5 $\pm$ 0.6 GeV/c$^2$ \\  
b &  - 1/3 $e$ & 4.18 $\pm$ 0.03 GeV/c$^2$ \\ \hline  
\end{tabu}
\end{center}  
\end{table}

\end{document}
share|improve this answer

The problem with the vertical alignment happens because the formula takes too much vertical space, so you need to open the lines a bit.

While thinking about your issues I got motivated to write my own version of your table in plain TeX, including (in my opinion) some typographical improvements:

  • the spacing between the numbers and the units

  • the kerning between the V and / in GeV/c^2

  • the centering of the charges irrespective of the minus sign and moving the unit (e) to the definition of the column

  • using right alignment for the masses, except for the column name which is centered

The issue with the vertical spacing I solved by defining a macro \openline#1 which inserts some points of vertical space.

You can copy&paste the table in your latex document too, it works with no modifications.

\def\hline{\noalign{\hrule}}
\def\openlineAux#1{height#1pt&\omit&\omit&\omit&height#1pt\cr}
\def\openline#1{\openlineAux#1\hline\openlineAux#1}

\vbox{\offinterlineskip
\halign{&\vrule#&\hfil#\hfil &\quad\hfil#\hfil &\quad\hfil#&\vrule#\cr
\hline\openlineAux3
&\multispan3 \hfil Quarks\hfil&\cr
\openline3
&\enskip\strut Flavour & Charge ($e$) & Mass \hfil&\cr
\openline3
&u & $\phantom{-}2/3$  & $2.3_{-0.5}^{+0.7}\; \rm MeV\!/c^2$ &\cr
\openline3
&d & $-1/3$  & $4.8_{-0.3}^{+0.7}\; \rm MeV\!/c^2$ &\cr
\openline3
&c & $\phantom{-}2/3$  & $1.275 \pm 0.025\; \rm GeV\!/c^2$ &\cr
\openline2
&s &  $-1/3$  & $95 \pm 5\; \rm MeV\!/c^2$  &\cr
\openline2
&t & $\phantom{-}2/3$  & $173.5 \pm 0.6\; \rm GeV\!/c^2$ &\cr
\openline2
&b &  $- 1/3$ & $4.18 \pm 0.03\; \rm GeV\!/c^2$ &\cr
\openlineAux2\hline
}}

enter image description here

share|improve this answer
    
Don't use \rm in LaTeX under any circumstance. It's an obsolete command and classes are allowed not to define it. For units the recommended route is siunitx. –  egreg Dec 17 '12 at 22:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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