Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim - building Latex files

I have a latex file (.tex) which I'm editing in vim. Usually, I just go into cmd and type pdflatex my-file.tex, hope for the best, and a .pdf pops out :)

What would I need to change in Vim, to use Vim's "make option". So, I can just do :make, and let Vim build my .tex files for me. Also, I'd like it to display the output in a new buffer to the right?

Can anyone give me some pointers on this? I just started using that feature (:make in Vim).

EDIT: Bonus points :) for tips that handle the problems mentioned by Sebastian, as well.

like image 564
Rook Avatar asked Dec 27 '22 08:12

Rook


1 Answers

I personally have the following in my .vimrc:

autocmd FileType tex setlocal makeprg=pdflatex\ --shell-escape\ '%'

That will let you :make in order to run pdflatex.

It is not perfect, however:

  • It doesn't take care of compiling BiBTeX, graphviz, etc... for you.
  • It doesn't compile twice if needed.
  • --shell-escape is a slightly dangerous option that allows the document to call any program, but it is needed in order to compile documents using dot2texi. (Embedded graphviz.)
  • Possibly more.

For more complicated documents, I tend to use the LaTeX Makefile. It's quite large and does quite a lot of things, but usually it'll do what you want automatically with no or only minor modifications.

like image 154
Sebastian Paaske Tørholm Avatar answered Dec 31 '22 14:12

Sebastian Paaske Tørholm