Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于建议改进latex workshop插件支持 #596

Closed
llk2why opened this issue Feb 22, 2021 · 16 comments
Closed

关于建议改进latex workshop插件支持 #596

llk2why opened this issue Feb 22, 2021 · 16 comments

Comments

@llk2why
Copy link

llk2why commented Feb 22, 2021

使用vscode上的latex workshop插件,按照.vscode/settings.json里的配置,保存tex时会自动编译,但生成的目录是空白的。根据make thesis的log显示,编译过程执行了三次才生成目录,而settings.json中的命令并未成功生成目录。按照网上建议,多次重复命令也未能成功生成目录,如果自动删除列表中注释“.aux”和“.toc”的话,生成的目录是上一次修改后的结果,不能即时更新目录。

尚未能找到一个配置方案能让latex workshop解决这个问题,希望TUNA的同学方便的话改进一下这个部分

核心需求:使用latex workshop的同时,每次修改完tex保存的时候,能保持目录内容是最新的。
改进的必要性:每次修改完按保存键(ctrl+s)的同时自动编译,可以大幅节省修改&编译时间。

@zepinglee
Copy link
Contributor

无法复现你的问题。latexmk for thuthesis 这个 recipe 可以正常编译。你的情况可能是编译报错,也可能是用了不合适的 recipe。建议贴一下本地的相关配置。

另外 latex-workshop.latex.autoBuild.run 默认就是 onFileChange.vscode/settings.json 没有修改。

@llk2why
Copy link
Author

llk2why commented Feb 22, 2021

无法复现你的问题。latexmk for thuthesis 这个 recipe 可以正常编译。你的情况可能是编译报错,也可能是用了不合适的 recipe。建议贴一下本地的相关配置。

另外 latex-workshop.latex.autoBuild.run 默认就是 onFileChange.vscode/settings.json 没有修改。

{
    "latex-workshop.intellisense.package.enabled": true,
    "latex-workshop.intellisense.unimathsymbols.enabled": true,
    "latex-workshop.latex.recipes": [
        {
            "name": "latexmk for thuthesis",
            "tools": [
                "xetex-thuthesis",
                "latexmk-xelatex"
            ]
        },
        {
            "name": "make thesis",
            "tools": [
                "make-thesis"
            ]
        }
    ],
    "latex-workshop.latex.tools": [
        {
            "name": "xetex-thuthesis",
            "command": "xetex",
            "args": [
                "-file-line-error",
                "-halt-on-error",
                "-interaction=nonstopmode",
                "thuthesis.ins"
            ],
            "env": {}
        },
        {
            "name": "latexmk-xelatex",
            "command": "latexmk",
            "args": [
                "-xelatex",
                "-file-line-error",
                "-halt-on-error",
                "-interaction=nonstopmode",
                "-synctex=1",
                "-pv-",
                "-pvc-",
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {}
        },
        {
            "name": "make-thesis",
            "command": "make",
            "args": [],
            "env": {}
        }
    ],
    "latex-workshop.latex.autoClean.run": "onBuilt", //注意结尾是 t 不是 d
    "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",
    ],
}

@llk2why
Copy link
Author

llk2why commented Feb 22, 2021

无法复现你的问题。latexmk for thuthesis 这个 recipe 可以正常编译。你的情况可能是编译报错,也可能是用了不合适的 recipe。建议贴一下本地的相关配置。

另外 latex-workshop.latex.autoBuild.run 默认就是 onFileChange.vscode/settings.json 没有修改。

编译没有任何问题,也不是保存不能自动编译的问题,而是自动编译之后,pdf里面的目录是空白的,复现的话,麻烦删除所有临时文件,使用latex workshop进行自动编译,不要手动使用make命令

@zepinglee

This comment has been minimized.

@llk2why

This comment has been minimized.

@zepinglee
Copy link
Contributor

zepinglee commented Feb 22, 2021

刚刚看错了。目录这一章的内容能编译出来,总之无法复现你的问题。

@llk2why llk2why closed this as completed Feb 22, 2021
@llk2why
Copy link
Author

llk2why commented Feb 22, 2021

刚刚看错了。目录这一章的内容能编译出来,总之无法复现你的问题。

