4

I have a very specific question and I hope someone can give me the benefit of their experience.

I have around 17000 lines of text. I am printing this text onto somewhere around 80 double sided pages, which I am cutting up and folding into small books (hey, it's a hobby!). This means that the text needs to find itself in small boxes in a strange pattern all over the page. More specifically....

https://i.stack.imgur.com/uRS7b.png

This page would be cut out so that AB, CD, EF, etc and their reverse sides get folded in half to form pages. These folded rectangles get placed inside one another for binding, so that the text needs to flow from A to the opposite side of C to C to the opposite side of E to E to F to.........

You get the point. So here's the problem:

My plan is to use C (or maybe sed or awk) to programmatically generate the LaTeX code, which should generate all the pdfs I'll need to get this printed. However, I need some way of changing the behaviour of LaTeX should the text go past the bottom of one of these boxes. That is, usually when text goes past a boundary, you simply continue it underneath. In this case, I need it to continue in a completely different place and on a completely different page. Due to the sheer size of this project, this really must be done using a package or something.

Does anyone know how this is done?

Mahkoe
  • 275
  • @barbarabeeton Isn't there an old TUGboat article about this? – musarithmia Feb 20 '15 at 16:36
  • @AndrewCashner -- you may be thinking of the article by peter wilson on "meandering miniature books", but that doesn't go into how to get text to automatically position itself, especially if a particular text isn't complete on one page. for that, nicola talbot's flowfram package is mentioned; another package that supports continuation of text "somewhere else", jumplines, has recently appeared on ctan, but i know no more about it. – barbara beeton Feb 20 '15 at 17:16
  • See http://snipplr.com/view/3633/pdf-to-tinybook/ ( have not tried it) – Aubrey Blumsohn Feb 20 '15 at 17:29

2 Answers2

6

First, you create the book using just a normal LaTeX approach, letting pages reformat according to the normal way. You will want to make your pages of an appropriate papersize and such. Here, with book.tex, given below, it creates a 26 page document book.pdf, with a letter on each page. If I needed to insert an extra page midway, or remove one, just let LaTeX do it.

Because I knew the result was to end up as a small book, I made each page 3" by 3" in this book, though it will be eventually shrunk by a factor of 2 for your small book (though that is not necessary for the process... it's just the way I did it.).

\documentclass{article}
\usepackage[paperwidth=3in,paperheight=3in,margin=.5in]{geometry}
\usepackage{graphicx}
\newcommand\makebook[1]{\makebookhelp#1\relax}
\def\makebookhelp#1#2\relax{%
  \scalebox{15}{#1}\clearpage%
  \ifx\relax#2\else%
  \makebookhelp#2\relax\fi%
}
\begin{document}
\centering
\makebook{ABCDEFGHIJKLMNOPQRSTUVWXYZ}
\end{document}

Now, that I have my book created in the normal way, I assemble it (in this case, on letterpaper) in the right order using this MWE:

\documentclass{article}
\usepackage[paper=letterpaper,margin=1.25in]{geometry}
\usepackage{graphicx,ifthen,stackengine}
\newcounter{bookpage}
\fboxsep=-\fboxrule\relax
\newcommand\nullpage{\fbox{\rule{0pt}{1.5in}\rule{1.5in}{0pt}}}
\newcommand\showthepage[2]{%
  \protect\fbox{\protect\includegraphics[width=1.5in,height=1.5in,page=#1]{#2}}%
}
\parindent 0in
\setstackgap{S}{0pt}
\begin{document}
\Shortstack
{
\showthepage{2}{book}%
\showthepage{3}{book}%
\showthepage{6}{book}%
\showthepage{7}{book} 
\showthepage{10}{book}%
\showthepage{11}{book}%
\showthepage{14}{book}%
\showthepage{15}{book} 
\showthepage{18}{book}%
\showthepage{19}{book}%
\showthepage{22}{book}%
\showthepage{23}{book} 
\showthepage{26}{book}%
\nullpage%
\nullpage%
\nullpage}
\clearpage
\Shortstack
{
\showthepage{8}{book}%
\showthepage{5}{book}%
\showthepage{4}{book}%
\showthepage{1}{book} 
\showthepage{16}{book}%
\showthepage{13}{book}%
\showthepage{12}{book}%
\showthepage{9}{book} 
\showthepage{24}{book}%
\showthepage{21}{book}%
\showthepage{20}{book}%
\showthepage{17}{book} 
\nullpage%
\nullpage%
\nullpage%
\showthepage{25}{book}}
\end{document}

It creates a two page document consisting of the 26 panels (1.5" in size) of book.pdf, assembled in such a way that, once cut, pages A-B-C-D will be on the first minileaf, E-F-G-H on the second, etc.

If your binding arrangement is different than that shown above (where minileaves did not get nested prior to binding), merely rearrange the order of the \showthepage invocations to get the desired layout. Once you set up the layout for a single piece of paper (that will be cut), I did not do it, but it would be trivial to implement a "leaf offset" into the execution of \showthepage. That way, a collection of (in my case, 32) invocations of \showthepage could be bundled into a single macro, and that macro could be reinvoked successively with an increasing "leaf offset" to handle larger documents seamlessly.

Here are the two pages that result from the second compilation. When printed with double-sided printing, it all matches up.

enter image description here

enter image description here

  • This is exactly what I needed. And it's quite straightforward. Thank you! – Mahkoe Feb 20 '15 at 20:10
  • @Mahkoe You are welcome. I just edited the answer to add text describing how I would go about treating larger volumes...by essentially introducing a "leaf offset" into the \showthepage macro. – Steven B. Segletes Feb 20 '15 at 20:11
3

If I have understand your question correctly, you are interested in a two-up booklet layout.If so, you can achieve this by some of already existing packages of latex. Here is the solution using booklet package:

\documentclass{article}
\usepackage{lipsum}

\usepackage[print]{booklet}
\setpdftargetpages

\begin{document}
\lipsum[1-20]
\end{document}

enter image description here

Note that without print option in \usepackage[print]{booklet} the output would look like any normal document. Package documentation claims that this works fine with duplex printing as well (check the link above for details).

Other package that might interest you (which is essentially the back-bone of booklet) is 2up. I believe you can obtain what you want using pdfpages as well. If you search 2up, two up or booklet in this website, you can find other solutions to this problem.

Pouya
  • 7,269