# a2ps.cfg                                           -*- Makefile -*-
#
# System configuration file for a2ps.
# Copyright (c) 1988-1993 Miguel Santana
# Copyright (c) 1995-2000 Akim Demaille, Miguel Santana
#

#
# This file is part of a2ps.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING.  If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#

#
# This file defines everything a2ps needs to know about
# -- your system (access to the printers)
#    It is strongly suggested that you check these parameters
#    are adapted to your system.
# -- customizable features
#
# It is related to the whole system, i.e., it is not the file
# the users should modify themselves for their own preferences.
# ~/.a2ps/a2psrc is the user's own configuration file, which
# is read after this file.
#


#################################################################
# 1)		Definition of some media 			#
# (Must be defined before --medium)				#
#################################################################
# Medium: name, width height [llx lly urx ury]
Medium: A3	    842    1190
Medium: A4	    595     842
Medium: A5	    420     595
Medium: B4	    729    1032
Medium: B5	    516     729
Medium: Letter	    612     792
Medium: Legal	    612    1008
Medium: Tabloid	    792    1224
Medium: Ledger	   1224     792
Medium: Statement   396	    612
Medium: Executive   540     720
Medium: Folio	    612     936
Medium: Quarto	    610     780
Medium: 10x14	    720    1008

# Desk Jet users: bigger margins
Medium: A4dj		595	842	24	50	571	818
Medium: Letterdj	612	792	24	40	588	768



#################################################################
# 2)	Path to the a2ps resource				#
#################################################################
# Default path where a2ps dropped its library files.
LibraryPath: /usr/local/share/a2ps/sheets:/usr/local/share/a2ps/ps:/usr/local/share/a2ps/encoding:/usr/local/share/a2ps/afm:/usr/local/share/ogonkify/afm:/usr/local/share/a2ps/ppd:/usr/local/share/a2ps/fonts:/usr/local/share/ogonkify/fonts:/usr/local/share/a2ps

# It may be useful to extend it so that a2ps can see some
# TeX or X11 resources: it likes AFM files and PF[AB] files.
#AppendLibraryPath: foo


#################################################################
# 3)	Default settings					#
#################################################################
# Two virtual pages per sheet
Options: -2

# Set automatic pretty-printing on (set to "plain" for off)
Options: --pretty-print

# By default, single sided printing.
Options: -s1

# Name of the document is the list of files
# (Don't put too many of them: it breaks some PS interpreters)
Options: --title='#10!f|$n|, |'

# Header is the client of the job
Options: --header=%a

# Title of the page is the (short) name of the current file
# or the first tagged text if there is
Options: --center-title=#?1|$t1|$n|

# Left part of the title is the mod. date of the file
# or empty is there is a tag2
Options: --left-title='#?2||$e $T|'

# Right part of the title is the page number
# or tag2 if there is
Options: --right-title='#?2|$t2|$Q|'

# If in landscape, print date on the left hand side
# If portrait, then print date on recto, and sheet # on verso
Options: --left-footer=#?l!%E!#?v|%E|%s./%s#|!

# Center footer is the list of files on this sheet if landscape
Options: --footer='#?l|#!s-$f-, -||'

# If in landscape, print date on the right hand side
# If portrait, then print date on verso, and sheet # on recto
Options: --right-footer=#?l!%s./%s#!#?v|%s./%s#|%E|!

# We want the %%Page comments to be instructive.
# There are two predefined choices: #{pl.short} and #{pl.long}
PageLabelFormat: #{pl.short}

# Report the number of lines which were wrapped.
Variable: cfg.wrapped 1

###############################################################
# 4)	Preconfigured Variables		                      #
###############################################################
#
# Some variables for the delegations
#

# Calling AcrobatReader for PDF to PostScript.
#Variable: del.acroread \
#   acroread -toPostScript

# Acrobat 4 lets us specify the medium, which is precious sometimes, and
# that we should shrink the document to the size of the medium.
#Variable: del.acroread \
#   acroread -toPostScript -size "#wx#h" -shrink

