主要叙述 Sublime 配置 LaTex 环境

配置特性

  • 正向、反向定位
  • 多图边距同时调节
  • 编辑跳转
  • 基于文章的自动记忆补全
  • 文献列表选择插入
  • LaTex代码片段快速插入及Table快速填充重要内容

准备工作

使用 Scoop 安装miktex包以及Sumatra PDF包,执行以下命令:

scoop update

scoop install miktex
scoop install sumatrapdf

进入 Sublime 按住ctrl+shift+p键选择 Install Package,依次安装LaTexTools(LaTex基本功能)以及LaTex-cwl(LaTex代码补全功能)

Sumatra PDF配置反向定位功能

  • 进入 Windows 的 cmd 终端,执行:
# 大家根据个人安装Sublime路径自行更改
sumatrapdf.exe -inverse-search "\"C:\Users\shaohan.tian\scoop\apps\sublime-text\4-4126\sublime_text.exe\" \"%f:%l\"

然后会弹出Sumatra PDF窗口,关闭即可

  • 打开Sumatra PDF,进入设置——> 选项,执行以下命令更改设置:
"C:\Users\shaohan.tian\scoop\apps\sublime-text\4-4126\sublime_text.exe" "%f:%l"

Sublime配置

  • LaTexTools 插件配置,进入 Preference --> LaTexTools --> Setting-User,替换以下对应代码:
"windows": {
    // 修改为个人的miktex、sumatrapdf以及subl路径
    "texpath" : "C:\\Users\\shaohan.tian\\scoop\\apps\\miktex\\current\texmfs\\install\\miktex\bin\\x64;$PATH",    
    "distro" : "miktex",    // LaTex编译器类型    
    "sumatra": "C:\\Users\\shaohan.tian\\scoop\\apps\\sumatrapdf\\3.4.6\\SumatraPDF.exe",
    "sublime_executable": "C:\\Program Files\\Sublfimfe Text\\subl.exe",
    "keep_focus_delay": 0.5
},

"builder": "simple" // 编译引擎类型
  • 进入 Preference --> Settings,更改 Sublime 的偏好配置:
{
    "theme": "Default Dark.sublime-theme",
    "color_scheme": "ayu-mirage.sublime-color-scheme",
    "ignored_packages":
    [
        "Vintage",
    ],
    "auto_complete_triggers":
    [
        {
            "characters": "<",
            "selector": "text.html, text.xml",
        },
        {
            "rhs_empty": true,
            "selector": "punctuation.accessor",
        },
        {
            "characters": "\\",
            "selector": "text.tex.latex",
        }
    ],
    "font_size": 12,
    "spell_check": true,
    "tab_completion": false,
    "update_check": false,
    "auto_match_enabled": true,
    "auto_complete": true,
    "auto_complete_delay": 100,
    "auto_complete_selector": "source, text",
    "added_words":
    [
        "reactance"
    ],
}
  • 进入 Preference --> Key Bindings,更改快捷键配置文件
[
    { "keys": ["ctrl+["], "command": "jump_back" },
    { "keys": ["ctrl+]"], "command": "jump_forward" },
    { "keys": ["ctrl+t"], "command": "title_case" },

    { 	"keys": ["ctrl+1"], 
     "context":  [
         {"key": "selector", "operator": "equal", "operand": "text.tex.latex"}],
     "command": "jump_to_pdf", "args": {"from_keybinding": true}},
    { "keys": ["ctrl+2"],
     "args": {"only_current_file": true},
     "context":  [
         {"key": "selector", "operator": "equal", "operand": "text.tex"}],
     "command": "latex_toc_quickpanel"},
]

设置说明:

快捷键设置 功能说明
ctrl + [ 跳转到上一个编辑处
ctrl + ] 跳转到下一个编辑处
ctrl + t 选中区域首字母大写
ctrl + 1 正向定位 PDF 对应位置
ctrl + 2 查看当前文件目录

尝试编译

\documentclass[UTF8]{ctexart}
\title{你好,world!}
\author{Liam}
\date{\today}
\begin{document}
\maketitle
\section{你好中国}
中国在 East Asia.

\subsection{Hello Beijing}
北京是 capital of China.

\subsubsection{Hello Dongcheng District}

\paragraph{Tian'anmen Square}
is in the center of Beijing

\subparagraph{Chairman Mao}
is in the center of 天安门广场。

\subsection{Hello 北京}

\paragraph{北京} is an international city。
section{测试部分}
我爱北京天安门,天安门上太阳升

\end{document}

注意:这里按住ctrl + shift +B 选择LaTex - XeLaTex编译:

推荐 LaTex 相关包

参考

LaTex 写作环境配置