5

please, consider the following two mwe-s:

the first:

\documentclass{article}
\usepackage{siunitx}
\usepackage{cellspace}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}
\addparagraphcolumntypes{X}
\usepackage{tabularx}

\begin{document}
\begin{tabularx}{3cm}{X Cc c}
    \hline
A   &   123   &   456   \\
    \hline
\end{tabularx}
\end{document}

the second:

\documentclass{article}
\usepackage{siunitx}
\usepackage{cellspace}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}
\addparagraphcolumntypes{X}
\usepackage{tabularx}

\begin{document}
\begin{tabularx}{3cm}{CX c c}
    \hline
A   &   123   &   456   \\
    \hline
\end{tabularx}
\end{document}

the first one work as expected, the second one throw error:

! Package array error: Illegal pream-token (\ecolumn): `c' used.

apparently specifier CX doesn't work as i expected. what i doing wrong?

  • For me (TL 2016), it works if I write C{X} instead of X in the \begin{tabularx}{3cm}{...} spec. – frougon May 11 '18 at 8:01
  • @frougon, indeed. so far this i dindn't found in mentioned packages documentation :-( – Zarko May 11 '18 at 8:08
  • I don't find it obvious from the documentation either (where explicit specifiers with braces like p{3cm} are given where S{...} is mentioned), that's why I just said “it works for me” and didn't propose it as an answer... – frougon May 11 '18 at 8:15
6

Like all column specifiers that set the column width (p, m, b), the X column type requires a pair of braces:

\documentclass{article}
\usepackage{siunitx}
\usepackage{cellspace}
\setlength\cellspacetoplimit{25pt}
\setlength\cellspacebottomlimit{25pt}
\addparagraphcolumntypes{X}
\usepackage{tabularx}

\begin{document}

\begin{tabularx}{3cm}{C{X} c c}
    \hline
A & 123 & 456 \\
    \hline
\end{tabularx}

\end{document} 

enter image description here

Edit: @UlrikeFischer's answer reminded me cellspace now lets you change the pre-specifier via an option of the package, so you're no more dependent on siunitx patch: if the part of siunitx concerning cellspace is removed, using, say:

\usepackage[column=O]{cellspace}

you can use {OX c c}as a preamble for the table, without braces around X (tested).

  • now i wonder, why specifier SX works if i delete siunitx package. for this reason i mentioned it in question title. however, for all columns' specifiers whit prescribed column width, encapsulation into curly braces is necessary. – Zarko May 11 '18 at 8:22
  • @Zarko: That's strange… A few years ago, neither would work without braces, if I remember well, and I didn't have the opportunity to test it recently. Maybe it (partially) works without braces since last year update? – Bernard May 11 '18 at 8:29
  • hm, this doesn't work at me -(. error: ! File ended while scaning use of \__siunitx_tmp:w }. i have installed recent siunitx and with tables related packages – Zarko May 11 '18 at 8:58
  • And did you update cellspace? – Bernard May 11 '18 at 9:06
  • i have: cellspace 2017/08/12—v1.7, siunitx v2.7o, 2018-05-02. it seems that Ulrike has right: it is also necessary to fool siunitx. – Zarko May 11 '18 at 10:34
6

The code siunitx uses to change the cellspace column type from S to C seems to be faulty. If one let cellspace change the name and fool siunitx so that it doesn't interfere it works again:

\documentclass{article}

\usepackage[column=C]{cellspace}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}
\addparagraphcolumntypes{X}
\usepackage{tabularx}
\usepackage{siunitx}

\usepackage{etoolbox}
\cslet{ver@cellspace.sty}{\somethingundefined} %fool siunitx 
\begin{document}
\begin{tabularx}{3cm}{CX c c}
    \hline
A   &   123   &   456   \\
    \hline
\end{tabularx}
\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.