LaTeX formatting

I’m currently doing an MSc; this includes a project, and there are regulations about how to write up the final report. In particular:

“The project report must also contain listings of all source code. The source code listings must be contained in an appendix, and do not count towards the 40 page limit for the project report. The code listings must be presented in a compact format (printed double-sided, and with two pages to a side).”
[..]
“It is strongly recommended that the document typesetting system TEX or LATEX is used.”

So, the compact format will replace 2 sides of A4 (portrait) with 2 sides of A5 (portrait) on a single side of A4 (landscape). This diagram may help:

LaTeX

Last year I installed TeX Live v7 on my PC, and I also bought a couple of books to help me:
“LaTeX: A Document Preparation System”
“The LaTeX Companion”

However, I’m more familiar with Word, so I initially wrote my report in that and tried to convert it into LaTeX format at the end. This didn’t work out very well, so I just left it in Word format, but I couldn’t see any way to shrink pages.

I took the document along to Prontaprint so that they could print it and bind it for me; since they’re professionals who do this every day, I hoped that they’d be able to do the doubling-up bit for me, as long as I could tell them the relevant page numbers. Unfortunately, their technical skills basically extended to “Open document, click Print button”. They were able to print some pages double-sided, but they couldn’t shrink/rotate anything for me.

This year, I decided that I would need to pre-format the document as much as possible, i.e. give the printing shop a pdf which looks exactly like the final printed page. I wrote the whole report in LaTeX, and I used the listings package to format the source code in the appendix, but that still left the whole document in full-size portrait mode.

My first attempt looked like this:

\documentclass[11pt,a4paper]{report}

[...]

\usepackage{lscape}
\usepackage{listings}
\usepackage{multicol}

[...]

\appendix

\begin{landscape}

\begin{multicols}{2}

\chapter{Source code}

\section{CBee.vb}

\begin{lstlisting}

[...]

\end{lstlisting}

\end{multicols}

\end{landscape}

\end{document}

(I’m reliably informed that multicol is more reliable than twocolumn.)

This produced a pretty weird looking dvi file, since I don’t think Windvi can handle a mixture of portrait and landscape. I then converted the dvi file into Postscript format, and used PdfTex to convert the ps file into a pdf. I opened the ps file in Ghostview v4.6 (with Ghostscript v8.14), and I opened the pdf file in Acrobat Reader 6.0, and the appendix looked the same in both:

LaTeX2

So, two columns of text have been rotated 90 degrees anti-clockwise (into landscape format) and positioned properly on the page. However, this still has the same 11pt text size as the rest of the document, so I get fewer lines per A5 page, as well as some problems with the two A5 pages overlapping or text from the right-hand page disappearing over the edge. There’s also a page number on the left hand side, which is still in portrait mode, i.e. I just see a single number for the combined page rather than a separate number for each A5 page, and the page number hasn’t been rotated with the rest of the text. I assume that it’s possible to reduce the font size for this part of the document, but the page numbers are a bit more of a problem.

I found a Usenet post (from comp.lang.postscript) discussing this, but their solution looked quite complicated: it involves dvidvi and dvips.

Doing more digging, I found a cached copy of a website which suggested:
dvidvi -m 2:0,1(7.3,0.0) infile.dvi outfile.dvi
I tried that, but the application crashed.

The most useful thing I found was to type:
pstops 2:0L@.7(21cm,0)+1L@.7(21cm,14.85cm) Final.ps Final2.ps
This works, and produces a new ps file with half as many pages as the original one, with each pair of pages doubled up as A5 (like a reducing photocopy), e.g.:

LaTeX3

The borders aren’t perfect here. By default, LaTeX puts wider borders near to the inside edge of each page (where the binding goes), so it needs to know whether you’re printing the document single-sided or double-sided. In my case, it thought the left side of each page would have the binding (portrait, single-sided), so it put a wider border on that side. When I scaled it down, my modified version still has a bigger border on the left than the right, along with an even bigger gap in the middle (right border of left page + left border of right page).

However, I would be binding each landscape page along a long edge rather than a short edge. More precisely, I wanted people to be able to rotate the “book” through 90 degrees, then read each double page spread from top to bottom, and flip pages up to turn them.

I would prefer to have the same size border on the left and right of each landscape page. It might also be useful to vary the top/bottom border for each page, depending on which is closer to the binding. However, I’m not too bothered about any of that; all the text was clearly legible.

So, here are my final steps:

  • Prepare the LaTeX file, all single sided and portrait. The main body of my report ran from pp1-28, with the appendix in pp29-118.
  • Compile .tex file to .dvi, and then to .ps
  • Run pstops 2:0L@.7(21cm,0)+1L@.7(21cm,14.85cm) Final.ps Final2.ps to create a 59 page “2up” version.
  • Use File|Convert in GSView to convert pp1-28 of Final.ps to Final1.pdf, and pp15-59 of Final2.ps to Final2.pdf

This gave me two Acrobat files. In theory I could have left the documents in Postscript format, but KallKwik said that they couldn’t handle that format. (I also tried Prontaprint, but my local branch said that their printers had broken!) So, from a pragmatic point of view, pdf is probably the best format to go for; it seems likely that most companies will already have suitable software installed on their machines.

I then told the printers to do three copies of Final1.pdf single-sided, and three copies of Final2.pdf double-sided. It may be possible to merge these two documents together, but then I’d have to give the printer a page range for single/double-sided, and I think there’s an advantage to keeping the instructions as simple as possible.

I think that having an even number of pages for the main body of the report made life simpler. If there had been an odd number, I’d have inserted a blank page at the end to make it even.

If you don’t want to mess around with command line utilities then a desktop publishing (DTP) program might do the job, e.g. Microsoft Publisher or Adobe InDesign.

Leave a Reply

Your email address will not be published. Required fields are marked *