# Nested commands and their arguments

Please consider this code snips:

\def\chaptermark##1{\markboth{\@chapapp\ \thechapter\ ##1}{##1}}    % left mark & right marks


and

\def\sectionmark##1{\markright{##1}}


How can I redefine \sectionmark{} so that it contains the value (the ##1 argument) from \chaptermark##1 in \markright{}?

i.e something like this :

\def\sectionmark{\markright{\chaptermark##1{##1}}}

-
I might be missing something here, but if a chapter has already set the right mark to ##1, why do you need the section to also set it explicitly? –  Will Robertson Dec 7 '10 at 4:03
What I am after is that in my header, I want to make leftmark corresond to "PageNumber | Chapter ChapterNumber" while I want rightmark to be "ChapterTitle | PageNumber". The problem is that rightmark is determined by sectionmark which is the section title, so I want to redefine sectionmark to contain by the chapter title. –  user2330 Dec 7 '10 at 13:29

My thought is to define some sort of dummy variable/quantity with a default value which is changed as appropriate by \chaptermark and used by \sectionmark. For instance (keeping in mind I don't use \def much/at all):

\def\dummy {some default value}
\def\chaptermark##1{\markboth{\@chapapp\ \thechapter\ ##1}{##1} \def\dummy{##1}}
\def\sectionmark{\markright{\dummy}}

-
I was beating about the bush the whole time, very good for your answer. \def\dummy {Chapter Dummy} \def\chaptermark##1{\def\dummy{##1}} \def\chaptermark##1{\markboth{\@chapapp\ \thechapter\ ##1}{##1} \def\dummy{##1}} \def\sectionmark##1{\markright{\dummy}} –  user2330 Dec 7 '10 at 14:15
\def\dummy{dummy}