这可能是一个很简单的问题。为什么最后一列没有垂直居中对齐?
以下是我使用的代码:
\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}
答案1
由于使用\\[<len>]
是导致问题的原因,因此这里有一个稍微不同(更具启发性)的解决方案:
\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}
最好始终如一。因此,更新\arraystretch
会均匀分布行。我还擅自使用了booktabs
的建议(限制水平规则和绝不使用垂直线)。演示文稿看起来更干净、更专业。
答案2
如果您需要行与行之间的可变间距,则添加一个额外的列来保存行距命令:
\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}
\vrule
您可以通过在每个最终单元格末尾放置一个来直观地了解为什么这样做有帮助:
\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}
由此您可以看到,在行尾添加的额外深度位于单元格段落的最后一行。
该解决方案是https://tex.stackexchange.com/a/94717/15925由 David Carlisle 撰写;特别是给出了最后一列的不同格式,因为l
在这种情况下添加列的其他解决方案不起作用。
答案3
\\[...]
本质上是\vspace{...}\\
,使用它将会给最后一个单元格添加一个垂直空间。一个简单(但不体面)的解决方案calc
是使用包:
\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}
结果: