
cat a/head.tex > ${HOME}/e/e/c/ect.tex

echo " " >  ${HOME}/e/e/c/list.tex

for c in `ls -1d c00[0-1]*`
do

echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% START of CHAPTER " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% /$c" >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex

export c
cd $c
echo '\\chapter{' >> ${HOME}/e/e/c/ect.tex
cat chapter.txt >> ${HOME}/e/e/c/ect.tex
echo "} " >> ${HOME}/e/e/c/ect.tex

cat -s chapter.tex | sed  "s/FIGURE/FIGURE[scale=1]{}{..\/s\/$c\/}/g" | sed  "s/GIF/GIF[scale=1]{}{..\/s\/$c\/}/g">> ${HOME}/e/e/c/ect.tex


for s in `ls -1d s0*`
do
export s
cd $s

echo '\\section{' >> ${HOME}/e/e/c/ect.tex
cat -s section.txt >> ${HOME}/e/e/c/ect.tex
echo "} " >> ${HOME}/e/e/c/ect.tex

cat -s section.tex | sed  "s/FIGURE/FIGURE[scale=1]{}{..\/s\/$c\/$s\/}/g" | sed  "s/GIF/GIF[scale=1]{}{..\/s\/$c\/$s\/}/g">> ${HOME}/e/e/c/ect.tex

for e in `ls -1d e0*`
do
export e
cd $e

echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% START " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% /$c/$s/$e" >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex

echo "\subsection{" >> ${HOME}/e/e/c/ect.tex
head -1 latex.tex >> ${HOME}/e/e/c/ect.tex
echo "} " >> ${HOME}/e/e/c/ect.tex


sed "s/\\\e{/\\\eLIST{}{/g" latex.tex | grep "eLIST" >> ${HOME}/e/e/c/list.tex
sed "s/\\\es{/\\\esLIST{/g" latex.tex | grep "esLIST" >> ${HOME}/e/e/c/list.tex
sed "s/\\\eS{/\\\eSLIST{/g" latex.tex | grep "eSLIST" >> ${HOME}/e/e/c/list.tex

echo "\setcounter{equation}{0}" >> ${HOME}/e/e/c/ect.tex

tail +2 latex.tex | sed  "s/FIGURE/FIGURE[scale=1]{}{..\/s\/$c\/$s\/$e\/}/g" | sed  "s/GIF/GIF[scale=1]{}{..\/s\/$c\/$s\/$e\/}/g">> ${HOME}/e/e/c/ect.tex

\GIF[scale=1]{../s/c0003/s0020/e0050/}{A}{buckethandle}{}


echo "\\STORY{../s/$c/$s/$e} "   >> ${HOME}/e/e/c/ect.tex

echo "%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% END " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex

cd ..
done
cd ..
done
cd ..
done

echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%" >> ${HOME}/e/e/c/ect.tex
echo "% START DEFINITIONS" >> ${HOME}/e/e/c/ect.tex
echo "%" >> ${HOME}/e/e/c/ect.tex

echo '\appendix ' >> ${HOME}/e/e/c/ect.tex

echo '\\chapter{Definitions}' >> ${HOME}/e/e/c/ect.tex

echo "%% " >> ${HOME}/e/e/c/ect.tex
echo "%% " >> ${HOME}/e/e/c/ect.tex

cat a/define.tex >> ${HOME}/e/e/c/ect.tex

echo "%%%%%%%%% END DEFINITIONS" >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex


echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% START LIST OF EXAMPLES" >> ${HOME}/e/e/c/ect.tex


echo '\\chapter{List of examples}' >> ${HOME}/e/e/c/ect.tex


cat ${HOME}/e/e/c/list.tex | sed "s/{p}/PAAAA/g" | sort -t\{ +2 -d -f | sed "s/PAAAA/{p}/g" >> ${HOME}/e/e/c/ect.tex

echo "%%%%%%%%% END LIST OF EXAMPLES" >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex


echo '\\begin{htmlonly} '   >> ${HOME}/e/e/c/ect.tex
echo '\\chapter{Technical information}' >> ${HOME}/e/e/c/ect.tex
echo '\\begin{rawhtml} '   >> ${HOME}/e/e/c/ect.tex
echo "<BR><B> " >> ${HOME}/e/e/c/ect.tex
echo "<B>Here you can find some useful " >> ${HOME}/e/e/c/ect.tex
echo "<a href="../../s/a/information.htm">" >> ${HOME}/e/e/c/ect.tex
echo " Technical information</a> concerning " >> ${HOME}/e/e/c/ect.tex
echo " file structure, compiling, latex2html, tex style,  " >> ${HOME}/e/e/c/ect.tex
echo " definitions file, references file etc." >> ${HOME}/e/e/c/ect.tex
echo "<BR><B> " >> ${HOME}/e/e/c/ect.tex
echo '\\end{rawhtml} '   >> ${HOME}/e/e/c/ect.tex
echo '\\end{htmlonly} '   >> ${HOME}/e/e/c/ect.tex


echo "%% " >> ${HOME}/e/e/c/ect.tex
echo "%% " >> ${HOME}/e/e/c/ect.tex

echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%% " >> ${HOME}/e/e/c/ect.tex
echo "%% " >> ${HOME}/e/e/c/ect.tex

cat a/index.tex >> ${HOME}/e/e/c/ect.tex

echo "%% " >> ${HOME}/e/e/c/ect.tex
echo "%% " >> ${HOME}/e/e/c/ect.tex

echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%% START REFERENCES" >> ${HOME}/e/e/c/ect.tex

echo '\\begin{thebibliography}{99}' >> ${HOME}/e/e/c/ect.tex
echo '\\bibliographystyle{alpha}' >> ${HOME}/e/e/c/ect.tex
echo "%% " >> ${HOME}/e/e/c/ect.tex
echo "%% " >> ${HOME}/e/e/c/ect.tex

cat a/cite.tex >> ${HOME}/e/e/c/ect.tex

echo "%% " >> ${HOME}/e/e/c/ect.tex
echo "%% " >> ${HOME}/e/e/c/ect.tex


echo "%%%%%%%%% END REFERENCES" >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% " >> ${HOME}/e/e/c/ect.tex

echo "\end{thebibliography}" >> ${HOME}/e/e/c/ect.tex
echo "\end{document}" >> ${HOME}/e/e/c/ect.tex
