0

I have a book which contains two books, each having their own preface. Here's the structure:

\book{An exhortation to virtue}

    \frontmatter

        \chapter{Preface}

        ...

    \mainmatter

        \chapter{This is the first chapter of the first book}

        ...

        \chapter{This is the second chapter of the first book}

        ...

\book{An instruction on virtue}

    \frontmatter

        \chapter{Preface}

        ...

    \mainmatter

        \chapter{This is the first chapter of the second book}

        ...

        \chapter{This is the second chapter of the second book}

        ...

This structure is based on this answer's advice to create a Preface by using \chapter inside of \frontmatter.

Obviously this structure won't work because it assumes two separate front-matters.

So what's another way to create two prefaces for two books within the same book?

Another goal is that this book should have a single Table of Contents containing both books in their entirety.

6
  • Instead of posting the image (which isn't actually that important to the question) create a small document that shows the structure of what you have already. It doesn't need to be fancy, just enough to show the \book structure you are using.
    – Alan Munn
    Sep 8 '15 at 0:22
  • @AlanMunn Okay I'll edit it right now, thanks for the advice.
    – Steven
    Sep 8 '15 at 0:26
  • @sdegutis No, this is a bit too schematic. Make a complete compilable document showing what you have (without the content). So you want each book to have its own frontmatter part, with e.g. roman numbering.
    – Alan Munn
    Sep 8 '15 at 0:42
  • What are the special characteristics that make certain chapters a "preface"? Lack of chapter number? special formatting in the TOC? page numbers in "roman" rather than "arabic"? other things?
    – jon
    Sep 8 '15 at 0:52
  • @jon All of those, plus chapter numbering starts over at Chapter 1 after each Preface.
    – Steven
    Sep 8 '15 at 1:01
3

I'd just use

\counterwithin*{chapter}{book} 

Then each time \book is used, chapter will be reset to zero.

2
  • (+1) I hope you will not mind that I changed my answer to integrate this rather than \apptocmd. If you object, you can use my code to create a complete example and I'll delete mine.
    – cfr
    Sep 8 '15 at 10:17
  • @cfr no problem. Just leave it. I'm currently at a tablet so large examples like your is not something I'm going to do on this device
    – daleif
    Sep 8 '15 at 10:20
1

Memoir does very nearly the right thing with the code you posted. Originally, I was not sure if it has a way to reset the chapter numbers per book, but I couldn't find it and couldn't think, so used etoolbox to patch the command. However, daleif's answer is much better and can easily be integrated into the code I was using. Other than that, I just changed your dots to Kant and added a table of contents:

\documentclass{memoir}
\counterwithin*{chapter}{book}
\usepackage{kantlipsum}

\begin{document}

\tableofcontents

\book{An exhortation to virtue}

\frontmatter

\chapter{Preface}

\kant[1]

\mainmatter

\chapter{This is the first chapter of the first book}

\kant[1]

\chapter{This is the second chapter of the first book}

\kant[1]

\book{An instruction on virtue}

\frontmatter

\chapter{Preface}

\kant[1]

\mainmatter

\chapter{This is the first chapter of the second book}

\kant[1]

\chapter{This is the second chapter of the second book}

\kant[1]
\end{document}

Memoir Kant

3
  • Thanks. This technically works, but I can't help but feel it's a bit hacky. I'll wait a day or two to give others a chance to chime in also.
    – Steven
    Sep 8 '15 at 3:45
  • @sdegutis Waiting for other answers is wise. But I don't see why you'd think using Memoir 'a bit hacky'. Or do you mean the use of etoolbox to reset the counter? You should be able to combine this with daleif's answer to avoid that.
    – cfr
    Sep 8 '15 at 10:10
  • @sdegutis Please see edit.
    – cfr
    Sep 8 '15 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.