I'm using the following commands inside my main TeX file right after the ToC.

\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ #1}{}}

I want to put it all into a new command \MainMatter. How can I do this? I have just tried to do so, however, I get the following error.

Illegal parameter number in definition of `\MainMatter`}.

How can this be done?


1 Answer 1


\newcommand definitions with arguments within another \renewcommand or \newcommand require a ##1, ##2 etc. for argument replacement, even if the outer command has no arguments at all.

In lack of a MWE, I just 'invented' one, defining the unknown command \myentitle.



\newcommand{\myentitle}{Some unknown text}
\renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter.\ ##1}{}}



\chapter{The very first chapter}


enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .