You are not logged in.

#1 2012-03-23 11:34:03

anti-destin
Member
Registered: 2009-02-14
Posts: 234

[solved] vim + pdflatex + bibtex

i use vim as my latex editor, and i've assigned a keyboard shortcut to compile documents. i have the following line in my ~/.vimrc:

map <C-p> :w<cr> :silent :!pdflatex -interaction=nonstopmode % >/dev/null<cr> :!bibtex %:r<cr> :!pdflatex -interaction=nonstopmode % >/dev/null<cr> :redraw!<cr>

1. i get a bibtex error when the tex file contains no citations. how should i change the code above? it would be nice to avoid having to create a second keybinding that doesn't include bibtex.

2. how can i hide the bibtex output?

3. when compiling, i briefly see the shell. is there any way to do all the compiling in the background so that the document remains in focus and i never see the shell?

4. do you have any suggestions to improve my command?

thanks.

Last edited by anti-destin (2012-03-31 12:01:01)

Offline

#2 2012-03-23 11:44:44

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [solved] vim + pdflatex + bibtex

2: try output redirection (you managed to do this with pdflatex, or was that blindly copy-pasted from the web? tongue But maybe the -interaction mode is also crucial for this to work with vim; no idea if that can be done with bibtex.)

4 and probably also 1: consider latexmk. It comes with texlive and automatically runs (pdf)latex multiple times if needed, as well as bibtex (and maybe other external tools).

Last edited by Raynman (2012-03-23 11:46:45)

Offline

#3 2012-03-23 11:47:41

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,557
Website

Re: [solved] vim + pdflatex + bibtex

I have a script on my work computer I use just for this purpose.

It has a conditional test which greps for usepackage{bibtex} and usepackage{beamer} to determine which sequence of commands to run. (1)

It also removes any unneeded files that latex creates (aux, etc). (2)

I've never tried to do three, I suspect one could map "script-name &" to have the script run in the bg.

I just bind this script to a key.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2012-03-31 12:00:49

anti-destin
Member
Registered: 2009-02-14
Posts: 234

Re: [solved] vim + pdflatex + bibtex

thanks for the replies.

this is what i have now:

map <C-p> :!latexmk -pdf -silent % &<cr><cr>

and it works pretty well. latexmk is great.

Offline

Board footer

Powered by FluxBB