Using Notepad++ with MiKTeX on Windows

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:

  1. Download and install Basic MiKTeX 2.9 (32-bit)
  2. Download and install SumatraPDF
  3. Create a batch file miktex_to_latex.bat and place it anywhere
    • For easy location, place the batch file in the [Notepad++ installation Path]
  4. 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  
    %~d1  
    cd %1
    
    :: Run Cleanup  
    call:cleanup  
    
    :: Run pdflatex -> bibtex -> pdflatex -> pdflatex  
    pdflatex %2  
    bibtex  %2  
    :: If you are using multibib the following will run bibtex on all aux files  
    :: FOR /R . %%G IN (*.aux) DO bibtex %%G  
    pdflatex %2  
    pdflatex %2  
    
    :: Run Cleanup  
    call:cleanup  
    
    :: Open PDF  
    START "" "C:\Progra~2\SumatraPDF\SumatraPDF.exe" %3 -reuse-instance  
    
    :: Cleanup Function  
    :cleanup  
    del *.dvi
    del *.out
    :: del *.log 
    :: del *.aux  
    :: del *.bbl    
    :: del *.blg  
    :: del *.brf  
    
    goto:eof  
  5. Take care of the following:

    • All lines beginning with double colon :: are comments
    • the START command should have the installation path of SumatraPDF
    • Make sure there are NO spaces in the path (Use Progra~2, not Program Files (X86))
    • The -reuse-instance allows us to edit and recompile without quitting the PDF
  6. Download (if it does not already exist) the NppExec plugin and place the .dll file in [Notepad++ installation path]\plugins

  7. Open a .tex file in Notepad++, click on F6 to execute

  8. Type the following lines in the window that pops up:

    NPP_SAVE
    "<Path_to_bat_file>" "$(CURRENT_DIRECTORY)" "$(NAME_PART)" "$(NAME_PART).pdf"

    In my case, this is:

    NPP_SAVE
    "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 .tex file"

  9. Click on "Save" and type in a recognizable name such as 'PDFLaTex'

  10. 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

  11. Navigate to the script name and choose any shortcut key like F7

  12. Press the shortcut key 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 recompiledwithout 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
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值