# Mathematical bookbinding

[2018-06-04 Mon]

Some problems: 1. Maths books are expensive. 2. Printing papers out is usually a waste; I lose track of which papers I have printed and they mount up in enormous, disorganised, dog-eared piles on my desk. I sometimes find it fun to work my way downwards through one of these piles, and see the stratified history of what I have been thinking about for the last year. But it's not a sensible way to organise one's life. 3. Screen-readers are just not the same... I got an iPad a few years ago so I could minimise printing, and it's very convenient to carry around all my papers in electronic form. But still, I find it very difficult to focus in depth on something I'm reading on a screen. I like to be able to flick through and hold different pages open. I like books.

So I recently took up bookbinding and I'm making my own hardback mathematics books out of freely available PDFs online (books or research papers that I've been meaning to read properly).

Here are the books I've made/am making so far

1. (Finished) Selected papers on the SYZ conjecture, Volume I:

2. (Finished) Selected papers on the SYZ conjecture, Volume II: 3. (In progress) Selected papers on pairs-of-pants decompositions: 4. (In progress) Dirichlet branes and homological mirror symmetry (Aspinwall et al, PDF freely available from the Clay Mathematics Foundation or buy the hardback book from the AMS for $115.00) From this, you can see some of the things I'm interested in at the moment. I think that these nice bound hardback books will be a better record of my reading history than a neglected pile of printouts in a corner of my desk. Here are some photos of the completed Volumes 1 and 2 of Selected Papers on the SYZ Conjecture: So here are the steps involved... 1. I pick a selection of papers I am planning to read in some level of detail. 2. I print them out into bindable signatures (groups of sixteen pages, printed four to a sheet (two front, two back), ordered in such a way that when you fold the pages and nest them into a mini-book, they read in the correct order and the correct orientation). 3. I fold all the signatures. Then I use an awl to make holes in the fold of each signature, then sew through the holes, signature by signature, to build up a book-block, binding the signatures to three pieces of linen tape. Here is a good video tutorial about sewing onto tapes: [https://www.youtube.com/watch?v=7cMZRPoyj4Q; rounding is covered from around 5 minutes into the video. I don't bother with a specialist hammer, I just use the glue pot to round the book. I also don't bother backing the book; it seems like too much effort. Once it is rounded, I glue over the whole spine, tapes and all. 7. I cover the spine with "fraynot" and archival kraft paper. 8. I create a book case (i.e. front and back cover) out of greyboard (thick bookbinding cardboard for the front and back), manila (for the spine) and bookcloth (covering everything). This involves some slightly tricky measuring. 9. I glue the endpapers to the case using wheat-paste. An excellent book which I use to guide me through the process (and which covers several other binding techniques that I haven't tried yet) is: *Kathy Abbott* /Bookbinding: a step-by-step guide/, The Crowood Press Ltd. 2010, ISBN-10 1847971539. It would benefit from a few more diagrams, but it's got everything you need to follow the steps above. The biggest challenge is not the actual bookbinding (which is actually quite therapeutic and rewarding) but the printing. I have written a couple of command-line scripts which automate the process of turning a set of PDFs into printable signatures (see below). To print them, you then just set your printer to 2-sided, short-edge binding, 2 pages per side and hope for the best. The real difficulty is getting the pages positioned correctly (printers seem to add extra whitespace around the edge) and I usually have to play around with PDFjam to trim the PDF pages before printing to get them centred properly after printing. This is a pain, and if anyone is reading this blog and has a suggestion of a more systematic way of tackling this problem, I would be glad to hear it. For what it's worth, here are the scripts I use to make my signatures: For each book, I create a folder, e.g. syz1. In syz1, I create the following files and folders: • folders: • ./pdfs/ • ./tmp/ • files: • bind.py • pgcount.sh I put the PDFs I want into ./pdfs/ and make sure their filenames appear ordered as I want them by pre-pending them with numbers (e.g. 0-contents.pdf, 1-kontsevich-soibelman-torus-fibration.pdf, 2-kontsevich-soibelman-non-arch.pdf). Watch out if you go over 10 to number your files 01, 02, etc. Then I run pgcount.sh (see below for what it does). It does some stuff, then calls bind.py (so both of these have to be executable by setting permissions to 755 or similar). bind.py generates a new program called binding.sh, whose permissions you should then change to 755 before running it (of course, you should first check my code thoroughly to make sure I'm not telling you to do something malicious). This will generate a file called draft2.pdf in ./tmp/, which you can then run through PDFjam to trim it as desired before printing. You need to have: • a command-line, • Python, • PDFjam installed to run these scripts. Here is pgcount.sh: pgcount=() for paper in ./pdfs/* do pgcount+=($(pdfinfo "$paper" | grep Pages | awk '{print$2}'))
done
printf '%s ' ./pdfs/* > ./tmp/pgcounts
printf '\n' >> ./tmp/pgcounts
printf '%s ' "\${pgcount[@]}" >> ./tmp/pgcounts
python ./bind.py


You can hopefully see that it just runs through the ./pdfs/ directory and, for each file it finds, it counts the number of pages. Then it creates a temporary file to store the names of the files it found and their page counts. Then it calls a python script, bind.py:

from subprocess import call

def evenise(n):
'If n is odd, increase it by 1'
if n%2!=0:
return n+1
else:
return n

F=4 # Number of folios/signature
N=4*F # Number of pages/signature

''' First run the shell script pgcount.sh to get
pdf names and page-counts'''

pgdata=open("./tmp/pgcounts","r") # Read this info into Python
pgdata.close()
filenames=rawdata[0].split()
pgcounts=[int(i) for i in rawdata[1].split()]

revisedpgcounts=[evenise(i) for i in pgcounts] # Add blank pages
P=sum(i for i in revisedpgcounts) # Total number of pages
S=P//N # Estimate of number of signatures
extrablanks=0 # Estimate number of extra blank pages required
if P!=S*N: # If there are not enough signatures...
S=S+1 # ...add an extra one...
extrablanks=S*N-P # ...and we add this many extra blank pages;

''' First concatenate all desired files, including contents page and a
blank page after contents and enough blank pages at the end to make
the total number of pages divisible by N (four times the number of
folios per signature)'''

pdfjoinarg=[]
for i in range(0,len(filenames)):
blanks=""
if i==len(filenames)-1:
blankslist=[",{}" for j in range(0,extrablanks)]
blanks="".join(blankslist)
if pgcounts[i]==1: # use 1,{}
newarg=filenames[i]+" '1"+",{}"+blanks+"' "
elif revisedpgcounts[i]!=pgcounts[i]: # use 1-n,{}
newarg=filenames[i]+" '1-"+str(pgcounts[i])+",{}"+blanks+"' "
else: # use 1-n
newarg=filenames[i]+" '1-"+str(pgcounts[i])+blanks+"' "
pdfjoinarg.append(newarg)

p1="pdfjoin --rotateoversize false --outfile ./tmp/draft1.pdf -- "
p2="".join(pdfjoinarg)
pdfjoinargstr=p1+p2

signcmd=[]
for i in range(0,S):
pgorder=[N+i*N,1+i*N,2+i*N,N-1+i*N]
for j in range(1,F):
pgorder.extend([N-2*j+i*N,1+2*j+i*N,2+2*j+i*N,N-1-2*j+i*N])
pgorderstr=[str(x) for x in pgorder]
signpages=",".join(pgorderstr)
signpages2="'"+signpages+"'"
signcmd.append("pdfjoin --rotateoversize false --outfile ./tmp/"+str(i)+".pdf -- ./tmp/draft1.pdf "+signpages2)

listoffiles=["./tmp/"+str(i)+".pdf" for i in range(0,S)]
stringoffiles=" ".join(listoffiles)
bindcmd="pdfjoin --rotateoversize false --outfile ./tmp/draft2.pdf -- "+stringoffiles

trimcmd="pdfjam --trim '1cm 4cm 3cm 4cm' --clip true --outfile book.pdf ./tmp/draft2.pdf"

shlscr=open('binding.sh','w')
shlscr.write("#/bin/bash\n")
shlscr.write(pdfjoinargstr+"\n")
for x in signcmd:
shlscr.write(x+"\n")
shlscr.write(bindcmd+"\n")
shlscr.close()


This script goes through and figures out if you need to add blank pages to avoid a new PDF starting on the reverse of a page, and if you need to add blank pages at the end to get a number of pages divisible by 16 (or whatever number of pages per signature you decide to set (4 * F in the script)). Then it goes through and writes a new shell script called binding.sh whose job is to run PDFjam a number of times, to concatenate your PDFs with extra blank pages added if necessary and then to reorder them into signatures. Finally, you run binding.sh. If you add the lines:

shlscr.write(trimcmd+"\n")
shlscr.write("rm ./tmp/*")


just before shlscr.close() then this script will additionally trim your PDFs a bit (you can set exactly how by modifying the line where the variable "trimcmd" is set) and empty out the tmp files created by the other scripts. I generally need to play with the trimming afterwards, so like to keep all the tmp files.

This three-script monstrosity seems like a convoluted way of doing the job. So why did I do it this way? Shell scripts are better than Python (i.e. easier to write) for calling external programs like PDFjam. But I find arithmetic in shell scripts is annoying and there were lots of little equations in that script. Doing it this way was the laziest way of avoiding both issues.

Let me know if you decide to try anything similar! I'm sure I could learn a lot from other people's experiences of mathematical bookbinding.

Comments, corrections and contributions are very welcome; please drop me an email at j.d.evans at lancaster.ac.uk if you have something to share.

CC-BY-SA 4.0 Jonny Evans.