0

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]
{
\paragraph{\faCommentsO}
}
{
~(#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 https://tex.stackexchange.com/q/17036/35864 – moewe Jun 19 '18 at 09:42
  • Alright thank you. That sucks so much, what's the point of all this.. – Odyseus_v4 Jun 19 '18 at 09: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 '18 at 09:56
  • 1
    You can use \NewDocumentEnvironment from the xparse package. I allows to use the argument in the end code. – Ulrike Fischer Jun 19 '18 at 10:08

0 Answers0