Vim - creating latex files

I have a latex file (.tex) that I am editing in vim. Usually, I just go to cmd and type pdflatex my-file.tex , I hope for the best, and .pdf pops up :)

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

Can someone give me some pointers to this? I just started using this function (: make in Vim).

EDIT: Bonus points :) for tips that also handle the issues mentioned by Sebastian.

+4
source share
4 answers

I have the following in my .vimrc :

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

This will allow you to :make execute pdflatex .

This is not ideal, however:

  • He does not care about compiling BiBTeX, graphviz, etc. for you.
  • If necessary, it will not be compiled twice.
  • --shell-escape is a slightly dangerous option that allows a document to invoke any program, but it is necessary for compiling documents using dot2texi . (Built-in graphviz.)
  • Perhaps more.

For more complex documents, I tend to use the LaTeX Makefile . It is large enough and does a lot of things, but usually it will do what you want automatically, without any minor changes.

+5
source

I would just write a Makefile and leave the Vim settings alone. In general, the makefiles I use are pretty dumb, but even they take care of BiBTeX, and I usually compile three times. You can do much better with more effort. Less effort example -

 myfoo.pdf: myfoo.tex pdflatex myfoo pdflatex myfoo bibtex myfoo pdflatex myfoo 

(except that you need to use tabs, not spaces, and I have not tested above, and I myself do not use pdflatex, so I expect errors). If you don't like Make (and who really does), then you can use some other similar build tool, then install makeprg for it. I have never tried this.

+2
source

Regarding latex reuse, consider latexmk .

+2
source

Take a look at vim-latex / latex-suite - it solves all your problems :)

+1
source

Source: https://habr.com/ru/post/1387876/


All Articles