Sunday, July 08, 2007

Vim + LaTeXSuite + XPDF for LaTeX editing

Here is my LaTeX editing configuration.

Since XPDF has a refresh feature, I have set up my LaTeX editor (Vim + LaTeXSuite) to generate a PDF file and automatically refresh the XPDF window. Hence, one command compiles the LaTeX file (an appropriate number of times to get the references and citations correct!), converts the dvi file to a PDF file and refreshes the XPDF window.

General comment. If you spend a lot of time editing text, then it is well worth your time to learn to use an efficient editor. Vim is one example of such an editor. Another is Emacs.

Installation. Use apt-get to install all the software.
apt-get install vim-gtk vim-latexsuite xpdf
Configuration. Here are the relevant entries of my .vimrc file.
" General features.
syntax enable " enable syntax highlighting
set hlsearch " hightlight search
set textwidth=70 " set textwidth to 70 to cause wrapping
set history=50 " 50 lines of command lines history
set viminfo='20,\"50 " read/write a .viminfo file with at most 50 lines
set ruler " show the cursor position all the time
set spell " turn on speel checking
set nojoinspaces " only put one space after periods

" For latex-suite, as suggested by the LatexSuite documentation.
filetype plugin on " to enable latex-suite when a tex file is loaded
set shellslash
set grepprg=grep\ -nH\ $*
filetype indent off

" Run latex, then dvipdf, then refresh the xpdf window.
let g:Tex_FormatDependency_pdf = 'dvi,pdf'
let g:Tex_CompileRule_pdf = 'dvipdf $*.dvi; xpdf -remote -reload -raise'
let g:Tex_ViewRule_pdf = 'xpdf -remote'
let g:Tex_DefaultTargetFormat = 'pdf'
" Set the target format to pdf.

" Set the warning messages to ignore.
let g:Tex_IgnoredWarnings =
\"specifier changed to\n".
\"You have requested\n".
\"Missing number, treated as zero.\n".
\"There were undefined references\n".
\"Citation %.%# undefined\n".
\'LaTeX Font Warning:'"
" This number N says that latex-suite should ignore the first N of the above.
let g:Tex_IgnoreLevel = 8

" TIP: if you write your \label's as \label{fig:something}, then if you
" type in \ref{fig: and press Ctrl-N you will automatically cycle through
" all the figure labels. Very useful!
set iskeyword+=:
Use. The command \lv launches xpdf and \ll runs latex, dvipdf, xpdf -reload. LaTeXSuite has many interesting features to allow for quick writing of LaTeX documents. For example, typing `a will insert \alpha and F5 offers a shortcut to inserting an environment (e.g., displaymath). Check out the online tutorial.