# Passes the options to psnup.  A problem with psnup is that even if
# no service is requested, the PostScript is altered.  There are such
# problems with dvips.  A symptom is that the figure are spread on
# several pages.  To avoid that, with ``-1'', we use cat instead of
# psnup -1.
# The files (in and out) are to be given if not stdin and stdout.
Variable: del.psnup \
   #?o!cat!psnup -#v #?V||-q| #?j|-d|| #?r||-c| -w#w -h#h!

# Passes to psselect for PS page selection.
Variable: del.psselect \
   #?p!psselect #?V||-q| -p#p!cat!

# Passes to psselect, and then psnup
Variable: del.psselnup #{del.psselect} | #{del.psnup}

# Calls to dvips.  The sequence waits for the file name, and
# produces on stdout.
Variable: del.dvips dvips #?p|-pp#p|| #?V||-q| -T#wpt,#hpt -f

# We use a modified texi2dvi which accepts -b (--batch), -c (--clean),
# and -l (--language).
Variable: del.texi2dvi \
 texi2dvi4a2ps -b -c #?V|--verbose|--quiet| 1>&2

# a2ps will be called upon decompressed files.
Variable: del.a2ps\
 a2ps #?p|-a#p|| #?V|-v2|-q| -#v -o- --stdin=$N

# convert, part of ImageMagick, is used for many image formats
# If you want the name of the file to be printed along with the picture,
# add `-label $f'
Variable: del.imagick convert -page #wx#h

# TeX MetaFont and MetaPost files.
Variable: del.metafont \
	(TEXINPUTS=%d:$$TEXINPUTS && \
	 mft $f && tex $N.tex '\\end') #?V|1>&2|> /dev/null|

Variable: del.metapost \
	(TEXINPUTS=%d:$$TEXINPUTS && \
	 mft $f && mv $f.tex $N.tex && tex $N.tex '\\end') #?V|1>&2|> /dev/null|

#
# Variables for special printers.
#

# Either GV (prefered) or Ghostview will be used as the "display" printer
# We give -dNOPLATFONTS so that real fonts are used
# (Strange results appear with Ogonkify's fonts for instance).
#Variable: ghostview ghostview -arguments -dNOPLATFONTS
#Variable: ghostview gv -antialias -arguments -dNOPLATFONTS

# Used for the `pdf' printer.
# Use as `#{ps2pdf} INPUT OUTPUT'.
# #Variable: ps2pdf gs -g"#wx#h" -r72 -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$N.pdf -c save pop -f #f0
#Variable: ps2pdf ps2pdf -g"#wx#h" -r72
#Variable: ps2pdf distill -pairs -pagesize #w #h pts

#
# Some macro for ToC or page label
#

# Useful for the page label format:
# pl.short: just the page intervals
Variable: pl.short #!s|$p-|,|
# pl.long: file name and page intervals
Variable: pl.long #!s|$n $p-|,|

# The default layout for Table of Contents
Variable: toc \\Keyword{Table of Contents}\n\
#-1!f\
|$2# \\keyword{$-.20n} sheets $3s< to $3s> ($2s#) pages \
$3p<-$3p> $4l# lines\n||



#################################################################
# 5)	Preconfigured delegations                               #
#################################################################
#
# Delegations are ways to hand off the processing of some
# files to other filters.
#
# When delegating, interesting meta sequences are
# $f         -- current filename, i.e. the one to delegate.
#               Note that $f expands exactly to the file, which means
#               that in most cases you need '$f' (with the two quotes)
#               to avoid both (i) problems with space in names, and
#               (ii) other shell active characters, such as $.
#               Yeah, I know, we need something more elaborated in case
#               the file has quotes ' in it :-(
# #f0 to #f9 -- temporary filename you can use.
#               rm is done by a2ps itself.  No need to quote.
#

