# What do \@mkboth and \markboth do?

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

• 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 '14 at 15:26
• Fair enough. I now edited the question to ask for \markboth as well. – Mappi Aug 30 '14 at 15:36

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{%


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

\if@twoside

• Are \markboth and \@mkboth thus only intended to be used with twoside option? – Mappi Aug 30 '14 at 17:41
• @Mappi: No. Their effect will depend on the twoside option, but you can use them in both. – Werner Aug 30 '14 at 17:47
• For anybody else who's also wondering what \unrestored@protected@xdef does, I asked this question (which was before I got enough reputation to comment everywhere, thus explaining why I didn't just ask in a comment on this answer.) – RandomDSdevel Dec 31 '17 at 2:32
• @Werner: OK, but what does the \temptokena macro do? – RandomDSdevel Dec 31 '17 at 2:38
• no \firatmark and \botmark are primitives so they will get the contents of \mark (both groups) but the latex macros \@leftmark and \@rightmark extract the first or second group respectively – David Carlisle Jan 2 '18 at 0:22