3

I am trying to recreate a certain table which displays the least positive primitive roots of the primes below 200.

enter image description here

One way to do this is to use the following code:

\documentclass{article}
\usepackage[greek]{babel}
\begin{document}
\begin{table}[htp]
\belowcaptionskip 0.5ex
\centering
\begin{tabular}{cc|cc}
\hline Πρώτος & Ελάχιστη θετική πρωταρχική ρίζα 
& Πρώτος & Ελάχιστη θετική πρωταρχική ρίζα \\
\hline 
$2$  & $1$ & $89$  & $3$  \\
$3$  & $2$ & $97$  & $5$  \\
$5$  & $2$ & $101$ & $2$  \\
$7$  & $3$ & $103$ & $5$  \\
$11$ & $2$ & $107$ & $2$  \\
$13$ & $2$ & $109$ & $6$  \\
$17$ & $3$ & $113$ & $3$  \\
$19$ & $2$ & $127$ & $3$  \\
$23$ & $5$ & $131$ & $2$  \\
$29$ & $2$ & $137$ & $3$  \\
$31$ & $3$ & $139$ & $2$  \\
$37$ & $2$ & $149$ & $2$  \\
$41$ & $6$ & $151$ & $6$  \\
$43$ & $3$ & $157$ & $5$  \\
$47$ & $5$ & $163$ & $2$  \\
$53$ & $2$ & $167$ & $5$  \\
$59$ & $2$ & $173$ & $2$  \\
$61$ & $2$ & $179$ & $2$  \\
$67$ & $2$ & $181$ & $2$  \\
$71$ & $7$ & $191$ & $19$ \\
$73$ & $5$ & $193$ & $5$  \\
$79$ & $3$ & $197$ & $2$  \\
$83$ & $2$ & $199$ & $3$  \\
\hline
\end{tabular}
\caption{Οι ελάχιστες θετικές πρωταρχικές ρίζες των πρώτων $< 200$}
\label{Table:LeastPositivePrimitiveRoots}
\end{table}
\end{document}

But that results in something ugly:

enter image description here

Any ideas how to achieve a better-looking result would be much appreciated. (The dollar signs around the numbers are needed due to babel; if I omit them, the numbers look different.)

chsk
  • 3,667
the_fox
  • 547

2 Answers2

4

Beauty is in the eye of the beholder, but how about this?

%!TEX TS-program = pdflatex
\documentclass{article}
\usepackage[greek]{babel}
\usepackage{booktabs}
\usepackage{makecell}
\begin{document}
\begin{table}[htp]
\belowcaptionskip 0.5ex
\centering
\begin{tabular}{cccc}
\toprule
\textbf{Πρώτος} & \makecell{\textbf{Ελάχιστη θετική}\\\textbf{πρωταρχική ρίζα}} &
\textbf{Πρώτος} & \makecell{\textbf{Ελάχιστη θετική}\\\textbf{πρωταρχική ρίζα}} \\
\midrule
$2$  & $1$ & $89$  & $3$  \\
$3$  & $2$ & $97$  & $5$  \\
$5$  & $2$ & $101$ & $2$  \\
$7$  & $3$ & $103$ & $5$  \\
$11$ & $2$ & $107$ & $2$  \\
$13$ & $2$ & $109$ & $6$  \\
$17$ & $3$ & $113$ & $3$  \\
$19$ & $2$ & $127$ & $3$  \\
$23$ & $5$ & $131$ & $2$  \\
$29$ & $2$ & $137$ & $3$  \\
$31$ & $3$ & $139$ & $2$  \\
$37$ & $2$ & $149$ & $2$  \\
$41$ & $6$ & $151$ & $6$  \\
$43$ & $3$ & $157$ & $5$  \\
$47$ & $5$ & $163$ & $2$  \\
$53$ & $2$ & $167$ & $5$  \\
$59$ & $2$ & $173$ & $2$  \\
$61$ & $2$ & $179$ & $2$  \\
$67$ & $2$ & $181$ & $2$  \\
$71$ & $7$ & $191$ & $19$ \\
$73$ & $5$ & $193$ & $5$  \\
$79$ & $3$ & $197$ & $2$  \\
$83$ & $2$ & $199$ & $3$  \\
\bottomrule
\end{tabular}
\caption{Οι ελάχιστες θετικές πρωταρχικές ρίζες των πρώτων $< 200$}
\label{Table:LeastPositivePrimitiveRoots}
\end{table}
\end{document}

enter image description here

This uses \toprule, \midrule and \bottomrule from booktabs, and also gets rid of the vertical line (which I personally am not a fan of; YMMV).

chsk
  • 3,667
  • I am trying to decide whether I want the middle vertical line or not. I am not a fan of vertical lines either, but in this case I think I'd prefer it. I am not completely sure though, so I'll mull it over for an hour or two. – the_fox Apr 09 '21 at 14:38
  • @the_fox I can see there being a case for including one here --- I primarily removed it because you'll get gaps if you use booktabs's rules. – chsk Apr 09 '21 at 14:42
