Recently I have installed vim-latex
plugin in gVim
. I use portable MiKTeX
to compile tex
document into pdf
documents. Till now, I have used command prompt to compile the tex files. After installing vim-latex
plugin I found that there's a compile option under Tex-Suite>Compile
menu. But clicking it doesn't do anything. So how can I configure vim-latex to use the portable MiKTeX compiler?
How to configure vim-latex to use portable MiKTeX to compile
2.2k views Asked by th1rdey3 AtThere are 2 answers
You need to set a few variables in vim to configure vim-latex.
This one sets the order in which you want to export your tex file:
let g:Tex_FormatDependency_pdf = 'dvi,ps,pdf'
Notice that it converts the *.tex to *.dvi, then the *.dvi to *.ps, then *.ps to *.pdf.
The next ones you need to set are the compile rules for vim-latex. Each of these rules define the program (and arguments) used to compile each output file:
let g:Tex_CompileRule_dvi = 'latex --interaction=nonstopmode $*'
let g:Tex_CompileRule_ps = 'dvips -Ppdf -o $*.ps $*.dvi'
let g:Tex_CompileRule_pdf = 'ps2pdf $*.ps'
When you convert from *.tex to *.dvi, vim-latex will use the 'latex' command. Then, when it converts from *.dvi to *.ps, it will use dvips. Finally it will use ps2pdf to convert from *.ps to *.pdf.
It looks like MikTex's executable is named 'latex', so you should be OK to use the above settings. Just be sure that you have 'dvips' and 'ps2pdf' installed on your system.
The output *.pdf file will be in the directory which contains your source *.tex file.
Initial googling let me to this link: http://vim-latex.sourceforge.net/documentation/latex-suite/customizing-compiling.html#Tex_CompileRule_format. However, I couldn't find any clue to where actually configure this variables. But finally I found the location. For my case it was
The texrc file has all the variables described in the link. As I said in my question, I use
miktex portable
so first I needed to change the compiler. So I searched forg:Tex_CompileRule_pdf
in the file and found this lineSo, I just replaced
pdflatex
with the full pathNext thing that needed to be changed is telling vim-latex to use
pdflatex
to compile by default. So, I searched for theg:Tex_DefaultTargetFormat
variable in the file and found this lineNo need to keep all this checking. so I commented out most of the lines
After this, vim-latex was able to compile my files. But the viewer wasn't working. So, needed to make a little more change. Searched for
g:Tex_ViewRule_ps
and changed the lines underif has('win32')
to look like this.I had to use
SumatraPDF
because for some reasonAdobe Reader 11
was giving the errorUnable to find the file
. ButSumatra
in not so bad. Now I can use vim-latex in peace :)