TransWikia.com

Spurious blank row with longtable and expl3 map function

TeX - LaTeX Asked by aejh on November 12, 2020

I’ve got some data in an expl3 sequence, which I’m using in a longtable. All works fine, but I’m getting an additional blank row after the inline map body. MWE:

documentclass{article}
usepackage{expl3}
usepackage{xparse}
usepackage{longtable}

ExplSyntaxOn

NewDocumentCommand{printData}{}
 {
   begin{longtable}{l}
     hline
     Minimal~Working~Example 
     hline
     endhead
     End 
     hline
     endfoot
     clist_map_inline:nn
       {comma,separated,list,of,data,also,fails,with,seq}
       {
         ##1 
         hline
       }
% Uncomment to fill the blank row
%       Mystery row here!  hline
   end{longtable}
 }

ExplSyntaxOff

begin{document}
printData
end{document}

Which produces:

Blank row

The intention is for the final loop of the inline map to close with an hline, running straight into the footer. I’m on an older version of texlive and pdflatex (from Ubuntu 18.04), but this error is also present on overleaf, which I’m assuming is up to date, so I presume the error is mine.

One Answer

Use clist_map_function:nN otherwise a cell would be started; to the contrary, clist_map_function:nN delivers its complete result before anything that TeX takes as the start of a cell is considered.

Tables are well known to be a source of problems of this kind.

documentclass{article}
usepackage{expl3}
usepackage{xparse}
usepackage{longtable}

ExplSyntaxOn

NewDocumentCommand{printData}{}
 {
  begin{longtable}{l}
  hline
  Minimal~Working~Example 
  hline
  endhead
  End 
  hline
  endfoot
  clist_map_function:nN {comma,separated,list,of,data} aejh_entry:n
  end{longtable}
 }

cs_new_protected:Nn aejh_entry:n { #1  hline }

ExplSyntaxOff

begin{document}

printData

end{document}

enter image description here

Correct answer by egreg on November 12, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP