Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}}}

share|improve this question
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

2 Answers 2

up vote 3 down vote accepted

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}}
share|improve this answer
    
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

Just what I was looking for, in my case I wanted a different style when there is only a chapter title but no sections (table of contets, glossary, etc in my thesis) and the rest that contains section to display the chapter but with different style. In case someone wonders this is the working code

\def\dummy{dummy}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\thechapter. #1 }}{\thechapter. #1} \def\dummy{#1}}
\renewcommand{\sectionmark}[1]{\markboth{\thechapter. \dummy}{\thechapter. \dummy}}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.