views:

90

answers:

2

I have to hand in a software project that requires either a paper or .pdf copy of all the code included.

One solution I have considered is grouping classes by context and doing a cat *.extension > out.txt to provide all the code, then by catting the final text files I should have a single text file that has classes grouped by context. This is not an ideal solution; there will be no page breaks.

Another idea I had was a shell script to inject latex page breaks in between files to be joined, this would be more acceptable. Although I'm not too adept at scripting or latex.

Are there any tools that will do this for me?

+4  A: 

Take a look at enscript (or nenscript), which will convert to Postscript, render in columns, add headers/footers and perform syntax highlighting. If you want to print code in a presentable fashion, this works very nicely.

e.g. here's my setting (within a zsh function)

  # -2 = 2 columns
  # -G = fancy header
  # -E = syntax filter
  # -r = rotated (landscape)

  # syntax is picked up from .enscriptrc / .enscript dir
  enscript -2GrE  $*
Brian Agnew
+1  A: 

For a quick solution, see a2ps, followed by ps2pdf. For a nicer, more complex solution I would go for a simple script that puts each file in a LaTeX listings environment and combines the result.

Stephan202