vscode配置latex出现Recipe terminated with error.

问题遇到的现象和发生背景

配置latex的时候报错。环境变量已经设置了。网上的大部分回答都试过了没有用
报错日志:

img

其中有一处错误来自texlive中的文件,代码放在最后。好像是字符集的问题?

img

下面是配置文件和texlive文件

问题相关代码,请勿粘贴截图

配置文件

{
    "latex-workshop.latex.recipes": [{
    "name": "xelatex",
    "tools": [
        "xelatex"
    ]
  }, 
  {
    "name": "latexmk",
    "tools": [
        "latexmk"
    ]
  },

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

texlive文件

%%
%% This is file `ctex-fontset-fandol.def',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% ctex.dtx  (with options: `fontset,fandol')
%% 
%%     Copyright (C) 2003--2021
%%     CTEX.ORG and any individual authors listed in the documentation.
%% ---------------------------------------------------------------------
%% 
%%     This work may be distributed and/or modified under the
%%     conditions of the LaTeX Project Public License, either
%%     version 1.3c of this license or (at your option) any later
%%     version. This version of this license is in
%%        http://www.latex-project.org/lppl/lppl-1-3c.txt
%%     and the latest version of this license is in
%%        http://www.latex-project.org/lppl.txt
%%     and version 1.3 or later is part of all distributions of
%%     LaTeX version 2005/12/01 or later.
%% 
%%     This work has the LPPL maintenance status "maintained".
%% 
%% ---------------------------------------------------------------------
%% 
\GetIdInfo$Id: ctex.dtx 07425fe 2021-03-14 16:43:36 +0800 Xiangdong Zeng <xdzeng96@gmail.com> $
  {Fandol fonts definition (CTEX)}
\ProvidesExplFile{ctex-fontset-fandol.def}
  {\ExplFileDate}{2.5.6}{\ExplFileDescription}
\ctex_fontset_case:nnnn
  { \ctex_fontset_error:n { fandol } }
  {
    \ctex_zhmap_case:nnn
      {
        \setCJKmainfont { FandolSong-Regular.otf }
          [
            cmap       = UniGB-UTF16-H,
            BoldFont   = FandolSong-Bold.otf,
            ItalicFont = FandolKai-Regular.otf
          ]
        \setCJKsansfont { FandolHei-Regular.otf }
          [ cmap = UniGB-UTF16-H, BoldFont = FandolHei-Bold.otf ]
        \setCJKmonofont { FandolFang-Regular.otf }
          [ cmap = UniGB-UTF16-H ]
        \setCJKfamilyfont { zhsong } { FandolSong-Regular.otf }
          [ cmap = UniGB-UTF16-H, BoldFont = FandolSong-Bold.otf ]
        \setCJKfamilyfont { zhhei  } { FandolHei-Regular.otf  }
          [ cmap = UniGB-UTF16-H, BoldFont = FandolHei-Bold.otf  ]
        \setCJKfamilyfont { zhfs   } { FandolFang-Regular.otf }
          [ cmap = UniGB-UTF16-H ]
        \setCJKfamilyfont { zhkai  } { FandolKai-Regular.otf  }
          [ cmap = UniGB-UTF16-H ]
        \ctex_punct_set:n { fandol }
        \ctex_punct_map_family:nn   { \CJKrmdefault         } { zhsong  }
        \ctex_punct_map_family:nn   { \CJKsfdefault         } { zhhei   }
        \ctex_punct_map_family:nn   { \CJKttdefault         } { zhfs    }
        \ctex_punct_map_bfseries:nn { \CJKrmdefault, zhsong } { zhsongb }
        \ctex_punct_map_bfseries:nn { \CJKsfdefault, zhhei  } { zhheib  }
        \ctex_punct_map_itshape:nn  { \CJKrmdefault         } { zhkai   }
      }
      {
        \ctex_load_zhmap:nnnn { rm } { zhhei } { zhfs } { fandol }
        \ctex_punct_set:n { fandol }
        \ctex_punct_map_family:nn   { \CJKrmdefault } { zhsong }
        \ctex_punct_map_bfseries:nn { \CJKrmdefault } { zhhei  }
        \ctex_punct_map_itshape:nn  { \CJKrmdefault } { zhkai  }
      }
      { \ctex_fontset_error:n { fandol } }
  }
  {
    \ctex_set_upfonts:nnnnnn
      { FandolSong-Regular.otf }
      { FandolSong-Bold.otf    }
      { FandolKai-Regular.otf  }
      { FandolHei-Regular.otf  }
      { FandolHei-Bold.otf     }
      { FandolFang-Regular.otf }
    \ctex_set_upfamily:nnn { zhsong } { upzhserif   } { upzhserifb }
    \ctex_set_upfamily:nnn { zhhei  } { upzhsans    } { upzhsansb  }
    \ctex_set_upfamily:nnn { zhfs   } { upzhmono    } {}
    \ctex_set_upfamily:nnn { zhkai  } { upzhserifit } {}
  }
  {
    \setCJKmainfont { FandolSong-Regular }
      [
        Extension  = .otf,
        BoldFont   = FandolSong-Bold,
        ItalicFont = FandolKai-Regular
      ]
    \setCJKsansfont { FandolHei-Regular  }
      [ Extension = .otf, BoldFont = FandolHei-Bold ]
    \setCJKmonofont { FandolFang-Regular }
      [ Extension = .otf ]
    \setCJKfamilyfont { zhsong } { FandolSong-Regular }
      [ Extension = .otf, BoldFont = FandolSong-Bold ]
    \setCJKfamilyfont { zhhei  } { FandolHei-Regular  }
      [ Extension = .otf, BoldFont = FandolHei-Bold  ]
    \setCJKfamilyfont { zhfs   } { FandolFang-Regular }
      [ Extension = .otf ]
    \setCJKfamilyfont { zhkai  } { FandolKai-Regular  }
      [ Extension = .otf ]
  }
\NewDocumentCommand \songti   { } { \CJKfamily { zhsong  } }
\NewDocumentCommand \heiti    { } { \CJKfamily { zhhei   } }
\NewDocumentCommand \fangsong { } { \CJKfamily { zhfs    } }
\NewDocumentCommand \kaishu   { } { \CJKfamily { zhkai   } }
%% 
%%
%% End of file `ctex-fontset-fandol.def'.



编译器pdflatex换XeLaTeX就行,参考

在settings.json文件里面替换下面代码,已解决。希望能帮到你

{
    // Latex workshop
    "latex-workshop.latex.tools": [
          {
            "name": "latexmk",
            "command": "latexmk",
            "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "-pdf",
            "%DOC%"
            ]
          },
          {
            "name": "xelatex",
            "command": "xelatex",
            "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%"
              ]
          },          
          {
            "name": "pdflatex",
            "command": "pdflatex",
            "args": [
            "-synctex=1",
            "-interaction=nonstopmode",
            "-file-line-error",
            "%DOC%"
            ]
          },
          {
            "name": "bibtex",
            "command": "bibtex",
            "args": [
            "%DOCFILE%"
            ]
          }
        ],
    "latex-workshop.latex.recipes": [
          {
            "name": "xelatex",
            "tools": [
            "xelatex"
                        ]
                  },
          {
            "name": "latexmk",
            "tools": [
            "latexmk"
                        ]
          },

          {
            "name": "pdflatex -> bibtex -> pdflatex*2",
            "tools": [
            "pdflatex",
            "bibtex",
            "pdflatex",
            "pdflatex"
                        ]
          }
        ],
    "latex-workshop.view.pdf.viewer": "tab",
    "latex-workshop.latex.clean.enabled": true,
    "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"
      ],

}



请按照如下方式进行系统变量的添加

对windows,win+R 然后输入sysdm.cpl 在高级中选择环境变量

找到path环境变量,将txtlive中的bin/win32路径添加进去

根据你安装的路径找到你的bin文件