[Tex/LaTex] What does \marks do

e-texmacrosprimitivestex-core

Recently I had cause to define a macro called \marks. If I try something like

\newcommand{\marks}{fred}

I get the error

! LaTeX Error: Command \marks already defined.

In LaTeX, if I do \show\marks I get > \marks=\marks, which I think means it's a TeX primitive, but if I execute the same show command in TeX, I get > \marks=undefined. I can't find \marks in any documentation that I have. What does it do?

Best Answer

\marks is an etex primitive command. It extends the \mark command of the original tex. You can use it to store text on the current page which you want to use at shipout in the headers.

\documentclass{article}
\usepackage{etex}
\newmarks\mymark
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\lhead{\topmarks\mymark, \botmarks\mymark, \firstmarks\mymark}
\begin{document}
text
\marks\mymark{A first mark}

\marks\mymark{A second mark}

\newpage

text \marks\mymark{A third mark}
\end{document}