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.

What do the toc related commands \@mkboth and \markboth do?

share|improve this question
2  
It is mostly the same as \markboth, the kernel docs suggest class and package writers sometimes use \@mkboth instead as then certain packages can redefine it to do nothing. See texdoc source2e –  daleif Aug 30 at 15:26
    
Fair enough. I now edited the question to ask for \markboth as well. –  Mappi Aug 30 at 15:36

1 Answer 1

up vote 7 down vote accepted

Here is the definition of \markboth from the LaTeX kernel:

\def\markboth#1#2{%
  \begingroup
    \let\label\relax \let\index\relax \let\glossary\relax
    \unrestored@protected@xdef\@themark {{#1}{#2}}%
    \@temptokena \expandafter{\@themark}%
    \mark{\the\@temptokena}%
  \endgroup
  \if@nobreak\ifvmode\nobreak\fi\fi}

It takes two arguments, designed to aid in the setting of the headers in twoside mode - the first is set as the left page header, while the second ends up in the right page header.

In contrast, \@mkboth is used as an internal kernel tool and may take on multiple functions. From source2e (section 65.3 marking conventions, p 310):

Commands like \tableofcontents that should set the marks in some page styles use a \@mkboth command, which is \let by the pagestyle command (\ps@...) to \markboth for setting the heading or to \@gobbletwo to do nothing.

For example, the empty page style (in latex.ltx) sets

\def\ps@empty{%
  \let\@mkboth\@gobbletwo\let\@oddhead\@empty\let\@oddfoot\@empty
  \let\@evenhead\@empty\let\@evenfoot\@empty}

while the headings page style (in article.cls) sets

\if@twoside
  \def\ps@headings{%
      \let\@oddfoot\@empty\let\@evenfoot\@empty
      \def\@evenhead{\thepage\hfil\slshape\leftmark}%
      \def\@oddhead{{\slshape\rightmark}\hfil\thepage}%
      \let\@mkboth\markboth
      ...
share|improve this answer
    
Are \markboth and \@mkboth thus only intended to be used with twoside option? –  Mappi Aug 30 at 17:41
    
@Mappi: No. Their effect will depend on the twoside option, but you can use them in both. –  Werner Aug 30 at 17:47

Your Answer

 
discard

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

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