使用htlatex转换html时出现编译错误

使用htlatex转换html时出现编译错误

我现在想把tex转成html文件,之前只有一些错误,但是我好像更新了一些包什么的之后,就不能生成html文件了,源代码和bib代码建议参考另一篇文章

[使用 htlatex 和 bibtex 转换为 html 然后转换为 word 时出现的问题

我使用的命令很简单

htlatex Text.tex

编译错误如下:

This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6350 64-bit) (preloaded format=latex 2017.10.24)  24 OCT 2017 20:55
entering extended mode
**\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx\HCode\def\HCod
e##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\doc
umentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname te
x4ht\endcsname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HC
ode}{\documentstyle[tex4ht]}}}\makeatother\HCode .a.b.c.\input  Fancypattern
(Fancypattern.tex (iopart.cls
Document Class: iopart 1996/06/10 v0.0 IOP Journals LaTeX article class
(iopart12.clo
File: iopart12.clo 1997/01/15 v1.0 LaTeX2e file (size option)
)
\c@jnl=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\indentedwidth=\skip43
\mathindent=\dimen102
\c@eqnval=\count87
)
(C:\Users\zhang\AppData\Roaming\MiKTeX\2.9\tex\generic\tex4ht\tex4ht.sty
version 2008-10-27-17:23
Package: tex4ht 
--------------------------------------
--- Note --- for _ at preamble, use the command line option `early_'
--------------------------------------
--------------------------------------
--- Note --- for ^ at preamble, use the command line option `early^'
--------------------------------------
\tmp:toks=\toks14
)
(C:\Users\zhang\AppData\Roaming\MiKTeX\2.9\tex\generic\tex4ht\usepackage.4ht
version 2009-05-21-09:32
)
("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\epstopdf.sty"
Package: epstopdf 2016/05/15 v2.6 Conversion with epstopdf on the fly (HO)

("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\epstopdf-base.sty"
Package: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf

("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\infwarerr.sty"
Package: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)
)
("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\grfext.sty"
Package: grfext 2016/05/16 v1.2 Manage graphics extensions (HO)

("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\kvdefinekeys.sty"
Package: kvdefinekeys 2016/05/16 v1.4 Define keys (HO)

("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ltxcmds.sty"
Package: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)
)))
("C:\Program Files\MiKTeX 2.9\tex\latex\oberdiek\kvoptions.sty"
Package: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)

("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\keyval.sty"
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks15
)
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\kvsetkeys.sty"
Package: kvsetkeys 2016/05/16 v1.17 Key value parser (HO)

("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\etexcmds.sty"
Package: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)

("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifluatex.sty"
Package: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)
Package ifluatex Info: LuaTeX not detected.
)
Package etexcmds Info: Could not find \expanded.
(etexcmds)             That can mean that you are not using pdfTeX 1.50 or
(etexcmds)             that some package has redefined \expanded.
(etexcmds)             In the latter case, load this package earlier.
)))
("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\pdftexcmds.sty"
Package: pdftexcmds 2017/03/19 v0.25 Utility functions of pdfTeX for LuaTeX (HO
)

("C:\Program Files\MiKTeX 2.9\tex\generic\oberdiek\ifpdf.sty"
Package: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch
)
Package pdftexcmds Info: LuaTeX not detected.
Package pdftexcmds Info: \pdf@primitive is available.
Package pdftexcmds Info: \pdf@ifprimitive is available.
Package pdftexcmds Info: \pdfdraftmode is ignored in DVI mode.
)

