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?


\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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.