您的位置:首页 > 其它

用vim编写LaTeX的小结

2014-06-03 15:52 141 查看
1~首先,需要下载普及率比较高的LATEX环境TEXLINE

直接
sudo
apt-get

install
texlive-full






比较大,花了15分钟。






2~其实现在已经可以在VIM下编写LATEX了。步骤如下:


2.1vim test.tex进入VIM编辑模式

2.2输入代码如下:

\documentclass{article}

\title{First \LaTeX Document}

\author{Wang Xu}

\begin{document}

\maketitle

Hello , \LaTeX!

\end{document}


2.3生成PDF文件:

pdflatex test.tex



2.4打开pdf文件

evince test.pdf

3~安装latex-suite插件

3.1将下载的tar.gz文件解压到~/.vim/文件夹下:tar -xvzf



将相同的文件夹合并,不同的文件夹放到.vim目录下

3.2在vim命令模式下输入:

helptags ~/.vim/doc

3.2修改配置文件 .vimrc

加入:



"LaTeX插件suite配置

"-- vim latex-suite setting --

"" REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.

filetype plugin on

" IMPORTANT: win32 users will need to have 'shellslash' set so that latex

" " can be called correctly.

set shellslash

"

" " IMPORTANT: grep will sometimes skip displaying the file name if you

" " search in a singe file. This will confuse Latex-Suite. Set your grep

" " program to always generate a file-name.

set grepprg=grep\ -nH\ $*

"

" " OPTIONAL: This enables automatic indentation as you type.

filetype indent on

"

" " OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults

" to

" " 'plaintex' instead of 'tex', which results in vim-latex not being loaded.

" " The following changes the default filetype back to 'tex':

let g:tex_flavor='latex'



4.Latex-suite 快捷键:

编译: \ll

查看: \lv

这样的快捷键显然不方便,需要重新设置快捷键

cd ~/.vim/ftplugin/

vim tex.vim

加入以下代码:

"F2保存并编译

map <F2> <ESC>:w<CR>\ll

imap <F2> <ESC>:w<CR>\ll

"F3查看

map <F3> <ESC>\lv



5.修改latex-suite编译的依赖关系:

cd ~/.vim/ftplugin/

vim tex.vim

输入代码:

"this is mostly a matter of taste. but LaTeX looks good with just a bit

" of indentation.

set sw=2

" TIP: if you write your \label's as \label{

" fig:something}, then if you

" " type in \ref{

" fig: and press <C-n> you will automatically cycle through

" " all the figure labels. Very useful!

set iskeyword+=:"

let g:Tex_DefaultTargetFormat = 'pdf'

"let g:Tex_FormatDependency_pdf = 'dvi,ps,pdf' 把依赖关系dvi-ps-pdf取消掉,则编译只会生成pdf



"let g:Tex_CompileRule_dvi = 'latex --interaction=nonstopmode $*'

"let g:Tex_CompileRule_ps = 'dvips -Ppdf -o $*.ps $*.dvi'

"let g:Tex_CompileRule_pdf = 'ps2pdf $*.ps'

let g:Tex_CompileRule_pdf = 'xelatex -interaction=nonstopmode $*'

let g:Tex_ViewRule_dvi = 'xdvi'

let g:Tex_ViewRule_ps = 'ghostview'

"let g:Tex_ViewRule_pdf = 'xpdf'

let g:Tex_ViewRule_pdf = 'evince' 查看pdf的方式,选择evince



6.写好的tex文件用哪种方式生成pdf?

推荐两种方式:xelatex 和 pdflatex

两者最大的区别是:XeLaTeX对应的XeTeX对字体的支持更好,允许用户使用操作系统字体来代替TeX的标准字体,而且对非拉丁字体的支持更好

修改生成pdf的方式:

cd ~/.vim/ftplugin/latex-suite/

vim texrc

把这一句修改为:TexLet g:Tex_CompileRule_pdf = 'xelatex -interaction=nonstopmode $*'

7.解决使用别人的模板编译tex出错的问题:

我报的错误是font not found找不到字体,因为我是用xelatex编译的,这种方式对字体支持不好

建议使用如下步骤:

latex file.tex

dvipdfm file.dvi

evince file.pdf

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: