0

When I use NewDocumentEnvironment of xparse and place a table to be inside this environment, I get an extra row at the end. Same code does not cause extra row in standard newenvironment. Is there a solution to this problem? I have tried using \ignorespaces and made entire thing single line without spaces, still the same result. I have compiled a MWE below:

\documentclass{article}

\usepackage{xparse}

\NewDocumentEnvironment{test}{}{%
    \begin{tabular}{|l|l|l|}\hline%
        A & B & C \\\hline%
}{%
    \end{tabular}%
}

\newenvironment{testtwo}{%
    \begin{tabular}{|l|l|l|}\hline%
        A & B & C \\\hline%
}{%
    \end{tabular}%
}

\begin{document}
    \begin{test}
        This & does not & work\\\hline
    \end{test}

    ~\\~\\

    \begin{testtwo}
        This & does & work\\\hline
    \end{testtwo}   
\end{document}

Result:

result

Browse other questions tagged or ask your own question.