I want to create a simple table using the siunitx package.
The right column of the table should look like this:
- The T should be centered above everything, which comes below
- The numbers and text below should be aligned individually
- The numbers should be aligned at their decimal point
- The text should be left aligned
After reading the user guide of siunitx I thought the two fitting commands would be:
"table-number-alignment = center" to center the T above everything else and
"table-align-text-post = true" to align the text (centered and not left aligned, but could be figured out later).
The alignment on the decimal point is already a default
Lets look at the results:
\documentclass[12pt,a4paper,twoside]{scrreprt}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[english]{babel}
\usepackage{hhline}
\usepackage{siunitx}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\renewcommand{\arraystretch}{2}
\begin{document} % Dokument beginnen
\sisetup{table-align-text-post = true}
\begin{table}[t!]
\begin{center}
\begin{tabular}{@{}C{0.25\textwidth}@{}S[table-column-width = 0.25\textwidth]@{}}
\hline\hline
{Type} & {T} \\
\hhline{--}
1 & 2.222 \textsuperscript{a} \\
2 & 3.333 \textsuperscript{b} \\
3 & 4.444 \textsuperscript{c} \\
4 & 5.555 \textsuperscript{d} \\
5 & 6.66 \textsuperscript{e} \\
\hline\hline
\end{tabular}
\end{center}
\end{table}
\sisetup{table-number-alignment = center,table-align-text-post = true}
\begin{table}[t!]
\begin{center}
\begin{tabular}{@{}C{0.25\textwidth}@{}S[table-column-width = 0.25\textwidth]@{}}
\hline\hline
{Type} & {T} \\
\hhline{--}
1 & 2.222 \textsuperscript{a} \\
2 & 3.333 \textsuperscript{b} \\
3 & 4.444 \textsuperscript{c} \\
4 & 5.555 \textsuperscript{d} \\
5 & 6.66 \textsuperscript{e} \\
\hline\hline
\end{tabular}
\end{center}
\end{table}
\end{document}
Somehow table-align-text-post = true does not align the post-text on its own and if table-number-alignment = center is used it aligns the post-text, but it overlaps with the numbers. My first idea was, that the overlapping can be avoided by choosing the correct value for table-format, but this does not work. Also the T is not centered above the number in any of the cases.
Best Answer
Welcome to TeX.SE!
center
environment intable
float. It add spurious vertical space. Instead it rather use\centering command after
\begin{table}` as is done in MWE (Minimal Working example) below.S
columns is centerhhline
I would rather usebootabs
rules as are in the second example.Are above results what you after?
Addendum: You may consider write table with use of the
tabularray
package: