I am using Vim+latex. In my project directory, I have another separate tex file (for example a tikz/PGF file to draw a figure). When I input \ll, instead of compiling my current file, the system compiles the project file. Is it possible to tell the system to compile my current file?

Thanks a lot!


1 Answer 1


This might be considered a workaround by some, but I think it will work for your purposes. From the LaTeX-Suite Reference:

Each time LaTeX-Suite opens a new LaTeX file, it will try to see if it is part of a multiple file project by searching upwards (to the root of the file-system) from the current file's directory to see if it finds a file of the form *.latexmain. If such a file is found, then it is considered that the current file is part of a larger project.

What this means is that you can have multiple *.latexmain files per project, provided they are at different directory levels.

So let's call your main document mydoc.tex and the separate file myfig.tex. If you set up the directory structure as follows:


everything should work as you wish. If myfig.tex is the active buffer and you press \ll, LaTeX-Suite will find myfig.latexmain and compile myfig.tex. If mydoc.tex is the active buffer, mydoc.latexmain will be found and the document will be compiled. If anything in myfiles/ is the active buffer, LaTeX-Suite will find no *.latexmain files in the current directory and will traverse up one level. It will then find mydoc.latexmain and compile the document as desired.

The only other change will be in the files containing the source of your document text. I assume that you are using


to include the compiled output of the figure file in your document. You'll need to change this to a relative path now that the files are in different directories. If the graphic is included from the project-dir/ level, use


or, if the graphic is included from the myfiles/ level, use


to include the compiled output.

This approach can be extended to multiple figure files as well: just introduce another directory for each figure such that the appropriate *.latexmain is always found first during the upward traversal of the directory tree.

All that said, if you need to do this for many figure files, the directory structure may get overly complex fast. It may be better to take a look at TikZ's externalization methods (Ch. 50 of the current pgf manual).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .