LaTeX 报错有时候真感觉挺无力的 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Cineray
V2EX    TeX

LaTeX 报错有时候真感觉挺无力的

  •  
  •   Cineray 2024-01-28 20:15:16 +08:00 3705 次点击
    这是一个创建于 621 天前的主题,其中的信息可能已经有所发展或是发生改变。

    论文写一半,latex 突然报错了,也没有加宏包什么的,后来发现模板也报错了,但之前都是好的。

    19: Undefined control sequence. \ExplSyntaxOn 20: Undefined control sequence. \seq 20: Missing $ inserted. \seq_ 20: Missing \begin{documen}. \seq_ 20: Undefined control sequence. \seq_new:N \g 20: Missing { inserted. \seq_new:N \g__ 21: Undefined control sequence. \DeclareDocumentCommand 21: Undefined control sequence. \DeclareDocumentCommand \mathcolor 23: Undefined control sequence. \mode 23: \mathcolor allowed only in math mode. ...f_math:F { \non@alpherr {\mathcolor\space} 24: Undefined control sequence. \seq 24: Undefined control sequence. \seq_gpush:No \g 24: Missing { inserted. \seq_gpush:No \g__ 25: Undefined control sequence. \group 25: Undefined control sequence. \group_insert_after:N \use 26: Undefined control sequence. \IfValueTF 26: You can't use `macro parameter character #' in math mode. \IfValueTF {# 26: Illegal parameter number in definition of \@@mod. \IfValueTF {#1} { \color[#1]{#2} 26: Undefined control sequence. \IfValueTF {#1} { \color[#1]{#2} 26: Package xcolor Error: Undefined color model `##1'. \IfValueTF {#1} { \color[#1]{#2} 26: Extra }, or forgotten \endgroup. \IfValueTF {#1} { \color[#1]{#2} } 26: Illegal parameter number in definition of \XC@@tmp. ...lueTF {#1} { \color[#1]{#2} } { \color{#2} 26: Undefined control sequence. ...lueTF {#1} { \color[#1]{#2} } { \color{#2} 26: Missing number, treated as zero. ...lueTF {#1} { \color[#1]{#2} } { \color{#2} 26: Undefined control sequence. ...lueTF {#1} { \color[#1]{#2} } { \color{#2} 26: Undefined control sequence. ...lueTF {#1} { \color[#1]{#2} } { \color{#2} 26: Missing } inserted. ...lueTF {#1} { \color[#1]{#2} } { \color{#2} 26: Undefined control sequence. ...lueTF {#1} { \color[#1]{#2} } { \color{#2} 26: Package xcolor Error: Undefined color model `##1'. ...lueTF {#1} { \color[#1]{#2} } { \color{#2} 26: Extra }, or forgotten \endgroup. ...eTF {#1} { \color[#1]{#2} } { \color{#2} } 27: You can't use `macro parameter character #' in math mode. # 29: Extra }, or forgotten \endgroup. } 30: Undefined control sequence. \cs 32: Undefined control sequence. \peek 34: Undefined control sequence. \group 35: Undefined control sequence. \token 37: Missing $ inserted. \c_ 37: Missing { inserted. \c_ 38: Missing $ inserted. \c_ 38: Missing { inserted. \c_ 39: Extra }, or forgotten $. } 42: Undefined control sequence. \token 44: Limit controls must follow a math operator. \limits 44: Limit controls must follow a math operator. \limits { \limits 45: Limit controls must follow a math operator. \nolimits 45: Limit controls must follow a math operator. \nolimits { \nolimits 46: Limit controls must follow a math operator. \displaylimits 46: Limit controls must follow a math operator. ... \displaylimits { \displaylimits 49: Undefined control sequence. \group 50: Undefined control sequence. ... \__mathcolor_scan_for_scripts:w \use 53: Undefined control sequence. \token 56: Missing { inserted. \c 56: Missing $ inserted. \c_ 56: Missing { inserted. \c_ 57: Extra }, or forgotten $. ... \exp_after:wN \prim@s \use 57: Undefined control sequence. ... \exp_after:wN \prim@s \use 58: Extra }, or forgotten $. } 60: Undefined control sequence. \group 62: Undefined control sequence. \seq 62: Undefined control sequence. \seq_gpop:NN \g 62: Missing { inserted. \seq_gpop:NN \g__ 65: Extra }, or forgotten $. } 66: Extra }, or forgotten $. } 67: Extra }, or forgotten $. } 68: Undefined control sequence. \cs 68: You can't use `macro parameter character #' in math mode. ...ected:Npn \__mathcolor_handle_scripts:Nw # 70: You can't use `macro parameter character #' in math mode. # 70: Missing $ inserted. #1 \c_ 70: Missing { inserted. #1 \c_ 70: Missing $ inserted. #1 \c_group_begin_token \c_ 70: Missing { inserted. #1 \c_group_begin_token \c_ 71: Undefined control sequence. \seq 71: Undefined control sequence. \seq_get:NN \g 71: Missing { inserted. \seq_get:NN \g__ 73: Undefined control sequence. \group 73: Missing $ inserted. \group_insert_after:N \c_ 73: Missing { inserted. \group_insert_after:N \c_ 74: Undefined control sequence. \group 75: Undefined control sequence. \peek 77: Undefined control sequence. \token 77: Missing $ inserted. ...token_if_eq_meaning:NNTF \l_peek_token \c_ 77: Missing { inserted. ...token_if_eq_meaning:NNTF \l_peek_token \c_ 79: Undefined control sequence. \group 80: Undefined control sequence. \peek 80: Missing $ inserted. \peek_catcode_remove:NT \c_ 80: Missing { inserted. \peek_catcode_remove:NT \c_ 81: Extra }, or forgotten $. } 83: Undefined control sequence. \exp_after:wN \group 84: Undefined control sequence. \use 84: Missing $ inserted. \use_ii_i:nn \c_ 84: Missing { inserted. \use_ii_i:nn \c_ 85: Extra }, or forgotten $. } 86: Extra }, or forgotten $. } 87: Extra }, or forgotten $. } 88: Undefined control sequence. \ExplSyntaxOff 802: Missing $ inserted. 6: Missing } inserted. \begin{document} 6: Missing $ inserted. \begin{document} 6: Missing } inserted. \begin{document} 6: Missing } inserted. \begin{document} : No journal specified, using default cha. 35: Command \l invalid in math mode 37: Command \c invalid in math mode : You have requested, on input line 109, version `2018/09/10' of package pdftexcmds, but only version `2017/03/19 v0.25 Utility functions of pdfTeX for LuaTeX (HO)' is available. 

    根据最后一条我以为是 tex 或者 pdftex 或者 luatex 的版本问题,但我用的最新的 texlive2023 ,所有的宏包也是新的,然后即便我强制修改了 version 问题,其他的报错我也找不到解决方法。

    TeX 3.141592653 (TeX Live 2023) pdfTeX 3.141592653-2.6-1.40.25 (TeX Live 2023) This is LuaTeX, Version 1.16.0 (TeX Live 2023) 

    环境设置也没有问题,overleaf 可以用,但是由于我文档太大了编译时间超过了免费版的时间,所以选择本地编译,也不应该这么难吧。。。

    texhash && fmtutil-sys --all也试过了,没有用,包都是最新的。google 也搜不到相关资料,写一天论文 debug 半天也挺无力的。

    26 条回复    2024-02-29 15:30:54 +08:00
    barlogscc
        1
    barlogscc  
       2024-01-28 20:18:17 +08:00 via Android
    用不同的编译器试试
    sunzhuo
        2
    sunzhuo  
       2024-01-28 20:43:37 +08:00
    GPT4 pro 试了吗?
    geelaw
        3
    geelaw  
       2024-01-28 20:59:33 +08:00 via iPhone   3
    技巧是看第一个错误,说的是 \ExplSyntaxOn 是未定义的控制序列,这是 LaTeX 3 的 expl3 功能,于是目前有两种可能,一是你的 TeX 没有支持它,二是某段代码破坏了这个控制序列。

    我想提示到这里你可以继续尝试调试了。
    ranaanna
        4
    ranaanna  
       2024-01-28 21:14:41 +08:00
    如果编译通过和通不过之间环境没有任何变动,那么多半是有语法错误。
    如果有变动,那么可能是用了过时的宏包。因为查了一下即使是“version `2018/09/10' of package pdftexcmds”也是过时的。也有可能是需要安装 pdftexcmds ,因为之前 pdftexcmds 是包含在 oberdiek 的,大概 19 年前后从后者分离出来了。所以如果近期更新了 oberdiek ,必须要新装 pdftexcmds ,参见 https://github.com/ho-tex
    passive
        5
    passive  
       2024-01-28 21:16:40 +08:00 via Android
    不用去读错误报告,直接上 git bisect
    A01514035
        6
    A01514035  
       2024-01-28 21:20:17 +08:00
    现在都用 overleaf 了,本地 latex 编译太恶心了。
    HongyuGao
        7
    HongyuGao  
       2024-01-28 21:25:09 +08:00
    +1 ,第一次用,被报错给整麻了,效果也达不到预期。即使没有报错了还是会出现一些奇奇怪怪的表现,也不知道是哪里出的问题,问 gpt 也不知道该怎么描述
    ranaanna
        8
    ranaanna  
       2024-01-28 21:25:13 +08:00
    @geelaw 哇,一针见血的答复。OP 的 TeX 不支持
    ranaanna
        9
    ranaanna  
       2024-01-28 21:36:14 +08:00
    @geelaw 所以是 l3kernel?
    Cineray
        10
    Cineray  
    OP
       2024-01-28 21:37:32 +08:00
    @sunzhuo 试过了
    @geelaw 我的 tex 是最新的版本应该支持 latex3 ?`某段代码破坏了这个控制序列`请问这个一般要怎么调试呀?现有的 log 文件没有更多的信息了。而且我没有改过除了我 tex 文件以外的代码。
    Cineray
        11
    Cineray  
    OP
       2024-01-28 21:41:04 +08:00
    @passive 没有上 git.应该是软件环境层的问题?我的 tex 代码是可以跑的。
    @A01514035 overleaf 确实好用,可惜太长的文件无法编译。
    @HongyuGao 对对对,写文章的时间一半要用来 debug ,资料也不多,难顶。
    ranaanna
        12
    ranaanna  
       2024-01-28 21:48:11 +08:00
    @Cineray 没有 latex3 ,已经停止开发了。但是相关的约定和概念都在 l3kernel 和 l3package 里面。如果要想有关的宏命令,要安装这两个包
    geelaw
        13
    geelaw  
       2024-01-28 21:53:12 +08:00 via iPhone
    @A01514035 #6 我感到很困惑,因为 Overleaf 的在线编译用的是同一套软件,会出现的错误都是一样的。另外,由于通用性问题,在线每次都是全量重编译,比本地慢很多。

    @ranaanna #9 我不知道,我个人使用的是 MiKTeX + 自动安装缺少的包,只会偶尔手动更新包到最新版,就没遇到过这种情况。

    @Cineray #10 第一步是利用版本控制或者复制代码,不断删减直到得到较小的出错代码。

    日志说第一个错误在第 19 行,后续包版本的问题却是第 109 行,并且中途显示 \begin{document} 是第 6 行,说明第一个错误不在 \begin{document} 所在的文件里面。

    首先找到第一个错误所在的文件,然后找到你自己写的文件里面所有引用那个文件之前的内容并观察。
    kenvix
        14
    kenvix  
       2024-01-28 21:59:09 +08:00   2
    latex 这东西的垃圾编译器是真的恶心,除了写论文我现在能 md 则 md ,不能 md 则 word ,最后才考虑 latex
    Cineray
        15
    Cineray  
    OP
       2024-01-28 22:27:45 +08:00
    @geelaw 装了个 MiKTeX ,好像没问题了。texlive2023 什么鬼(捂脸
    zhuangzhuang1988
        16
    zhuangzhuang1988  
       2024-01-28 22:44:36 +08:00
    要不试试 Typst
    虽然功能肯定没有 latex 强。
    Cineray
        17
    Cineray  
    OP
       2024-01-28 23:14:16 +08:00
    @zhuangzhuang1988 这种都是 paper 指定的 latex 模板。不然我觉得 word 也能写哈哈哈
    petermu
        18
    petermu  
       2024-01-29 00:18:49 +08:00
    可以试试 TeXPage (www.texpage.com),免费版编译时长 1 分钟,大多数情况下 1 分钟够用了,TeXPage 提供 LaTeX 方面的技术支持服务,遇到问题可以通过发送邮件到 [email protected] 获取帮助。
    RVRGnXxwawP5kwKW
        19
    RVRGnXxwawP5kwKW  
       2024-01-29 03:55:41 +08:00 via iPhone
    LaTeX 的 debug 确实非常麻烦,报错信息不直接,这是历史遗留问题基本上也无解了。

    我的经验是,一步步把代码都注释了,直到不报错为止,然后一段段取消注释,应该就能定位到问题。

    Overleaf 使用的 TeXlive ,所以 overleaf 能编译那么本地 texlive 应该也能编译。
    dcoder
        20
    dcoder  
       2024-01-29 04:54:22 +08:00
    不写论文的话, 真是不想折腾这垃圾东西
    Masonn
        21
    Masonn  
       2024-01-29 08:36:10 +08:00
    用 IEEE Member 通过机构换 Overleaf 的订阅会员
    v2yllhwa
        22
    v2yllhwa  
       2024-01-29 08:56:37 +08:00 via Android
    texlive2023 我也用得有问题,切回上个版本了...
    Cineray
        23
    Cineray  
    OP
       2024-01-29 12:01:48 +08:00
    @petermu 感谢推荐,刚刚试了一下,bib 链不上,ref 出不来,不知道哪里出了问题,我之后再研究研究。

    @RVRGnXxwawP5kwKW 因为用了一个杂志的 cls 模板,内容比较多,定位起来非常耗时,后面试了一下 miktex 又好了,很奇怪。

    @v2yllhwa 也是类似的问题吗?我到时候也切回 2022 试试
    chengandc
        24
    chengandc  
       2024-01-29 14:58:35 +08:00
    可以试下这个 latex 在线协作编写器,https://scienhub.com/
    Scirocco
        25
    Scirocco  
       2024-02-25 01:33:42 +08:00
    @petermu 学校买 TeXPage 的话大概是什么价钱
    petermu
        26
    petermu  
       2024-02-29 15:30:54 +08:00
    @Scirocco 学校整体采购有比较大的优惠,也会帮助对接学校的统一身份认证登录,您可以邮箱联系 [email protected] 获取报价单。
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2737 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 29ms UTC 11:32 PVG 19:32 LAX 04:32 JFK 07:32
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86