\begin{table}[hbt]
\centering
\begin{tabular}{ |>{\centering} p{1cm}|>{\centering}p{2cm}|>{\centering}p{2cm}|>{\centering}p{2cm}| >{\centering}p{2cm} | >{\centering}p{2cm}| >{\centering\arraybackslash}p{2cm} | }
\hline
$n$ & $x_n$ & $e_n$ & $y_n$ & $f_n$ & $z_n$ & $h_n$ \\
\hline
14 & 14 & 13 & 14 & 14 & 13 & 12 \tabularnewline
5 & 6 & 56 & 56 & 34 & 12 & 22 \tabularnewline
5 & 6 & 56 & 56 & 34 & 12 & 22 \tabularnewline
5 & 6 & 56 & 56 & 34 & 12 & 22 \tabularnewline
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \tabularnewline
5 & 6 & 56 & 56 & 34 & 12 & 22 \tabularnewline
5 & 6 & 56 & 56 & 34 & 12 & 22 \tabularnewline
5 & 6 & 56 & 56 & 34 & 12 & 22 \tabularnewline
\hline
\end{tabular}
\end{table}
如何让 vdot 位于表格的中心?
答案1
至少,您需要将所有实例更改为\vdots
;$\vdots$
进行此更改的结果显示在下方第一个表中。
您的设置采用绝对列宽而非相对列宽,无法保证表格适合文本块的宽度。事实上,如屏幕截图所示,它远远超出了可用宽度。
为了确保表格确实适合,同时也确保六个数据列的宽度相等,我建议您切换到环境tabularx
;请参见下表以了解最终的“外观”。
\documentclass{article}
\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash}X} % centered version of 'X' col. type
\begin{document}
\begin{table}[hbt]
\caption{Minimalist solution: Replace \texttt{\string\vdots} with \texttt{\$\string\vdots\$}\strut}
\centering
\begin{tabular}{ | >{\centering}p{1cm} | *{6}{>{\centering\arraybackslash}p{2cm}|} }
\hline
$n$ & $x_n$ & $e_n$ & $y_n$ & $f_n$ & $z_n$ & $h_n$ \\
\hline
14 & 14 & 13 & 14 & 14 & 13 & 12 \tabularnewline
5 & 6 & 56 & 56 & 34 & 12 & 22 \tabularnewline
5 & 6 & 56 & 56 & 34 & 12 & 22 \tabularnewline
5 & 6 & 56 & 56 & 34 & 12 & 22 \tabularnewline
$\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \tabularnewline
5 & 6 & 56 & 56 & 34 & 12 & 22 \tabularnewline
5 & 6 & 56 & 56 & 34 & 12 & 22 \tabularnewline
5 & 6 & 56 & 56 & 34 & 12 & 22 \tabularnewline
\hline
\end{tabular}
\end{table}
\begin{table}[hbt]
\caption{Better solution: Switch to a \texttt{tabularx} environment\strut}
\setlength\extrarowheight{1pt}
\begin{tabularx}{\textwidth}{ | w{c}{1cm} | *{6}{C|} }
\hline
$n$ & $x_n$ & $e_n$ & $y_n$ & $f_n$ & $z_n$ & $h_n$ \\
\hline
14 & 14 & 13 & 14 & 14 & 13 & 12 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
$\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\vdots$ \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
\hline
\end{tabularx}
\end{table}
\end{document}
答案2
以下是两个不同的版本:
附注:目前,您的表格非常宽。您可能需要考虑减小列宽,以确保表格不超过文本宽度。
\documentclass{article}
\usepackage{geometry}
\usepackage{array}
\begin{document}
\[
\begin{array}{|*{7}{c|}}
\hline
n & x_n & e_n & y_n & f_n & z_n & h_n \\
\hline
14 & 14 & 13 & 14 & 14 & 13 & 12 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
\hline
\end{array}
\]
\begin{table}[hbt]
\centering
\begin{tabular}{|>{$}wc{1cm}<{$}|*{6}{>{$}wc{2cm}<{$}|}}
\hline
n & x_n & e_n & y_n & f_n & z_n & h_n \\
\hline
14 & 14 & 13 & 14 & 14 & 13 & 12 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
5 & 6 & 56 & 56 & 34 & 12 & 22 \\
\hline
\end{tabular}
\end{table}
\end{document}