MacOS安装latex

基于MacTeX安装latex

安装mactex

  1. 下载mactex
    下载地址:http://tug.org/mactex/mactex-download.html
    ps:实验室校园网下载,嗷嗷快,(不用挂科学上网)
  2. 安装mactex
    双击下载好的dmg文件,下一步,下一步~

vscode 设置

  1. 安装LaTeX Workshop插件

  2. vscode 配置文件

 "latex-workshop.latex.autoBuild.cleanAndRetry.enabled": true,
 "latex-workshop.latex.autoClean.run": "onFailed",
 "editor.wordWrap": "on", // 自动换行
 "workbench.startupEditor": "newUntitledFile",
 "latex-workshop.view.pdf.viewer": "tab",
 "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",
     "*.gz"
 ],
 "ltex.enabled": true, // 启用插件
 "ltex.language": "en-US",
 "ltex.en-US.dictionary": [
     "CKBQA",
     "KGQA"
 ],
 // 安装MacTeX 就能直接用,要个锤子的docker
 "latex-workshop.showContextMenu": true, //右键菜单
 "latex-workshop.intellisense.package.enabled": true, //根据加载的包,自动完成命令或包
 "latex-workshop.latex.autoBuild.run": "never", //禁止保存文件时自动build
 "latex-workshop.synctex.afterBuild.enabled": true,
 "latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
 "latex-workshop.latex.recipes": [
     {
         "name": "xelatex",
         "tools": [
             "xelatex"
         ]
     },
     {
         "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.tools": [
     {
         "name": "xelatex",
         "command": "xelatex",
         "args": [
             "-synctex=1",
             "-interaction=nonstopmode",
             "-file-line-error",
             "-pdf",
             "%DOC%"
         ]
     },
     {
         "name": "latexmk",
         "command": "latexmk",
         "args": [
             "-synctex=1",
             "-interaction=nonstopmode",
             "-file-line-error",
             "-pdf",
             "%DOC%"
         ]
     },
     {
         "name": "pdflatex",
         "command": "pdflatex",
         "args": [
             "-synctex=1",
             "-interaction=nonstopmode",
             "-file-line-error",
             "%DOC%"
         ]
     },
     {
         "name": "bibtex",
         "command": "bibtex",
         "args": [
             "%DOCFILE%"
         ]
     }
 ],

把上面的配置文件的内容粘贴到vscode的配置页,然后保存并重启vscode软件就行

  • vscode配置页打开方式👇

使用

  1. 打开文件夹,选择主tex文件,LaTeX Workshop插件回自动跳出
  2. 编译
    保存自动编译 or ctrl+alt+b
  3. tex跳转到pdf
    ctrl+alt+j
  4. pdf跳转到tex
    双击 or ctrl+单击

基于docker安装latex

  • 不推荐
  • 占用磁盘空间多于上一种方法
  • 使用时docker要一直开着

依赖

  1. vscode
  2. docker

环境

macOS Catalina 10.15.7

过程

安装docker
拉取镜像

docker pull mirisbowring/texlive_ctan_full:2019
地址: https://hub.docker.com/r/mirisbowring/texlive_ctan_full

配置vscode
插件

LaTeX Workshop

配置文件
    "latex-workshop.latex.autoBuild.cleanAndRetry.enabled": true,
    
    "editor.wordWrap": "on", // 自动换行
    "workbench.startupEditor": "newUntitledFile",
    "latex-workshop.view.pdf.viewer": "tab",
    "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",
        "*.gz"
    ],
    "ltex.enabled": true, // 启用插件
    "ltex.language": "en-US",
    "ltex.en-US.dictionary": [
        "CKBQA",
        "KGQA"
    ],
    "latex-workshop.docker.enabled": true,
    "latex-workshop.docker.image.latex": "d46f027f062f",//镜像id
    "latex-workshop.intellisense.package.enabled": true,
    "latex-workshop.synctex.afterBuild.enabled":true,
    "latex-workshop.view.pdf.internal.synctex.keybinding":"double-click",
    "latex-workshop.latex.recipes": [

        {
            "name": "xelatex",
            "tools": [
                "xelatex"
            ]
        },
        {
            "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.tools": [
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "-outdir=%OUTDIR%",
                "%DOCFILE%"
            ],
            "env": {}
        },
        {
            "name": "xelatex",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-outdir=%OUTDIR%",
                "-xelatex",
                "%DOCFILE%"
            ],
            "env": {}
        },
        {
            "name": "bibtex",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-outdir=%OUTDIR%",
                "-bibtex",
                "%DOCFILE%"
            ],
            "env": {}
        },
        {
            "name": "pdflatex",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-outdir=%OUTDIR%",
                "-pdflatex",
                "%DOCFILE%"
            ]
        }
    ],

使用

  1. 启动docker desktop
  2. 打开文件夹,选择主tex文件
  3. 编译
    保存自动编译 or ctrl+alt+b
  4. tex跳转到pdf
    ctrl+alt+j
  5. pdf跳转到tex
    双击 or ctrl+单击

更多

https://72b27340.wiz06.com/wapp/pages/view/share/s/1OIDd00vu4cV2ZGM4M3sXIVT3gkoll2JBANr2pPcyP3vXX01

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