# How to solve error - Illegal parameter number in definition of \AP@

I'm new to Latex and struggling to properly format a specific cover for my article.

I have the following code that fulfils what is expected from it and even compiles. However, the "Illegal parameter number in definition of \AP@" error appears when compiled.

What needs to change for the error to disappear?

\usepackage{afterpage}
\afterpage{
\newenvironment{capa}[2]{
\begin{list}{}{
\setlength{\topskip}{0pt}
\setlength{\leftmargin}{#1}
\setlength{\rightmargin}{#2}
\setlength{\listparindent}{0pt}
\setlength{\itemindent}{0pt}
\setlength{\parsep}{\parskip}
\setlength{\parindent}{0mm}
}
\item[]}{\end{list}}
\definecolor{grayish}{RGB}{89,89,89}

\centering
\includegraphics[scale=0.4]{xxxxxxxx} \\
\begin{capa}{7.9cm}{1.9cm}
\vspace*{65mm}
\noindent{
\textcolor{grayish}{\LARGE{xxxxxxxxx}}}
\vspace*{9mm}\\
\textcolor{grayish} {\LARGE { \noindent{ \textbf{xxxxxxxx}}} \\}
\vspace*{50mm}
\noindent { \textcolor{grayish} {\large{xxxxxxxxx}} \\ \\
\textcolor{grayish} {\large{xxxxxxxxx}}} \\
\\
\noindent {\textcolor{grayish} {\large{xxxxxxx }}\\
\textcolor{grayish} {\large{ \textit {xxxxxxxx}}}}
\vspace*{30mm}
\Small {ffffefefefe}
\newpage
\end{capa}
\restoregeometry}


Thanks for the help! Cheers.

• in the definition of capa, use ##1 and ##2 not #1 and #2. But \newenvironment will work only once, it would be better to move this definition to somwhere else. – user4686 Dec 11 '18 at 15:04
• It solved my problem! Thank you very much! I do want the newenvironment to work only in this case :) – Diogo Sá Dec 11 '18 at 15:29
• you are lucky the LaTeX team has not made \newenvironment preamble-only... – user4686 Dec 11 '18 at 16:04