首先, 編輯器可選, 可用texpad、sublime谅海、vim等.
其次, mactex是必裝環(huán)境.
一、安裝MacTex
在如下地址下載MacTex, 月3G以上, 雙擊安裝.
http://www.tug.org/mactex/mactex-download.html
說明:MacTex自帶的編輯器Texshop簡(jiǎn)單實(shí)用
二蹦浦、安裝Vim-latex
Vim-latex 插件
Vim-latex?插件是一個(gè)強(qiáng)大的Latex插件, 它的安裝方法是:
1. 將下面代碼放在~/.vimrc 中:
Plugin 'vim-latex/vim-latex'
" 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
" 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'
然后在vim中運(yùn)行:
:source %
:PluginInstall
2.?In addition, the following settings could go in your ~/.vim/ftplugin/tex.vim file:
" 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+=:
3.?In the unlikely case that Latex-Suite is installed, but you do not want to use it (e.g., if it is installed system-wide and you use some other package to deal with tex files), you can suppress the loading of Latex-Suite by setting
let b:suppress_latex_suite = 1
in your ~/.vim/ftplugin/tex.vim.
4. 到這里扭吁,就完成了vim的安裝∶は猓可以在vim中查看其幫助文檔:
:help latex-suite.txt
:help latexhelp.txt
試錯(cuò)和使用
1.報(bào)錯(cuò)解決
安裝完成之后侥袜,就可以使用了。打開一份latex文檔溉贿,在normal模式下枫吧,按下:
\ll
順利的話就可以編譯成功,latex生成的pdf宇色。不過九杂,這里我還是遇到了報(bào)錯(cuò):
I can't find file `latex_notes.tex`. latex_notes.tex
Emergency stop. latex_notes.tex
網(wǎng)上查了下,好像是由于latex源文件所在的路徑中有中文字符導(dǎo)致的宣蠕。這里遷就下例隆,將其放到一個(gè)全是英文的路徑中,然后重新編譯抢蚀,應(yīng)該就可以了(參考鏈接)镀层。
如果latex文件中有中文字符,這時(shí)編譯得到的pdf文檔里面中文字符的位置皿曲,可能全是空白唱逢。這里需要設(shè)置下latex的編譯引擎,將其設(shè)置為xelatex谷饿。vim-latex配置文件(.vim/ftplugin/latex-suite/texrc)
110 TexLet g:Tex_CompileRule_pdf = 'xelatex -interaction=nonstopmode $*'
這樣惶我,應(yīng)該就可以編譯成功了。(參考鏈接)
2.使用
下面是幾個(gè)操作命令:
\ll編譯
\lv預(yù)覽pdf
先寫這些博投,后續(xù)再補(bǔ)充。