我不知道这是否是最新 TL 更新导致的新错误。但这是我第一次看到它。
这个 MWE 编译 lualatex 没有问题,但是给出
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/ts1cmr.fd) (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphicx.sty (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/graphics-hooks.4ht) (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphics.sty
! Missing number, treated as zero.
<to be read again>
^
l.39 \catcode`\^^
A=\catcode`\%
?
使用 tex4ht 编译时。这是我能制作的显示错误的最小示例。Latex 是自动生成的。
\documentclass[11pt]{article}
\usepackage{amsmath}
\usepackage{mathtools}
\begin{document}
\begin{align*}
\frac{1}{18} \, \sqrt{3} \log\left(\frac{{\left| 6 \, x - 2 \, \sqrt{3} \right|}}
{{\left| 6 \, x + 2 \, \sqrt{3} \right|}}\right) - \frac{1}{18} \, \sqrt{3}
\log\left(-\frac{{\left| -6 \, x - 8 \, \sqrt{3} + 6 \, \sqrt{x^{2} + 1} - \frac{6}{x - \sqrt{x^{2} + 1}} \right|}}
{2 \, {\left(3 \, x - 4 \, \sqrt{3} - 3 \, \sqrt{x^{2} + 1} + \frac{3}{x - \sqrt{x^{2} + 1}}\right)}}\right)
- \frac{4 \, {\left(x - \sqrt{x^{2} + 1} + \frac{1}{x - \sqrt{x^{2} + 1}}\right)}}
{3 \, {\left(3 \, {\left(x - \sqrt{x^{2} + 1} +
\frac{1}{x - \sqrt{x^{2} + 1}}\right)}^{2} - 16\right)}} - \frac{4 \, x}{3 \, {\left(3 \, x^{2} - 1\right)}}
\end{align*}
\end{document}
现在我使用以下命令进行编译:
make4ht -ulm default -a debug foo5.tex "htm"
它给
(base) >make4ht -ulm default -a debug foo5.tex "htm"
[INFO] mkparams: Output dir:
[INFO] mkparams: Compiler: dvilualatex
[INFO] mkparams: Latex options: -jobname=foo5
[INFO] mkparams: tex4ht.sty: xhtml,htm,charset=utf-8
[INFO] mkparams: tex4ht: -cmozhtf -utf8
[INFO] mkparams: build_file: foo5.mk4
[INFO] mkparams: Output format: html5
[STATUS] make4ht: Conversion started
[STATUS] make4ht: Input file: foo5.tex
[INFO] mkutils: Load extension common_domfilters
[INFO] mkutils: Cannot open config file foo5.mk4
[INFO] make4ht-lib: setting param correct_exit
[INFO] make4ht-lib: setting param correct_exit
[INFO] make4ht-lib: setting param correct_exit
[INFO] make4ht-lib: setting param ext
[INFO] make4ht-lib: Adding: ext dvi
[INFO] htlatex: LaTeX call: dvilualatex --interaction=errorstopmode -jobname=foo5 '\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\g@addto@macro\@documentclasshook{\RequirePackage[#1,html]{tex4ht}}\let\HCode\documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname tex4ht\endcsname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode xhtml,htm,charset=utf-8,html5.a.b.c.\input "\detokenize{foo5.tex}"'
This is LuaTeX, Version 1.12.0 (TeX Live 2020)
restricted system commands enabled.
LaTeX2e <2020-10-01> patch level 2
L3 programming layer <2020-12-07> xparse <2020-03-03> (./foo5.tex (/usr/local/texlive/2020/texmf-dist/tex/latex/base/article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/size11.clo)) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/tex4ht.sty) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/usepackage.4ht) (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/local/texlive/2020/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/local/texlive/2020/texmf-dist/tex/latex/mathtools/mathtools.sty (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/keyval.sty) (/usr/local/texlive/2020/texmf-dist/tex/latex/tools/calc.sty) (/usr/local/texlive/2020/texmf-dist/tex/latex/mathtools/mhsetup.sty)) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/tex4ht.4ht
::::::::::::::::::::::::::::::::::::::::::
TeX4ht info is available in the log file
::::::::::::::::::::::::::::::::::::::::::
) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/tex4ht.sty
--- needs --- tex4ht foo5 ---
(./foo5.tmp) (./foo5.xref) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/unicode.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html5.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/unicode.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html5.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/latex.4ht (/usr/local/texlive/2020/texmf-dist/tex/latex/base/fontenc.sty (/usr/local/texlive/2020/texmf-dist/tex/latex/lm/ot1lmr.fd)) (/usr/local/texlive/2020/texmf-dist/tex/generic/kastrup/binhex.tex) (/usr/local/texlive/2020/texmf-dist/tex/latex/base/tuenc.def) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/tuenc-luatex.4ht
(/usr/local/texlive/2020/texmf-dist/tex/luatex/luatexbase/luatexbase.sty (/usr/local/texlive/2020/texmf-dist/tex/luatex/ctablestack/ctablestack.sty)) (/usr/local/texlive/2020/texmf-dist/tex/lualatex/luacode/luacode.sty (/usr/local/texlive/2020/texmf-dist/tex/generic/iftex/ifluatex.sty (/usr/local/texlive/2020/texmf-dist/tex/generic/iftex/iftex.sty))) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/unicode.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html5.4ht)) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/unicode.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html5.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4.4ht)
(/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/unicode.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html5.4ht)) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/fontmath.4ht (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/unicode.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html5.4ht)) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/article.4ht (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/unicode.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html5.4ht)) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/amsmath.4ht
(/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/unicode.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html5.4ht)) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/amstext.4ht (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/unicode.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html5.4ht)) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/amsbsy.4ht (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/unicode.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/amsopn.4ht (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/unicode.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html5.4ht)) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/mathtools.4ht (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/unicode.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html5.4ht)) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/unicode.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html4-math.4ht) (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/html5.4ht))
(/usr/local/texlive/2020/texmf-dist/tex/latex/l3backend/l3backend-dvips.def) (./foo5.aux) (/usr/local/texlive/2020/texmf-dist/tex/latex/base/ts1cmr.fd) (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphicx.sty (/usr/local/texlive/2020/texmf-dist/tex/generic/tex4ht/graphics-hooks.4ht) (/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphics.sty
! Missing number, treated as zero.
<to be read again>
^
l.39 \catcode`\^^
A=\catcode`\%
?
删除包时\usepackage{mathtools}
,编译成功。没有错误。TL 已在 3-4 天前全面更新。
make4ht --version
make4ht version v0.3f
which tex4ht
/usr/local/texlive/2020/bin/x86_64-linux/tex4ht
答案1
编辑:
我找到了这个问题的根源。TeX4ht 重新定义\@begindocumenthook
并执行了它前后的一些代码。\@begindocumenthook
包含使用 添加的代码\AtBeginDocument
。它已被新的 LaTeX 钩子系统弃用。由于不再使用它,因此\AtBeginDocument
不会执行处理的 TeX4ht 代码,从而导致此 catcode 冲突。
可以使用钩子系统执行 TeX4ht 处理来修复此问题\AtBeginDocument
。我已经在 TeX4ht 源中修复了它。与此同时,您可以使用以下.cfg
文件模拟它:
\Preamble{xhtml}
\AddToHook{begindocument/before}[tex4ht]{\csname a:AtBeginDocument\endcsname}
\AddToHook{begindocument/end}[tex4ht]{\csname b:AtBeginDocument\endcsname}
\begin{document}
\EndPreamble
原始答案:
Mathtoolsgraphicx
在 中加载包\AtBeginDocument
。 它是在.4ht
处理完包文件后加载的,似乎存在一些 catcode 冲突。
最简单的修复方法是将graphicx
包加载到文档中,如 Egreg 所示。TeX4ht 方面的修复方法是graphicx
加载mathtools.4ht
:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% mathtools.4ht 2009-05-21-09:32 %
% Copyright (C) 2007--2009 Eitan M. Gurari %
% %
% 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. The latest version of this license is %
% in %
% http://www.latex-project.org/lppl.txt %
% and version 1.3c or later is part of all distributions %
% of LaTeX version 2005/12/01 or later. %
% %
% This work has the LPPL maintenance status "maintained".%
% %
% This Current Maintainer of this work %
% is Eitan M. Gurari. %
% %
% If you modify this program your changing its signature %
% with a directive of the following form will be %
% appreciated. %
% \message{signature} %
% %
% [email protected] %
% http://www.cse.ohio-state.edu/~gurari %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\immediate\write-1{version 2009-05-21-09:32}
\@ifpackageloaded{graphicx}{}{\RequirePackage{graphicx}}
\ifx \o:endgathered:\:UnDef\else
\HRestore\endgathered
\fi
\def\shortintertext{\intertext}
\def\:tempc#1#2{{\csname a:prescript\endcsname}\sp{#1}\sb{#2}}
\expandafter\HLet\csname prescript \endcsname=\:tempc
\NewConfigure{prescript}{1}
\Configure{prescript}{\HCode{<mrow class="prescript"></mrow>}}
\renewenvironment{dcases}[1][c]{%
\RIfM@\else
\nonmatherr@{\begin{\@currenvir}}%
\fi
\left\lbrace
\vcenter \bgroup
\Let@ \chardef\dspbrk@context\@ne \restore@math@cr
\spread@equation
\ialign\bgroup
\strut@$\m@th\displaystyle{##}$\hfil&\quad$\m@th\displaystyle{##}$\hfil\strut@
\crcr
}
{\endaligned\right.}
\catcode`\#13 \catcode`\!6
\def\reg:dcases[!1]{%
\RIfM@\else
\nonmatherr@{\begin{dcases}}%
\fi
\vcenter\bgroup
\Let@ \chardef\dspbrk@context\@ne \restore@math@cr
\SaveMkHalignConf:g{dcases}%
\MkHalign#{$\m@th\displaystyle{\HCode{}}#$&\quad$\m@th\displaystyle{\HCode{}}#$}%
}
\catcode`\#=6 \catcode`\!=12
\def\:tempc{\crcr\EndMkHalign
\RecallMkHalignConfig \egroup\b:dcases \right.}
\HLet\enddcases\:tempc
\def\:temp{\left\lbrace \pic:MkHalign{dcases}}
\expandafter\HLet\csname \string\dcases\endcsname\:temp
\NewConfigure{dcases}{6}
\renewenvironment{dcases*}[1][c]{%
\RIfM@\else
\nonmatherr@{\begin{\@currenvir}}%
\fi
\left\lbrace
\vcenter \bgroup
\Let@ \chardef\dspbrk@context\@ne \restore@math@cr
\spread@equation
\ialign\bgroup
\strut@$\m@th\displaystyle{##}$\hfil&\quad{##}\hfil\strut@
\crcr
}
{\endaligned\right.}
\catcode`\#13 \catcode`\!6
\expandafter\def\csname reg:dcases*\endcsname[!1]{%
\RIfM@\else
\nonmatherr@{\begin{dcases*}}%
\fi
\vcenter\bgroup
\Let@ \chardef\dspbrk@context\@ne \restore@math@cr
\SaveMkHalignConf:g{dcases*}%
\MkHalign#{$\m@th\displaystyle{\HCode{}}#$\quad&#}%
}
\catcode`\#=6 \catcode`\!=12
\def\:tempc{\crcr\EndMkHalign
\RecallMkHalignConfig \egroup\csname b:dcases*\endcsname \right.}
\expandafter\HLet\csname enddcases*\endcsname\:tempc
\def\:temp{\left\lbrace \pic:MkHalign{dcases*}}
\expandafter\HLet\csname \string\dcases*\endcsname\:temp
\NewConfigure{dcases*}{6}
\edef\cat:underscore{%
\noexpand\catcode`\noexpand\_=\the\catcode`\_ }
\catcode`\_=11
\def\MT_gathered_pre:{}
\def\MT_gathered_post:{}
\def\MT_gathered_env_end:{}
\catcode`\#13 \catcode`\!6
\def\reg:MT_gathered_env[!1]{%
\RIfM@\else
\nonmatherr@{\begin{MT_gathered_env}}%
\fi
\null \vcenter\bgroup
\Let@ \chardef\dspbrk@context\@ne \restore@math@cr
\SaveMkHalignConf:g{MT_gathered_env}%
\MkHalign#{$\m@th\displaystyle{\HCode{}}#$}%
}
\catcode`\#=6 \catcode`\!=12
\def\:tempc{\crcr\EndMkHalign
\RecallMkHalignConfig \egroup\b:MT_gathered_env}
\HLet\endMT_gathered_env\:tempc
\def\:temp{\pic:MkHalign{MT_gathered_env}}
\expandafter\HLet\csname \string\MT_gathered_env\endcsname\:temp
\NewConfigure{MT_gathered_env}{6}
\def\:tempc#1#2{{\m@th#1{#2}}}
\HLet\MT_cramped_internal:Nn\:tempc
\cat:underscore
\Hinput{mathtools}
\endinput
经过此修复后,文档处理不再出现错误。
答案2
加载 时发生错误graphics.sty
。我不确定为什么会发生这种情况,但解决方法是加载graphicx
前 mathtools
。
\documentclass{article}
\usepackage{graphicx}
\usepackage{mathtools}
\begin{document}
test
\begin{align*} a&=b\\c&=d\end{align*}
\end{document}
mathtools
有什么问题?
\AtBeginDocument{\RequirePackage{graphicx}...}
这是不正确的,应该
\RequirePackage{graphicx}
\AtBeginDocument{...}
另一方面,tex4ht
使其^
成为数学活跃字符,因此类别代码为 12。加载具有“奇怪”类别代码的包可能会导致意外结果。
所以,在我看来,mathtools
和tex4ht
是密谋关联的,两者都应该解决各自的问题;mathtools
应该尽早加载包,并且tex4ht
应该尽可能晚地更改类别代码。