# Why isn't this new comment environment working ? "Illegal parameter number", "can't use macro parameter # in horizontal mode" [duplicate]

I wanted to create a new comment environment with special format of comments to a text. Here is the MWE:

\documentclass[french, 11pt, a4paper, titlepage]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{fontawesome}

\newenvironment{commentaire}[1]
{
}
{
~(#1)
}

\begin{document}
text above
\begin{commentaire}{author}
comment
\end{commentaire}
text bellow
\end{document}


Got those two errors

• Illegal parameter number in definition of \endcommentaire line 12
• You can't use 'macro parameter character #' in horizontal mode. line 18

I don't understand, especially because my new environment seems to feature the recquirements Thank you !

• AFAIK you can't have an argument in the end code easily. It is only available in the start code. You would have to save it and use it later. See tex.stackexchange.com/q/17036/35864 Jun 19, 2018 at 9:42
• Alright thank you. That sucks so much, what's the point of all this.. Jun 19, 2018 at 9:50
• You can use \NewDocumentEnvironment from the xparse package. I allows to use the argument in the end code. Jun 19, 2018 at 10:08