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
Code: Select all
"11007=11007=Command.PDFLaTeX=PDFLaTeX=/l53007/l=exec:pdflatex.bat"
Code: Select all
<MAINFILEDIR> <MAINFILENAMEEXT> <MAINFILEDISK> <BatchesDir> <MAINFILENAME>
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:
Code: Select all
C:
cd %4
ClosePdf.vbs
%3
cd %1
pdflatex.exe %2
%5.pdf
3: Go to the batch directory of LEd again (\Batches). Create a new text document, and type the following:
Code: Select all
' VB Script Document, to close a pdf before running pdflatex
option explicit
dim WshShell
set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 50
'Start the viewer if it is not yet started
WshShell.Exec("C:\Program Files\PDF-XChange Viewer\pdf-viewer\PDFXCview.exe")
'Change foces to viewer to be able to send keys to it, and sent Ctrl+w to close the active document
WshShell.AppActivate "PDF-XChange Viewer"
WScript.Sleep 0
WshShell.SendKeys "^w"
WScript.Sleep 0
'Change focus to LEd to observe the compilation.
WshShell.AppActivate "LEd"
Last remarks:
- 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).