########## Compressed files
# A compressed file should be decompressed and processed by a2ps
# A consequence is that the decompressed file may be delegated.
Delegation: gzip-a2ps gzip:ps     gzip -cd '$f' | #{del.a2ps}

Delegation: gzip-a2ps compress:ps gzip -cd '$f' | #{del.a2ps}

#Delegation: bzip-a2ps bzip:ps     bzip -cd '$f' | #{del.a2ps}

#Delegation: bzip2-a2ps bzip2:ps   bzip2 -cd '$f' | #{del.a2ps}

########## DVI files
# Pass DVI files to dvips.
# * A problem with dvips is that even on failure it dumps its
#   prologue, hence it looks like a success (output is produced). To
#   avoid that, we use an auxiliary files and conditional call to psnup
#   instead of piping.
# * It tries to figure if the doc is landscape (use of seminar for
#   instance) by looking for `landscape' in the first strings of
#   the DVI file.
##Delegation: dvips dvi:ps\
##   if strings '$f' | sed 10q | fgrep landscape > /dev/null 2>&1; then \
##     #{del.dvips} -T#hpt,#wpt '$f' -o #f0 && #?o|cat|#{del.psnup} -r| #f0; \
##   else \
##     #{del.dvips} '$f' -o #f0 && #{del.psnup} #f0; \
##   fi

########## HTML files
# Pass HTML to Netscape, hoping that there is an Netscape running...
# Tricks:
# 1. Netscape can't output on stdout, hence use a tmp file (#f0)
# 2. openfile refuses relative paths, so prepend cwd (%d) when relative
# 3. remote 'openfile' -remote 'saveas' is bad, because it is handled
#    asynchronously, and the output can correspond to a previously
#    loaded page (not that of openfile).  So run Netscape twice.
# 4. It asks the user if s/he wants to replace an existing output file,
#    so rm before.
#Delegation: Netscape html:ps    \
#  rm -f #f0; \
#  if echo '$f' | grep '^/' >/dev/null 2>&1; then \
#    ${NETSCAPE:-netscape} -noraise -remote 'openfile($f)'; \
#  else \
#    ${NETSCAPE:-netscape} -noraise -remote 'openfile(%d/$f)'; \
#  fi && \
#  ${NETSCAPE:-netscape} -noraise -remote 'saveas(#f0,postscript)' && \
#  #{del.psselect} #f0 | #{del.psnup}

########## MetaFont / MetaPost files
Delegation: MetaFont mf:ps \
      #{del.metafont} && #{dvips} $N.dvi | #{psnup}

Delegation: MetaPost mp:ps \
      #{del.metapost} && #{dvips} $N.dvi | #{psnup}

########## PDF files
# Delegated to pdf2ps, GS 5.50
##Delegation: pdf2ps pdf:ps \
##   pdf2ps '$f' #f0 && #{del.psselect} #f0 | #{del.psnup}
# Delegated to AcrobatReader
##Delegation: Acrobat pdf:ps \
##   #{del.acroread} < '$f' | #{del.psselnup}

########## PostScript files
# Pass the PostScript files to psnup and psselect
#Delegation: PsNup ps:ps fixps #?V||-q| '$f' | #{del.psselnup}

########## ROFF files
# Pass the roff files to groff.  Ask grog how groff should be called.
# Use fixps to ensure there is a %%BeginSetup/%%EndSetup section.
#Delegation: Groff roff:ps	\
#  eval `grog -Tps '$f'` | fixps #?V!!-q! | #{del.psselnup}

########## TeX files, supposed to be LaTeX files in fact
# Use texi2dvi for TeX file
###Delegation: texi2dvi tex:ps	\
###  #{del.texi2dvi} -l latex -o #f0 '$f' && #{del.dvips} -f #f0 | #{del.psnup}

########## Texinfo files
# Use texi2dvi for Texinfo file
# In a near future, we might no longer have to specify --expand, but
# currently, it is safer.
###Delegation: texi2dvi texinfo:ps	\
###  #{del.texi2dvi} -e -o #f0 -l texinfo '$f' && #{del.dvips} -f #f0 | #{del.psnup}

