Ⅰ. 插件描述
LightweightⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin '/tex-pdf'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle '/tex-pdf'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug '/tex-pdf'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-scripts/TeX-PDF
Ⅳ. 文档说明
Description
This plugin provides support for specialized lightweight "stay-out-of-your-way"
TeX-to-PDF compilation and viewing. In contrast to some of the other more
comprehensive TeX/LaTeX suites, it provides nothing else but two commands, and
leaves the rest of your Vim platform undisturbed, except for a few key maps to
invoke the commands.
Features
- Runs "make" if a Makefile is found, otherwise invokes Rubber (if
installed) or pdflatex (otherwise) on the current file.
- Successful builds will result in PDF being opened/refreshed in the
default external viewer.
- Unsuccessful builds will result in the QuickFix buffer being opened and
to list the errors, with line numbers, description etc.
Usage
Once the plugin is installed (see below), when you have a TeX or LaTeX document
open in the buffer, type 'r' or <Shift-F9> to compile the document and open
(or refresh) the resulting PDF in your system's default PDF viewer. To just
compile the document to PDF without opening it, type 'm' or <F9>. If there
are any compile errors, a window will open and list all the problematic lines.
As usual, you can navigate forward and backward through this list using the
':cnext' and ':cprev' commands, and you will automatically be taken to the
corresponding line in the source document.
Working with Rubber
This plugin will work quite happily with the stock TeX/LaTeX tools found on
most systems. As described above, for example, this plugin will run "make" if a
Makefile is found in the current working directory (by-passing Rubber, even if
installed), and fall back to the standard "pdflatex" if Rubber is not
installed.
However, installation of "Rubber" (https://launchpad.net/rubber) in conjunction
with this plugin makes Vim a very powerful, yet highly ergonomic and
non-intrusive, LaTeX IDE, making Makefiles unneccessary for many document
- Rubber takes care of the multiple TeX compile passes required to get
- the bibliographies, references, cross-references, etc. correctly built,
while this plug-in takes care of opening/refreshing the PDF view on successful
builds, as well as providing for a clean view of the errors on an
unsuccessful build.
Operation
This plugin provides two commands: "BuildAndViewTexPdf" and "BuildTexPdf".
"BuildAndViewTexPdf" will build the PDF from the TeX source, and, if
successful, will open the resulting PDF for viewing in an external viewer (or
refresh the PDF if already opened).
"BuildTexPdf" will build the PDF from the TeX source without opening/refreshing
the PDF.
The build logic is:
(1) If a Makefile is found in the current directory, then "make" will be
invoked.
(2) If there is no Makefile in the current directory, but "Rubber"
(https://launchpad.net/rubber) is installed and available, then this will
invoked on the current buffer file.
(3) If Rubber is not installed, then "pdflatex" will be invoked on the
current buffer file.
If the build is unsuccessful, the QuickFix buffer is populated with the
(parsed, cleaned, and filtered) error messages and automatically opened,
showing, for each error, the line number and description of the error. You can
then used ":cnext", ":cprev", etc. to visit each of the error lines.
Key Mapping
By default, '<Leader>r' (mnemonic: 'run') and '<S-F9>' are mapped to
"BuildAndViewTexPdf", while '<Leader>m' (mnemonic: 'make') and '<F9>' are
mapped to "BuildTexPdf"
If you prefer not to have any of the above keys mapped, then include the
following in your '~/.vimrc':
let g:tex_pdf_map_keys = 0
If you prefer not to have the 'r' and 'm' leader keys mapped but keep the
function key mapping, you can include the following in your '~/.vimrc':
let g:tex_pdf_map_leader_keys = 0
Alternatively, you can keep the leader keys mapped but by-pass the function key
mapping by including the following in your '~/.vimrc':
let g:tex_pdf_map_func_keys = 0
You can, of course, map any keys that you want to the commands. For example,
by including the following in your '~/.vimrc', you will map Command-V to the
"compile and view" command and Command-T to the "just compile" command in
both normal and insert modes:
noremap <silent> <D-V> <Esc>:BuildAndViewTexPdf<CR>
inoremap <silent> <D-V> <Esc>:BuildAndViewTexPdf<CR>
noremap <silent> <D-T> <Esc>:BuildTexPdf<CR>
inoremap <silent> <D-T> <Esc>:BuildTexPdf<CR>