美化表格

美化表格

所以我不确定这个问题是否合适,但我还是会问。我没有太多在 latex 中创建表格的经验,现在我需要创建一个。不过在我看来它不太合适。如果有任何有经验的用户可以权衡如何他们将创建相同的表格,我将不胜感激。

\documentclass[]{article}
\begin{document}
\begin{table}[ht]
\caption{Approximations to $\pi(x)$}
\centering
\begin{tabular}{|r| r| r| r| r| r|}
\hline
$x$ & $\pi(x)$ & $x/\log x$ & $\pi(x) / \frac{x}{\log x}$ & $\mathrm{Li}(x)$ & $\pi(x) / \mathrm{Li}(x)$  \\ [0.6ex] % inserts table %heading
\hline
$10^1$ & $4$     & $4.3$      & $0.921$ & $6$     & $0.6487609$ \\
$10^2$ & $25$    & $21.7$     & $1.151$ & $30$    & $0.8298440$ \\
$10^3$ & $168$   & $144.8$    & $1.160$ & $178$   & $0.9438202$ \\
$10^4$ & $1229$  & $1085.7$   & $1.132$ & $1246$  & $0.9863563$ \\
$10^5$ & $9592$  & $8685.9$   & $1.104$ & $9630$  & $0.9960540$ \\ 
$10^6$ & $78498$ & $72382.4$  & $1.085$ & $78628$ & $0.9983466$ \\        
\hline
\end{tabular}
\label{Table:ApproximationsPNT}
\end{table}
\end{document}

答案1

确实,使用booktabs和效果更好siuntix

姆韦

\documentclass[]{article}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}

\begin{table}[h!]
\caption{Jailed approximations to $\pi(x)$}
\centering
\begin{tabular}{|r| r| r| r| r| r|}
\hline
$x$ & $\pi(x)$ & $x/\log x$ & $\pi(x) / \frac{x}{\log x}$ & $\mathrm{Li}(x)$ & $\pi(x) / \mathrm{Li}(x)$  \\ [0.6ex] % inserts table %heading
\hline
$10^1$ & $4$     & $4.3$      & $0.921$ & $6$     & $0.6487609$ \\
$10^2$ & $25$    & $21.7$     & $1.151$ & $30$    & $0.8298440$ \\
$10^3$ & $168$   & $144.8$    & $1.160$ & $178$   & $0.9438202$ \\
$10^4$ & $1229$  & $1085.7$   & $1.132$ & $1246$  & $0.9863563$ \\
$10^5$ & $9592$  & $8685.9$   & $1.104$ & $9630$  & $0.9960540$ \\ 
$10^6$ & $78498$ & $72382.4$  & $1.085$ & $78628$ & $0.9983466$ \\        
\hline
\end{tabular}
\label{Table:ApproximationsPNT}
\end{table}

\begin{table}[h!]
\tabcolsep1em\belowcaptionskip1ex
\caption{Open approximations to $\pi(x)$\label{Table:Open}}
\centering
\begin{tabular}{
@{}S[table-format=0.0e5]
S[table-format=5.0]
S[table-format=5.1]
S[table-format=1.3]
S[table-format=5.1]
S[table-format=1.7]
}
\toprule
{$x$} &
{$\pi(x)$} &
{$x/\log x$} & 
{$\pi(x) / \frac{x}{\log x}$} &
{$\mathrm{Li}(x)$} &
{$\pi(x) / \mathrm{Li}(x)$}  \\\midrule
e1 & 4     & 4.3      & 0.921 & 6     & 0.6487609 \\
e2 & 25    & 21.7     & 1.151 & 30    & 0.8298440 \\
e3 & 168   & 144.8    & 1.160 & 178   & 0.9438202 \\
e4 & 1229  & 1085.7   & 1.132 & 1246  & 0.9863563 \\
e5 & 9592  & 8685.9   & 1.104 & 9630  & 0.9960540 \\ 
e6 & 78498 & 72382.4  & 1.085 & 78628 & 0.9983466 \\        
\bottomrule
\end{tabular}
\end{table}
\end{document}

相关内容