# Adding footnote to the table leads to the error: ! Extra }, or forgotten endgroup

TeX - LaTeX Asked on November 3, 2020

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> [email protected] plus.5fillrelax egroup egroup
begingroup [email protected] [email protected]
l.23 ...tal & 160tabularnote{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}

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]
}
Good & 120, & 41,5\
Total & 260,tabularnote{My footnote text.} & 100,0\
end{NiceTabular}
}
end{document}


(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}

sisetup{output-decimal-marker={,}}

protecteddefmyfootnote{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]
}
Good  & 120,5hphantom{textsuperscript{a}} & 41,5\
Bad   & 140rlap{tabularnote{My first note}}hphantom{,5textsuperscript{a}}  & 58,5\
Bad   & 140,5tabularnote{My second note}  & 58,5\
Total & hphantom{0}60hphantom{,5textsuperscript{a}} & 100,0\
end{NiceTabular}
}

end{document}


Correct answer by F. Pantigny on November 3, 2020

(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}

sisetup{output-decimal-marker={,}}

NewDocumentCommand { mytablenum } { } { tablenum[table-format=3,zero-decimal-to-integer]}

protecteddefmyfootnote{My table note.}

begin{document}
{footnotesize
begin{NiceTabular}[hvlines,code-before=rowcolor{gray!50}{1-1}]{
l
c
S[table-format=3.1]
}
Good  & mytablenum{120,5{tabularnote{myfootnote}}} & 41.5\
Total & mytablenum{60}rlap{tabularnote{Another table note.}} & 100.0\
end{NiceTabular}
}

end{document}


Answered by F. Pantigny on November 3, 2020

## Related Questions

### Left Align custom label with spaces along with items

1  Asked on May 9, 2021 by cpage

### TikZ transparency group breaks with overlay

1  Asked on May 9, 2021

### write18 with csname not evaluating

1  Asked on May 9, 2021 by kazza

### Filling an area with a pattern saved in a file

2  Asked on May 9, 2021

### Accordion Keyboard layout with TikZ

1  Asked on May 9, 2021 by zaord

### ConTeXt: Mix XHTML and TeX commands

1  Asked on May 9, 2021 by dave-jarvis

### In powerdot changed colors are always active and do not take the iacolor when they are inactive

1  Asked on May 9, 2021 by virgil

### Pandoc xelatex font-family with relative path

1  Asked on May 8, 2021 by ewilan-r

### Understanding [email protected]@accent and renewing it for conjoining diacritics

3  Asked on May 8, 2021 by niranjan

### CircuiTikZ – change position of voltage label along open draw

3  Asked on May 8, 2021 by draux

### Tikz: Is it possible to align any two nodes by aligning their subnodes？

2  Asked on May 8, 2021 by ziyan-chen

### Transform an imported list between brackets to a list between parentheses

3  Asked on May 8, 2021 by bruno-stonek

### Tuning spacing between words

1  Asked on May 8, 2021 by f3ss1

### TikZ plot for Enneper’s minimal surface?

2  Asked on May 8, 2021 by yiannis-i

### Creating a stacked bargraph with tikz, without values changing

1  Asked on May 8, 2021 by user214704

### Remove vertical spacing in wrapfigure (above/below hrule)

1  Asked on May 8, 2021 by anton-hinneck

### how to add caption above and alongside on Matrix

1  Asked on May 8, 2021

### Set path for SASnRDisplay

1  Asked on May 8, 2021 by qwethm

### Horizontal spacing between the footnote mark and the footnote text

0  Asked on May 8, 2021 by xavierstuvw

### Using different page numbering on bookclass, oneside with separate tex files

0  Asked on May 7, 2021