Page LayoutParagraph Range on each Page with \markboth

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
LJM
Posts: 1
Joined: Mon Jun 27, 2011 9:05 am

Paragraph Range on each Page with \markboth

Post by LJM »

Hello,

I'm trying to get LaTeX to print at the foot of each page the range of paragraph numbers contained in that page: e.g. 1-5, 6-13, and so on until the end. To do this, the explanation given in the fancyhdr manual (p. 11) on how to make dictionary headings has helped me a lot, and it feels like I'm almost there -- but not quite. The paragraph numbers, for which I created a new counter, still don't come out right.

Here's a minimal code example. Would you mind taking a look at it? I think the main problem may be in the line

Code: Select all

\markboth{\value{parnum} #1}{\value{parnum} #1}},
as I don't know how to pass the values of the counter (first and last of each page) to \markboth.

Thank you for your help,

LJM

Code: Select all

\documentclass[12pt,twoside]{article}

%DEFINE NEW COUNTER
\newcounter{parnum}
\newcommand{\N}{%
   \noindent\refstepcounter{parnum}
   \makebox[\parindent][l]{\arabic{parnum}}}
\setlength{\parindent}{2em}

%SETTING UP NEW PAGE FOOT
\usepackage{fancyhdr}
\pagestyle{fancyplain}
\renewcommand{\headrulewidth}{0pt} %no rule
\renewcommand{\sectionmark}[1]{} %empty sectionmark
\renewcommand{\subsectionmark}[1]{} %empty subsectionmark
\markboth{\value{parnum} #1}{\value{parnum} #1}}
\fancyhf{}
\newcommand{\mymarks}
{
        \ifthenelse{\equal{\leftmark}{\rightmark}}
        {\rightmark}
        {\rightmark--\leftmark}
}
\fancyfoot[LE,RO]{\thepage}
\fancyfoot[RE,LO]{\mymarks}

\begin{document}

\N This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.

\N This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.

\N This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.

.
.
.

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply