macos上latex环境搭建(homebrew安装+vscode配置+ MacTex)和B站视频、网站、教程等相关资料推荐(Overleaf、公式预览网站)

扫测资讯 2024-07-16 06:07   487 0

安装及配置

本机环境

本人为 macos ,已经安装了 homebrew vscode 。希望得到的效果是在 vscode 中编辑并预览 latex 文件

MacTex安装

首先,使用 brew 安装 MacTex (新版本的 brew 已经将 install install --cask 合并了)

brew install mactex

安装后一般会置于如下路径下:

/usr/local/Caskroom/mactex/2024.xx.xx

进入该路径看到一个 pkg 包,手动安装一下。
然后打开应用程序的文件夹,看是否会出现 TeX 目录,目录下为如下软件:

vscode 配置

然后打开 vscode ,安装 LaTex Workshop 拓展并重启。
按住 command + shift + p ,选择 首选项:打开用户设置(JSON) Preferences:Open User Settings (JSON) 。添加如下内容:

{
	以前的内容...,
"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"
    ],
    "latex-workshop.latex.autoClean.run": "onFailed",
    "latex-workshop.latex.recipe.default": "lastUsed",
    "latex-workshop.view.pdf.internal.synctex.keybinding": "double-click",
}

ctrl+s 保存后我们重新打开 vscode

tex编写和验证

新建一个 test.tex ,输入一下内容

\documentclass{article}
\usepackage{amsmath}

\title{A Simple \LaTeX{} Document}
\author{Your Name}
\date{\today}

\begin{document}
\maketitle

\section{Introduction}
Welcome to the world of \LaTeX{}! With \LaTeX{}, you can create beautifully formatted documents with ease. Here's a simple example of a \LaTeX{} document.

\section{Mathematics}
\LaTeX{} excels at typesetting mathematical equations. For example, here's the quadratic formula:

\begin{equation}
  x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\end{equation}

\end{document}

然后点击文件右上角的绿色三角形图标,意味着编译该文件。随后点击绿色三角形右边的图标,意味着查看编译后的pdf文件。

相关推荐

B站入门视频

因为本人有编程基础,所以只看了一个视频(

网站

Overleaf :
https://www.overleaf.com/
简历模板
https://www.overleaf.com/latex/templates/tagged/cv/page/6
公式预览
https://latex.codecogs.com/eqneditor/editor.php

教程

入手Overleaf的教程:
https://blog.csdn.net/weixin_43301333/article/details/114374854