booklet.mak 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. # -*- makefile -*-
  2. #
  3. # booklet.mak - making booklets from Texinfo.
  4. #
  5. # Copyright 2013 John Darrington.
  6. #
  7. # This file is free software; as a special exception the author gives
  8. # unlimited permission to copy and/or distribute it, with or without
  9. # modifications, as long as this notice is preserved.
  10. #
  11. # This program is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
  13. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. #
  15. # This makefile can be used to generate booklets from Texinfo sources.
  16. # It reduces each page to A5 size and renders two pages per sheet onto
  17. # A4 landscape. The pages are ordered into a "quire" or "gathering".
  18. # This means that you can print the result on a standard laser printer,
  19. # fold in half and using simple stapler bind the result into a
  20. # booklet.
  21. # Targets are <foo>-{a4,a5}-book.{dvi,ps,pdf} where <foo>.texi is the texinfo
  22. # source file.
  23. # It is suitable for Texinfo documents up to approx. 70 pages.
  24. # The *-a4-book targets produce A4 half area reduced pages. The *-a5-book
  25. # targets produce A5 full sized pages. The *a5-book option will therefore
  26. # have larger text, but will have a higher page count. It may also have
  27. # problems if the document has @display or @example environments with
  28. # long lines.
  29. # Example of use:
  30. # 1. make -f Makebook manual-a4-book.ps
  31. # 2. Print the result on a double sided laser printer. Alternatively
  32. # if your laser printer does not support double sided printing, print the ODD
  33. # numbered sheets, retreive the result from the printer and thinking carefully
  34. # about the page orientation, shove them back into the paper tray. Depending
  35. # on your printer, you may have to reverse the order of the sheets. Then print
  36. # the EVEN numbered sheets. I find gv usefull for this.
  37. # 3. Fold the result along the short dimension.
  38. # 4. Staple in place, using a long arm stapler.
  39. # 5. Using a guillotine cut the pages such that their edges co-incide.
  40. # 6. Sit back in an armchair and enjoy your reading.
  41. # For those of you who live in countries which refuse to conform to ISO 216,
  42. # you have a problem.
  43. # End of instructions.
  44. all:
  45. echo 'Usage: make -f Makebook <target>'
  46. # Mutate the source, with appropriate headings, overriding anything that the
  47. # author has thoughtlessly imposed.
  48. # We want to specify the paper size, and double headings. Anything else?
  49. %-a4.texi: %.texi
  50. sed -e 's/@afivepaper/@afourpaper/' -e '/@end titlepage/a @headings double' $< > $@
  51. %-a5.texi: %.texi
  52. sed -e 's/@afourpaper/@afivepaper/' -e '/@end titlepage/a @headings double' $< > $@
  53. # Older versions of Texinfo break if the locale is non-english.
  54. %.dvi: %.texi
  55. LC_ALL=C texi2dvi $< -o $@
  56. # Reorder the dvi into the correct order for the quire.
  57. %-sig.dvi: %.dvi
  58. dvibook $< -o $@
  59. # Render 2 pages per sheet, ensuring there is an appropriate "gutter"
  60. %-a5-book.dvi: %-a5-sig.dvi
  61. dvitodvi '2:0+1(148mm,0)' $< $@
  62. %-a4-book.dvi: %-a4-sig.dvi
  63. dvitodvi '2:700@0(-15mm,-5mm)+1(210mm,-5mm)' $< $@
  64. # print the result in landscape orientation
  65. %.ps: %.dvi
  66. dvips -t a4 -t landscape -t landscape $< -o $@
  67. %.pdf: %.ps
  68. ps2pdf $< $@
  69. .PHONY: clean
  70. clean:
  71. $(RM) *-a[54].*