views:

310

answers:

3

I am generating a pdf output with pdflatex with the following command in gVim:

:!pdflatex %

This command in turns executes the following in the Command Prompt:

cmd.exe /c pdflatex /testvim.tex

Now, the problem I'm having with this is that the pdf is outputted to the system32 folder:

C:\windows\system32\testvim.pdf

How can I instruct pdflatex to generate the pdf in the folder where the tex file resides?

A: 

This depends mainly on your LaTeX version. Do you use MikTeX or TeXLive ?

The pdflatex command of MikTeX has a command line option for specifying the output directory and the auxiliary directory (for .aux files). I don't have MikTeX installed on my PC now, but you should be able to figure it out when running pdflatex --help or pdflatex /? from the command prompt.

If you are using TeXLive, you can first switch to the wanted output directory, then run pdflatex with the full path to your latex input file. This outputs everything into the current working directory, including temporary tex files.

I would suggest that you write your own runpdflatex.bat file which includes the correct call to pdflatex so you don't have to bother with it every time you want to compile your latex file.

Wolfgang Ulmer
A: 

Do you start GVim per Icon? I do the following:

  1. Opening Dos Box
  2. Change to my tex-directory cd\local\tex\make
  3. gvim foobar.tex
  4. Executing :!pdflatex % creates the PDF document in local\tex\make not in the system32-folder
vbd
+1  A: 

What about using the latex plugin for vim? http://vim-latex.sourceforge.net/

Niall Murphy
latex-suite is a great plugin for anyone who frequently writes LaTeX documents in Vim. `:TTarget`, then enter `pdf`, then, in normal mode, type `\ll` to compile to PDF, then `\lv` to view the file . If you always want to generate PDFs, put `let g:Tex_DefaultTargetFormat = "pdf"` in your `.vimrc` (`_vimrc`) file.
gotgenes