Package epstopdf Warning: No graphics package `graphic{s,x}' loaded.

)) ("C:\Program Files\MiKTeX 2.9\tex\latex\subfigure\subfigure.sty"
Package: subfigure 2002/07/30 v2.1.4 subfigure package
\subfigtopskip=\skip44
\subfigcapskip=\skip45
\subfigcaptopadj=\dimen103
\subfigbottomskip=\skip46
\subfigcapmargin=\dimen104
\subfiglabelskip=\skip47
\c@subfigure=\count88
\c@lofdepth=\count89
\c@subtable=\count90
\c@lotdepth=\count91

****************************************
* Local config file subfigure.cfg used *
****************************************
("C:\Program Files\MiKTeX 2.9\tex\latex\subfigure\subfigure.cfg")
\subfig@top=\skip48
\subfig@bottom=\skip49
)
("C:\Program Files\MiKTeX 2.9\tex\latex\cite\cite.sty"
LaTeX Info: Redefining \cite on input line 302.
LaTeX Info: Redefining \nocite on input line 332.
Package: cite 2015/02/27  v 5.5
)
("C:\Program Files\MiKTeX 2.9\tex\latex\multirow\multirow.sty"
Package: multirow 2016/11/25 v2.2 Span multiple rows of a table
\multirow@colwidth=\skip50
\multirow@cntb=\count92
\multirow@dima=\skip51
\bigstrutjot=\dimen105
)
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphicx.sty"
Package: graphicx 2014/10/28 v1.0g Enhanced LaTeX Graphics (DPC,SPQR)

("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\graphics.sty"
Package: graphics 2017/04/14 v1.1b Standard LaTeX Graphics (DPC,SPQR)

("C:\Program Files\MiKTeX 2.9\tex\latex\graphics\trig.sty"
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
)
("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-cfg\graphics.cfg"
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: dvips.def on input line 99.

("C:\Program Files\MiKTeX 2.9\tex\latex\graphics-def\dvips.def"
File: dvips.def 2016/07/10 v3.1a Driver-dependent file (DPC,SPQR)
))
\Gin@req@height=\dimen106
\Gin@req@width=\dimen107
) (iopams.sty
Package: iopams 1997/02/13 v1.0

("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsgen.sty"
File: amsgen.sty 1999/11/30 v2.0 generic functions
\@emptytoks=\toks16
\ex@=\dimen108
)
("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amsfonts.sty"
Package: amsfonts 2013/01/14 v3.01 Basic AMSFonts support
\symAMSa=\mathgroup4
\symAMSb=\mathgroup5
LaTeX Font Info:    Overwriting math alphabet `\mathfrak' in version `bold'
(Font)                  U/euf/m/n --> U/euf/b/n on input line 106.
)
("C:\Program Files\MiKTeX 2.9\tex\latex\amsfonts\amssymb.sty"
Package: amssymb 2013/01/14 v3.01 AMS font symbols
)
("C:\Program Files\MiKTeX 2.9\tex\latex\amsmath\amsbsy.sty"
Package: amsbsy 1999/11/29 v1.2d Bold Symbols
\pmbraise@=\dimen109
))
("C:\Program Files\MiKTeX 2.9\tex\latex\adjustbox\adjustbox.sty"
Package: adjustbox 2012/05/21 v1.0 Adjusting TeX boxes (trim, clip, ...)

("C:\Program Files\MiKTeX 2.9\tex\latex\xkeyval\xkeyval.sty"
Package: xkeyval 2014/12/03 v2.7a package option processing (HA)

("C:\Program Files\MiKTeX 2.9\tex\generic\xkeyval\xkeyval.tex"
("C:\Program Files\MiKTeX 2.9\tex\generic\xkeyval\xkvutils.tex"
\XKV@toks=\toks17
\XKV@tempa@toks=\toks18
)
\XKV@depth=\count93
File: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)
))
("C:\Program Files\MiKTeX 2.9\tex\latex\adjustbox\adjcalc.sty"
Package: adjcalc 2012/05/16 v1.1 Provides advanced setlength with multiple back
-ends (calc, etex, pgfmath)
)
("C:\Program Files\MiKTeX 2.9\tex\latex\adjustbox\trimclip.sty"
Package: trimclip 2012/05/16 v1.0 Trim and clip general TeX material

("C:\Program Files\MiKTeX 2.9\tex\latex\collectbox\collectbox.sty"
Package: collectbox 2012/05/17 v0.4b Collect macro arguments as boxes
\collectedbox=\box26
)
\tc@llx=\dimen110
\tc@lly=\dimen111
\tc@urx=\dimen112
\tc@ury=\dimen113
Package trimclip Info: Using driver 'tc-dvips.def'.

("C:\Program Files\MiKTeX 2.9\tex\latex\adjustbox\tc-dvips.def"
File: tc-dvips.def 2012/05/13 v1.0 Clipping driver for dvips
))
\adjbox@Width=\dimen114
\adjbox@Height=\dimen115
\adjbox@Depth=\dimen116
\adjbox@Totalheight=\dimen117

