6

When using this code, all is OK:

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{cellspace}
\begin{document}

\begin{tabular}{|c|S{p{1cm}}|}
    \hline
    foo & bar \\
    \hline
     a & É \\
    \hline  
\end{tabular}

\end{document}

Resulting output is OK

But when a p-column type with the cellspace contain an empty cell, as in this code:

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{cellspace}
\begin{document}

\begin{tabular}{|c|S{p{1cm}}|}
    \hline
    foo &  \\
    \hline
     a & É \\
    \hline  
\end{tabular}

\end{document}

I obtain a white first page, and on the second page, an huge height for the first row:

Resulting output is not OK

The log contain this message:

Overfull \vbox (482.37025pt too high) has occurred while \output is active

Is this the expected behaviour?

To workaround this, instead of an empty cell, I can use an explicit white space (\ ). But perhaps there is a better solution?

Same bug with an m-column-type (from the array package). l, c and r column-types aren't affected by this strange behaviour.

2
2

Add an >{\arraybackslash} to the last column:

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{cellspace}
\setlength{\cellspacetoplimit}{4pt}
\setlength{\cellspacebottomlimit}{4pt}

\begin{document}

\begin{tabular}{|c|S{>{\arraybackslash}p{1cm}}|}
    \hline
    foo & \\
    \hline
     a & É \\
    \hline
\end{tabular}

\end{document} 

enter image description here

4
  • What is the technical reason for the necessity to adding >{\arraybackslash} on this S-column, when a cell is empty? Why only for p or m column type? – quark67 Mar 22 at 11:51
  • I don't know the details, but as far as I know, there may be problems with the \\ row breaking in tables when the last column is p{some length} or similar, because it may happen that latex doesn't know whether it is used for a new row or for a line break in the cell? – Bernard Mar 22 at 11:56
  • But without the S specification, >{\arraybackslash} isn't needed. Anyway, I have opened an issue on the GitHub project for the cellspace package. – quark67 Mar 22 at 11:59
  • You did well. I guess there's an interaction between cellspace, the paragraph-like column types and \\, for some reason. I already had a similar problem with an X column type. – Bernard Mar 22 at 12:02
2

For information, if you use nicematrix and its parameter cell-space-limits, you don't have that problem.

\documentclass[11pt]{article}
\usepackage{nicematrix}
\begin{document}

\NiceMatrixOptions{cell-space-limits=1pt}
\begin{NiceTabular}{|c|p{1cm}|}
    \hline
    foo &  \\
    \hline
     a & É \\
    \hline  
\end{NiceTabular}

\end{document}

Output of the above code

1
  • Good to know. Thanks. – quark67 Mar 22 at 12:02

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.