好的我先看看如何合理复现,可能是我用的linux系统,等找到合适的方式再请教,谢谢。

@yaox12
Copy link

yaox12 commented Feb 25, 2021

@llk2why 我知道是为什么,因为模板默认的主文件thuthesis-example.tex第二行有一句magic comments:

% !TeX program = xelatex

此时latex workshop的auto build会使用xelatex的recipe,只编译一遍。
解决办法是把该行改成:

% !TeX program = latexmk

就可以保存的时候自动根据latexmkrc编译了,目录都是正常的,而且不需要在.vscode/settings.json里定义recipe和tools

@zepinglee
Copy link
Contributor

此时latex workshop的auto build会使用xelatex的recipe,只编译一遍。

vscode/settings.json 应该已经覆盖了默认 recipes,所以不会调用 xelatex 的 recipe,左边的菜单里也找不到。

解决办法是把该行改成:

% !TeX program = latexmk

就可以保存的时候自动根据latexmkrc编译了,目录都是正常的,而且不需要在.vscode/settings.json里定义recipe和tools

% !TeX program = latexmk 对别的编辑器不太友好,像 texworks 是不认 latexmk 的。

@llk2why
Copy link
Author

llk2why commented Feb 25, 2021

@llk2why 我知道是为什么,因为模板默认的主文件thuthesis-example.tex第二行有一句magic comments:

% !TeX program = xelatex

此时latex workshop的auto build会使用xelatex的recipe,只编译一遍。
解决办法是把该行改成:

% !TeX program = latexmk

就可以保存的时候自动根据latexmkrc编译了,目录都是正常的,而且不需要在.vscode/settings.json里定义recipe和tools

确实解决了,谢谢大佬

@llk2why
Copy link
Author

llk2why commented Feb 25, 2021

此时latex workshop的auto build会使用xelatex的recipe,只编译一遍。

vscode/settings.json 应该已经覆盖了默认 recipes,所以不会调用 xelatex 的 recipe,左边的菜单里也找不到。

解决办法是把该行改成:

% !TeX program = latexmk

就可以保存的时候自动根据latexmkrc编译了,目录都是正常的,而且不需要在.vscode/settings.json里定义recipe和tools

% !TeX program = latexmk 对别的编辑器不太友好,像 texworks 是不认 latexmk 的。

可以考虑在说明文档里给需要用latex workshop的同学说明一下,这个插件确实很方便,每次修改完手动编译太折腾了。同时也多谢关注

@yaox12
Copy link

yaox12 commented Feb 25, 2021

vscode/settings.json 应该已经覆盖了默认 recipes,所以不会调用 xelatex 的 recipe,左边的菜单里也找不到。

我这里如果只修改settings.json,保持% !TeX program = xelatex,按ctrl + s自动编译的时候确实不行,目录和引用都没有编译上。和楼主的情况应该是一样的。
另外如果我直接在左边的菜单里点latexmk for thuthesis的recipe,会报错,因为我把thuthesis.ins删掉了。所以我认为ctrl + s的auto build没报错就是调了xelatex的recipe。我再把thuthesis.ins加回去试试。

@yaox12
Copy link

yaox12 commented Feb 25, 2021

我试了一下,结论如下:

  1. 在自定义了recipes和tools的情况下。删掉% !TeX program或置为latexmk时,自动保存时的auto build能正常编译;置为xelatex时可编译,但目录和引用均没有显示。
  2. 无自定义recipes和tools的情况下。置为latexmkxelatex时与1中的结论相同,删掉% !TeX program则自动保存时会报错。

@zepinglee
Copy link
Contributor

找到了,原来是 latex-workshop.latex.build.forceRecipeUsage
Screen Shot 2021-02-25 at 16 49 56

@llk2why
Copy link
Author

llk2why commented Feb 25, 2021

刚刚看错了。目录这一章的内容能编译出来,总之无法复现你的问题。

@zepinglee 所以之前是因为你本地开了这个开关能编译出来吗?

@zepinglee
Copy link
Contributor

@zepinglee 所以之前是因为你本地开了这个开关能编译出来吗?

不是,应该是因为我本地配置了 "latex-workshop.latex.recipe.default": "lastUsed"

zepinglee added a commit that referenced this issue Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants