我正在尝试在这里完成我之前的请求:使用 siunitx 时 htlatex 崩溃
为了便于理解,我正尝试使用 将用 .tex 编写的手稿转换为 .odt 文件make4ht
。我使用的是 Linux Mint 和 pdfTeX 3.141592653-2.6-1.40.25 (TeX Live 2023)。
这是我的 MWE:
\documentclass[a4paper,12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[top=2.0cm, left=1.0cm, right=1.5cm]{geometry}
\usepackage[affil-it]{authblk}
%\renewcommand*{\Authfont}{\raggedright}
\renewcommand*{\Affilfont}{\normalsize\raggedright}
\usepackage{booktabs} %For \toprule, \midrule and \bottomrule in tables
\usepackage[flushleft]{threeparttable} %For a more structured tables
\AtBeginEnvironment{tablenotes}{\scriptsize}
\usepackage{caption}
\captionsetup{justification=justified,
singlelinecheck=false,format=hang}
\usepackage{multirow}
\usepackage[version=4]{mhchem}
\title{Germination of Avocado using special germination media}
\author[1]{Ermando Sandoval}
\affil[1]{University of Glastoc, Mirano Institute}
\usepackage{siunitx}
\sisetup{mode=text}
\sisetup{range-units = single}
\sisetup{separate-uncertainty}
\sisetup{inter-unit-product=\textperiodcentered}
\sisetup{open-bracket=\, ,
close-bracket=\,}
\sisetup{tight-spacing=true}
\sisetup{print-unity-mantissa=false}
\sisetup{retain-zero-uncertainty=true}
\sisetup{separate-uncertainty-units=single}
\sisetup{group-separator = {,}}
\DeclareSIUnit\cells{cells}
\begin{document}
\maketitle
There are \qty{3.25(2)e12}{\cells\per\milli\litre} in this sample.
The results are provided in Table \ref{Tab1} below.
\begin{table}[h!]
\begin{threeparttable}
\caption{This is a test table. Let's see how this renders in the odt.} \label{Tab1}
\begin{tabular}{l l S S c S S}
\toprule
\multirow{2}{*}{\textbf{Groups}} & \multirow{2}{*}{\textbf{Compounds}} & \multicolumn{2}{c}{\textbf{Potential}} & & \multicolumn{2}{c}{\textbf{Discovery}}\\
\cline{3-4} \cline{6-7}
& & \textbf{Perm} & \textbf{Tab} & & \textbf{Perm} & \textbf{Tab} \\
\midrule
\multirow{3}{*}{Amines} & methylamine& 16.5(2) & 18.6(26) & & 49 & 62.1(2)\\
& ethylamine &6.5\tnote{a} & {N/A} & & 0.2(0) & 0.6(1)\\
& tert-butyl amine&15.6 & 88 & & 55.5(156) & 26\\
\midrule
\multirow{3}{*}{Salts} & \ce{NaCl} & 99.6(2) & {N/A} & & 12 & 16.8(15)\\
& \ce{CaCO3} & 6.5(1) & {N/A} & & 15 & 19.2(35)\\
& \ce{(NH4)2SO4}& 16.2(16) & {N/A} & & 49 & 69.6(12)\\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item[a] Significantly low.
\item N/A = sample loss
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
当我执行此操作时,它会以 pdf 格式向我提供以下输出:
我尝试使用以下命令获取 .odt 文件:make4ht -c config.cfg -f odt Test.tex
,其中config.cfg
包含:
\RequirePackage{color}
\Preamble{xhtml}
\begin{document}
\EndPreamble
但在.odt 文件中得到以下输出:
在正常文本中,不确定性显示为粘贴文本,指数显示不正确。标题、表注和表格内容也丢失了。
在终端上,我得到以下输出:
[STATUS] make4ht: Conversion started
[STATUS] make4ht: Input file: Test.tex
[ERROR] htlatex: Compilation errors in the htlatex run
[ERROR] htlatex: Filename Line Message
[ERROR] htlatex: ./Test.tex 75 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 75 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 88 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 88 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 88 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 88 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 89 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 89 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 89 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 89 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 90 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 90 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 90 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 90 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 92 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 92 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 93 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 93 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 93 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 93 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 94 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 94 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 94 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 94 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 95 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 95 Missing $ inserted.
[ERROR] htlatex: Compilation errors in the htlatex run
[ERROR] htlatex: Filename Line Message
[ERROR] htlatex: ./Test.tex 75 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 75 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 88 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 88 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 88 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 88 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 89 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 89 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 89 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 89 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 90 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 90 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 90 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 90 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 92 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 92 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 93 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 93 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 93 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 93 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 94 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 94 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 94 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 94 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 95 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 95 Missing $ inserted.
[ERROR] htlatex: Compilation errors in the htlatex run
[ERROR] htlatex: Filename Line Message
[ERROR] htlatex: ./Test.tex 75 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 75 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 88 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 88 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 88 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 88 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 89 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 89 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 89 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 89 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 90 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 90 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 90 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 90 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 92 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 92 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 93 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 93 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 93 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 93 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 94 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 94 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 94 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 94 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 95 Missing $ inserted.
[ERROR] htlatex: ./Test.tex 95 Missing $ inserted.
[STATUS] make4ht: Conversion finished
答案1
为了实现此功能,需要修复 TeX4ht 中的几个问题。
首先,Siunitx 支持存在两个问题。一个是该tight-spacing
选项会导致编译错误,另一个是由S
表格中的列引起的,因为它导致表格完全混乱。这两个问题都可以使用此配置文件修复siunitx.4ht
:
% siunitx.4ht (2024-01-22-12:04), generated from tex4ht-4ht.tex
% Copyright 2021-2024 TeX Users Group
%
% 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".
%
% The Current Maintainer of this work
% is the TeX4ht Project <http://tug.org/tex4ht>.
%
% If you modify this program, changing the
% version identification would be appreciated.
\immediate\write-1{version 2024-01-22-12:04}
\RequirePackage{color}
\ExplSyntaxOn
\cs_set_protected:Npn \__siunitx_angle_arc_print_auxv_fourht:w
#1 \q_nil #2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_stop
{\bgroup\siunitx_print_number:n {#1#2#3#4#5}\egroup}
\HLet\__siunitx_angle_arc_print_auxv:w\__siunitx_angle_arc_print_auxv_fourht:w
\cs_set_protected:Npn \__siunitx_angle_arc_print_auxvi_fourht:n #1
{
% we need to define these commands here
\def\degree{\ht:special{t4ht@+&{35}x2218;}x}
\def\arcminute{\prime}
\def\arcsecond{\prime\prime}
\ensuremath{\NoFonts\sp{#1}\EndNoFonts}
}
\HLet\__siunitx_angle_arc_print_auxvi:n\__siunitx_angle_arc_print_auxvi_fourht:n
% https://tex.stackexchange.com/q/707485/2891
\bool_set_false:N \l__siunitx_number_tight_bool
% disable S columns for tables
% https://tex.stackexchange.com/q/707485/2891
\cs_set_protected:Npn \siunitx_cell_begin:w {}
\cs_set_protected:Npn \siunitx_cell_end: {}
\ExplSyntaxOff
\Hinput{siunitx}
\endinput
该软件包还存在另一个问题mhchem
。它分发了自己的配置文件,mhchem.4ht
其中包含硬编码的 HTML 元素。因此,化学元素不会显示在 ODT 输出中。此版本mhchem.4ht
应该可以解决该问题:
%% mhchem.4ht
%% 2021-12-31
%% Copyright 2015-2021 Martin Hensel
%
%% This file is part of the mhchem bundle for LaTeX
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c
% which is included as lppl-1-3c.txt.
%
% This work has the LPPL maintenance status "maintained".
% The Current Maintainer of this work is Martin Hensel.
%
% ( In order to fight spam, the maintainer's contact )
% ( information is "encrypted" with ROT13. )
% ( If you do not know ROT13 yet and have no tool for )
% ( decryption, simply do an Internet search for "ROT13". )
%
% ,---[ ROT 13 ]---
% | Gur Pheerag Znvagnvare bs guvf jbex vf Znegva Urafry
% | jub pna or pbagnpgrq ivn
% | [email protected]
% | be ivn znvy
% | Znegva Urafry
% | Cbfgfge. 20
% | 09232 Unegznaafqbes
% | Treznal
% `----------
%
% This work consists of all files listed in manifest.txt.
%
%
\ExplSyntaxOn
\Css
{
.mhchem ~ .mhchem-cf { white-space: nowrap; }
.mhchem ~ .mhchem-isotope { font-size: 0.65em; line-height: 1; display: inline-block; vertical-align: sub; text-align: right; }
.mhchem ~ .mhchem-supsub { font-size: 0.65em; line-height: 1; display: inline-block; vertical-align: sub; }
.mhchem ~ .mhchem-sup { font-size: 0.65em; line-height: 1; display: inline-block; vertical-align: 68\%; }
.mhchem ~ .mhchem-sub { font-size: 0.65em; line-height: 1; display: inline-block; vertical-align: sub; }
.mhchem ~ .mhchem-rlap { display: inline-block; width: 0; }
.mhchem ~ .mhchem-bond-half-top { vertical-align: 60\%; }
.mhchem ~ .mhchem-bond-half-middle { vertical-align: 35\%; }
.mhchem ~ .mhchem-bond-top { vertical-align: 20\%; }
.mhchem ~ .mhchem-bond-bottom { vertical-align: -20\%; }
.mhchem ~ .mhchem-arrow { display: inline-flex; flex-direction: column; vertical-align: middle; }
.mhchem ~ .mhchem-arrow > span { line-height: 80\%; text-align: center; }
.mhchem ~ .mhchem-arrow > .mhchem-above { min-height: 1em; font-size: 60\%; }
.mhchem ~ .mhchem-arrow > .mhchem-below { min-height: 1em; font-size: 60\%; }
.mhchem ~ .mhchem-arrow > span.mhchem-arrow-normal { line-height: 40\%; }
.mhchem ~ .mhchem-arrow > span.mhchem-arrow-larger { line-height: 25\%; font-size: 150\%; }
.mhchem ~ .mhchem-arrow > span.mhchem-arrow-complement { line-height: 25\%; }
}
% basic mhchem containers
\NewConfigure{mhchemce}{2}
\NewConfigure{mhchemcf}{2}
\pend:def\__mhchem_output_begin_ce:{\a:mhchemce}
\append:def\__mhchem_output_end_ce:{\b:mhchemce}
\pend:def\__mhchem_output_begin_cf:{\a:mhchemcf}
\append:def\__mhchem_output_end_cf:{\b:mhchemcf}
\Configure{mhchemcf}{\HCode{<span~class="mhchem">}}{\HCode{</span>}}
\Configure{mhchemce}{\HCode{<span~class="mhchem">}}{\HCode{</span>}}
% alternative version of coreFivd
\NewConfigure{mhchemisotope}{3}
\Configure{mhchemisotope}{\HCode{<span~class="mhchem-isotope">}}{\HCode{<br~/>&\#xfeff;}}{\HCode{</span>}}
\NewConfigure{mhchemsub}{2}
\Configure{mhchemsub}{\HCode { <sub~class="mhchem-sub"> }}{\HCode { </sub> } }
\NewConfigure{mhchemsup}{2}
\Configure{mhchemsup}{\HCode { <sup~class="mhchem-sup"> }}{\HCode { </sup> } }
\cs_set_protected:Npn \__mhchem_output_coreFivefourht:nnnnnnn #1#2#3#4#5#6#7
{
\bool_if:nT
{ \tl_if_empty_p:n {#7} && ! \tl_if_empty_p:n {#5} }
{ \bool_set_true:N \l__mhchem_option_superscriptsStacked_bool }
\tl_if_empty:nF {#1#2}
{
\a:mhchemisotope
\__mhchem_output_withFont:n { #1 }
\b:mhchemisotope
\__mhchem_output_withFont:n { #2 }
\c:mhchemisotope
}
\__mhchem_output_withFont:n { #3 }
\bool_if:NTF \l__mhchem_option_superscriptsStacked_bool
{
\tl_if_empty:nTF {#4#5#7}
{
\tl_if_empty:nF {#6}
{
\a:mhchemsub
\__mhchem_output_withFont:n { #6 }
\b:mhchemsub
}
}
{
\tl_if_empty:nTF {#6}
{
\a:mhchemsup
\__mhchem_output_withFont:n { #4#5#7 }
\b:mhchemsup
}
{
\HCode { <span~class="mhchem-supsub"> }
\__mhchem_output_withFont:n { #4#5#7 }
\HCode { <br~/>&\#xfeff; }
\__mhchem_output_withFont:n { #6 }
\HCode { </span> }
}
}
}
{
\tl_if_empty:nF {#4}
{
\a:mhchemsup
\__mhchem_output_withFont:n { #4 }
\b:mhchemsup
}
\tl_if_empty:nF {#6}
{
\a:mhchemsub
\__mhchem_output_withFont:n { #6 }
\b:mhchemsub
}
\tl_if_empty:nF {#5#7}
{
\a:mhchemsup
\__mhchem_output_withFont:n { #5#7 }
\b:mhchemsup
}
}
}
% replace original coreFive with our alternative version. it will work in picture math
\HLet\__mhchem_output_coreFive:nnnnnnn\__mhchem_output_coreFivefourht:nnnnnnn
\cs_set_protected:Npn \__mhchem_output_withFont:n #1 %. output #1 as math or text
{
\bool_if:NTF \l__mhchem_output_isMathMode_bool
{ \mathrm {#1} }
{ \text {#1} }
}
\NewConfigure{mhchemoperator}{2}
\Configure{mhchemoperator}{\HCode { <span~class="mhchem-operator"> ~ }}{\HCode { ~ </span> }}
% ideally, the following commands should be redefined using \HLet, to support picture math.
% the current definition should work in MathML, I am not sure about normall HTML, as
\cs_set_protected:Npn \__mhchem_output_skipAfterAmount: { \HCode { ~ } } % space for copy & paste
\cs_set_protected:Npn \__mhchem_output_skipBeforeStateOfAggregation: {}
\cs_set_protected:Npn \__mhchem_output_minus: { \HCode { − } }
\cs_set_protected:Npn \__mhchem_output_operatorPlus:
{ \a:mhchemoperator + \b:mhchemoperator }
\cs_set_protected:Npn \__mhchem_output_operatorMinus:
{ \a:mhchemoperator\HCode {−} \b:mhchemoperator }
\cs_set_protected:Npn \__mhchem_output_operatorEquals:
{ \a:mhchemoperator = \b:mhchemoperator }
\cs_set_protected:Npn \__mhchem_output_operatorPlusMinus:
{\a:mhchemoperator \HCode {± } \b:mhchemoperator }
\cs_set_protected:Npn \__mhchem_output_electronDot: { \HCode { • } }
\cs_set_protected:Npn \__mhchem_output_additionCompound: { \HCode { · } }
\cs_set_protected:Npn \__mhchem_output_excited: { \HCode { &\#x2731; } }
\cs_set_protected:Npn \__mhchem_output_commaDecimal: { , }
\cs_set_protected:Npn \__mhchem_output_commaEnumeration: { , \HCode {   } }
\cs_set_protected:Npn \__mhchem_output_commaEnumerationSmall: { , \HCode {   } }
\cs_set_protected:Npn \__mhchem_output_bond_single: { \HCode { − } }
\cs_set_protected:Npn \__mhchem_output_bond_double: { \HCode { = } }
\cs_set_protected:Npn \__mhchem_output_bond_triple: { \HCode { ≡ } }
% todo: add MathML support for these
\cs_set_protected:Npn \__mhchem_output_bond_half: % todo: improve
{ \HCode { <span~class="mhchem-bond-half-middle">&\#xfe4d;</span> } }
\cs_set_protected:Npn \__mhchem_output_bond_oneAndHalf: % todo: improve
{ \HCode { <span~class="mhchem-rlap">−</span><span~class="mhchem-bond-half-top">&\#xfe4d;</span> } }
\cs_set_protected:Npn \__mhchem_output_bond_twoAndHalf: % todo: improve
{ \HCode { <span~class="mhchem-rlap">=</span><span~class="mhchem-bond-half-top">&\#xfe4d;</span> } }
\cs_set_protected:Npn \__mhchem_output_bond_twoAndHalff: % todo: improve
{ \HCode { <span~class="mhchem-rlap~mhchem-bond-top">−</span><span~class="mhchem-rlap~mhchem-bond-bottom">−</span><span~class="mhchem-bond-half-middle">&\#xfe4d;</span> } }
\cs_set_protected:Npn \__mhchem_output_bond_dotdotdot: { \HCode { ··· } }
\cs_set_protected:Npn \__mhchem_output_bond_dotdotdotdot: { \HCode { ···· } }
\cs_set_protected:Npn \__mhchem_output_bond_rightArrow: { \HCode { &\#xffeb; } }
\cs_set_protected:Npn \__mhchem_output_bond_leftArrow: { \HCode { &\#xffe9; } }
\NewConfigure{mhchemarrow}{2}
\NewConfigure{mhchemarrowabove}{2}
\NewConfigure{mhchemarrowyields}{1}
\NewConfigure{mhchemarrowyieldsLeft}{1}
\NewConfigure{mhchemarrowyieldsLeftRight}{1}
\NewConfigure{mhchemarrowmesomerism}{1}
\NewConfigure{mhchemarrowequilibrium}{1}
\NewConfigure{mhchemarrowequilibriumRight}{1}
\NewConfigure{mhchemarrowequilibriumLeft}{1}
\Configure{mhchemarrow}{\HCode {<span~class="mhchem-arrow">}}{\HCode{</span>}}
\Configure{mhchemarrowabove}{\HCode { <span~class="mhchem-above">}}{\HCode{</span>}}
\Configure{mhchemarrowyields}{ \HCode { <span~class="mhchem-arrow-normal">&\#x27F6;</span> } }
\Configure{mhchemarrowyieldsLeft}{ \HCode { <span~class="mhchem-arrow-normal">&\#x2190;</span> } }
\Configure{mhchemarrowyieldsLeftRight}{ \HCode { <span~class="mhchem-arrow-normal">&\#x21c4;</span> } } % todo: improve
\Configure{mhchemarrowmesomerism}{ \HCode { <span~class="mhchem-arrow-normal">&\#x2194;</span> } } % todo: improve
\Configure{mhchemarrowequilibrium}{ \HCode { <span~class="mhchem-arrow-normal">&\#x21cc;</span> } } % todo: improve
\Configure{mhchemarrowequilibriumRight}{ \HCode { <span~class="mhchem-arrow-larger">&\#x21c0;</span><span~class="mhchem-arrow-complement">&\#x21bd;</span> } } % todo: improve
\Configure{mhchemarrowequilibriumLeft}{ \HCode { <span~class="mhchem-arrow-complement">&\#x21c0;</span><span~class="mhchem-arrow-larger">&\#x21bd;</span> } } % todo: improve
\cs_set_protected:Npn \__mhchem_arrow_deployfourht:nnnnn #1#2#3#4#5
{
\a:mhchemarrow
\tl_if_empty:nF {#3#5}
{
\a:mhchemarrowabove
\str_case:nnF {#2}
{
{ } { \ce { #3 } }
{ M } { \ensuremath { #3 } }
{ T } { \text { #3 } }
{ C } { \ce { #3 } }
}
{ \msg_error:nnn { mhchem } { unexpected-arrow-type } {#2} }
\b:mhchemarrowabove
}
\str_case:nnF {#1}
{
{ yields } {\a:mhchemarrowyields }
{ yieldsLeft } {\a:mhchemarrowyieldsLeft }
{ yieldsLeftRight } {\a:mhchemarrowyieldsLeftRight } % todo: improve
{ esomerism } {\a:mhchemarrowesomerism } % todo: improve
{ equilibrium } {\a:mhchemarrowequilibrium } % todo: improve
{ equilibriumRight } {\a:mhchemarrowequilibriumRight } % todo: improve
{ equilibriumLeft } {\a:mhchemarrowequilibriumLeft } % todo: improve
}
{ \msg_error:nnn { mhchem } { unexpected-arrow-type } {#1} }
\tl_if_empty:nF {#3#5}
{
\a:mhchemarrowabove
\str_case:nnF {#2}
{
{ } { \ce { #5 } }
{ M } { \ensuremath { #5 } }
{ T } { \text { #5 } }
{ C } { \ce { #5 } }
}
{ \msg_error:nnn { mhchem } { unexpected-arrow-type } {#2} }
\b:mhchemarrowabove
}
\b:mhchemarrow
}
\HLet\__mhchem_arrow_deploy:nnnnn\__mhchem_arrow_deployfourht:nnnnn
\ExplSyntaxOff
% Additional configurations for MathML
% print mathml command or html, depending on if we are inside mathml or not
\newcommand\:mhmathmlorhtml[2]{\ifmathml\a:mathml #1\else #2\fi}
\newcommand\:mhonlyinmathml[1]{\ifmathml #1\fi}
\:CheckOption{mathml}
\if:Option
\Configure{mhchemcf}{\HCode{<\:mhmathmlorhtml{mrow}{span}\space class="mhchem-cf">}}{\HCode{</\:mhmathmlorhtml{mrow}{span}>}}
\Configure{mhchemce}{\HCode{<\:mhmathmlorhtml{mrow}{span}\space class="mhchem-ce">}}{\HCode{</\:mhmathmlorhtml{mrow}{span}>}}
\Configure{mhchemsub}{%
\:mhmathmlorhtml{%
\Send{BACK}%
{<\a:mathml msub><\a:mathml mrow\Hnewline>}%
\Tg</\a:mathml mrow>\Tg<\a:mathml mrow\Hnewline>\trap:base%
}{%
\HCode{<sub>}}%
}{\:mhmathmlorhtml{\Tg</\a:mathml mrow>\TG</\a:mathml msub\Hnewline>}{\HCode{</sub>}}}
\Configure{mhchemsup}{%
\:mhmathmlorhtml{
\Send{BACK}
{<\a:mathml msup><\a:mathml mrow\Hnewline>}%
\Tg</\a:mathml mrow>\Tg<\a:mathml mrow\Hnewline>\trap:base
}{%
\HCode{<sup>}}%
}{\:mhmathmlorhtml{\Tg</\a:mathml mrow>\TG</\a:mathml msup\Hnewline>}{\HCode{</sup>}}}
\Configure{mhchemoperator}{\HCode{<\:mhmathmlorhtml{mo}{span} class="mhchem-operator">}\PauseMathClass}{\EndPauseMathClass\HCode {</\:mhmathmlorhtml{mo}{span}>}}
\Configure{mhchemarrow}{\HCode {<\:mhmathmlorhtml{mrow}{span} class="mhchem-arrow">\:mhonlyinmathml{<mo>}}}{\HCode{\:mhonlyinmathml{</mo>}</\:mhmathmlorhtml{mrow}{span}>}}
\Configure{mhchemarrowabove}{\HCode { <\:mhmathmlorhtml{mrow}{span} class="mhchem-above">\:mhonlyinmathml{<mo>}}}{\HCode{\:mhonlyinmathml{</mo>}</\:mhmathmlorhtml{mrow}{span}>}}
\Configure{mhchemarrowyields}{ \HCode { <\:mhmathmlorhtml{mrow}{span} class="mhchem-arrow-normal">\:mhonlyinmathml{<mo>}&\#x2192;\:mhonlyinmathml{</mo>}</\:mhmathmlorhtml{mrow}{span}> } }
\Configure{mhchemarrowyieldsLeft}{ \HCode { <\:mhmathmlorhtml{mrow}{span} class="mhchem-arrow-normal">\:mhonlyinmathml{<mo>}&\#x2190;\:mhonlyinmathml{</mo>}</\:mhmathmlorhtml{mrow}{span}> } }
\Configure{mhchemarrowyieldsLeftRight}{ \HCode { <\:mhmathmlorhtml{mrow}{span} class="mhchem-arrow-normal">\:mhonlyinmathml{<mo>}&\#x21c4;\:mhonlyinmathml{</mo>}</\:mhmathmlorhtml{mrow}{span}> } } % todo: improve
\Configure{mhchemarrowmesomerism}{ \HCode { <\:mhmathmlorhtml{mrow}{span} class="mhchem-arrow-normal">\:mhonlyinmathml{<mo>}&\#x2194;\:mhonlyinmathml{</mo>}</\:mhmathmlorhtml{mrow}{span}> } } % todo: improve
\Configure{mhchemarrowequilibrium}{ \HCode { <\:mhmathmlorhtml{mrow}{span} class="mhchem-arrow-normal">\:mhonlyinmathml{<mo>}&\#x21cc;\:mhonlyinmathml{</mo>}</\:mhmathmlorhtml{mrow}{span}> } } % todo: improve
\Configure{mhchemarrowequilibriumRight}{ \HCode { <\:mhmathmlorhtml{mrow}{span} class="mhchem-arrow-larger">\:mhonlyinmathml{<mo>}&\#x21c0;\:mhonlyinmathml{</mo>}</\:mhmathmlorhtml{mrow}{span}><\:mhmathmlorhtml{mrow}{span} class="mhchem-arrow-complement">\:mhonlyinmathml{<mo>}&\#x21bd;\:mhonlyinmathml{</mo>}</\:mhmathmlorhtml{mrow}{span}> } } % todo: improve
\Configure{mhchemarrowequilibriumLeft}{ \HCode { <\:mhmathmlorhtml{mrow}{span} class="mhchem-arrow-complement">\:mhonlyinmathml{<mo>}&\#x21c0;\:mhonlyinmathml{</mo>}</\:mhmathmlorhtml{mrow}{span}><\:mhmathmlorhtml{mrow}{span} class="mhchem-arrow-larger">\:mhonlyinmathml{<mo>}&\#x21bd;\:mhonlyinmathml{</mo>}</\:mhmathmlorhtml{mrow}{span}> } } % todo: improve
\else
\fi
% }
\Hinput{mhchem}
\endinput
还有一些额外的 HTML 标签,您需要使用此配置文件将其删除config.cfg
:
\RequirePackage{color}
\Preamble{xhtml}
\Configure{mhchemce}{}{}
\Configure{mhchemcf}{}{}
\begin{document}
\EndPreamble
编译使用:
$ make4ht -c config.cfg -f odt Test.tex
结果如下: