5

By making tables I am using packages siunitx, nicematrix and makecell. These three packages applied simultaneously seems to be sufficient for solving my problems with tables - like this one. I am using siunitx package, not dcolumn package, because the last one gives not satisfying placement of numbers. I met the problem with placing the table note. The note mark has to be placed in the cell of the middle column. While I am using S-type column within NiceTabular environment I got the error:

! Extra }, or forgotten \endgroup. <template> ...z@ plus.5fill\relax \egroup \egroup \begingroup \CT@setup \CT@... l.23 ...tal & 160\tabularnote{My footnote text.} & 100,0\\ 

How to solve this problem? It resembles this one (in this topic probably one of @moewe's comments leads to the solution, nevertheless I can't cope with it). Code:

\documentclass[table]{standalone} \usepackage{siunitx} \usepackage{makecell} \usepackage{nicematrix} \usepackage{enumitem} \renewcommand{\theadfont}{\footnotesize\bfseries} \sisetup{output-decimal-marker={,}} \begin{document} {\footnotesize \begin{NiceTabular}[hvlines,code-before=\rowcolor{gray!50}{1-1}]{ l S[table-format=3,zero-decimal-to-integer,table-space-text-post=\textsuperscript{a}] S[table-format=3.1] } {\thead{Side-heading\\description}} & {\thead{First column\\with data\\description}} & {\thead{Second column\\with data\\description}}\\ Good & 120, & 41,5\\ Bad & 140, & 58,5\\ Total & 260,\tabularnote{My footnote text.} & 100,0\\ \end{NiceTabular} } \end{document} 
0

2 Answers 2

3

(I'm the author of nicematrix)

In a first answer to this question, I have said that the problem of the OP is a (partial) incompatibility between nicematrix and the columns S of siunitx. I've given a workaround with \tablenum of siunitx.

Here is another workaround: siunitx is not used at all (in the first column). This is really a heavy workaround because you have to do the job of centering by hand will \hphantom and \rlap. However, by this way, the contents are strictly centered (including the labels of the tabular notes).

\documentclass{article} \usepackage{siunitx} \usepackage{makecell} \usepackage{nicematrix} \usepackage{enumitem} \renewcommand{\theadfont}{\footnotesize\bfseries} \sisetup{output-decimal-marker={,}} \protected\def\myfootnote{My table note.} \begin{document} {\footnotesize \begin{NiceTabular}[hvlines,code-before=\rowcolor{gray!50}{1-1}]{ l c S[table-format=3.1,zero-decimal-to-integer] } {\thead{Side-heading\\description}} & {\thead{First column\\with data\\description}} & {\thead{Second column\\with data\\description}}\\ Good & 120,5\hphantom{\textsuperscript{a}} & 41,5\\ Bad & 140\rlap{\tabularnote{My first note}}\hphantom{,5\textsuperscript{a}} & 58,5\\ Bad & 140,5\tabularnote{My second note} & 58,5\\ Total & \hphantom{0}60\hphantom{,5\textsuperscript{a}} & 100,0\\ \end{NiceTabular} } \end{document} 

Output of the above code

8

(I'm the author of nicematrix).

This is a partial incompatibility between nicematrix and the columns S of siunitx.

I will try to find a solution but here is a workaround by using the command \tablenum of siunitx (which is the 'command version' of the S column type).

However, the command tablenum seems to delete all the spaces in its argument (and it will delete the spaces in the text of the tabular note). That's why I have put the text of the tabular note in a TeX macro \myfootnote (it would be possible to use \NewDocumentCommand but I wanted to emphasize the fact that it must be protected).

Moreover, the case of an integer number requires a special treatment...

\documentclass{article} \usepackage{siunitx} \usepackage{makecell} \usepackage{nicematrix} \usepackage{enumitem} \renewcommand{\theadfont}{\footnotesize\bfseries} \sisetup{output-decimal-marker={,}} \NewDocumentCommand { \mytablenum } { } { \tablenum[table-format=3,zero-decimal-to-integer]} \protected\def\myfootnote{My table note.} \begin{document} {\footnotesize \begin{NiceTabular}[hvlines,code-before=\rowcolor{gray!50}{1-1}]{ l c S[table-format=3.1] } {\thead{Side-heading\\description}} & {\thead{First column\\with data\\description}} & {\thead{Second column\\with data\\description}}\\ Good & \mytablenum{120,5{\tabularnote{\myfootnote}}} & 41.5\\ Bad & \mytablenum{140,} & 58.5\\ Total & \mytablenum{60}\rlap{\tabularnote{Another table note.}} & 100.0\\ \end{NiceTabular} } \end{document} 

Output of the above code

8
  • Thank you for the response. Now I am trying to apply this to the integer number - it is not correct to emphasize that in some process is not engaged the fractional part of person, by adding decimal part to the number (in Polish komma is s decimal separator). Could you give some prompt, how to apply your solution to column with integers, please? Commented Sep 29, 2020 at 7:48
  • 1
    I'm not sure to understand what you mean but I have modified my answer to put a tabular note next to an integer number (it's a workaround...). Commented Sep 29, 2020 at 8:52
  • In my table the number of people has to be eg. 721, not 721.0. Removing the statement table-space-text-post=\textsuperscript{a} leads to wrong horizontal placement: the widest string (according to my guidebooks), which in your response is 120,5a has to be centered horizontally in the cell. But adding table-space-text-post=\textsuperscript{a} gives unwanted space between number and footnotemark. Commented Sep 29, 2020 at 9:48
  • 1
    If you want the contents of the first column centered (including the lables of the tabular notes), I think that, as of now, you will have to drop \tablenum in that column and do the job by hand. I have put a second answer where I do the whole job by hand (it's an awful workaround). Commented Sep 29, 2020 at 11:14
  • 1
    Yes. It would work but the \!\!\!\! is an adjustement 'by hand'... Commented Sep 29, 2020 at 19:03

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.