2

I wondered whether I could insert a * next to special values in a table. All values are right aligned to make them easily comparable. If I just type the * after an entry, the respective entry will no longer be in line with the others. Can I somehow place the *-symbol "outside the column"?

Edit: Some sample code, as requested by leandriis:

\begin{table*}[ht]
\centering
\begin{tabular}{lrrrrrrrrr}
   sample &\multicolumn{3}{c}{As [mg/kg]} &\multicolumn{3}{c}{Fe [g/kg]} &\multicolumn{3}{c}{Mn [mg/kg]} \\
 ID & digestion & HCl & PO4 & digestion & HCl & PO4 & digestion & HCl & PO4 \\

 \hline
G-01 & 5.60 & 0.52 & 0.79 & 232.35 & 1.64 & 0.36 & 20.89 & 193.06 & 138.13 \\ 
  GL-S1 & 1.00 & 0.52 & 0.41 & 5.31 & 1.68 & 0.32 & 139.77 & 216.07 & 98.11 \\

  GL-S2 & 1.07 & 0.49 & 0.58* & 5.58 & 1.63 & 0.34* & 124.60 & 191.87 & 138.28 \\

  GL-S3 & 1.20 & 0.55 & 0.73 & 6.34 & 1.81 & 0.34 & 120.96 & 198.15 & 127.67
\end{tabular}
\end{table*}
4
  • 3
    yes, e.g. with \rlap, siunitx has options for this too. Jun 21, 2019 at 16:19
  • Could you please add some example code for others to work with? Apart from that, the siunitx package and its S type columns might be useful given thatn "vaules" refers to numerical values.
    – leandriis
    Jun 21, 2019 at 16:19
  • 1
    Thanks for adding the example code. I have updated my answer to demonstrate how to apply the siunitx package (as well as some other changes) to your table.
    – leandriis
    Jun 21, 2019 at 16:39
  • Thanks a lot, your suggestion is a huge improvement to my table! Jun 22, 2019 at 22:04

1 Answer 1

2

Here is an updated answer on how to use the siunitx package on your example table. I have also used the horizontal lines from the booktabs package and the \ce command from the mhchem package in order to typeset PO4. (If this refers to the phosphate anion, you might want to add the charge as well.)

enter image description here

\documentclass{article}
\usepackage{geometry}
\usepackage[per-mode=symbol]{siunitx}
\usepackage[version=4]{mhchem}
\usepackage{booktabs}

\begin{document}

\begin{table*}[ht]
\centering
\begin{tabular}{l
                S[table-format=1.2]
                S[table-format=1.2]
                S[table-format=1.2,table-space-text-post = {*}]
                S[table-format=3.2]
                S[table-format=1.2]
                S[table-format=1.2,table-space-text-post = {*}]
                S[table-format=3.2]
                S[table-format=3.2]
                S[table-format=3.2]
                }
   sample &\multicolumn{3}{c}{As [\si{\mg\per \kg}]} &\multicolumn{3}{c}{Fe [\si{\g \per \kg}]} &\multicolumn{3}{c}{Mn [\si{\mg \per \kg}]} \\ 
   \cmidrule(r){2-4} \cmidrule(lr){5-7} \cmidrule(l){8-10}
 ID & {digestion} & {HCl} & \ce{PO4} & {digestion} & {HCl} & \ce{PO4} & {digestion} & {HCl} & \ce{PO4} \\
\midrule
G-01 & 5.60 & 0.52 & 0.79 & 232.35 & 1.64 & 0.36 & 20.89 & 193.06 & 138.13 \\ 
  GL-S1 & 1.00 & 0.52 & 0.41 & 5.31 & 1.68 & 0.32 & 139.77 & 216.07 & 98.11 \\

  GL-S2 & 1.07 & 0.49 & 0.58* & 5.58 & 1.63 & 0.34* & 124.60 & 191.87 & 138.28 \\

  GL-S3 & 1.20 & 0.55 & 0.73 & 6.34 & 1.81 & 0.34 & 120.96 & 198.15 & 127.67
\end{tabular}
\end{table*}
\end{document}

Original answer:

\documentclass{article}
\usepackage{siunitx}

\begin{document}

\begin{tabular}{lS[table-format=2.3,table-space-text-post = {*}]}
left aligned text & 1.24 \\
more text         & 1.343* \\
more text & 21.24* \\
more text         & 21.343 \\
\end{tabular}

\bigskip

\sisetup{table-align-text-post    = false}
\begin{tabular}{lS[table-format=2.3,table-space-text-post = {*}]}
left aligned text & 1.24 \\
more text         & 1.343* \\
more text & 21.24* \\
more text         & 21.343 \\
\end{tabular}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .