目前的问题在于使用化学软件包进行排版。正如预期的那样,PDF 生成没有任何问题,但使用 tex4ht 生成 html 时出现了明显问题。
HTML 文件编译得很好,对我来说没有任何危险信号(除了尝试加载chemmacros
包) 但是预期和所需的子文本和超级文本脚本未成功排版。
正在使用以下命令从 BAT 文件编译文档,即使可以省略整个“...”部分并获得相同的结果...
htlatex html_chem_textScripts.tex "html,mathplayer,early^,early_"
内容html_chem_textScripts.tex
:
\documentclass{report}
\usepackage{verbatim}
\usepackage{enumitem}
\usepackage{siunitx}
\usepackage[version=3]{mhchem} % Package for chemical equation typesetting - needs to be before math loads
\DeclareSIUnit{\Co}{Co^{2+}}
\DeclareSIUnit{\Coe}{\ce{Co^{2+}}}
\ifdefined\HCode
% no alternative known at this point
\else
\usepackage{chemmacros}
\fi
\newcommand{\degC}{$\,^{\circ}\mathrm{C}$ }
\begin{document}
Investigating superscripts in html via htlatex. Problems observed siunitx packages (only pacakges tested so far other than math mode and chemmacros)
\begin{itemize}[noitemsep] % sets no itemsep for just this list
\item \si{\Co} using siunitx unit to typset
\item \si{\Coe} using siunnitx to typset with the ce command embedded.
\item $Co^{2+}$ produced in math mode
\item \ce{Co^{2+}} mhchem package
\item \ce{Co^2+} mhchem package without extra curly braces to group exponential
\end{itemize}
Bigger problem with chemmacros package \medskip
\ifdefined\HCode
\begin{verbatim}
chemmacros pacakge can't compile a \ch{Co2+} string in htlatex. Note. Package can't even be loaded...
Error produced:
! Undefined control sequence.
\pgfsys@svg@newline ->\Hnewline
l.190 \pgfusepathqfill}
?
\end{verbatim}
\else
Using chemmacros package, a nicely formated chemical equation can be produced in pdf mode, \ch{Co^2+} but throws a pdf error in html mode.
\fi
\end{document}
从下面的 HTML 代码可以看出,当从mhchem
包,但 2+ 在代码括号之外,这表明这一次,它不是浏览器或数学脚本库的问题,而是一种编译方法,如果有一个配置文件或包选项可以让它与 tex4ht 一起工作,这种方法可能会受益。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html >
<head><title></title><script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=MML_HTMLorMML"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<meta name="originator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)">
<!-- html,mathplayer,early,early_ -->
<meta name="src" content="html_chem_textScripts.tex">
<meta name="date" content="2015-01-14 18:01:00">
<link rel="stylesheet" type="text/css" href="html_chem_textScripts.css">
</head><body
>
<!--l. 23--><p class="noindent" >Investigating superscripts in html via htlatex. Problems observed siunitx packages
(only pacakges tested so far other than math mode and chemmacros)
<ul class="itemize1">
<li class="itemize">Co<sup class="textsuperscript"><span
class="cmr-9">2+</span></sup> using siunitx unit to typset
</li>
<li class="itemize">Co<sub></sub>2+ using siunnitx to typset with the ce command embedded.
</li>
<li class="itemize"><span
class="cmmi-10">Co</span><sup><span
class="cmr-7">2+</span></sup> produced in math mode
</li>
<li class="itemize">Co<sub></sub>2+ mhchem package
</li>
<li class="itemize">Co<sub></sub>2+ mhchem package without extra curly braces to group exponential</li></ul>
<!--l. 33--><p class="indent" > Bigger problem with chemmacros package
<div class="verbatim" id="verbatim-1">
chemmacros pacakge can’t compile a \ch{Co2+} string in htlatex.  Note.  Package can’t even be loaded...
 <br />
 <br />
 <br />Error produced:
 <br />
 <br />! Undefined control sequence.
 <br />\pgfsys@svg@newline ->\Hnewline
 <br />
 <br />l.190   \pgfusepathqfill}
 <br />
 <br />?
</div>
<!--l. 48--><p class="nopar" >
</body></html>
我是否错过了这些软件包的文档(siunitx
,mhchem
,以及chemmacros
)在加载专门针对 TeX4ht 的包时配置/指定的选项,以应用/修复已知的 HTML 要求?我在xcolor
,graphicx
, 和hyperref
仅举几例。
注意:我还假设我对某些选项做的不太正确,htlatex
例如early^
因为无论是否使用它都没有区别。