I managed to find the perfect solution! For some reason, this didn't show up on my previous Google searches. I tailored my version of this solution: http://nimal.info/blog/2010/latex-on-windows-with-miktex-and-notepad/
My version (on a 64-bit Windows 7 machine) is as follows:
- Download and install Basic MiKTeX 2.9 (32-bit)
- Download and install SumatraPDF
- Create a batch file
miktex_to_latex.bat and place it anywhere
- For easy location, place the batch file in the [Notepad++ installation Path]
Copy-paste the following into the batch file and save it
:: Called from Notepad++ Run
:: [path_to_bat_file] "$(CURRENT_DIRECTORY)" "$(NAME_PART)"
:: Change Drive and to File Directory
:: Run Cleanup
:: Run pdflatex -> bibtex -> pdflatex -> pdflatex
:: If you are using multibib the following will run bibtex on all aux files
:: FOR /R . %%G IN (*.aux) DO bibtex %%G
:: Run Cleanup
:: Open PDF
START "" "C:\Progra~2\SumatraPDF\SumatraPDF.exe" %3 -reuse-instance
:: Cleanup Function
:: del *.log
:: del *.aux
:: del *.bbl
:: del *.blg
:: del *.brf
Take care of the following:
- All lines beginning with double colon
:: are comments
START command should have the installation path of SumatraPDF
- Make sure there are NO spaces in the path (Use
Program Files (X86))
-reuse-instance allows us to edit and recompile without quitting the PDF
Download (if it does not already exist) the NppExec plugin and place the
.dll file in [Notepad++ installation path]\plugins
.tex file in Notepad++, click on F6 to execute
Type the following lines in the window that pops up:
"<Path_to_bat_file>" "$(CURRENT_DIRECTORY)" "$(NAME_PART)" "$(NAME_PART).pdf"
In my case, this is:
"C:\Progra~2\Notepad++\miktex_to_latex.bat" "$(CURRENT_DIRECTORY)" "$(NAME_PART)" "$(NAME_PART).pdf"
The above lines basically tell NppExec to "save the current
.tex file, run the batch file, store results in current directory and name it the same as the
Click on "Save" and type in a recognizable name such as 'PDFLaTex'
Go to the menubar, Plugins -> NppExec -> Advanced Options.. Under 'Menu item', choose the script we just created above, and 'Add/Modify' it to the Menu items with a suitable name. This allows us to assign shortcut keys through Settings -> Shortcut Mapper -> Plugin commands
Navigate to the script name and choose any shortcut key like Shift+F7
Press the shortcut key Shift+F7 to save and compile the
.tex file. The SumatraPDF window should pop up and show the compiled PDF. Changes can be made and the file recompiled without having to close the PDF.
The BEST parts about this method are:
- There is no need to keep pressing Ctrl+S to save and then compile to PDF. Everything is done in one key press!
- There is no need to keep closing the opened PDF and reopening it on recompiling (as in the case with Adobe Reader)
- It is very easy to cleanup all the junk files generated
- It is completely open-source and can be easily integrated with an existing Notepad++ installation
Thanks Nimal, Jonas, Bert and the others who contributed to this awesome solution!