24

Today I started using vim in combination with the latex-suite plugin, and so far I love it. Other editors also make using LaTeX easier by providing code completed and such, but latex-suites's versatility seems unmatched.

The only issue that I have so far is that I want to keep using my latexmk setup. At the moment, I store a .latexmkrc file in my working directory, and run latexmk --pdf --pvc file.tex from a terminal.

How can I combine latexmk and latex-suite such that I can keep using latex-suite's useful set-up with the error windows at the bottom? Here is a screenshot to clarify which "error window" I mean:

vim with latex-suite, error window


I have updated my vimrc according to Aditya's proposal. Here is the relevant part:

filetype plugin on
set grepprg=grep\ -nH\ $*
filetype indent on
let g:tex_flavor='latex'

let g:Tex_DefaultTargetFormat = 'pdf'
let g:Tex_CompileRule_pdf = 'latexmk -pdf -pvc $*'
set iskeyword+=:

When pressing \ll now, nothing happens at all.

Any thoughts would be greatly appreciated!

  • 1
    See :he latex-compiling and :he compiler-rules. I guess that setting g:TeX_CompileRule_pdf = 'latexmk -pdf -pvc $*' should work (assuming that -pvc sets interactionmode=nonstop behind the scenes. – Aditya Oct 23 '11 at 18:24
  • Thanks Aditya, I have played around with your proposal recently but couldn't get it to work - strangely! It would be great if you could also check my updated question. – Ingo Oct 25 '11 at 19:57
  • Btw. in your comment it must be g:Tex_CompileRule_pdf .... with a small x. Almost drove me crazy until I found that out ;-). – Ingo Oct 25 '11 at 20:07
  • 1
    Not directly answer your question. You may consider latex-box (vim.org/scripts/script.php?script_id=3109) and snipMate (vim.org/scripts/script.php?script_id=2540). Latex-box use latexmk for compilation and provides omni-completion for citations, reference. Also it is easy to get it work with user defined non-standard citation commands like biblatex's. as well as reference commands. snipMate, which emulate the snip concept in TextMate, is the best way I know for code completion. latex-box is lightweight, unlike latex-suite's versatility. But they just work. – Yan Zhou Oct 25 '11 at 20:36
  • Might it be possible to get only the macros of latex-suite working, but using latex-box for compiling? So that I ]could still use things like ` a giving \alpha, but latex-box would do the rest? – Ingo Oct 26 '11 at 5:50
9
+50

The following works on my end: Create a file called latexmk.vimrc in the current directory with the following content

set nocompatible
filetype plugin on
set grepprg=grep\ -nH\ $*
filetype indent on
let g:tex_flavor='latex'

let g:Tex_DefaultTargetFormat = 'pdf'
let g:Tex_CompileRule_pdf = 'latexmk -pdf -f $*'
set iskeyword+=:

Call vim -u latexmk.vimrc filename where filename is a tex file. Type \ll in normal mode runs latexmk. I need to press enter at the end but I don't know how to get rid of that.

  • Still can not get this to work. I'll give AutomaticLaTeXPlugin a shot now and see how that works, it uses LaTeXBox in the background which natively applies latexmk. – Ingo Oct 27 '11 at 17:03
  • @tehingo: Did you try the method exactly (using -u latexmf.vimrc, which does not load any local settings). If you use gvim, add -U NONE so that the settings from .gvimrc are not loaded. – Aditya Oct 27 '11 at 17:27
2

There two plugins which support latexmk within vim:

LatexBox

and

AutomaticTexPlugin

The last one has also built-in method to compile documents in the background (live updates) and shows a progress bar. It also has a very good completion, see the feature list.

  • 1
    If this is a product of yours, please disclose it, see the faq. – doncherry Nov 24 '12 at 16:55
0

An alternative to creating a latexmk.vimrc that I have found easy is to use :cd %:p:h to place yourself in the directory of the active tex file and compile from within Vim using :!latexmk -pdf %.

When recompiling, one has only to use :! followed by the up arrow!

Though easy, the disadvantage is that it does not open the quickfix and other error windows at the bottom of the vim window as mentioned in the original question.

However, about a week ago I found a working solution at

http://ditraglia.com/2015/01/02/synctex-latexmk-and-vim-latex.html

This post has two parts. Part I: Compilation Commands is the one relevant to this question. It only involves editing ~/.vimrc. I've been using it successfully for the last week or so. I gave it a test today with a course outline using the multibib package to compile a two-part bibliography and it was successful. The quickfix window does open normally.

(Part II: Evince and Synctex is also worthwhile and helpful but not related to the compilation with latexmk.)

This method also requires no latexmk.vimrc. Loading the latexmk.vimrc seems to prevent the loading of other settings in the normal .vimrc (if I've understood correctly). This seems undesirable to me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.