LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
"Julien RIVAUD (_FrnchFrgg_)" <[log in to unmask]>
Reply To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Mon, 4 Apr 2016 18:16:48 +0200
Content-Type:
text/plain
Parts/Attachments:
text/plain (68 lines)
Hello,

Here is a MWE showing that xparse-created environments have unsafe 
closing code in alignments:

\documentclass{book}

\usepackage{xparse}

\NewDocumentEnvironment{foo}{m}{%
     \begin{tabular}{#1}%
}{%
     \end{tabular}%
}

\begin{document}

\fbox{
     \begin{foo}{ccc}
         \hline
         Test & a & b \\
         \hline
     \end{foo}
}

\fbox{
     \begin{tabular}{ccc}
         \hline
         Test & a & b \\
         \hline
     \end{tabular}
}

\end{document}

The first and second \fbox-es should produce the same output, but don't: 
the foo environment starts a second line at closing time, before the 
control is passed to the author-supplied closing code.

This example compiles but the output is wrong; it is simple to produce 
an error by including an \hline before the \end{tabular} when closing 
the |foo| environment:

\NewDocumentEnvironment{foo}{m}{%
     \begin{tabular}{#1}%
     \hline
}{%
     \hline
     \end{tabular}%
}

breaks with a "misplaced \noalign" (probably a "misplaced \omit" with 
mdwtabs since it doesn't use \noalign{\hrule} to draw \hlines, because 
of "unboxed" tabulars IIRC)

I remembered in error that the \endgroup of \end itself trigerred an 
error, but that's not the case (my belief was stupid anyway because 
tabular closes correctly tables with a missing \\ at the end). The fact 
remains that
* we get a spurious line that's very hard to remove
* the closing code of the environment is expanded in a cell, which is 
unexpected (even though tabular-enclosing authors should cope with 
unfinished lines IMHO)

Cheers,

Julien

ATOM RSS1 RSS2