sublime text 搭建latex平台 公式显示、文献检索、拼写检测全教程

直接推荐这个B站的分享,非常全面,看他的不用看我的:https://www.bilibili.com/video/BV1wY4y1W7sj/?spm_id_from=333.788&vd_source=05fc8bcdf5c894cb7a9229e2f2b32afe

1. 安装TexLive

https://www.tug.org/texlive

2. 安装Sublime Text

https://www.sublimetext.com

3. 安装SumatraPDF

https://www.sumatrapdfreader.org/free-pdf-reader
并把其地址加入Path:

SumatraPath.png

将SumatraPDF的路径加入到环境变量中

4. 正反链接sublime text 和sumatra

安装 Package Control

依次点击 Tools -> Install Package Control,或者参考官网给出的两种方法。

插件安装

Control+Shift+P,输入'pcip'或者install(找到Package Control: Install Package),回车后,输入LaTeX,找到待安装的插件—— LaTeXTools、LaTeX-cwl、LaTeXYZImageMagick等等,依次敲回车后进行安装。

在sublime text新建tex文件:

\documentclass{article}
\title{Title}
\author{Your Name} 
\begin{document}  
\maketitle{}
\section{Introduction}
This is where you will write your content. 
\newpage
this is a new page to test inverse link.
\end{document}

编译如果不成功是正常的,打开

然后把sublime text的地址放到sumatra的里面用来在pdf中双击一个位置能够反向链接到tex的对应位置

接下来用 Sumatra PDF 打开生成的 PDF,然后点击左上角,找到设置,然后点击选项,在最下方添加以下字符:

"C:\Program Files\Sublime Text 3\sublime_text.exe" "%f:%l"
如图所示。


Sublime-Sumatra

注意:
这里一定要多试一下,tex文件里多加点儿东西再编译一下试试看。我碰到了编译一次之后加内容再编译会再开一个pdf,此时新的pdf无法反向定位,老的pdf的定位可能有问题。被迫要每次编译都要重新关开一次pdf,很捉急。后来查到的这个链接说是portable版本的sumatra没问题,我试了一下确实如此,不知道为啥,反正先能用再说。
链接:https://github.com/sumatrapdfreader/sumatrapdf/discussions/2741
关键内容:

see [#2642](https://github.com/sumatrapdfreader/sumatrapdf/issues/2642)
The issue is still open for recent 64bit installs, 3.4.6 should work or try latest 3.5.xxx pre-release however it seems to be variable after 3.3.3
if using installed but possibly not when using portable ?
Check your version and try not to use any -inverse-search in the call but each configuration may be different.

https://www.bilibili.com/video/BV18u411e7mg/?vd_source=05fc8bcdf5c894cb7a9229e2f2b32afe

图片和公式预览

安装ImageMagick & GhostScript,见:
https://seanchristspc.github.io/2021/03/30/Latex-Sublime-configure/
https://www.jianshu.com/p/8d5e89228d60
图片实时预览要加这个系统全局变量
https://seanchristspc.github.io/2021/03/30/Latex-Sublime-configure/
https://www.latexstudio.net/archives/51449.html

  • 注:一开始装了magick和GS之后一定要把magick和GS的可执行exe文件的地址放到latexTools的preference里面的texpath里面,如图:
EquationFigurePreview

好的参考:
https://www.jianshu.com/p/8d5e89228d60
图片实时预览要加这个系统全局变量
https://seanchristspc.github.io/2021/03/30/Latex-Sublime-configure/

用这个的时候要注意:引用的图片地址必须用反斜杠/,双斜杠\\单斜杠\都会报错!

自动补全在斜杠后全有问题,会吃掉最前面的\

还是这个 issue1506 的解决方案, 稍加了一点点改动

Package

打开 Packages/LaTeXTools/latex_cwl_completions.py, 在最开始加一行

_ST4 = sublime.version() >= '4000'

然后找到 LatexCwlCompletion 类下的 on_query_completions 函数的这部分:

    # autocompleting with slash already on line
    # this is necessary to work around a short-coming in ST where having a
    # keyed entry appears to interfere with it recognising that there is a
    # \ already on the line
    #
    # NB this may not work if there are other punctuation marks in the
    # completion
    if is_prefixed:
        completions = [
            (c[0], c[1][1:]) if c[1].startswith("\\") else c
            for c in completions
        ]

issue回答是说由于一个自动补全的bug, 这里需要这么写才有效果, 然而 ST4 应该是修复了这bug, 所以不需要这个了
顺带一提, 4的自动补全真的比3用起来爽一万倍!

在前面加一个判断, 不是 _ST4 才执行:

    if not _ST4:
        # autocompleting with slash already on line
        # this is necessary to work around a short-coming in ST where having a
        # keyed entry appears to interfere with it recognising that there is a
        # \ already on the line
        #
        # NB this may not work if there are other punctuation marks in the
        # completion
        if is_prefixed:
            completions = [
                (c[0], c[1][1:]) if c[1].startswith("\\") else c
                for c in completions
            ]

\cite{后自动补全参考文献

保证设置文件LaTeXTools.default-settings中参考文献自动补全命令设置为true:“"cite_auto_trigger": true”
然后可以重启一下sublime text, 同时打开tex和bib文件,这时候应该就能找到了

拼写检查

  • 下载了词典,把.dic字典文件放到对应的Package文件夹里面,在Preference->Settings里面多加几行:
    "dictionary":"Packages/en_US-large.dic",
    "added_words":["unobscurable"],
    "ignored_words":["revelationary"]``, View里面有dictionary和spell-check,勾选一下即可。
    见: [https://www.sublimetext.com/docs/3/spell_checking.html](https://links.jianshu.com/go?to=https%3A%2F%2Fwww.sublimetext.com%2Fdocs%2F3%2Fspell_checking.html)

# 关掉自动括号补全
*   我还在preference-setting里关掉了自动补全符号,如引号、括号等,因为开了自动补全有时候单独打不出来其中一个,一次自动打两个:`"auto_match_enabled": false,`

参考:
https://blog.csdn.net/weixin_42465278/article/details/117332092
https://github.com/SublimeText/LaTeXTools/issues/1527

你可能感兴趣的:(sublime text 搭建latex平台 公式显示、文献检索、拼写检测全教程)