0

This question already has an answer here:

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

marked as duplicate by Maarten Dhondt, user13907, Romain Picot, AboAmmar, Joseph Wright Jan 6 '16 at 10:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Browse other questions tagged or ask your own question.