#!/bin/bash
################################################
# Processes the FIG source file for the poster #
################################################

######################################################
#                                                    #
# Usage:                                             #
#         1. Design a poster with Xfig.              #
#         2. Save it as a normal FIG file, with      #
#            the name, e.g., `myfile.fig'.     	     #
#         3. Substitute `BASE=myfile' for the line   #
#            `BASE=poster' in this script.	     #
#         4. Run this script within the directory    #
#            where `myfile.fig' lies.	             #
#         5. The output files will be:		     #
#            `myfile-a0.ps' - one poster-sized page  #
#            `myfile-a4-1.ps' - a4-sized mini-poster #
#            `myfile-a4-16.ps' - sixteen tile pages  #
#						     #
######################################################

# basename

BASE=poster

# convert the FIG into LaTeX + PostScript

echo '
\documentclass{article}
\usepackage{amsmath}          % symbols and equations
\usepackage{amsfonts}         % needed for blackboard characters
\usepackage[spanish]{babel}   % titles in our language
\usepackage[latin9]{inputenc} % accented characters
\usepackage[a0paper,margin=0cm,nohead,nofoot]{geometry} % margins
\usepackage{graphicx}         % including figures
\usepackage{color}            % import from Xfig
\usepackage{epic}             % complements the following
\usepackage{eepic}            % Xfig filling
\usepackage{rotating}         % text in figures
\usepackage{type1cm}          % arbitrarily sized fonts
\begin{document}
' > $BASE.tex

fig2dev -L pstex $BASE.fig > $BASE.pstex

echo -n '
\begin{picture}(0,0)
\includegraphics{'$BASE'.pstex}
\end{picture}
' >> $BASE.tex

fig2dev -L pstex_t $BASE.fig >> $BASE.tex

echo '\end{document}' >> $BASE.tex

# typeset the source LaTeX

latex $BASE

# transform into a PostScript of size almost DIN A0

dvips -o $BASE-a0.ps -T 84cm,118cm $BASE

# build the small A4 version of the poster

psresize -Pa0 -pa4 $BASE-a0.ps $BASE-a4-1.ps

# build the 16 A4 pages composing the poster

dvips -o $BASE.eps -T 84cm,118cm -E $BASE
poster -mA4 -pA0 $BASE.eps > $BASE-a4-16.ps
