# Vim LaTeX-suite: EFI macro expand differently

I an learning LaTeX-suite, and I found that the EFI macro for figure environment performance differently for different documents. Sometimes the image file line would be

\psfig{figure=<+eps file+>}


and sometimes it would be

\includegraphics{<+file+>}


This two kind of expansions seems happen randomly, since every time I just start a new empty article document. I think for the 'psfig' one the LaTeX-suite assume I am creating a .dvi file, but I was using pdfLaTeX all the time. How the LaTeX-suite decide which expansion would be used in a specific document?

• I know nothing about vim but you shouldn't use \psfig in any document written after about 1994, just use \includegraphics – David Carlisle May 15 '16 at 22:58
• @DavidCarlisle I never use this so I'm confused why LaTeX-suite generate this for me. – J Shèng May 16 '16 at 17:41

## 2 Answers

It seems to me like \psfig is being used if the graphicx package (or I guess equivalent) has not been loaded, this way (in principle) the inserted environment can be guaranteed to compile. However on my machine at least it seems to miss when a package called in the main document (or at least an own package) in turn calls graphicx.

To always get \includegraphics defining g:Tex_Env_figure according to

let g:Tex_Env_figure="\\begin{figure}[<+htpb+>]\<cr>\\centering\<cr>\\includegraphics{<+file+>}\<cr>\\caption{<+caption text+>}\<cr>\\label{fig:<+label+>}\<cr>\\end{figure}<++>"


should produce \includegraphics when the figure environment is called (whether via EFI or F5).

I keep running into this problem too. It appears that vim-latex is supposed to automatically detect which graphics package you're using, but this fails sometimes (in my case, I guess because I load graphicx in a different file).

The correct solution is to just let latex-vim know what package you want to use with: let g:Tex_package_detected = 'graphicx' (issue in command mode, put in vimrc, or whatever)

Or add

if !exists("g:Tex_package_detected")
let g:Tex_package_detected = 'graphicx'
elseif g:Tex_package_detected !~ '\<graphicx\>'
let g:Tex_package_detected = g:Tex_package_detected.',graphicx'
endif


to .vim/after/ftplugin/tex.vim

Or you can hardcode the figure macro yourself, as suggested in Dai Bowen's answer. Here's the manual for that: Manual: http://vim-latex.sourceforge.net/documentation/latex-suite.html#customizing-macros