MacOS 环境配置

本文指导读者通过TUNA镜像安装Homebrew,配置wget、tmux,并为MacTeX和VSCode LaTeX环境提供详细步骤,包括Perlbrew、依赖项安装及VSCode LaTeX Workshop插件配置。
摘要由CSDN通过智能技术生成

Homebrew

参考 TUNA 安装 Homebrew 。

cd
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"' >> .zprofile
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"' >> .zprofile
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"' >> .zprofile
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"' >> .zprofile
source .zprofile

git clone --depth=1 https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install.git brew-install
bash brew-install/install.sh
rm -rf brew-install

# brew 命令的地址需要查看上一步的输出中的 `Next steps`
# e.g. echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> .zprofile
echo 'eval "$(/path/to/brew shellenv)"' >> .zprofile
source .zprofile

通过 Homebrew 安装 wget 、 tmux 等软件。

brew install wget
brew install openssh  # 解决 sftp 不能用 tab 补全的 bug
brew install tmux

oh-my-zsh 、 oh-my-tmux 、 awesome-vimrc 的配置方法可以参考 Ubuntu 新用户创建与环境配置(oh-my-zsh / oh-my-tmux / awesome-vimrc)

LaTeX

TUNA 下载并安装 MacTeX.pkg

参考 Perlbrew 安装

curl -L https://install.perlbrew.pl | bash
perlbrew install perl-5.36.0
perlbrew switch perl-5.36.0

安装依赖项

cpan YAML::Tiny
cpan File::HomeDir

在 VS Code 中安装 latex-workshop 插件,将如下配置加入 settings.json

{
    "latex-workshop.latex.tools": [
        {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
                "--shell-escape",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {}
        },
        {
            "name": "lualatexmk",
            "command": "latexmk",
            "args": [
                "--shell-escape",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-lualatex",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {}
        },
        {
            "name": "xelatexmk",
            "command": "latexmk",
            "args": [
                "--shell-escape",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-xelatex",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {}
        },
        {
            "name": "latexmk_rconly",
            "command": "latexmk",
            "args": [
                "%DOC%"
            ],
            "env": {}
        },
        {
            "name": "pdflatex",
            "command": "pdflatex",
            "args": [
                "--shell-escape",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "%DOC%"
            ],
            "env": {}
        },
        {
            "name": "bibtex",
            "command": "bibtex",
            "args": [
                "%DOCFILE%"
            ],
            "env": {}
        },
        {
            "name": "rnw2tex",
            "command": "Rscript",
            "args": [
                "-e",
                "knitr::opts_knit$set(concordance = TRUE); knitr::knit('%DOCFILE_EXT%')"
            ],
            "env": {}
        },
        {
            "name": "jnw2tex",
            "command": "julia",
            "args": [
                "-e",
                "using Weave; weave(\"%DOC_EXT%\", doctype=\"tex\")"
            ],
            "env": {}
        },
        {
            "name": "jnw2texminted",
            "command": "julia",
            "args": [
                "-e",
                "using Weave; weave(\"%DOC_EXT%\", doctype=\"texminted\")"
            ],
            "env": {}
        },
        {
            "name": "pnw2tex",
            "command": "pweave",
            "args": [
                "-f",
                "tex",
                "%DOC_EXT%"
            ],
            "env": {}
        },
        {
            "name": "pnw2texminted",
            "command": "pweave",
            "args": [
                "-f",
                "texminted",
                "%DOC_EXT%"
            ],
            "env": {}
        },
        {
            "name": "tectonic",
            "command": "tectonic",
            "args": [
                "--synctex",
                "--keep-logs",
                "%DOC%.tex"
            ],
            "env": {}
        }
    ],
    "latex-workshop.latexindent.args": [
        "-c",
        "%DIR%/",
        "%TMPFILE%",
        "-l",
        "%WORKSPACE_FOLDER%/.latexindent.yaml",
        "-m"
    ]
}

常见问题

  1. Recipe terminated with fatal error: spawn latexmk ENOENT
    参考 macOS 配置 LaTeX ( MacTeX + VScode + Skim ) ,可优先尝试重启 VS Code 或 MacOS 。

  2. Package minted Error: You must have ‘pygmentize’ installed to use this package
    使用系统 pip 运行

pip install Pygments
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

LutingWang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值