0

I am writing a book and I want to add several images.

I could add them in between the text but what I want to do (and what I've seen in existing books) is to put images in the middle of the book.

Let's say I have 5 pages of images with their description and my book is 20 pages long with the text, I want to have:

10 (text) / 5 (images) / 10 (text)

I can do it manually by doing page breaks and inserting the images but is it possible to do this dynamically depending on the total number of pages in the document?

johhnry
  • 43
  • 3
  • Somewhat related: https://tex.stackexchange.com/questions/307082/full-page-landscape-figure-in-middle-of-document – John Kormylo Sep 28 '23 at 17:37
  • BTW, the practice of putting pictures together in a multipage signature is due to Smyth Sewing bookbinding. Howver you should use an even number of pages (8 or 16 is typical). – John Kormylo Sep 29 '23 at 13:18
  • Thanks John I'll look at that! – johhnry Oct 01 '23 at 17:22
  • If you want more help, we need more deatils. Do you want page numbers and normal margins, or do you want to use pdfpages? – John Kormylo Oct 01 '23 at 22:46
  • Yes I want to use page numbers and normal margins, if I use pdfpages I need to create the pages separatly and include them in the main document which is not ideal – johhnry Oct 08 '23 at 19:41
  • Traditionally, you want the images printed on one set of sheets and the regular pages on another. This minimises the costs of more expensive paper and higher quality, possibly colour, printing. This doesn't have to be in the middle. That's one model. But it's also possible to arrange your signatures so you have more than one group of image pages, provided things are set up so they are joined to another group of image pages. That's a fairly common model, too. – cfr Oct 10 '23 at 04:48

1 Answers1

1

This uses macros \addpictures and \picturepages to add several pages worth of pictures. In this case I used [p] figures, although that isn't really needed and adds another page delay.

\@abspage@last is a global macro provided by LaTeX (recent addition) in the aux file. It takes two runs to work.

\documentclass{book}
\usepackage{graphicx}
\usepackage{afterpage}
\usepackage{lipsum}% MWE only
\usepackage{duckuments}% MWE only

\newcommand{\picturepages}{5}% number of pages for \addpictures

\newcommand{\addpictures}{\begin{figure}[p]% picture 1 \includegraphics[width=\textwidth, height=0.5\textheight]{example-image-duck} \caption{A cartoon duck.} \end{figure} \begin{figure}[p]% picture 2 \includegraphics[width=\textwidth, height=0.5\textheight]{example-image-duck} \caption{A cartoon duck.} \end{figure} \begin{figure}[p]% picture 3 \includegraphics[width=\textwidth, height=0.5\textheight]{example-image-duck} \caption{A cartoon duck.} \end{figure} \begin{figure}[p]% pictuer 4 \includegraphics[width=\textwidth, height=0.5\textheight]{example-image-duck} \caption{A cartoon duck.} \end{figure} \begin{figure}[p]% picure 5 \includegraphics[width=\textwidth, height=0.5\textheight]{example-image-duck} \caption{A cartoon duck.} \end{figure}}

\newcounter{abspage}% \thepage not reliable \setcounter{abspage}{1}% adjust for delay

\makeatletter \AddToHook{shipout/before}{\stepcounter{abspage}% \ifnum@abspage@last=\maxdimen\relax% first run \gdef@abspage@last{0}% \afterpage{\addpictures}% \else \count1=@abspage@last\relax \advance\count1 by -\picturepages\relax% \divide\count1 by 2\relax \ifnum\count1=\value{abspage}% \afterpage{\addpictures}% \fi \fi} \makeatother

\begin{document}

\lipsum[1-60]

\end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120