• 入门latex——环境搭建


    一、环境:

    注意:最好记住安装路径,同时安装路径最好只有英文,不要有中文、特殊符号。

    1、VSC;默认你装了。

    2、VSC上的Latex workshop插件;左侧插件搜一下,install

    3、texlive,地址:https://mirrors.sustech.edu.cn/CTAN/systems/texlive/Images/

    具体安装流程可以参考连接:

    https://zhuanlan.zhihu.com/p/166523064

    https://zhuanlan.zhihu.com/p/56982388

    很详细,结合着看可以。这里不在复述。

     4、外部pdf查看使用sumatraPDF,地址:https://www.sumatrapdfreader.org/download-free-pdf-viewer

    (32位选下面的那个install的exe)

    安装很easy。

    二、配置:

    以上软件装完后,保证每项软件自身时可以使用的,否则下面配置时可能有问题。

    主要参考https://zhuanlan.zhihu.com/p/166523064,使用vsc+sumatra PDF,支持正反双向搜索。

    本文可以作为对参考链接的总结与补充。当参考时如果遇到问题,可以来这里看看~

    在vsc中找到配置文件:

    这里面初始的关于latex的配置是

    把这行注释掉,添加下面的代码

            //------------------------------LaTeX 配置----------------------------------
               // 设置是否自动编译
               "latex-workshop.latex.autoBuild.run":"never",
               //右键菜单
               "latex-workshop.showContextMenu":true,
               //从使用的包中自动补全命令和环境
               "latex-workshop.intellisense.package.enabled": true,
               //编译出错时设置是否弹出气泡设置
               "latex-workshop.message.error.show": false,
               "latex-workshop.message.warning.show": false,
               // 编译工具和命令
               "latex-workshop.latex.tools": [
                   {
                       "name": "xelatex",
                       "command": "xelatex",
                       "args": [
                           "-synctex=1",
                           "-interaction=nonstopmode",
                           "-file-line-error",
                           "%DOCFILE%"
                       ]
                   },
                   {
                       "name": "pdflatex",
                       "command": "pdflatex",
                       "args": [
                           "-synctex=1",
                           "-interaction=nonstopmode",
                           "-file-line-error",
                           "%DOCFILE%"
                       ]
                   },
                   {
                       "name": "latexmk",
                       "command": "latexmk",
                       "args": [
                           "-synctex=1",
                           "-interaction=nonstopmode",
                           "-file-line-error",
                           "-pdf",
                           "-outdir=%OUTDIR%",
                           "%DOCFILE%"
                       ]
                   },
                   {
                       "name": "bibtex",
                       "command": "bibtex",
                       "args": [
                           "%DOCFILE%"
                       ]
                   }
               ],
               // 用于配置编译链
               "latex-workshop.latex.recipes": [
                   {
                       "name": "XeLaTeX",
                       "tools": [
                           "xelatex"
                       ]
                   },
                   {
                       "name": "PDFLaTeX",
                       "tools": [
                           "pdflatex"
                       ]
                   },
                   {
                       "name": "BibTeX",
                       "tools": [
                           "bibtex"
                       ]
                   },
                   {
                       "name": "LaTeXmk",
                       "tools": [
                           "latexmk"
                       ]
                   },
                   {
                       "name": "xelatex -> bibtex -> xelatex*2",
                       "tools": [
                           "xelatex",
                           "bibtex",
                           "xelatex",
                           "xelatex"
                       ]
                   },
                   {
                       "name": "pdflatex -> bibtex -> pdflatex*2",
                       "tools": [
                           "pdflatex",
                           "bibtex",
                           "pdflatex",
                           "pdflatex"
                       ]
                   }
               ],
               //文件清理。此属性必须是字符串数组
               "latex-workshop.latex.clean.fileTypes": [
                   "*.aux",
                   "*.bbl",
                   "*.blg",
                   "*.idx",
                   "*.ind",
                   "*.lof",
                   "*.lot",
                   "*.out",
                   "*.toc",
                   "*.acn",
                   "*.acr",
                   "*.alg",
                   "*.glg",
                   "*.glo",
                   "*.gls",
                   "*.ist",
                   "*.fls",
                   "*.log",
                   "*.fdb_latexmk"
               ],
               //设置为onFaild 在构建失败后清除辅助文件
               "latex-workshop.latex.autoClean.run": "onFailed",
               // 使用上次的recipe编译组合
               "latex-workshop.latex.recipe.default": "lastUsed",
               // 用于反向同步的内部查看器的键绑定。ctrl/cmd +点击(默认)或双击
               "latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
           
           
           
               //使用 SumatraPDF 预览编译好的PDF文件
               // 设置VScode内部查看生成的pdf文件
               "latex-workshop.view.pdf.viewer": "external",
               // PDF查看器用于在
    ef上的[View on PDF]链接
               "latex-workshop.view.pdf.ref.viewer":"auto",
               // 使用外部查看器时要执行的命令。此功能不受官方支持。
               "latex-workshop.view.pdf.external.viewer.command": "D:/SumatraPDF/SumatraPDF.exe", // 注意修改路径
               // 使用外部查看器时,latex-workshop.view.pdf.external.view .command的参数。此功能不受官方支持。%PDF%是用于生成PDF文件的绝对路径的占位符。
               "latex-workshop.view.pdf.external.viewer.args": [
                   "%PDF%"
               ],
               // 将synctex转发到外部查看器时要执行的命令。此功能不受官方支持。
               "latex-workshop.view.pdf.external.synctex.command": "D:/SumatraPDF/SumatraPDF.exe", // 注意修改路径
               // latex-workshop.view.pdf.external.synctex的参数。当同步到外部查看器时。%LINE%是行号,%PDF%是生成PDF文件的绝对路径的占位符,%TEX%是触发syncTeX的扩展名为.tex的LaTeX文件路径。
               "latex-workshop.view.pdf.external.synctex.args": [
                   "-forward-search",
                   "%TEX%",
                   "%LINE%",
                   "-reuse-instance",
                   "-inverse-search",
                //    "code "D:\Microsoft VS Code\resources\app\out\cli.js" -r -g "%f:%l"", // 注意修改路径
                   ""D:/Microsoft VS Code/Code.exe" "D:/Microsoft VS Code/resources/app/out/cli.js" -r -g "%f:%l"", // 注意修改路径
                   "%PDF%"
            ]
    View Code

    正向搜索快捷键ctrl+alt+j

    反向搜索快捷键ctrl+alt+z(原来的不好使,修改了下)

    可能遇到的问题是:

    1、sumatra PDF的路径不对,导致快捷键打不开sumatra PDF

    2、正向搜索可以,反向搜索不行。经过实验发现,latex-workshop.view.pdf.external.synctex.args下面的参数似乎不会影响反向搜索,影响的是正向搜索。

    反向搜索需要在sumatraPDF中修改个地方:

    打开高级选项(不要使用选项!我当时使用选项配置遇到了奇怪的问题。。),搜Inv,找到

    把这里的路径修改为你的电脑的路径。

    路径:"D:/Microsoft VS Code/Code.exe" "D:/Microsoft VS Code/resources/app/out/cli.js"  -g "%f:%l"

    记得保存。

    参考

    https://zhuanlan.zhihu.com/p/166523064

    https://zhuanlan.zhihu.com/p/56982388

  • 相关阅读:
    Python字符串学习
    文本压缩版本三
    文件压缩版本二
    文件压缩(2)
    d17包,logging模块,hashlib模块 openpyxl模块,深浅拷贝
    d16 collections模块 时间模块 random模块 os模块 sys模块 序列化模块 subprocess模块
    d15 常用模块之正则模块
    14天 模块 , 导模块 , 循环导入, 相对,绝对导入, 项目目录规范,
    13t天 迭代器,生成器,内置函数
    55 jquery
  • 原文地址:https://www.cnblogs.com/gudygudy/p/15320617.html
Copyright © 2020-2023  润新知