Turning Latex into PostScript

Introduction

Latex often needs to be run together with dvips, and there is an annoying clutter of files produced. This is even more so when Bibtex referencing is employed. The Linux scripts t2ps and b2ps simplify the generation of PS files from latex source, and delete the clutter afterwards.

To install these shell scripts, copy them to files named t2ps and b2ps in your bin directory, i.e. to ~/bin/, type chmod +x t2ps b2ps to make them executable, and try them out. (C shell users will also need to type rehash, to update their PATH cache. This just needs to be done once.)

t2ps

This script is sufficient for processing documents without bibliographies.
#!/bin/tcsh
# This script runs latex on the specified .tex file(s).  It then
# runs dvips, provided there are no serious errors during the
# running of latex.  Any number of .tex files may be specified.
#
# Examples:
#     t2ps cv.tex            (process cv.tex)
#     t2ps intro main        (process intro.tex and main.tex)
#     t2ps chapter*.tex      (process chapter*.tex)
#     t2ps doc1 doc1         (process doc1.tex twice)
#     t2ps                   (script will prompt for a file name)
# 
# As may be seen from these examples, the extension '.tex' is optional 
# on the command line, and wildcard characters ('*' and '?') are allowed.  
#
# It is possible to specify a .tex file in a directory other than
# the pwd, but doing so is unconventional and not advisable.

if ($#argv == 0) then
  echo -n "File(s): "
  set filelist = ($<)
else
  set filelist = ($argv[*])
endif

# Strip extensions, if present
set filelist = ($filelist:gr)

# Process each file, checking first that each exists
foreach filename ( $filelist )
  if ( -e $filename.tex && -f $filename.tex ) then
    latex $filename.tex && dvips $filename -o && rm $filename.{dvi,log} 
  else
    echo "t2ps: input file $filename.tex not found"
  endif
end

b2ps

This version runs Bibtex as well as Latex, in order to generate the bibliography afresh.
#!/bin/tcsh
# This script runs latex and bibtex on the specified .tex file(s).  
# It then runs dvips, provided there are no serious errors during the
# running of latex.  Any number of .tex files may be specified.
#
# Examples:
#     b2ps cv.tex            (process cv.tex)
#     b2ps intro main        (process intro.tex and main.tex)
#     b2ps chapter*.tex      (process chapter*.tex)
#     b2ps doc1 doc1         (process doc1.tex twice)
#     b2ps                   (script will prompt for a file name)
# 
# As may be seen from these examples, the extension '.tex' is optional 
# on the command line, and wildcard characters ('*' and '?') are allowed.  
#
# It is possible to specify a .tex file in a directory other than
# the pwd, but doing so is unconventional and not advisable.

if ($#argv == 0) then
  echo -n "File(s): "
  set filelist = ($<)
else
  set filelist = ($argv[*])
endif

# Strip extensions, if present
set filelist = ($filelist:gr)

# Process each file, checking first that each exists
foreach filename ( $filelist )
  if ( -e $filename.tex && -f $filename.tex ) then
    latex $filename.tex && bibtex $filename && \
    latex $filename.tex && latex $filename.tex && \
    dvips $filename -o && rm $filename.{dvi,log,blg,bbl,aux} 
  else
    echo "b2ps: input file $filename.tex not found"
  endif
end

 


Last changed 2009-02-05 Chris Rennie