2

I found the related question Easiest way to delete a column?, which has a good answer for regular c type columns. But my data is formatted in the S type from siunitx, in the form of value \pm error. According to the array package, c is one of the supported column types, but the S type is not. Here is a MWE of what I tried:

\documentclass[a4paper]{article}
\usepackage{siunitx}
\usepackage{array}
\newcolumntype{H}{>{\setbox0=\hbox\bgroup}c<{\egroup}@{}} % hidden column for c
\newcolumntype{G}{>{\setbox0=\hbox\bgroup}S<{\egroup}@{}} % hidden column for S

\begin{document}

\fbox{ \begin{tabular}{ccSc} % current format of my table, I want to hide the S column one & two & \text{S-type column} & three\ 1 & 2 & 2 \pm 1 & 3 \end{tabular} }

\fbox{ \begin{tabular}{ccHc} % column hide solution from the linked question one & two & hide & three\ 1 & 2 & H & 3 \end{tabular} }

\fbox{ \begin{tabular}{ccc} % intended result one & two & three\ 1 & 2 & 3 \end{tabular} }

\end{document}

The result is that in the second table, the third column is hidden. What I want to achieve is to hide the third column in the first table. But if I naively replace the S in the table format {ccSc} with my new G type {ccGc}, LaTeX throws an error:

! Extra }, or forgotten \endgroup.
<template> \unskip \egroup 
                           \__siunitx_table_print: \relax \d@llarend \do@row...
l.14 }

?

skaphle
  • 23
  • 1
    Use H, what’s the problem? – egreg Oct 21 '20 at 16:42
  • @egreg the problem is that the entries in the table don't work with c or H because of the 2 \pm 1. I get
    <inserted text> 
                    $
    l.14 }```
    
    – skaphle Oct 22 '20 at 18:20
  • Please, add a proper example, then. – egreg Oct 22 '20 at 19:24
  • @egreg What would a proper example look like? I thought I made a good MWE in my question. I could add the minimal non-working example, but it is only replacing S with G in the first table. Apologies if that is unclear. – skaphle Oct 23 '20 at 11:02

1 Answers1

1

You can add instructions to ignore \pm.

\documentclass[a4paper]{article}
\usepackage{siunitx}
\usepackage{array}
\newcolumntype{H}{>{\setbox0=\hbox\bgroup\let\pm\relax}c<{\egroup}@{}} % hidden column for c

\begin{document}

\begin{tabular}{ccS[table-format=1.0(1)]c} one & two & \text{S-type column} & three\ 1 & 2 & 2 \pm 1 & 3 \end{tabular}

\begin{tabular}{ccHc} one & two & \text{S-type column} & three\ 1 & 2 & 2 \pm 1 & 3 \end{tabular}

\end{document}

enter image description here

egreg
  • 1,121,712