4

So I am not sure if this is an appropriate question, but I'll ask it anyway. I don't have much experience with creating tables in latex and I needed to create one now. It doesn't look quite right to me though. If any experienced users could weigh in on how they would create the same table, I'd appreciate it a lot.

\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}
2

1 Answer 1

7

Indeed, better with booktabs and siuntix:

mwe

\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}
2
  • +1. I'd consider adding the instruction \sisetup{group-four-digits} in order to give a more uniform visual treatment to four- and five-digit numbers. And, for the penultimate column, replace S[table-format=5.1] with S[table-format=5.0]?
    – Mico
    Feb 14, 2021 at 10:28
  • @Mico Although in this table look more aesthetic, I would not group in four digits if this must be also applied for consistency elsewhere in the main text. And yes, the penultimate column should be 5.0.
    – Fran
    Feb 15, 2021 at 5:08

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