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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

Post Reply