Mercurial > hg > mtridoc
comparison mume2012/aaai_script.sh @ 51:3d4469f9e172
inital commit for MUME2012. Just dumbed the templates and copied SMC paper. Beginning of converting to aaai template.. still a mess :)
author | Henrik Ekeus <hekeus@eecs.qmul.ac.uk> |
---|---|
date | Thu, 21 Jun 2012 00:26:03 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
50:41aac49ad50e | 51:3d4469f9e172 |
---|---|
1 #!/bin/bash | |
2 | |
3 # ---------------------------------------------------------------------- | |
4 # This shell script produces the latex source-package of a paper | |
5 # as required by AAAI, in preparation for printed proceedings. | |
6 # Copyright (C) 2009 Christian Fritz "fritz at cs dot toronto dot | |
7 # edu" | |
8 # ---------------------------------------------------------------------- | |
9 # This program is free software: you can redistribute it and/or | |
10 # modify it under the terms of the GNU General Public License as | |
11 # published by the Free Software Foundation, either version 3 of | |
12 # the License, or (at your option) any later version. | |
13 # | |
14 # This program is distributed in the hope that it will be useful, | |
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 # GNU General Public License for more details. | |
18 # | |
19 # You should have received a copy of the GNU General Public | |
20 # License along with this program. If not, see | |
21 # <http://www.gnu.org/licenses/>. | |
22 # ---------------------------------------------------------------------- | |
23 | |
24 # function for recursive processing of style files | |
25 recurseStyles() { | |
26 echo "..recursively processing required packages of $1" | |
27 PACKAGES=`grep RequirePackage $1 | sed 's/RequirePackage\[[^]]*\]/RequirePackage/g' | sed 's/.*RequirePackage{\([^}]*\)}.*/\1/' | sed -e 's/, */\n/g'` | |
28 for name in $PACKAGES; do | |
29 if [ ! -e sources/$name.sty ]; then | |
30 echo "..locating and copying: $name" | |
31 FILE=`locate /$name.sty | head -n 1` | |
32 if [ -e $FILE ]; then | |
33 cp $FILE sources | |
34 else | |
35 echo "..cannot locate $name.sty" | |
36 fi | |
37 if [ -e sources/$name.sty ]; then | |
38 recurseStyles sources/$name.sty | |
39 fi | |
40 fi | |
41 done | |
42 } | |
43 | |
44 # ------------------------------- | |
45 | |
46 # give a tex file as parameter | |
47 if (( $# < 1 )); then | |
48 echo "Error: Please give a tex-file as parameter, e.g., ./aaai_script.sh main.tex"; | |
49 exit; | |
50 fi; | |
51 | |
52 mkdir sources | |
53 | |
54 echo "locating and copying all used packages" | |
55 PACKAGES=`grep ^.usepackage $1 | sed -e 's/.*usepackage{\(.*.\)}.*/\1/' | sed -e 's/, /\n/g'` | |
56 for name in $PACKAGES; do | |
57 echo "locating and copying: $name" | |
58 if [ -e $name.sty ]; then | |
59 cp $name.sty sources | |
60 else | |
61 FILE=`locate /$name.sty | head -n 1` | |
62 if [ -e $FILE ]; then | |
63 cp $FILE sources | |
64 else | |
65 echo "cannot locate $name.sty" | |
66 fi | |
67 fi | |
68 if [ -e sources/$name.sty ]; then | |
69 recurseStyles sources/$name.sty | |
70 fi | |
71 done | |
72 | |
73 | |
74 echo "inlining all included files" | |
75 cp $1 __tmp1 | |
76 while ( grep ^.input __tmp1 ); do | |
77 # INPUTS=`grep ^.input __tmp1 | sed 's/.*input *{*\([^.}]*\).*/\1/'` | |
78 # cat __tmp1 | sed '/^%.*$/d' > __tmp2 | |
79 # for name in $INPUTS; do | |
80 # echo "inlining $name" | |
81 # awk -v filename=$name '{ if ($0 ~ ".input.*"filename) { system("cat "filename".tex | sed '/^%.*\$/d'"); } else { print $0; } }' < __tmp2 > __tmp1 | |
82 # done | |
83 awk '{ if ( $0 ~ /\\input( |{)/ ) { sub(/\\input( |{)/,""); sub(/}/, ""); sub(/\.tex/, ""); system("cat "$0".tex | sed '/^%.*\$/d'") } else { print $0; } }' __tmp1 > __tmp2 | |
84 cp __tmp2 __tmp1 | |
85 done | |
86 | |
87 echo "inlining bibitems" | |
88 BIBFILE=`echo $1 | sed 's/.tex/.bbl/'` | |
89 awk -v filename=$BIBFILE '{ if ($0 ~ ".bibliography{") { system("cat "filename); } else { print $0; } }' < __tmp1 > __tmp2 | |
90 cp __tmp2 sources/full.tex | |
91 | |
92 | |
93 echo "getting figures" | |
94 FIGURES=`grep includegraphics __tmp2 | grep -v ^% | sed 's/.*{\([^}]*\)}*/\1/'` | |
95 for name in $FIGURES; do | |
96 echo "getting figure $name" | |
97 mkdir -p sources/`echo "$name" | sed 's/\(.*\)\/.*/\1/'` | |
98 cp $name.*ps sources/`echo "$name" | sed 's/\(.*\)\/.*/\1/'` | |
99 done | |
100 | |
101 # ------------------------------- | |
102 | |
103 cd sources | |
104 echo "latexing source" | |
105 latex full.tex | |
106 echo "latexing source once more" | |
107 latex full.tex | |
108 | |
109 echo "creating the PDF using" | |
110 dvips -Ppdf -G0 -tletter full -o full.ps | |
111 ps2pdf -sPAPERSIZE=letter -dMaxSubsetPct=100 -dCompatibilityLevel=1.2 -dSubsetFonts=false -dEmbedAllFonts=true full.ps | |
112 cd .. | |
113 | |
114 echo "DONE" |