I was not satisfied using Adobe Reader and prefer PDF-XChange viewer, so I wanted to change that. Furthermore, I wanted to be able to compile a new pdf using pdflatex while the old one is still open (in default, you have to close it by hand first). After a lot of trial and error it works now. It is not a very elegant solution (i am not a programmer) but it works, so I thought to place it here so someone else can use it. If someone has a better/less quirky solution, please reply on this topic.
You need to change three things: change the arguments given to pdflatex.bat, edit pdflatex.bat, and use a vbs file to close the open document properly. So there we go:
1: open tex_cmd.gd with a text editor. You can find the file in your LEd installation directory, submap \Definitions. Go to line the line defining the pdflatex command, which should start like
2: go to the LEd\Batches directory, copy and backup your PdfLaTeX.bat to for instance PdfLaTeX.bat.bak, and edit PdfLaTex.bat using a text editor to the following:
So what does this mean? The %4 for instance means the fourth argument passed to this bat file, which is <BatchesDir> now, which is the directory of the batch files of LEd. You should read a bat file like a set of command line commands, so what now happens is: the script goes to the batches directory, runs ClosePdf.vbs, goes to your LaTeX-project directory, creates a pdf, and opens it in your viewer. So what still misses is a script for closing the pdf-file that is already open. We will fix that in step three.
3: Go to the batch directory of LEd again (\Batches). Create a new text document, and type the following:
So this starts the pdf viewer if it was not yet open, changes focus to it and sends the keystroke Ctrl+w to it. This is the usual keystroke to close a document. Immediately after this, it switches back to LEd.
- if this does not work, first make sure that the paths are correct. If this is correct and you don't get error messages, you might want to increase the timers in the vbs script: change WScript.Sleep 0 to WScript.Sleep 500 for instance, and see if this solves the problem.
- The scripting is fairly general, so mutatis mutandis this might work for other pdf viewers too (Foxit, Sumatra etc).