######################## Using ImageMagick for images
########## GIF files
##Delegation: ImageMagick gif:ps\
##        #{del.imagick} 'gif:$f' ps:- | #{del.psselnup}

########## JPEG files
##Delegation: ImageMagick jpeg:ps\
##        #{del.imagick} 'jpeg:$f' ps:- | #{del.psselnup}

########## PNG files
##Delegation: ImageMagick png:ps\
##        #{del.imagick} 'png:$f' ps:- | #{del.psselnup}

########## TIFF files
##Delegation: ImageMagick tiff:ps\
##        #{del.imagick} 'tiff:$f' ps:- | #{del.psselnup}

########## XBM files
##Delegation: ImageMagick xbm:ps\
##        #{del.imagick} 'xbm:$f' ps:- | #{del.psselnup}

########## XPM files
##Delegation: ImageMagick xpm:ps\
##        #{del.imagick} 'xpm:$f' ps:- | #{del.psselnup}


#################################################################
# 6)	Some interesting UserOptions/Printers			#
#################################################################
# Print like an old fashioned ASCII printer
UserOption: lp -1m -Eplain -B --borders=no

# Print mails.  Strip some headers.
UserOption: mail     -gEmail --strip=1
UserOption: longmail -gEmail --strip=1 -2R

# Printing a booklet

# To print a booklet, we must be sure to output Simplex, and 1 up.
# Install the lp hook for booklets.
UserOption: book -1Dlp.hook=#{lp.hook.book} -s1

# This variable defines a hook for `lp'.  The output is piped into
# psbook in order to print a booklet.
Variable: lp.hook.book \
#?o! psbook #?V,,-q, | psnup -2 #?V,,-q, | psset -nt | \
! echo "Cannot be used with more than two pages per sheet." >&2 ; exit 1!



# Some special setpagedevice requests
UserOption: manual -SManualFeed:true
# Force a2ps to issue a Simplex request.
UserOption: s1      -SDuplex:false
UserOption: simplex -SDuplex:false

# Nice display, i.e., use colors, and one virtual per page.
UserOption: display -1 --prolog=color -Pdisplay

# It is better not to pipe in ghostview
#Printer: display | cat > #f0 && #{ghostview} #f0

# Save into a file named after the input files.
# E.g. a2ps src/foo.c => foo.ps
Printer: file > $N.#.

# Dry run.  Helpful to know the page usage etc.
Printer: void > /dev/null

# Produce PDF.
# It is better not to output in two up, or even worse: in landscape.
#Printer: pdf | cat >#f0 && #{ps2pdf} #f0 $N.pdf
UserOption: pdf -1 -P pdf --prologue=color

# We define the DefaultPrinter and the Unknown Printer just in case
# a2ps-site.cfg fails to define them.  Under normal circumstances
# these entries *will* be overridden.

# First, the default printer (option -d, no argument)
DefaultPrinter: | #{lp.default}

# Second, a printer unknown to a2ps (option -P, argument is #o)
UnknownPrinter: | #{lp} #o



#################################################################
# 7)	Your local settings					#
#################################################################
# How to call file(1), and if possible, follow the links
FileCommand: /usr/bin/file -L


# Define a variable to call lp/lpr on the default printer, preceded
# with a hook to post-process PostScript (to call psbook for instance).
# Something like `#{lp.hook} lp  #{lp.options}'
#             or `#{lp.hook} lpr #{lp.options}'.
Variable: lp.default #{lp.hook} lpr #{lp.options}


# The same, but when a printer is specified.
# Something like `#{lp.hook} lp  #{lp.options} -d'
#             or `#{lp.hook} lpr #{lp.options} -P'.
Variable: lp #{lp.hook} lpr #{lp.options} -P


# To avoid that the next installation of a2ps destroys your
# definitions, local customization would be better done in
# a2ps-site.cfg.

Include: a2ps-site.cfg