4

In the following code, I used two \cmidrules from the booktabs package in combination with a horizontal white space in order to visually separate the two pairs of columns without using a vertical line. I also used the makecell package in order to add a linebreak in the column headers. Additionally, I added siunitx in order to improve the alignment of the numbers in their columns.

enter image description here

\documentclass{article}
\usepackage[greek]{babel}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{makecell}
\renewcommand{\theadfont}{\normalsize}

\begin{document} \begin{table}[htp] \belowcaptionskip 0.5ex \centering \begin{tabular}{S[table-format=2]S[table-format=1]@{\qquad}S[table-format=3]S[table-format=2]} \toprule {\thead{Πρώτος}} & {\thead{Ελάχιστη θετική\ πρωταρχική ρίζα}} & {\thead{Πρώτος}} & {\thead{Ελάχιστη θετική\ πρωταρχική ρίζα}} \ \cmidrule(r{2em}){1-2} \cmidrule(l){3-4} 2 & 1 & 89 & 3 \ 3 & 2 & 97 & 5 \ 5 & 2 & 101 & 2 \ 7 & 3 & 103 & 5 \ 11 & 2 & 107 & 2 \ \addlinespace 13 & 2 & 109 & 6 \ 17 & 3 & 113 & 3 \ 19 & 2 & 127 & 3 \ 23 & 5 & 131 & 2 \ 29 & 2 & 137 & 3 \ \addlinespace 31 & 3 & 139 & 2 \ 37 & 2 & 149 & 2 \ 41 & 6 & 151 & 6 \ 43 & 3 & 157 & 5 \ 47 & 5 & 163 & 2 \ \addlinespace 53 & 2 & 167 & 5 \ 59 & 2 & 173 & 2 \ 61 & 2 & 179 & 2 \ 67 & 2 & 181 & 2 \ 71 & 7 & 191 & 19 \ \addlinespace 73 & 5 & 193 & 5 \ 79 & 3 & 197 & 2 \ 83 & 2 & 199 & 3 \ \bottomrule \end{tabular} \caption{Οι ελάχιστες θετικές πρωταρχικές ρίζες των πρώτων < 200} \label{Table:LeastPositivePrimitiveRoots} \end{table} \end{document}


To save some more space, you could also use three insted of two pairs of columns. With a slightly decreased font size in the column headers the whole table still fits into the textwidth while at the same only needing 16 instead of 23 rows:

enter image description here

\documentclass{article}
\usepackage[greek]{babel}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{makecell}

\begin{document} \begin{table}[htp] \belowcaptionskip 0.5ex \centering \begin{tabular}{@{}S[table-format=2]S[table-format=1]@{\qquad} S[table-format=3]S[table-format=1] @{\qquad} S[table-format=3]S[table-format=2]@{}} \toprule {\thead{Πρώτος}} & {\thead{Ελάχιστη θετική\ πρωταρχική ρίζα}} & {\thead{Πρώτος}} & {\thead{Ελάχιστη θετική\ πρωταρχική ρίζα}} & {\thead{Πρώτος}} & {\thead{Ελάχιστη θετική\ πρωταρχική ρίζα}} \ \cmidrule(r{2em}){1-2} \cmidrule(lr{2em}){3-4} \cmidrule(l){5-6} 2 & 1 & 59 & 2 & 137 & 3 \ 3 & 2 & 61 & 2 & 139 & 2 \ 5 & 2 & 67 & 2 & 149 & 2 \ 7 & 3 & 71 & 7 & 151 & 6 \ \addlinespace 11 & 2 & 73 & 5 & 157 & 5 \ 13 & 2 & 79 & 3 & 163 & 2 \ 17 & 3 & 83 & 2 & 167 & 5 \ 19 & 2 & 89 & 3 & 173 & 2 \ \addlinespace 23 & 5 & 97 & 5 & 179 & 2 \ 29 & 2 & 101 & 2 & 181 & 2 \ 31 & 3 & 103 & 5 & 191 & 19 \ 37 & 2 & 107 & 2 & 193 & 5 \ \addlinespace 41 & 6 & 109 & 6 & 197 & 2 \ 43 & 3 & 113 & 3 & 199 & 3 \ 47 & 5 & 127 & 3 \ 53 & 2 & 131 & 2 \ \bottomrule \end{tabular} \caption{Οι ελάχιστες θετικές πρωταρχικές ρίζες των πρώτων < 200} \label{Table:LeastPositivePrimitiveRoots} \end{table} \end{document}

leandriis
  • 62,593
  • Thanks. One issue I am having is that the table (both your example and chsk's) takes up a whole page by itself, even though there is space for text to go above it and below it. Is there anything I can try? – the_fox Apr 09 '21 at 18:32
  • 1
    @the_fox: https://tex.stackexchange.com/a/169711/134144 might be interesting. – leandriis Apr 09 '21 at 18:37
  • Thanks! I wasn't aware of that 60% rule. – the_fox Apr 09 '21 at 18:47