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


    安装及配置

    本机环境

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

    MacTex安装

    安装mactex

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

    brew install mactex
    

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

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

    进入该路径看到一个pkg包,手动安装一下。
    然后打开应用程序的文件夹,看是否会出现TeX目录,目录下为如下软件:
    在这里插入图片描述
    也有可能不出现这个目录,目录下也不一定是这几个软件和文件。反正有TeXShopLaTeXiT即可。
    那么代表在本机安装LaTex成功。

    添加至系统路径

    然后我们进入~/Library下看是否有TeX目录,目录下是否存在textbin
    如果存在,我们在终端的zshrc文件中加入该路径

    export PATH="/Library/TeX/texbin:$PATH"
    

    随后重启终端后分别输入如下命令。

    xelatex --version
    pdflatex --version
    

    能分别看到输出,即说明我们将latex加入了系统路径中。

    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文件。
    在这里插入图片描述
    最后整体效果如下:
    在这里插入图片描述
    左边侧栏中的TEX还有更多功能和对应的图标,有兴趣的话可以去看看。
    (如果你已经打开了PDF预览窗口,LaTeX Workshop插件通常会在编译完成后自动刷新PDF预览窗口)
    在这里插入图片描述
    此外,譬如点击了“构建LaTeX项目”后如何看到什么时候构建完成,构建结果是什么,是否构建异常呢?
    可以见页面最下方,会有命令执行的状态。譬如如下是“正在构建中”。
    在这里插入图片描述
    更详细的信息,可以见“输出”
    在这里插入图片描述
    如果显示类似于Process finished with exit code 0的消息,表示编译成功完成。

    相关推荐

    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

  • 相关阅读:
    【MySQL】MySQL数据管理——DDL数据操作语言(数据表)
    离子液体负载修饰磁性纳米材料四氧化三铁(Fe3O4)(齐岳bio)
    【python自动化】使用关键字驱动实现appium自动化
    Redo Log Undo Log 与 Bin Log介绍
    【教学类-07-03】20221106《破译电话号码-2款图形篇+自制(PDF打印)》(大班主题《我要上小学》)
    java和设计模式(创建模式)
    星火认知大模型Spark3.5 api调用 #AI夏令营 #Datawhale #夏令营
    超火的低代码平台长什么样
    QT学习总结之QWidget详解
    爬虫在金融领域的应用:股票数据收集
  • 原文地址:https://blog.csdn.net/zhiaidaidai/article/details/140440448