Recently I started to use latex to write papers. I want to edit latex in my favorite editor - vim. I found the project vim-latex: http://vim-latex.sourceforge.net/. It is powerful and convenient to use.
However, one feature I want is to generate output files (.div, .ps, .log, etc) into a separate directory rather than the same directory as tex files. It turns out that vim-latex does not support it natively. So I hacked into the source code to make it work on Windows.
-
Edit file ~/vimfiles/ftplugin/tex.vim
Add following config:
set iskeyword+=: let g:Tex_Outdir='out' let g:Tex_ViewRule_pdf='"Foxit Reader.exe" ' let g:Tex_CompileRule_dvi='mkdir '.g:Tex_Outdir.' & latex -output-directory='.g:Tex_Outdir.' -src-specials --interaction=nonstopmode $*' let g:Tex_CompileRule_pdf=g:Tex_CompileRule_dvi.' & cd '.g:Tex_Outdir.' & dvipdfm $*.dvi'
Basically above config specifies
- output directory of latex compilation
- How to view PDF files (if you don't give full path, the command needs to be in env variable PATH)
- How to compile dvi: create the output directory and put output there
- How to compile pdf: first compile tex to dvi, and then call dvipdfm to generate pdf
-
Change ~/vimfiles/ftplugin/latex-suite/compiler.vim
Change line 252 to (this line adds the full path of output directory):
let execString = 'start '.s:viewer.' "'.expand('%:p:h').'/'.g:Tex_Outdir.'/$*.'.s:target.'"'
Change line 405 to (this line adds the full path of output directory):
Note: the text in blue is what I added (diff against the original code)let execString = 'silent! !'.viewer.' "'.expand('%:p:h').'/'.g:Tex_Outdir.'/'.mainfnameRoot.'.'.s:target.'" '.line('.').' "'.expand('%').'"'
No comments:
Post a Comment