Document ClassesMemoir class & part numbering

Information and discussion about specific document classes and how to create your own document classes.
Julian_S_Moore
Posts: 72
Joined: Sun Nov 16, 2008 1:26 pm

Memoir class & part numbering

Post by Julian_S_Moore »

I'm typesetting a book that has as parts only chapters (apart from front matter etc.) (but assume for the sake of answering that I might have to use Part and/or Book as well...)

I want to place a unique graphic in the footer of each page - how do I retrieve/obtain the chapter/part/book number and the page number within that chapter/part/book... and how do I then combine those values into a string to make a filename that I can use with \includegraphics?

Thanks

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

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Memoir class & part numbering

Post by meho_r »

I'm not sure if this is at least partially the right answer (it isn't completely clear to me what exactly you're trying to achieve), but I hope this example will be useful to you:

Code: Select all

\documentclass{memoir}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{xcolor}

\makepagestyle{test}% creating a new style named "test"

\makeevenhead{test}{}{\color{blue}Testing header}{}% setting left, middle and right parts of left page header
\makeevenfoot{test}{\color{red}\thepart\ -- \thepage}{}{}% setting left, middle and right parts of left page footer

\makeoddhead{test}{}{\color{blue}Testing header}{}% setting left, middle and right parts of right page header
\makeoddfoot{test}{}{}{\color{red}\thepage\ -- \thepart}% setting left, middle and right parts of right page footer
% try using \thepart, \thechapter, \thesection etc. counters in your header/footer

\makeheadrule{test}{\textwidth}{.4pt}% set a rule below the header

\pagestyle{test}% activating page style for headers and footers

\begin{document}

\book{Book title}

\part{Part title}

\blinddocument


\part{Another part}

\blinddocument

\end{document}
Alternatively, you may try customizing headers and footers with fancyhdr.
Julian_S_Moore
Posts: 72
Joined: Sun Nov 16, 2008 1:26 pm

Memoir class & part numbering

Post by Julian_S_Moore »

Thanks...

Memoir already provides extensive Header/Footer facilities that replace fancyhdr

I can see from your example the use of \thepart etc. but what I want to do is this. Assuming for the moment that I can set up the footer to include graphics, I want to know how to construct a filename out of whatever counters are available and/or create the necessary counters, retrieve values and pass them suitably concatenated as a parameter to the \includegraphics so that the footers automatically work like this...

Part 1, Ch1, Page1 (of Ch1)
\includegraphics{Pt1Ch1P1.eps)

Part 1, Ch1, Page1 (of Ch1)
\includegraphics{Pt1Ch1P2.eps)
.
.
.
Part 16, Ch2, Page17 (of Ch2)
\includegraphics{Pt16Ch2P17.eps}

I guess (I'm rather new at this) that I would end up with something like
\newcommand{\footergraphic}[3] {\includegraphics{Pt#1Ch#2P#3.eps}} (may have got the syntax wrong but that's the level I'm at...) But e.g. how do I maintain per chapter page numbering somewhere (without upsetting the numbers actually used as page numbers)?

Hope that clarifies the objective!
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: Memoir class & part numbering

Post by meho_r »

I tried couple of ideas, but none of them worked. I hope some of (La)TeX gurus here on forum will be able to help you. Until that, I'm afraid you'll have to use manual approach. Sorry :(
Julian_S_Moore
Posts: 72
Joined: Sun Nov 16, 2008 1:26 pm

Re: Memoir class & part numbering

Post by Julian_S_Moore »

Thanks to Lars Madsen over on comp.text.tex who suggested Oberdiek's zref package...

Manual Sect. 5 has an example that provides a promising starting point for doing this... once I have got to grips with the zref package etc.

But - if anyone else reading this knows zref please feel free to chip in with info!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Memoir class & part numbering

Post by localghost »

With regard your other request I don't see the necessity of th zref package [1]. In your example from above including graphics files that depend on several counters shouldn't be very diffcult.

Code: Select all

Part 1, Chapter 1, Page 1 (of Chapter 1)
\includegraphics{Pt\thepart Ch\thechpater P\thepage.eps)
This requires that at the time of inclusion the counters have appropriate values. As mentioned in the other topic, the fancyhdr manual contains a useful example.

[1] View topic: Unique per page graphics in footer?


Best regards
Thorsten
Julian_S_Moore
Posts: 72
Joined: Sun Nov 16, 2008 1:26 pm

Re: Memoir class & part numbering

Post by Julian_S_Moore »

Yes, all working now... just needed to add a line to chapter to reset the sheetsequence counter...

\setcounter{sheetsequence}{1}

then use Ch\thechapter P\thesheetsequence

Thanks
daleif
Posts: 199
Joined: Wed Nov 19, 2008 12:46 am

Re: Memoir class & part numbering

Post by daleif »

I don't quite understand the need for the page numbers in those figure names, could you explain the reason for these?
Julian_S_Moore
Posts: 72
Joined: Sun Nov 16, 2008 1:26 pm

Re: Memoir class & part numbering

Post by Julian_S_Moore »

Certainly daleif...

It's just a design feature - each page has a unique graphic (created in Mathematica) in the footer; the easiest way to pull them in uniquely, in sequence is to give each a sequential per chapter per page number by graphics export in MMA and then include the eps file by the counter values.

Not a common requirement I would guess, but I could see other uses for relative page numbering within a chapter.
daleif
Posts: 199
Joined: Wed Nov 19, 2008 12:46 am

Re: Memoir class & part numbering

Post by daleif »

ahh, each page, I thought it was only on the part pages, ok that makes sense
Post Reply