You have two options: use a makefile (which I would recommend) or run the command several times inside g:Tex_CompileRule_pdf
.
Use a Makefile
LaTeX documents, when they become big, may be troublesome to manage:
- several BibTeX reference files,
- gnuplot graphs that are compiled differently in
{draft}
mode,
- and general
\input
documents.
If you try to manage that with a single command line it will quickly become impossible to maintain. Using a Makefile allows for better dependency checking between files and also Vim can compile the LaTeX document with :make
(with the default :makeprg
, which is set to make
). An example Makefile could be like the following:
# Makefile for my LaTeX doc
LATEX = pdflatex -output-directory=output -synctex=-1 -src-specials -interaction=nonstopmode
BIBTEX = bibtex
RM = rm -f
BIB = mybibs.bib
LTFS = *.aux *.lof *.log *.lot *.fls *.out *.toc
DOCS = *.dvi *.pdf
BIBS = *.bbl *.blg
IDXS = *.idx *.ilg *.ind *.ist
OTHER = *.acn *.acr *.glg *.glo *.gls *.brf *.lol
all: document.pdf
%.pdf: %.tex %.bbl
$(LATEX) $<
$(LATEX) $<
.PRECIOUS: %.aux
%.aux: %.tex
$(LATEX) $<
.PRECIOUS: %.bbl
%.bbl: %.aux $(BIB)
$(BIBTEX) $<
.PHONY: clean
clean:
$(RM) $(LTFS) $(DOCS) $(BIBS) $(IDXS) $(OTHER)
This Makefile runs pdflatex
two times by default: once to build the sections and page numbers and a second time to make proper cross references. If a reference changes the .aux
file will be changed and pdflatex
will be run three times.
If you do not use BibTeX you do not need the parts about %.bbl
files.
Put several commands into g:Tex_CompileRule_pdf
I'll once again warn that this will quickly become unmaintainable. Tracking dependencies between files through a very long command line is very difficult.
Anyhow, you can use $*
several times inside an external command in Vim. In essence you can do this:
let g:Tex_CompileRule_pdf = 'pdflatex -output-directory=output '
\. '-synctex=-1 -src-specials -interaction=nonstopmode $*; '
\. 'pdflatex -output-directory=output '
\. '-synctex=-1 -src-specials -interaction=nonstopmode $*'
And it will run pdflatex
twice (note the semicolon) when you press <leader>ll
.
Extra note: we do have the vi.SE section of the website for Vim specific questions. It is often faster to get Vim related answers there.