Page Layoutmemoir | Number of the last Page in a Chapter

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
myself
Posts: 6
Joined: Sun Jul 15, 2012 3:26 pm

memoir | Number of the last Page in a Chapter

Post by myself »

Hi,

I'm a new user of this forum (and of any forum !).

I don't speak or write English easily (I think you have already understood this :) ).

I read the board rules and I apologize if I don't respect some rules.

I've searched on the forum but I probably miss the answer. My English is so bad that it's possible I read the answer but I don't understand it.

My question :

I try to use the memoir class to do a document with this page numbering:
"<part number> - <chapter number> - <page number> / <number of pages of the current chapter>".
But I don't have any idea on how to obtain the number of the last page of the chapter.

Thanks for the help, and if not thanks for the reading (I think my post it's probably not easy to read).

Bye

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

Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

memoir | Number of the last Page in a Chapter

Post by Stefan Kottwitz »

That's a very unusual numbering style. I would think again, if such a numbering is really required, since implementing it would be a bit challenging. I would start this way:
  • Hook into the \chapter command or a related one, to automatically place a label, for example:

    Code: Select all

    \let\memclearforchapter\clearforchapter
    \renewcommand*{\clearforchapter}{\label{chapter-\thechapter}\memclearforchapter}
  • By manually placing labels yourself instead, you can avoid such programming.
  • In the document footer, you could use \pageref, such as

    Code: Select all

    \newcommand*{\footnumbering}{\thepart\ - \thechapter\ - \thepage\ / \pageref{chapter-\thechapter}}
    \makeevenfoot{headings}{}{\footnumbering}{}
  • If you need calculations, such as page number minus pages of chapter, use the calc package.
However, in my opinion numbering such as I - 1 - 12 / 19 is very strange and I think it's not very useful for the original purpose of page numbering: to look up pages using the numbers you got from the table of contents. It looks more like "look, I can count in a complex way and I've got a lot to count." ;-) Also, a total number of pages in a chapter is not useful for look-up. Sometimes, numbering such as 1 of 17 is used in presentations, where the audience may wish to know how much slides are left.

I simply would not do this, saving a lot of time which could be used to improve the content and the layout.

Stefan
LaTeX.org admin
myself
Posts: 6
Joined: Sun Jul 15, 2012 3:26 pm

Re: memoir | Number of the last Page in a Chapter

Post by myself »

Thank you very much for the answer.

A little explanation : i'm a teacher and i want to give to my students a lot of sheets concerning functions, probability, ... but each of them are fragmented in several intermediate curses and those intermediate curses are given like this : some curse about function, some curse about proba then function ... so i want a numbering which permit to the pupils to "easily" know if they have all the pages of a chapter (and so my question) and to keep the sheets in the "logical" way (all sheets about functions in one part, ...).
I prefer a hard numbering but a "sure" numbering (because i'm not sure that my students are well ordonned). But if someone has a better idea i listen with attention.

Sorry for the language.

I'll try your ideas and i'll post what happens.
myself
Posts: 6
Joined: Sun Jul 15, 2012 3:26 pm

memoir | Number of the last Page in a Chapter

Post by myself »

I tried your solution and ... it works (tears of happiness)
Stefan_K wrote: I simply would not do this, saving a lot of time which could be used to improve the content and the layout.
Stefan
I hope the content is improved ;)

I become a latex fan so i think i'll spend a lot of time to improve the layout and to learn the programming.



Thanks a lot for this good (and quick) answer.
myself
Posts: 6
Joined: Sun Jul 15, 2012 3:26 pm

memoir | Number of the last Page in a Chapter

Post by myself »

Sorry Stefan_K, i've closed the post (edited now) but i've been a little blind : the code works well for all pages but not for the last page of the chapter just before a new part :( where the number printed is the number of the first page of the first chapter of the new part.

To be clear : with the code below, the page (not blank) before the second part is numbered "I : 1.2 / 2.1" but the correct numbering is "I : 1.2 / 1.2"

Code: Select all

\documentclass{memoir}

\usepackage{chappg}
%
\let\memclearforchapter\clearforchapter%
\renewcommand*{\clearforchapter}{\label{\thechapter}\memclearforchapter}%
\newcommand*{\numpage}{\thepart : \thepage\ / \pageref{\thechapter}}%
%
\makepagestyle{myheadings}%
\makeevenfoot{myheadings}{\numpage}{}{ }%
\makeoddfoot{myheadings}{ \numpage }{}{}%
%
\begin{document}
\pagestyle{myheadings}%
%
\part{F}
\chapter{curse one}
blablabla
\newpage
blobloblo
\part{G}
\chapter{curse one}
\end{document}
It works like if \part acts after the corresponding page is created (so it's a chapter page and not a part page when the \pageref is computed).

I tried very boldly some things : \patchcommand{\part}{\clearforchapter}{} to simulate a new chapter and stop the numbering for exemple but it doesn't work (some conditionals too with respect to the sectioning degree).

I tried to understand what happens : it seems to me that the state of the page ("chapter" and not "part") is not good or the effect of the cross-reference come too soon.

But i see truly that i don't understand nothing : i read that the \pageref print the number of the page where the \label command appears so the \label is processed at the end of the building of the chapter and not at the first page of the chapter ? or \chapter (or \clearforchapter) is processed on each page of the current chapter ?

There would be someone to bring me light ?

Thanks for any help (and for the past help).
Post Reply