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.

Probably a straightforward problem. Why is the final column not center aligned vertically?

enter image description here

Here is the code I'm using:

\documentclass{article}
\usepackage{array}

\begin{document}

\begin{table}[h]
    \begin{center}
      \caption{Data Units, Sources, and Dates}

    \begin{tabular}{| >{\centering\arraybackslash}m{1in} | >{\centering\arraybackslash}m{1in} | >{\centering\arraybackslash}m{1in} | >{\centering\arraybackslash}m{1in} |}

    \hline

    {\bf Variable} & {\bf Dates} & {\bf Units} & {\bf Source}  \\[2ex] \hline
    {\bf Nominal Physical Capital Stock} & 1950-1990 & Billions  US\$ & Nehru and Dhareshwar (1993) \\[0ex] \hline
    {\bf Total Population} & 1950-1990 & Billions & Nehru and Dhareshwar (1993) \\[0ex] \hline
    {\bf Nominal GDP} & 1950-1990 & Billions  US\$ & PWT \\[5ex] \hline
    {\bf Real GDP per capita} & 1950-1990 & 2005 US\$ per capita & PWT \\[5ex] \hline

  \end{tabular}

  \label{tabular:UKJPNdata}
  \end{center}
\end{table}


\end{document}
share|improve this question

migrated from stackoverflow.com Aug 7 '13 at 3:39

This question came from our site for professional and enthusiast programmers.

    
Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. –  Werner Aug 7 '13 at 4:09
    

3 Answers 3

Since the use of \\[<len>] is the cause of the problem, here is a slightly different (more suggestive) solution:

enter image description here

\documentclass{article}
\usepackage{array,booktabs}% http://ctan.org/pkg/{array,booktabs}

\begin{document}

\begin{table}[ht]
  \centering
  \caption{Data Units, Sources, and Dates}
  \renewcommand{\arraystretch}{1.5}% Spread rows out...
  \begin{tabular}{>{\centering\bfseries}m{1in} >{\centering}m{1in} >{\centering}m{1in} >{\centering\arraybackslash}m{1in}}
    \toprule
    Variable & \textbf{Dates} & \textbf{Units} & \textbf{Source} \\
    \midrule
    Nominal Physical Capital Stock & 1950-1990 & Billions  US\$ & Nehru and Dhareshwar (1993) \\
    Total Population & 1950-1990 & Billions & Nehru and Dhareshwar (1993) \\
    Nominal GDP & 1950-1990 & Billions  US\$ & PWT \\
    Real GDP per capita & 1950-1990 & 2005 US\$ per capita & PWT \\
    \bottomrule
  \end{tabular}
\end{table}

\end{document}

It's best to be consistent. As such, updating \arraystretch spreads the rows out evenly. I've also taken the liberty of using booktabs's suggestions (limiting horizontal rules and never using vertical rules). The presentation looks cleaner and more professional.

share|improve this answer

\\[...] is essentially \vspace{...}\\ so that using it will add a vertical space to the last cell. A simple (but not decent) solution utilizing calc package is:

\documentclass{article}
\usepackage{array}
\usepackage{calc}

\begin{document}

\begin{table}[h]
    \begin{center}
      \caption{Data Units, Sources, and Dates}

    \begin{tabular}{| >{\centering\arraybackslash}m{1in} | >{\centering\arraybackslash}m{1in} | >{\centering\arraybackslash}m{1in} | >{\centering\arraybackslash}m{1in} |}

    \hline

    \textbf{Variable} & \textbf{Dates} & \textbf{Units} & \textbf{Source}  \parbox{0pt}{\rule{0pt}{2ex+\baselineskip}}\\ \hline
    \textbf{Nominal Physical Capital Stock} & 1950-1990 & Billions  US\$ & Nehru and Dhareshwar (1993) \\[0ex] \hline
    \textbf{Total Population} & 1950-1990 & Billions & Nehru and Dhareshwar (1993) \\[0ex] \hline
    \textbf{Nominal GDP} & 1950-1990 & Billions  US\$ & PWT \parbox{0pt}{\rule{0pt}{5ex+\baselineskip}}\\ \hline
    \textbf{Real GDP per capita} & 1950-1990 & 2005 US\$ per capita & PWT \parbox{0pt}{\rule{0pt}{5ex+\baselineskip}}\\ \hline

  \end{tabular}

  \label{tabular:UKJPNdata}
  \end{center}
