add interactive latex scripts
[dotfiles.git] / x / .local / bin / pdflatexi
1 #!/usr/bin/expect
2 spawn pdflatex {*}$argv
3 set latexpid $spawn_id
4 set oldresult ""
5 expect -re "^.*File .(.*). not found.*$|^.*language definition file (.*) was not foun" {
6 set result $expect_out(1,string)
7 send_user "\nTrying to install missing package\n"
8 if {$oldresult == $result} {
9 send_user "$result has been tried twice with no results\n"
10 send_user "Is this not an image? Aborting...\n"
11 exit
12 } {
13 spawn tlmgri $result
14 interact
15 set spawn_id $latexpid
16 close
17 wait
18 spawn pdflatex {*}$argv
19 set oldresult $result
20 exp_continue
21 }
22 }