#! /bin/sh

#                                                                                       #

src2tex* version 2.12 (Sep 9, 1996)

Kazuo Amano† and Shinichi Nomoto‡

#                                                                                       #

#  src2latex2ps  #

   src2latex2ps [-twocolumns or -fourcolumns or -sixcolumns] [-pagelength <n>] filenames

It is necessary for src2latex2dvi that the following softwares are installed properly:

nkf , src2latex , jlatex , dvi2ps , psnup .

Src2latex2dvi is just written by K. Amano for his private use. Here Kanji converter nkf would be unnecessary if you are not Japanese. If you are a TEX user, you have to replace “latex“ with “tex“. If jtex and jlatex are not installed at your site and if you are a Japanese install them else replace them with tex and latex respectively.

#                                                                                       #

#  Preliminaries  #

Though src2latex accepts only one single filename, src2latex2ps allows to input multiple filenames by virtue of the first “ for ⋯ ” statement. There are three options related to column style

    -twocolumns or -fourcolumns

and number of lines printed in each logical page

    -pagelength n

Here we also make a carbon copy of tilde file filename˜ which is created by Emacs, Mule or something like that.

#                                                                                       #
if
        test $# = 0
then
        echo -n "Usage: src2latex2ps [-twocolumns] [-fourcolumns]"
        echo " [-pagelength <n>] filenames"
fi
src2tex option=""
psnup option=""
if

* Permission to use, copy, and modify this software and its documentation is granted under no conditions. However, the authors would be very happy if users could inform any modifications to kamano@tansei.cc.utokyo.ac.jp. Since src2tex is a free software, there is no warranty of any kind for the program.

† Department of Mathematics, Josai University, Keyakidai, Sakado, Saitama, 350-02, JAPAN (kamano@ po.iijnet.or.jp)

‡ Department of Mathematics, Josai University, Keyakidai, Sakado, Saitama, 350-02, JAPAN (m93093@ crescent.josai.ac.jp)

test "$1" = "-twocolumns" -o "$1" = "-twocolumn" -o "$1" = "-2"
then
psnup option="-2"
shift
fi
if
test "$1" = "-fourcolumns" -o "$1" = "-fourcolumn" -o "$1" = "-4"
then
psnup option="-4"
shift
fi
if
test "$1" = "-sixcolumns" -o "$1" = "-sixcolumn" -o "$1" = "-6"
then
psnup option="-6"
shift
fi
if
test "$1" = "-eightcolumns" -o "$1" = "-eightcolumn" -o "$1" = "-8"
then
psnup option="-8"
shift
fi
if
test "$1" = "-pagelength" -o "$1" = "-p"
then
shift
src2tex option="-$1"
shift
fi
if
test "$1" = "-twocolumns" -o "$1" = "-twocolumn" -o "$1" = "-2"
then
psnup option="-2"
shift
fi
if
test "$1" = "-fourcolumns" -o "$1" = "-fourcolumn" -o "$1" = "-4"
then
psnup option="-4"
shift
fi
if
test "$1" = "-sixcolumns" -o "$1" = "-sixcolumn" -o "$1" = "-6"
then
psnup option="-6"
shift
fi
if
test "$1" = "-eightcolumns" -o "$1" = "-eightcolumn" -o "$1" = "-8"
then
psnup option="-8"
shift

fi
for i in $*
do
if
        test -f $i~
then
        mv $i~ $i.bak
fi

#  Any Kanji ⇒ EUC Kanji  #

This conversion is necessary since src2latex works only for EUC codes. If you don’t use Japanese, you can skip this procedure.

#                                                                                       #
if
        test -f $i
then
        mv $i $i~
        nkf -e $i~ > $i
fi

#  Source File ⇒ LaTeX file  #

This block is actually the main part of src2latex2ps. Given source files are translated into TEX here.

#                                                                                       #
if
        test -f $i
then
        echo "src2latex" $src2tex option $i
        src2latex $src2tex option $i
fi
if
        test -f $i~
then
        mv $i~ $i
fi

#  EUC Kanji ⇒ JIS Kanji  #

The official Kanji is JIS Kanji at the author’s site. So, he has applied nkf, with -j option, to TEX file generated by src2latex. And also, if there exits an input file it is included at the beginning of TEX file.

#                                                                                       #
if
        test -f $i.tex
then
        if
                test -f $i.input
        then
                mv $i.tex $i.tex~
                nkf -j $i.input > $i.tex
                nkf -j $i.tex~ >> $i.tex

        else
                mv $i.tex $i.tex~
                nkf -j $i.tex~ > $i.tex
        fi
fi

#  TeX file ⇒ DVI file  #

If jlatex is not installed, then replace it with latex. Here DVI file is nothing more than intermediate product.

#                                                                                       #
if
        test -f $i.tex
then

# jtex $i.tex

        jlatex $i.tex
fi

#  DVI file ⇒ PS file  #

If dvi2ps is not installed, then replace it with something like that, e.g., dvips , jdvi2kps. The command ”psnup“ is used to put some logical pages on each sheet of paper. We remove several intermediate files at the last stage.

#                                                                                       #
if
        test -f $i.dvi
then
        dvi2ps $i.dvi > $i.ps~
        psnup $psnup option $i.ps~ $i.ps

# rm $i.tex >/dev/null 2>&1

        rm $i.tex~ >/dev/null 2>&1
        rm $i.aux >/dev/null 2>&1
        rm $i.log >/dev/null 2>&1
        rm $i.dvi >/dev/null 2>&1
        rm $i.ps~ >/dev/null 2>&1
fi
done