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}


    text above
    text bellow

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
    – moewe
    Jun 19, 2018 at 9:42
  • Alright thank you. That sucks so much, what's the point of all this..
    – Odyseus_v4
    Jun 19, 2018 at 9:50
  • Well, that's just one of TeX's little quirks. But as you can see in the linked question there are work-arounds that are not too complicated. \newcommand{\commarg}{}\newenvironment{commentaire}[1] {\renewcommand*{\commarg}{#1}\paragraph{\faCommentsO}} {~(\commarg)} probably being the easiest.
    – moewe
    Jun 19, 2018 at 9:56
  • 1
    You can use \NewDocumentEnvironment from the xparse package. I allows to use the argument in the end code. Jun 19, 2018 at 10:08


Browse other questions tagged or ask your own question.