mac vscode latex实用

发布时间:2024年01月14日

网上有教程怎么在vscode里安装macTex以及插件,然后就可以在latex里写代码了,这里需要修改的是对应的json文件,输入command + P,可以看到最近打开的json设置文件,结果如下
在这里插入图片描述
然后设置这个json文件,我的json文件设置如下

{
    "terminal.integrated.inheritEnv": false,
    "workbench.colorTheme": "Visual Studio Light",
    "security.workspace.trust.untrustedFiles": "open",
    "python.defaultInterpreterPath": "/Users/yxk/anaconda3/bin/python",
    "notebook.output.textLineLimit": 500,
    "notebook.output.scrolling": true,
    "jupyter.askForKernelRestart": false,
    "explorer.compactFolders": false,

    "editor.language.brackets": [],
    "files.autoSave": "afterDelay",
    "[latex]": {
        "editor.quickSuggestions": {
            "comments": "on",
            "strings": "on",
            "other": "on"
        }
    },
    "latex-workshop.latex.tools": [
        
        {
            "name": "latexmk",
            "command": "latexmk",
            //"args": [
                //"-synctex=1",
                //"-interaction=nonstopmode",
                //"-file-line-error",
                //"-pdf",
                //"-outdir=%OUTDIR%",
                //"%DOC%"
            //],
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-xelatex",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {}
        },
        {
            "name": "lualatexmk",
            "command": "latexmk",
            "args": [
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-lualatex",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {}
        },
        {
            "name": "xelatexmk",
            "command": "latexmk",
            "args": [
                "-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": [
                "-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": {}
        }
    ],
}

中文案例

\documentclass{article}  

\usepackage[UTF8]{ctex}  
\begin{document}  
    this is very story
    这是中英混合混合形式的

    这是使用啥的字体
    一的第七章
    中文输入  
\end{document}

注意这里使用的是最简单的,没有进行任何字体的设置,因为接下来的是mac里面最重要的一个问题,字体和windows下不匹配的问题,这个需要我来尝试解决

中文案例2

\documentclass[12pt,UTF8]{ctexart}
    %ctexrep - report ; ctexbook - book ; ctexart - article
\usepackage{xeCJK}

\setCJKmainfont{NotoSerifCJKsc-Bold}

\author{匿名}
\title{诗经}

\begin{document}
\maketitle
\begin{center}
\begin{Large}
    \begin{verse}
    关关雎鸠,在河之洲。窈窕淑女,君子好逑。\\
    参差荇菜,左右流之。窈窕淑女,寤寐求之。\\
    求之不得,寤寐思服。悠哉悠哉,辗转反侧。\\
    参差荇菜,左右采之。窈窕淑女,琴瑟友之。\\
    参差荇菜,左右芼之。窈窕淑女,钟鼓乐之。\\
    \end{verse}
\end{Large}
\end{center}
\end{document}

结果如下
在这里插入图片描述解决问题如下
安装字体
https://www.jianshu.com/p/fd96fb3daea1

然后需要修改第一句话,很奇怪

\documentclass{article}  
    %ctexrep - report ; ctexbook - book ; ctexart - article
\usepackage{xeCJK}

\setCJKmainfont{NotoSerifCJKsc-Bold}

\author{匿名}
\title{诗经}

\begin{document}
\maketitle
\begin{center}
\begin{Large}
    \begin{verse}
    关关雎鸠,在河之洲。窈窕淑女,君子好逑。\\
    参差荇菜,左右流之。窈窕淑女,寤寐求之。\\
    求之不得,寤寐思服。悠哉悠哉,辗转反侧。\\
    参差荇菜,左右采之。窈窕淑女,琴瑟友之。\\
    参差荇菜,左右芼之。窈窕淑女,钟鼓乐之。\\
    \end{verse}
\end{Large}
\end{center}
\end{document}

但是结果是有的
在这里插入图片描述
所以目前有一个问题就是如果我换成

\documentclass[fontset=windows]{ctexart}
    %ctexrep - report ; ctexbook - book ; ctexart - article
\usepackage{xeCJK}

\setCJKmainfont{NotoSerifCJKsc-Bold}

\author{匿名}
\title{诗经}

\begin{document}
\maketitle
\begin{center}
\begin{Large}
    \begin{verse}
    关关雎鸠,在河之洲。窈窕淑女,君子好逑。\\
    参差荇菜,左右流之。窈窕淑女,寤寐求之。\\
    求之不得,寤寐思服。悠哉悠哉,辗转反侧。\\
    参差荇菜,左右采之。窈窕淑女,琴瑟友之。\\
    参差荇菜,左右芼之。窈窕淑女,钟鼓乐之。\\
    \end{verse}
\end{Large}
\end{center}
\end{document}

注意第一行我把\documentclass{article} 换成了\documentclass[fontset=windows]{ctexart}这个就会出现以下错误
Package fontspec: The font “SimSun” cannot be found.

文章来源:https://blog.csdn.net/qq_45759229/article/details/135587669
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。