3

I want to produce a table with two prices in a row, using siunitx to achieve a pleasant and consistent display of the numbers. Trying not to repeat the currency symbol in the data rows, I insert it as a suffix into the relevant columns. This works well with one price tag per row; with a second one, however, siunitx seems to increase the space reserved for the suffix with each occurrence per row. Here is a pretty minimal example:

\documentclass{scrartcl}
\usepackage{polyglossia}
\usepackage{siunitx}
\sisetup{table-number-alignment=right}
\newcolumntype{E}[0]{S[
           table-figures-decimal=0,
           table-align-text-post=true,
           table-space-text-post={€}]<{€}}
\begin{document}
\begin{tabular}{EE}
63 & 126 \\
49 & 49 \\
\end{tabular}
\end{document}

If I get the format of the first column right, there is too much whitespace in the second one. Getting the second one right, moves the currency symbol into the figures of the first column.

(In case it matters: I'm using lualatex from the Debian texlive packages, version 2015.20160117-1.)

Any suggestions how I can get this working?

  • 2
    Manual, p. 71 "Adding items after the last column of a tabular" – Joseph Wright Feb 10 '16 at 15:53
  • Thank you! The \cr helps. Since this didn't hit me as long as I only had one S column per row (even if it was the last one), I must confess I ignored this hint. – DetlefL Feb 10 '16 at 16:03
1

enter image description here

% arara: lualatex

\documentclass{scrartcl}
\usepackage{polyglossia}
\usepackage{siunitx}
\newcolumntype{E}[1]{S[%
    ,table-format=#1
    ,table-space-text-post={\,€}]<{\,€}
    }

\begin{document}
% Quote taken from the manual page 71
When processing tables, \verb|siunitx| will expand anything stored
inside a macro, unless it is long or protected. \LaTeXe{} robust
commands are also detected and are not expanded. 
Values which would otherwise be expanded
can be protected by wrapping them in a set of braces. As \TeX{} itself
will expand the first token in a table cell before \verb|siunitx|
can act on it, using the $\varepsilon$-\TeX{} protected mechanism is the
recommended course of action to prevent expansion of macros in
table cells. (As is shown in the table, \TeX's expansion of
\LaTeXe{} robust commands can lead to unexpected results.)
\bigskip

\begin{tabular}{E{2.0}E{3.0}}
    63 & 126 \cr
    49 &  49 \cr
\end{tabular}
\end{document}

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.