Content-Type: |
text/plain; charset=utf-8; format=flowed |
Date: |
Mon, 4 Apr 2016 18:16:48 +0200 |
Reply-To: |
|
Subject: |
|
MIME-Version: |
1.0 |
Message-ID: |
|
Content-Transfer-Encoding: |
7bit |
Sender: |
|
From: |
|
Parts/Attachments: |
|
|
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
|
|
|