Latex Workshop 错误:无法找到 LaTeX 根文件

Latex Workshop 错误:无法找到 LaTeX 根文件

我最近从 Windows 换到了 Ubuntu,因为我正在学习编程。我以前用 vscode 和 Latex Workshop 用 LaTeX 写课堂作业。但是,我尝试在 Ubuntu 中设置它,却遇到了多个错误。我能够解决(或者至少我认为我能够解决)每一个错误,但我无法解决最后一个错误。

问题如下:尝试构建 Latex 项目时,终端显示以下内容:

[19:17:56.309][Commander] BUILD command invoked.
[19:17:56.310][Commander] The document of the active editor: file://%WS1%/main
[19:17:56.310][Commander] The languageId of the document: latex
[19:17:56.310][Manager] Current workspace folders: ["file://%WS1%"]
[19:17:56.311][Manager] Found root file from active editor: %WS1%/main
[19:17:56.311][Manager] Keep using the same root file: %WS1%/main
[19:17:56.312][Event] ROOT_FILE_SEARCHED
[19:17:56.312][Commander] Cannot find LaTeX root file. See https://github.com/James-Yu/LaTeX-Workshop/wiki/Compile#the-root-file
[19:17:58.322][Cacher] Error loading cache: %WS1%/main . Forcing.
[19:17:58.328][Structure][LaTeX] Error loading content during structuring: %WS1%/main .
[19:17:58.330][Structure] Structure updated with 0 root sections for %WS1%/main .
[19:17:58.333][Event] STRUCTURE_UPDATED

什么都没发生。当我打开 vscode 时,它​​显示以下内容:

[19:17:31.034][Logger] New log placeholder %WS1% registered for /home/alejandro/Documentos/latex/tfm .
[19:17:31.034][Config] latex-workshop.latex.tools: things-that-flagged-the-question-as-spam.
[19:17:31.044][Config] latex-workshop.latex.outDir: "%DIR%/build" .
[19:17:31.085][Manager] Set $LATEXWORKSHOP_DOCKER_LATEX: ""
[19:17:31.093][Server] Creating LaTeX Workshop http and websocket server.
[19:17:31.142][Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":41019} .
[19:17:31.164][Extension] Initializing LaTeX Workshop.
[19:17:31.164][Extension] Extension root: /home/alejandro/.vscode/extensions/james-yu.latex-workshop-9.15.0
[19:17:31.164][Extension] $PATH: /home/alejandro/anaconda3/envs/latex/bin:/home/alejandro/anaconda3/condabin:/usr/local/texlive/2023/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
[19:17:31.165][Extension] $SHELL: /bin/bash
[19:17:31.165][Extension] $LANG: en_US.UTF-8
[19:17:31.165][Extension] $LC_ALL: undefined
[19:17:31.165][Extension] process.platform: linux
[19:17:31.165][Extension] process.arch: x64
[19:17:31.165][Extension] vscode.env.appName: Visual Studio Code
[19:17:31.166][Extension] vscode.env.remoteName: undefined
[19:17:31.166][Extension] vscode.env.uiKind: 1
[19:17:31.166][Extension] LaTeX Workshop initialized.
[19:17:31.173][Format][Bib] Bibtex format config: {"tab":"  ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]}
[19:17:31.174][Extension] Trigger characters for intellisense of LaTeX documents: ["\\",",","{"]
[19:17:31.176][Manager] Current workspace folders: ["file://%WS1%"]
[19:17:31.176][Manager] Found root file from active editor: %WS1%/main
[19:17:31.177][Manager] Root file changed: from undefined to %WS1%/main
[19:17:31.177][Manager] Start to find all dependencies.
[19:17:31.177][Manager] Root file languageId: undefined
[19:17:31.177][Event] ROOT_FILE_CHANGED: "%WS1%/main"
[19:17:31.178][Cacher][Watcher] Reset.
[19:17:31.183][Cacher] Adding %WS1%/main .
[19:17:31.185][Cacher][Watcher] Watched %WS1%/main with a new watcher on %WS1% .
[19:17:31.185][Event] FILE_WATCHED: "%WS1%/main"
[19:17:31.186][Event] ROOT_FILE_SEARCHED
[19:17:31.187][Cacher][Path] Non-existent .fls for %WS1%/main .
[19:17:31.298][Server] valdOrigin is http://127.0.0.1:41019
[19:17:35.047][Cacher] Error loading cache: %WS1%/main . Forcing.
[19:17:35.055][Structure][LaTeX] Error loading content during structuring: %WS1%/main .

现在我将列举我为达到这一点所做的事情:

  1. 我首先尝试跟随TexLive 快速安装文档
    1. 我在家里创建了一个 texlive 目录
    2. 我执行了文档中的所有命令,直到出现错误cd install-tl-*,因此我不得不写出它的全名。
    3. 我尝试更新 PATH,但是没有成功。
  2. 更新路径:我看到了这里也有人遇到同样的问题。我按照其中一些人的指示操作,但没有成功。我尝试通过 tlmgr gui 进行操作,但仍然echo $PATH没有显示 texlive。
  3. 我跟着Ubuntu 的 encitomental 变量文档并创建一个myenvsvars.shin/etc/profile.d/并放在export PATH=$PATH:/my/which/pdflatex/那里。我最终在 PATH 中找到了 texlive,如下所示:
/home/alejandro/anaconda3/envs/latex/bin:/home/alejandro/anaconda3/condabin:/usr/local/texlive/2023/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
  1. latexmk通过安装sudo apt install latexmk
  2. 解决这个问题后,我遇到了我发布的错误,并尝试(以防万一)将 PATH 添加到环境 latexworkshop,如下所示这里。现在我的latex-workshop.latex.tools样子是这样的:
            "command": "latexmk",
            "args": [
                "--shell-escape",
                "-synctex=1",
                "-interaction=nonstopmode",
                "-file-line-error",
                "-pdf",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {"PATH": "/usr/local/texlive/2023/bin/x86_64-linux:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin"}

对于每个环境。这实际上并没有改变输出。

  1. (稍后添加)我能够在终端中编译乳胶。

我想这就是我要说的全部内容了。我在发布的页面中使用了一些命令,但我真的不知道这些命令怎么会搞乱后面的命令。我使用的是 Ubuntu 23.10,非常感谢您的帮助。谢谢。

相关内容