\end{table}

\end{document}

Result: enter image description here

share|improve this answer
    
Don't use {\bf text}, use \textbf{text} instead. See tex.stackexchange.com/q/41681/27635 –  karlkoeller Aug 7 '13 at 6:00
    
@karlkoeller: Thanks for reminding me, those follow from OP's code :) –  Francis Aug 7 '13 at 6:03

If you need the variable spacing from row to row, then add an extra column to hold the line spacing commands:

Sample output

\documentclass{article}

\usepackage{array}

\begin{document}

\begin{table}[htp]
  \begin{center}
    \caption{Data Units, Sources, and Dates}
    \begin{tabular}{| *4{>{\centering\arraybackslash}m{1in}|} @{}m{0pt}@{}}
    \hline
    \textbf{Variable} & \textbf{Dates} & \textbf{Units} &
    \textbf{Source}  &\\[2ex] 
    \hline
    \textbf{Nominal Physical Capital Stock} & 1950-1990 & Billions
    US\$ & Nehru and Dhareshwar (1993) &\\[0ex]
    \hline
    \textbf{Total Population} & 1950-1990 & Billions & Nehru and
    Dhareshwar (1993) &\\[0ex]
    \hline
    \textbf{Nominal GDP} & 1950-1990 & Billions  US\$ & PWT &\\[5ex]
    \hline
    \textbf{Real GDP per capita} & 1950-1990 & 2005 US\$ per capita &
    PWT &\\[5ex]
    \hline
  \end{tabular}
  \label{tabular:UKJPNdata}
  \end{center}
\end{table}

\end{document}

You can visualise why this is helping by placing a \vrule at the end of each final cell:

Visualation example

\documentclass{article}

\usepackage{array}

\newcommand{\myrule}{\vrule width 3pt}

\begin{document}

\begin{table}[htp]
  \begin{center}
    \caption{Data Units, Sources, and Dates}
    \begin{tabular}{| *4{>{\centering\arraybackslash}m{1in}|}}
    \hline
    \textbf{Variable} & \textbf{Dates} & \textbf{Units} &
    \textbf{Source}  \myrule\\[2ex] 
    \hline
    \textbf{Nominal Physical Capital Stock} & 1950-1990 & Billions
    US\$ & Nehru and Dhareshwar (1993) \myrule\\[0ex]
    \hline
    \textbf{Total Population} & 1950-1990 & Billions & Nehru and
    Dhareshwar (1993) \myrule\\[0ex]
    \hline
    \textbf{Nominal GDP} & 1950-1990 & Billions  US\$ & PWT \myrule\\[5ex]
    \hline
    \textbf{Real GDP per capita} & 1950-1990 & 2005 US\$ per capita &
    PWT \myrule\\[5ex]
    \hline
  \end{tabular}
  \label{tabular:UKJPNdata}
  \end{center}
\end{table}

\begin{table}[htp]
  \begin{center}
    \caption{Data Units, Sources, and Dates}
    \begin{tabular}{| *4{>{\centering\arraybackslash}m{1in}|} @{}m{0pt}@{}}
    \hline
    \textbf{Variable} & \textbf{Dates} & \textbf{Units} &
    \textbf{Source}  &\myrule\\[2ex] 
    \hline
    \textbf{Nominal Physical Capital Stock} & 1950-1990 & Billions
    US\$ & Nehru and Dhareshwar (1993) &\myrule\\[0ex]
    \hline
    \textbf{Total Population} & 1950-1990 & Billions & Nehru and
    Dhareshwar (1993) &\myrule\\[0ex]
    \hline
    \textbf{Nominal GDP} & 1950-1990 & Billions  US\$ & PWT &\myrule\\[5ex]
    \hline
    \textbf{Real GDP per capita} & 1950-1990 & 2005 US\$ per capita &
    PWT &\myrule\\[5ex]
    \hline
  \end{tabular}
  \label{tabular:UKJPNdata}
  \end{center}
\end{table}

\end{document}

From this you can see that the extra depth being added by at the end of lines is on the final line of the cell's paragraph.

This solution is a variation of http://tex.stackexchange.com/a/94717/15925 by David Carlisle; in particular a different format for the last column is given, as the other solution adding an l column happens not to work in this case.

share|improve this answer

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.