htlatex 定义一个命令然后阻止它

htlatex 定义一个命令然后阻止它

我正在尝试将 LaTeX 文档编译为 HTML 文档,但一直遇到同样的问题。当我编译时(使用命令htlatex .\scratch.tex myhtml),我得到以下输出:

G:\PhD\Thesis 3\Scratch> htlatex .\scratch.tex myhtml

G:\PhD\Thesis 3\Scratch>latex  \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 myhtml.a.b.c.\input  .\scratch.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (MiKTeX 2.9.6800 64-bit)
entering extended mode
LaTeX2e <2018-04-01> patch level 5
! Undefined control sequence.
<*> ...tother\HCode myhtml.a.b.c.\input  .\scratch
                                                  .tex

从这个输出来看,问题似乎与文档无关(无论文档是什么,错误都是相同的),而是 tex4ht 中的一个错误,但供参考的scratch.tex是:

\documentclass{article}

\begin{document}
Text text.
\end{document}

看起来 tex4ht 试图定义一个命令(\HCode),然后在运行实际文档之前运行它,但由于某种原因,定义未能生效。

更新 MikTeX 并没有改变任何东西。从这个问题,tex4ht 的一个类似问题通过修改 tex4ht 使用的一个.def文件解决了。但我不知道哪个文件导致了这个错误,也不知道如何修复它。

因此,我的两个问题是:1) 导致此错误的原因是什么,2) 我需要更改哪个文件来修复它。我在 Windows 10 64 位上使用 MiKTeX 2.9,希望对您有所帮助。

答案1

因此,解决方案是运行htlatex scratch.tex myhtml而不是htlatex .\scratch.tex myhtml- 这.\会混淆编译器,它会认为您正在尝试运行命令\scratch。感谢 michal.h21 指出这一点。

更好的解决方案是使用 make4ht,它不会阻塞.\

我应该注意,这.\scratch.tex就是您使用 PowerShell 自动完成功能时所获得的结果。

相关内容