("C:\Program Files\MiKTeX 2.9\tex\latex\ifoddpage\ifoddpage.sty"
Package: ifoddpage 2016/04/23 v1.1 Conditionals for odd/even page detection
\c@checkoddpage=\count94
)
("C:\Program Files\MiKTeX 2.9\tex\latex\ltxmisc\varwidth.sty"
Package: varwidth 2009/03/30 ver 0.92;  Variable-width minipages
\@vwid@box=\box27
\sift@deathcycles=\count95
\@vwid@loff=\dimen118
\@vwid@roff=\dimen119
))
("C:\Program Files\MiKTeX 2.9\tex\latex\was\upgreek.sty"
Package: upgreek 2003/02/12 v2.0 (WaS)
Package upgreek Info: Using Euler Roman for upright Greek on input line 31.
\symugrf@m=\mathgroup6
LaTeX Font Info:    Overwriting symbol font `ugrf@m' in version `bold'
(Font)                  U/eur/m/n --> U/eur/b/n on input line 38.
)
(C:\Users\zhang\AppData\Roaming\MiKTeX\2.9\tex\generic\tex4ht\tex4ht.4ht
version 2009-01-07-07:11
--------------------------------------
--- Note --- for additional information, use the command line option `info'
--------------------------------------

::::::::::::::::::::::::::::::::::::::::::
 TeX4ht info is available in the log file 
::::::::::::::::::::::::::::::::::::::::::
) (C:\Users\zhang\AppData\Roaming\MiKTeX\2.9\tex\generic\tex4ht\tex4ht.sty
version 2008-10-27-17:23

--- needs --- tex4ht Fancypattern ---
\tmp:cnt=\count96
\openout15 = `Fancypattern.tmp'.

(Fancypattern.tmp)
\tmp:dim=\skip52
--------------------------------------
--- Note --- for XML code, use the command line option `xml' or `xhtml'
--------------------------------------
 (Fancypattern.xref
Runaway argument?
{\GenericError { }{LaTeX Error: No \let \reserved@d =[\def \def docum\ETC.
! Paragraph ended before \:CrsWrd was complete.
<to be read again> 
                   \par 
l.2 ...voidb@x \futurelet \:temp \def \:temp {\par
                                                   }\:temp \relax \xdef {0}{...

? 

! LaTeX Error: Missing \begin{document} in `'.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.2 ...\futurelet \:temp \def \:temp {\par }\:temp
                                                   \relax \xdef {0}{}{{2}{{0...

? 
! Missing control sequence inserted.
<inserted text> 
                \inaccessible 
l.2 ...mp \def \:temp {\par }\:temp \relax \xdef {
                                                  0}{}{{2}{{0}{}}}}\def \bgr...

? 
! Too many }'s.
l.2 ...par }\:temp \relax \xdef {0}{}{{2}{{0}{}}}}
                                                  \def \bgroup \def \:temp {...

? 
! Too many }'s.
l.2 ...t 2\afterassignment \xdef \:temp {1}\egroup
                                                   \mth:op \tmp:cnt {\gdef \...

? 
! Undefined control sequence.
l.2 ...rassignment \xdef \:temp {1}\egroup \mth:op
                                                   \tmp:cnt {\gdef \ht:every...

? 
! Missing number, treated as zero.
<to be read again> 
                   {
l.2 ... \xdef \:temp {1}\egroup \mth:op \tmp:cnt {
                                                  \gdef \ht:everypar {\relax...

? 
! Missing control sequence inserted.
<inserted text> 
                \inaccessible 
l.2 ... \xdef \:temp {1}\egroup \mth:op \tmp:cnt {
                                                  \gdef \ht:everypar {\relax...

? 
! Too many }'s.
l.2 ...t 2\afterassignment \xdef \:temp {1}\egroup
                                                   \mth:op \tmp:cnt {\ht:eve...

? 
! Undefined control sequence.
l.2 ...rassignment \xdef \:temp {1}\egroup \mth:op
                                                   \tmp:cnt {\ht:everypar {}...

? 
! Missing number, treated as zero.
<to be read again> 
                   {
l.2 ... \xdef \:temp {1}\egroup \mth:op \tmp:cnt {
                                                  \ht:everypar {}}\xdef \glo...

? 
! Missing control sequence inserted.
<inserted text> 
                \inaccessible 
l.2 ... \xdef \:temp {1}\egroup \mth:op \tmp:cnt {
                                                  \ht:everypar {}}\xdef \glo...

? 
! Missing { inserted.
l.2 ...:cnt {\ht:everypar {}}\xdef \global \let  }
                                                   }
? 
! Too many }'s.
l.2 ...nt {\ht:everypar {}}\xdef \global \let  } }

? 
! Use of \bgroup doesn't match its definition.
\:CrossWord ->\bgroup \no:catcodes 
                                   {128}{255}{12}\catcode `\: 12 \catcode `\...
l.3 \:CrossWord
               {)Qx1-10001}{1}{2}%
? 
! Too many }'s.
\:CrsWrd #1#2#3->\egroup 
                         \sv:crs {#1}{#2}{#3}
l.3 \:CrossWord{)Qx1-10001}{1}{2}
                                 %
? 
! Missing $ inserted.
<inserted text> 
                $
l.4 \:
      CrossWord{1cAp0}{x1-10011}{4}%
? 
! Use of global doesn't match its definition.
extract@font ...@external@font global expandafter 
                                                  font font@name external@fo...
l.4 \:
      CrossWord{1cAp0}{x1-10011}{4}%
? 
! Use of global doesn't match its definition.
extract@font ...@external@font global expandafter 
                                                  font font@name external@fo...
l.4 \:
      CrossWord{1cAp0}{x1-10011}{4}%
? 
! Use of global doesn't match its definition.
extract@font ...@external@font global expandafter 
                                                  font font@name external@fo...

但是当我将其编译为 pdf 文件时绝对没有错误。谁能告诉我发生了什么?也许我应该为 HTlatex 创建一个特殊的配置文件?

答案1

正如我在我的上一个答案,主要问题是iopart该类重新定义了许多标准 LaTeX 宏,甚至更改了它们可能采用的参数。其中一些问题可以在的配置文件中解决tex4ht,但有些问题需要在类本身中修复。

我只修复了最明显的问题:

  • \maketitle导致tex4ht致命错误

  • 标题命令产生错误格式

  • 分段命令在使用前会在线产生虚假数字

  • \br命令导致编译错误

除部分问题之外的所有问题都可以在配置文件中修复。

文件iopart.4ht

\input article.4ht

\let\maketitle\relax
\let\br\hline

\NewConfigure{title}{2}
\Configure{title}{\ifvmode\IgnorePar\fi\EndP\HCode{<h2 class="titleHead">}\NoFonts}{\ifvmode\IgnorePar\fi\EndP\EndNoFonts\HCode{</h2>\Hnewline}}

\NewConfigure{author}{2}
\Configure{author}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="author">}\NoFonts}{\ifvmode\IgnorePar\fi\EndP\EndNoFonts\HCode{</div>\Hnewline}}

\NewConfigure{address}{2}
\Configure{address}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="address">}\NoFonts}{\EndNoFonts\ifvmode\IgnorePar\fi\EndP\HCode{</div>\Hnewline}}

\NewConfigure{pacs}{2}
\Configure{pacs}{\ifvmode\IgnorePar\fi\EndP\HCode{<div class="pacs">}\NoFonts}{\EndNoFonts\ifvmode\IgnorePar\fi\EndP\HCode{</div>\Hnewline}}

% \let\s:title\@stitle
\def\@stitle[#1]#2{\a:title{#2}\b:title}

% \let\f:title\@ftitle
\def\@ftitle#1{\a:title{#1}\b:title}

\def\@sauthor[#1]#2{\a:author#2\b:author}
\def\@fauthor#1{\a:author#1\b:author}

\def\pacs#1{\a:pacs PACS numbers: #1\b:pacs\par}

\renewcommand\address[1]{\a:address#1\b:address}

\renewenvironment{abstract}{\textbf{\abstractname.}}{}
\Css{div.abstract{font-size:0.8rem;}}
\Css{div.address{text-align:center;}}


\Hinput{iopart}
\endinput

部分问题需要在 中修复iopart.cls。似乎部分默认宏被重新定义,以便在部分计数器的最后一个数字后获得点。

以下代码:

\def\@sect#1#2#3#4#5#6[#7]#8{\ifnum #2>\c@secnumdepth
     \let\@svsec\@empty\else
     \refstepcounter{#1}
     \edef\@svsec{\csname the#1\endcsname. }
     \fi
     \@tempskipa #5\relax
      \ifdim \@tempskipa>\z@
        \begingroup #6\relax
          \noindent{\hskip #3\relax\@svsec
          }%
          {\interlinepenalty \@M #8\par}%
        \endgroup
       \csname #1mark\endcsname{#7}\addcontentsline
         {toc}{#1}{\ifnum #2>\c@secnumdepth \else
                      \protect\numberline{\csname the#1\endcsname}\fi
                    #7}\else
        \def\@svsechd{#6\hskip #3\relax  %% \relax added 2 May 90
                   \@svsec #8\csname #1mark\endcsname
                      {#7}\addcontentsline
                           {toc}{#1}{\ifnum #2>\c@secnumdepth \else
                             \protect\numberline{\csname the#1\endcsname}\fi
                       #7}}\fi
     \@xsect{#5}}
%
\def\@ssect#1#2#3#4#5{\@tempskipa #3\relax
   \ifdim \@tempskipa>\z@
     \begingroup #4\noindent{\hskip #1}{\interlinepenalty \@M #5\par}\endgroup
   \else \def\@svsechd{#4\hskip #1\relax #5}\fi
    \@xsect{#3}}

可以替换为

 \renewcommand{\@seccntformat}[1]{\csname the#1\endcsname.\quad}

它的作用是相同的,但不会中断tex4ht

经过这些更改后,文档如下所示:

在此处输入图片描述

相关内容