Setup latex on vim

This guide will show you how to turn vim into a latex editor. We will install the latex-suite tool and then create a Makefile that allows us to compile latex within vim.

1. Install texlive:


sudo apt-get update
sudo apt-get install texlive-full

2. Install latex-suite:

http://vim-latex.sourceforge.net/index.php?subject=download

http://vim-latex.sourceforge.net/documentation/latex-suite/recommended-settings.html

Don’t install latex-suite from Vundle. Otherwise, the F9 key will not work.

3. Install gvim (optional):


sudo apt-get install vim-gnome

4. Compile latex and generate .pdf file from vim:

http://vim.wikia.com/wiki/Compiling_LaTeX_from_Vim

Use rubber


sudo apt-get update
sudo apt-get install rubber

Create a makefile latex.mk:


%.pdf: %.tex $(DEPENDS)
rubber -f --pdf -s $<
rubber-info --check $<
rm -rf *.log *.aux *.dvi   # remove unnecessary files!

Add these lines to ~/.vim/ftplugin/tex_latexSuite.vim


setlocal errorformat=%f:%l:\ %m,%f:%l-%\\d%\\+:\ %m
if filereadable('Makefile')
setlocal makeprg=make
else
exec "setlocal makeprg=make\\ -f\\ $PATH_TO_LATEX_MAKE_FILE/latex.mk\\ " . substitute(bufname("%"),"tex$","pdf", "")
endif

Replace $PATH_TO_LATEX_MAKE_FILE accordingly with path to your latex.mk.

To compile enter :make  in vim.

 

Comments

comments