My requirement is printing a cookbook consisting of a set of recipes. However, there will be frequent updates of recipes and inserts of new ones. Therefore I need a solution to prevent re-printing the whole book, when only parts of it changed.

My solution draft is to handle it like some law book publishers do. They provide the book with a binding that can be opened to remove or add single pages. This way I only need to print the changed pages as well as the index.

My problem are page numbers. I search for a solution to keep page numbers steady for the inserted part and postfix them there, e.g., 21a, 21b. Is there any possibility to do that? I'm completely out of ideas where even to start searching for such a solution.

(By the way: I am not fixed on my solution above. If anyone has a better idea to handle frequently changing large documents for print, I'd be glad to hear it.)

  • 3
    if you were a BASIC programmer from the 1970s you would address this problem by numbering the pages 100,200,300.. then inserts after page 100: 110,120,... and inserts on inserts after page 120: 121,122,... Apr 26 '17 at 6:57
  • Too young for that, sorry. When I started with programming, my faculty had already switched to FORTRAN 90...
    – Boldewyn
    Apr 26 '17 at 7:39
  • If one of the provided answers is satisfying you might accept it. If not, you should further specify your question.
    – Skillmon
    Apr 26 '17 at 15:41
  • Yes, I will do so, thanks for the reminder. I just didn't have the opportunity to try them, yet.
    – Boldewyn
    Apr 26 '17 at 15:59
  • @DavidCarlisle: I had to laugh reading your comment. I was a BASIC programmer – and frequently use exactly this approach to number overlay steps on complex beamer frames :-)
    – Daniel
    Apr 26 '17 at 21:56

To change the numbers in a range you might do the following (I don't guarantee that this would not break things):

EDIT: I made the environment nestable. Also I changed the page numbers from \alph to \roman to allow more than 26 subpages.





    First page in not nested \texttt{subpages}
    Second page in not nested \texttt{subpages}
        First page in nested \texttt{subpages}
        Second page in nested \texttt{subpages}
    After the nested \texttt{subpages}

  • Nice, thanks. That's a good starting point.
    – Boldewyn
    Apr 26 '17 at 7:37
  • The edit. When I started the comment, I was about to ask how to reset the counter.
    – Boldewyn
    Apr 26 '17 at 7:39
  • You could use the alphalph package to provide more than the usual 26 letters for \alph (or \Alph) counter output
    – user31729
    Apr 26 '17 at 20:18
  • @ChristianHupfer I just checked but using \alphalph from the package I get a missing number error in the above code.
    – Skillmon
    Apr 26 '17 at 20:32
  • @Skillmon: \alphalph {\value {page}} should work.... note the \value there!
    – user31729
    Apr 26 '17 at 20:49

As you don't want to change the page numbers, I suggest making the page numbers depend upon the recipes. For example, the pages of the Carrot cake recipe could be numbered CC1, CC2, and so on -- although most recipes would probably fit on one page? You could make the "page number prefix" depend on the recipe, like this, or instead assign it in some sensible way.

The pages in the book would appear in lexicographic order, making it easy to insert new pages and finding the page that you were after.

Here is one way to implement this idea:


\let\realchapter\chapter% save the definition of \chapter for later use
\def\pageprefix{}% prefix for page numbers

%\chapter<page prefix>[short title]{title}
\RenewDocumentCommand\chapter{ r<> o m }{%
    \IfNoValueTF{#2}{\realchapter{#3}}%   without short title
                  {\realchapter[#2]{#3}}% with    short title
    \def\pageprefix{#1}\setcounter{page}{1}% reset page counter




    \chapter<CC>{Carrot cake}


So the \chapter command now has a mandatory argument that sets the page prefix. The syntax is:

\chapter<page prefix>[short title]{title}

As is the case with the \chapter command, the short title is optional and can be omitted.

Another variation on this idea would be to label the pages as aaa, aab, aac, ..., bba, bbb, bbc,... Again, this would be easy to do using the code above, by replacing the re-definition of \thepage by

  • I really like the idea! Automatic sorting of the chapters would make it perfect (and would really interest me, as I have no idea how to implement it nicely).
    – Skillmon
    Apr 26 '17 at 7:46
  • @Skillmon I thought that the original question was just about page numbering, so automatic sorting is probably a different question:) How were you envisaging writing/typing the book? How are new recipes added? Should they all go in the same file? Are you suggesting the new recipes are just added to the end of some file and that they should be magically sorted for printing? Some details like this would be helpful.
    – user30471
    Apr 26 '17 at 7:52
  • @Skillmon I think that you probably want to "sort" the recipes by hand when you add new ones, as a latex solution would be too inefficient especially if the recipes are to have "complicated" formatting. Rereading your question, what you might want to do however, is add a "date" to each recipe and make it possible to print out only those recipes added before or after a certain date, or for a range of dates. This isn't so hard to do. If this interests you then please add some more details to the question - the more detail the better!
    – user30471
    Apr 26 '17 at 8:10
  • I'm not the original poster, but provided an answer to this question. Then I saw your answer and you said something about lexicographic order and I was just interested how to implement that. I asked just out of curiosity and do realize that this is another question, but I won't ask it. Maybe the OP if he is interested in it will ask that :)
    – Skillmon
    Apr 26 '17 at 8:59
  • 2
    I want to bake a Chocolate Cake... So CC1 does lead me to Carrot Cake or to Chocolate Cake? ;-)
    – user31729
    Apr 26 '17 at 20:19

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.