2

I'm making a small table with numbers and units given with the \SI{num}{unit} call. However, the units stretches outside the table width, such that the booktabslines (or any other line) looks too short.

An MWE:

\documentclass[11pt, english]{article}

\usepackage{siunitx}
\usepackage{booktabs}
\newcommand{\m}{\hat{m}}

\begin{document}
\begin{table}[H]
    \centering
    \caption{Some table}
    \begin{tabular}{
    r
    c
    S[table-format = 3.2]
    }
        \toprule
        Beskrivelse & Variabel & {Verdi}  \\
        \midrule
        Temperaturer & $T_{\m_2}^\text{rev}$ & 558.3\si{\kelvin} \\
        & $T_{\m_4}^\text{rev}$ & 542.3\si{\kelvin} \\
        Reversibelt arbeid & $W_{s,1}^\text{rev}$ & 237.5\si{\kilo\watt} \\
                           & $W_{s,2}^\text{rev}$ & 213.4\si{\kilo\watt} \\
        Arbeid & $W_{s,1}$ & 339.3\si{\kilo\watt} \\
               & $W_{s,2}$ & 304.9\si{\kilo\watt} \\
        Totalt & $W_s$ & 644.2 \si{\kilo\watt} \\
        \bottomrule
    \end{tabular}
\end{table}
\end{document}  

which produces the following

short_lines

As you can see, it doesn't look good. Any solution to this?

7
  • 1
    The S column is for numbers only: you are sticking in 'extra stuff' without allowing any space for it. – Joseph Wright Mar 19 '13 at 15:14
  • 1
    As @JosephWright explains: You will either use table-space-text-post=\si{\kilo\watt} or (recommended) a separate s column (it’s there for exactly this reason). – Qrrbrbirlbel Mar 19 '13 at 15:17
  • Is there a problem if you leave out the table-format option, i.e. just let siunitx center the content decimally without explicitly specifying the width? – bencarabelli Mar 19 '13 at 15:18
  • 2
    @benwilfut In that case, the stagey is to centre the decimal marker. That works well if the number is approximately 'symmetrical', but is less good if it's not. – Joseph Wright Mar 19 '13 at 16:10
  • Isn't the normal recommentation to add the row units to the (row) stub instead? i.e. write Temperaturer (\si{\kelvin}) and then remove the unit from the value itself. – daleif Mar 19 '13 at 16:12
4

According the questions comments, the answer would be:

\documentclass[11pt, english]{article}  
\usepackage{siunitx}
\usepackage{booktabs}
\newcommand{\m}{\hat{m}}
\begin{document}
\begin{table}
    \centering
    \caption{Some table}
    \begin{tabular}{
    l
    c
    S[table-format = 3.1]      
    @{\,}
    s[table-unit-alignment = left]
    }
        \toprule
        Beskrivelse & Variabel & \multicolumn{2}{c}{Verdi} \\
        \midrule
        Temperaturer & $T_{\m_2}^\text{rev}$ & 558.3&\kelvin \\
        & $T_{\m_4}^\text{rev}$ & 542.3&\kelvin \\
        Reversibelt arbeid & $W_{s,1}^\text{rev}$ & 237.5&\kilo\watt \\
                           & $W_{s,2}^\text{rev}$ & 213.4&\kilo\watt \\
        Arbeid & $W_{s,1}$ & 339.3&\kilo\watt \\
               & $W_{s,2}$ & 304.9&\kilo\watt \\
        Totalt & $W_s$ & 644.2&\kilo\watt \\
        \bottomrule
    \end{tabular}
\end{table}
\end{document} 

I find it strange to have the units centered and that far away from the numbers. For different mantissa lengths, this might be the correct way. But here, the mantissa is set to 3.2. The distance between number and unit can be shortened by the mantissa length 3.1. The alignment is changed by the column option table-unit-alignment=left (thanks to @Qrrbrbirlbel).

enter image description here

4
  • 1
    S[table-format = 3.1] @{\,} s[table-alignment = left] for the last two columns. The first column should be left aligned and Verdi should be \multicolumn{2}{c}{Verdi} so as to encompass both the final columns. – egreg Mar 19 '13 at 15:35
  • @egreg: thanks. adopted your comment. Overlooked that option in the doc. – Toscho Mar 19 '13 at 15:42
  • @egreg Just to clarify: The table-alignment option sets the options table-number-alignment, table-text-alignment and table-unit-alignment to the same value. For a global declaration (i.e. \sisetup in the preamble) it’s better to use table-unit-alignment. In this particular case (no text in the s column) it doesn’t really matter. – Qrrbrbirlbel Mar 19 '13 at 15:55
  • @Qrrbrbirlbel There are too many options! ;-). Better to correct, anyway. – egreg Mar 19 '13 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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