[texhax] First and last value of custom counter in header

Aleksandar Zec zealeksanman at gmail.com
Mon May 10 09:18:43 CEST 2010


2010/5/9 Heiko Oberdiek <heiko.oberdiek at googlemail.com>:
> Classical case for a marks register. Example that uses an additional
> marks register provided by e-TeX:
> [tex code]

Heiko, thank you very much, I didn't know for this ellegant e-TeX
possibility regarding marks. However, this does not always work in
multicols environment (it works without multicols). Example:

\documentclass[a4paper]{article}
\usepackage{etex}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{multicol}
\newmarks\dictmark
\usepackage{fancyhdr}
\fancyhead{}
\fancyhead[C]{\firstmarks\dictmark--\botmarks\dictmark}
\fancyfoot{}
\fancyfoot[C]{page \thepage}
\pagestyle{fancy}

\newcounter{cnt}
\newcommand*{\TheCnt}{%
  \stepcounter{cnt}%
  \marks\dictmark{\thecnt}%
  \thecnt. %
}
\begin{document}
\begin{multicols}{2}
\TheCnt \blindtext\par
\TheCnt \blindtext\par
\TheCnt \blindtext\par
\TheCnt \blindtext\par
\TheCnt \blindtext\par
\TheCnt \blindtext\par
\TheCnt \blindtext\par
\TheCnt \blindtext\par
\TheCnt \blindtext\par
\TheCnt \blindtext\par
\TheCnt \blindtext\par
\TheCnt \blindtext\par
\TheCnt \blindtext\par
\TheCnt \blindtext
\end{multicols}
\end{document}

Headers should be "1--6", "7--12" and "13--14", but they appear as
"1--7", "7--12" and "14--14".

Best wishes,
Aleks


More information about the texhax mailing list