阅读权限 255 威望 0 级论坛币 3206 个 通用积分 5056.6800 学术水平 539 点 热心指数 537 点 信用等级 538 点 经验 10157 点 帖子 300 精华 2 在线时间 90 小时 注册时间 2010-10-3 最后登录 2024-4-6
Package Control 的安装 Package Control 是个控制包的包,为了更加简单的安装其他的包,我们首先需要安装 Package Control, 然后今后借助 Package Control 来安装其他的包,这样就方便多了。安装 Package Control 有自动和手动两种方式。关于这两种方式的介绍在官网都有说明,详见官网安装说明 。
自动安装 自动安装需要调出 Sublime Text Console,两种方式可以实现:
通过组合键 CTRL+ ` 通过菜单命令 View -> Show Console
然后将下面的代码复制到下面的 Console 就行了(这是 Sublime Text 3 的代码,对于 Sublime Text 2,官网有对应的代码)。
1
2
import[color=rgb(0, 111, 224) !important] urllib[color=rgb(51, 51, 51) !important]. request[color=rgb(51, 51, 51) !important], os[color=rgb(51, 51, 51) !important], hashlib[color=rgb(51, 51, 51) !important]; [color=rgb(0, 111, 224) !important] h[color=rgb(0, 111, 224) !important] =[color=rgb(0, 111, 224) !important] '7183a2d3e96f11eeadd761d777e62404'[color=rgb(0, 111, 224) !important] +[color=rgb(0, 111, 224) !important] 'e330c659d4bb41d3bdf022e94cab3cd0'[color=rgb(51, 51, 51) !important]; [color=rgb(0, 111, 224) !important] pf[color=rgb(0, 111, 224) !important] =[color=rgb(0, 111, 224) !important] 'Package[color=rgb(0, 111, 224) !important] Control[color=rgb(51, 51, 51) !important]. sublime-package'[color=rgb(51, 51, 51) !important]; [color=rgb(0, 111, 224) !important] ipp[color=rgb(0, 111, 224) !important] =[color=rgb(0, 111, 224) !important] sublime[color=rgb(51, 51, 51) !important]. installed[color=rgb(51, 51, 51) !important]_ packages[color=rgb(51, 51, 51) !important]_ path[color=rgb(51, 51, 51) !important]( [color=rgb(51, 51, 51) !important]) [color=rgb(51, 51, 51) !important]; [color=rgb(0, 111, 224) !important] urllib[color=rgb(51, 51, 51) !important]. request[color=rgb(51, 51, 51) !important]. install[color=rgb(51, 51, 51) !important]_ opener[color=rgb(51, 51, 51) !important]( [color=rgb(0, 111, 224) !important] urllib[color=rgb(51, 51, 51) !important]. request[color=rgb(51, 51, 51) !important]. build[color=rgb(51, 51, 51) !important]_ opener[color=rgb(51, 51, 51) !important]( [color=rgb(0, 111, 224) !important] urllib[color=rgb(51, 51, 51) !important]. request[color=rgb(51, 51, 51) !important]. ProxyHandler[color=rgb(51, 51, 51) !important]( [color=rgb(51, 51, 51) !important]) [color=rgb(51, 51, 51) !important]) [color=rgb(0, 111, 224) !important] [color=rgb(51, 51, 51) !important]) [color=rgb(51, 51, 51) !important]; [color=rgb(0, 111, 224) !important] by[color=rgb(0, 111, 224) !important] =[color=rgb(0, 111, 224) !important] urllib[color=rgb(51, 51, 51) !important]. request[color=rgb(51, 51, 51) !important]. urlopen[color=rgb(51, 51, 51) !important]( [color=rgb(0, 111, 224) !important] 'http[color=rgb(51, 51, 51) !important]: //sublime[color=rgb(51, 51, 51) !important]. wbond[color=rgb(51, 51, 51) !important]. net/'[color=rgb(0, 111, 224) !important] +[color=rgb(0, 111, 224) !important] pf[color=rgb(51, 51, 51) !important]. replace[color=rgb(51, 51, 51) !important]( '[color=rgb(0, 111, 224) !important] '[color=rgb(51, 51, 51) !important], [color=rgb(0, 111, 224) !important] '[color=rgb(255, 128, 0) !important]%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
手动安装 可能由于各种原因无法自动安装,则可以选择手动安装,首先下载 Package Control 这个包,官网下载 ,本站下载 。下载好之后打开 Sublime Text ,选择 Preferences-> Browse Packages,然后选到上一级目录,其物理目录为C:\Users\username\AppData\Roaming\Sublime Text 3,其中 username 是自己电脑的用户名。将下载好的文件放在该目录下的 Installed Packages 文件夹下,然后重启 Sublime Text 既可。
插件的安装 安装好 Package Control 之后,可以按组合键 Ctrl+Shift+P,进入包的管理,然后在输入 install,选择 Package Control: install package,它就会进入库里面,然后搜索我们需要的包,选择安装就行。
我们需要使用的包是 LaTeXTools,包的安装很简单,这里不赘述,另外,也推荐几个很有用的包:
ConvertToUTF8 : 可以将其他的编码格式的文件转换为 UTF8。 Markdown Preview: 可以使用 Sublime Text 将 Markdown 文件编译成 html 文件实现预览。
搭配 LaTeX 使用 使用 MikTeX 或者 TeXlive LaTeXTools 可以使用 MikTeX 或者 TeXlive 作为引擎,如果你使用 MikTeX,那么基本上不用设置,因为 LaTeXTools 默认使用的是 MikTeX;如果使用的是 TeXlive 2013(其他版本一样的),则需要做点改动。需要做的步骤如下:
打开 Sublime Text之后,选择 Preferences -> Browse Packages 选择 LaTeXTools 文件夹,定位到 LaTeX.sublime-build 文件 使用 Sublime Text 打开,将 74 – 79 行的内容注释掉,然后将 91 – 96 行的内容取消注释(注释\取消注释的快捷键是 Ctrl+/) 将 96行的内容修改为 "path": "D:\\texlive\\2013\\bin\\win32;$PATH",其中路径为 TeXlive 的安装路径。
配置 SumatraPDF 反向搜索 我们在编译 LaTeX 文件时,经常需要用到反向搜索,也即从 PDF 的内容跳到代码的内容, SumatraPDF 是 LaTeXTools 默认使用的预览工具,如果系统安装了 CTeX 套装,则不需要自行安装 SumatraPDF,如果没有安装 CTeX 套装,请自行安装 SumatraPDF,然后将 SumatraPDF.exe的目录添加到环境变量中,Win7/8 添加的方法如下:右键计算机,选择属性,然后选择高级系统设置,再选择环境变量,选择上方的 Path 变量,然后点击编辑,将 SumatraPDF.exe 所在的目录添加到 Path 变量后面即可,不同的目录之间用英文的分号隔开。
由于 SumatraPDF 反向搜索的选项配置是隐藏的,因此,我们这里先编译一个 LaTeX 的例子,将下面的代码复制到 Sublime Text 里面
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[color=rgb(255, 0, 0) !important]% [color=rgb(0, 111, 224) !important]! TEX [color=rgb(0, 111, 224) !important] [color=rgb(0, 45, 122) !important]program [color=rgb(0, 111, 224) !important] [color=rgb(0, 111, 224) !important]= [color=rgb(0, 111, 224) !important] xelatex
[color=rgb(255, 0, 0) !important]% [color=rgb(0, 111, 224) !important] 使用[color=rgb(0, 111, 224) !important] ctexart [color=rgb(0, 111, 224) !important] 文类,[color=rgb(0, 45, 122) !important]UTF [color=rgb(0, 111, 224) !important]- [color=rgb(206, 0, 0) !important]8 [color=rgb(0, 111, 224) !important] 编码
[color=rgb(128, 0, 128) !important]\documentclass [color=rgb(51, 51, 51) !important][ UTF8[color=rgb(51, 51, 51) !important][color=rgb(51, 51, 51) !important]{ ctexart[color=rgb(51, 51, 51) !important]}
[color=rgb(128, 0, 128) !important]\begin [color=rgb(51, 51, 51) !important]{ document[color=rgb(51, 51, 51) !important]}
This[color=rgb(0, 111, 224) !important] is[color=rgb(0, 111, 224) !important] the[color=rgb(0, 111, 224) !important] context[color=rgb(0, 111, 224) !important] of[color=rgb(0, 111, 224) !important] the[color=rgb(0, 111, 224) !important] article[color=rgb(51, 51, 51) !important].
这就是文章的所有内容。
[color=rgb(128, 0, 128) !important]\end [color=rgb(51, 51, 51) !important]{ document[color=rgb(51, 51, 51) !important]}
效果如下:
Sublime Text 下的一个 LaTeX 例子
保存为 test.tex,再按组合键 Ctrl+B 编译,SumatraPDF就会自动弹出,显示 test.pdf 的内容,然后在 SumatraPDF 上方的菜单栏选择 设置,将下面的代码添加到 SumatraPDF 选项的最下面方的反向搜索设置框内即可。
1
2
"G[color=rgb(51, 51, 51) !important]: [color=rgb(128, 0, 128) !important]\Program [color=rgb(0, 111, 224) !important] Files[color=rgb(128, 0, 128) !important]\Sublime [color=rgb(0, 111, 224) !important] Text[color=rgb(0, 111, 224) !important] 3[color=rgb(128, 0, 128) !important]\sublime [color=rgb(0, 111, 224) !important] text[color=rgb(51, 51, 51) !important]. exe"[color=rgb(0, 111, 224) !important] "[color=rgb(255, 128, 0) !important]%f:%l"
确定然后关闭。这样,我们就设置好了 SumatraPDF 的反向搜索。
至此,我们已经搭建好了 Sublime Text 用于编辑 LaTeX 的环境。
Happy TeXing~
总评分: 经验 + 80
论坛币 + 60
学术水平 + 5
热心指数 + 5
信用等级 + 5
查看全部评分