#! /bin/sh
######################################
##### Model Transformation Tools #####
######################################
# Bourne shell script: latex_tidy
# Tidies up LaTex format files
# P.J.Gawthrop 12 June 1990, Dec 1994
# Copyright (c) P.J.Gawthrop, 1990, 1994
###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.4 1996/12/12 15:54:20 peterg
## Saved it.
##
## Revision 1.3 1996/08/30 14:36:46 peter
## Added some more subscripts.
## -- its high time this was rewritten in awk or perl!!!
##
## Revision 1.2 1996/08/19 14:35:51 peter
## Prettyfied z dot.
##
## Revision 1.1 1996/08/18 20:03:12 peter
## Initial revision
##
###############################################################
cat $1 | \
tr "[A-Z]" "[a-z]" | \
sed -e "s/\// \\\over /g" \
-e "s/mttex/\\\chi/g" \
-e "s/mttdx/\\\dot x/g" \
-e "s/mttdz/\\\dot z_/g" \
-e "s/mttdu/\\\dot u_/g" \
-e "s/dot_/ \\\dot /g" \
-e "s/mtta/A/g" \
-e "s/mttb/B/g" \
-e "s/mttc/C/g" \
-e "s/mttd/D/g" \
-e "s/mtte/E/g" \
-e "s/mttg/G/g" \
-e "s/mtti/I/g" \
-e "s/mttm/M/g" \
-e "s/mtto/O/g" \
-e "s/mttv/V/g" \
-e "s/mttx\([0-9]*\)/x_{\1}/g" \
-e "s/mttui\([0-9]*\)/v_{\1}/g" \
-e "s/mttu\([0-9]*\)/u_{\1}/g" \
-e "s/mtty0/y_0/g" \
-e "s/mttu0/u_0/g" \
-e "s/mttx/x/g" \
-e "s/mttz/z/g" \
-e "s/[0-9a-z_]*mttu/u/g" \
-e "s/mttyy/Y/g" \
-e "s/[0-9a-z_]*mtty\([0-9]*\)/y_{\1}/g" \
-e "s/mttw/w/g" \
-e "s/mtttf/G/g" \
-e "s/mttpar//g" \
-e "s/\*\*/\^/g" \
-e "s/\*/ /g" \
-e "s/!/\\\/g" \
-e "s/\\$//g" \
-e "s/(/{(/g" \
-e "s/)/)}/g" \
-e "s/\left/\left (/g" \
-e "s/\right/\right )/g" \
-e "s/sqrt/\\\sqrt/g" \
-e "s/theta/\\\theta/g" \
-e "s/tau/\\\tau/g" \
-e "s/alpha/\\\alpha/g" \
-e "s/beta/\\\beta/g" \
-e "s/epsilon/\\\epsilon/g" \
-e "s/lambda/\\\lambda/g" \
-e "s/mu/\\\mu/g" \
-e "s/phi/\\\phi/g" \
-e "s/rho/\\\rho/g" \
-e "s/sigma/\\\sigma/g" \
-e "s/omega/\\\omega/g" \
-e "s/zeta/\\\zeta/g" \
-e "s/sin/\\\sin/g" \
-e "s/cos/\\\cos/g" \
-e "s/23/{23}/g" \
-e "s/+-/ -/g" |\
cat -s | \
sed -e "s/ $//g" | \
tr -s '\012' '\012' \
>junk
mv junk $1