Vim插件之Latex实时预览——vim-latex-live-preview

1. 官网
    博客: https://www.topbug.net/blog/2013/06/13/live-preview-of-latex-in-vim/
    源码: https://github.com/xuhdev/vim-latex-live-preview

2. 概述
     vim-latex-live-preview是一个可以pdf形式实时预览Latex文件的插件。如下图示(图片来自官网)。当前仅支持 UNIX-like操作系统(不含Windows)。
Vim插件之Latex实时预览——vim-latex-live-preview_第1张图片

3. 安装
  • 系统要求:
    • 操作系统:UNIX-like(*nix或Mac),不支持Windows
    • tex编译环境,我用的是TexLive 2014.
    • pdf浏览器:evience
    • Vim 7.3+,支持Python
      • 检查方法:vim中【:version】
  • 安装
    • 手动
      • 下载【latexlivepreview.vim】,并将其拷贝至【~/.vim/plugin】目录下。
    • 用Vundle安装
      • 在【~/.vimrc】中适当位置增加:【Bundle ‘xuhdev/vim-latex-live-preview’】
      • :BundleInstall
4. 配置(在【~/.vimrc】中增加)
  • PDF文件刷新频率
    • autocmd Filetype tex setl updatetime=1
      • 官方推荐值为“1”,单位应是“秒”。可根据需要设置。
  • PDF浏览器
    • 默认使用evince、okular,支持zathura、skim、preview
    • zathura支持:
      • let g:livepreview_previewer = 'zathura'
    • skim支持:
      • 刷新频率过高时支持不太好
      • let g:livepreview_previewer = 'open -a Skim'
    • preview支持:
      • 仅支持OS X
      • 仅当Preview失去焦点时才更新pdf文件
        • 原文:the preview only updates when you move the focus on the Preview 
      • : let g:livepreview_previewer = 'open -a Preview'
  • 预览PDF
    • :LLPStartPreview
    • 注:第一次预览时速度较慢。
  • 键映射
    • nmap :LLPStartPreview

以上部分翻译自官网, 红色字体为笔者所加

5. 中文支持问题
     vim-latex-live-preview默认使用pdflatex来编译.tex文件。如果.tex文件中有中文的话,会报错,如下图示:
Vim插件之Latex实时预览——vim-latex-live-preview_第2张图片

    打开【latexlivepreview.vim 】文件,将其中的【pdflatex】全部替换为【xelatex】,保存后,重新启动vim,编辑含中文的.tex文件,实时预览正常。

参考: https://www.topbug.net/blog/2013/06/13/live-preview-of-latex-in-vim/

本文历史:
v1     2015.1.31     XAN

你可能感兴趣的:(Linux,vim,latex)