1

I got a table has two rows as titles at the top of it, and numbers in the rest cells, so I've checked the document of the siunitx, It says something abt multicolumn but its kinda different from what I want. Here is my latex code.

\begin{table}[]
\begin{tabular}{ll}
\multirow{2}{*}{twoc} & head   \\
                      & sub    \\
one                   & 3.456  \\
two                   & \textbf{23.657}
\end{tabular}
\end{table}

so basically its abt the multirow command I used here, and seems siunitx by default affects from the 2nd row if you put S[table-format=3.2] in the tabular, since I want it affects from the 3rd row cause I've got first 2 rows as titles, what should I do. Any good suggestions?

2
  • 1
    Your code isn't compilable. Please read about Minimal Working Example, adjust your question and it'll be easier for people to test your code and suggest corrections. Thank you.
    – Miyase
    Jul 2, 2022 at 15:38
  • @Miyase thanks, and I've changed my table codes, I merely want to align the 2 numbers with the decimal point.
    – Cup Y
    Jul 2, 2022 at 16:29

1 Answer 1

0

Like this?

enter image description here

As you see, numbers in third row are aligned at decimal pints, in the fourth row is centered.

Last (second) column is of S type, defined in the siunitx package:

\documentclass[margin=3mm, varwidth]{standalone}
\usepackage{siunitx}
\usepackage{multirow}

\usepackage{etoolbox}
\newrobustcmd\B{\DeclareFontSeriesDefault[rm]{bf}{b}%
                \bfseries}

\begin{document}
\begin{table}[ht]
\sisetup{detect-weight,
         mode=text,
         table-format = 2.3}
\begin{tabular}{l S}
    \hline
\multirow{2}{*}{two}    & {head}    \\
                        & {sub}     \\
    \hline
one                     &    3.456  \\
two                     &\B 23.657  \\
three                   & {12345}   \\
    \hline
\end{tabular}
\end{table}
\end{document}

is this what you looking for?

2
  • That's awesome! It works and I remain a few questions. Seems {} can maintain its original format, that's what I was looking for, or the sub may display improperly. And why \textbf doesn't work, what's the difference between them.
    – Cup Y
    Jul 3, 2022 at 3:27
  • @CupY, curly braces protect contents from align mechanism at decimal points. default is centered, but you can define other positioning (left, right). For details see package documentation. \t works inside braces, but then then formatting at decimal point is lost. For boldface numbers you need to switch cell to "boldface mode" (by use defined \B) and tell to siunitx (before) that should be aware of text weight.
    – Zarko
    Jul 3, 2022 at 4:34

You must log in to answer this question.

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