I am trying to define a new command in my Latex file like this
\newcommand{\newchunk}[1][2]{\section{#2}\label{sec:#1}\quad}
But I get the following error after Latex compilation
ERROR: Illegal parameter number in definition of \\newchunk.
--- TeX said ---
<to be read again>
2
l.58 ...nk}[1][2]{\section{#2}\label{sec:#1}\quad}
--- HELP ---
This is probably caused by a \newcommand, \renewcommand,
\newenvironment, or \renewenvironment command in which a # is used
incorrectly. A # character, except as part of the command name \#,
can be used only to indicate an argument parameter, as in #2, which
denotes the second argument. This error is also caused by nesting one
of the above four commands inside another, or by putting a parameter
like #2 in the last argument of a \newenvironment or \renewenvironment
command.
Don't we use #2 to refer to the second argument? Where am I going wrong?
\newchunk{label}{Title}over the clearer\section{Title}\label{label}? – egreg Nov 06 '18 at 00:14\labelcommands in the source. Here you're hiding them so chances are your editor will not see these labels and include them in the choose reference interface. – daleif Nov 06 '18 at 07:03