2

Current problem is typesetting with the chemical packages. As would be expected, the PDF is produced without any problems but distinct issues arise with the html production using tex4ht.

The HTML file compiles fine without any red flags to me (except when trying to load the chemmacros package) however the expected and desired sub and super text scripts aren't successfully typeset.

Document is being compiled from a BAT file using the following, even though the entire "..." portion can be omitted and the same result obtained...

htlatex html_chem_textScripts.tex "html,mathplayer,early^,early_"

Contents of 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}

As can be seen from the HTML code below, the sub- and super- script instructions are even present when \ce{} was called from the mhchem package, but the 2+ is outside the code braces indicating to me that this time, it is not a browser or math script library problem but a compilation approach that might benefit if there was a config file or package option to get this working with 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&#x00A0;pacakge&#x00A0;can&#8217;t&#x00A0;compile&#x00A0;a&#x00A0;\ch{Co2+}&#x00A0;string&#x00A0;in&#x00A0;htlatex.&#x00A0;&#x00A0;Note.&#x00A0;&#x00A0;Package&#x00A0;can&#8217;t&#x00A0;even&#x00A0;be&#x00A0;loaded...
&#x00A0;<br />
&#x00A0;<br />
&#x00A0;<br />Error&#x00A0;produced:
&#x00A0;<br />
&#x00A0;<br />!&#x00A0;Undefined&#x00A0;control&#x00A0;sequence.
&#x00A0;<br />\pgfsys@svg@newline&#x00A0;-&#x003E;\Hnewline
&#x00A0;<br />
&#x00A0;<br />l.190&#x00A0;&#x00A0;&#x00A0;\pgfusepathqfill}
&#x00A0;<br />
&#x00A0;<br />?
</div>
<!--l. 48--><p class="nopar" >

</body></html> 

Have I missed in the documentation of these packages (siunitx, mhchem, and chemmacros) an option to configure/specify when loading the package specifically for TeX4ht to apply/fix known HTML requirements? I have seen this in xcolor, graphicx, and hyperref to name a few.

Note: I also presume I am doing something not quite right with htlatex options such as early^ because it makes no difference whether it is used or not.

EngBIRD
  • 3,985
  • \pgfsys@svg@newline ->\Hnewline is well known, see http://sourceforge.net/p/pgf/discussion/477362/thread/63c6fd79 – michal.h21 Dec 30 '14 at 20:24
  • regarding mhchem and superscripts, this depends on a way mhchem actually prints sub and super scripts, maybe it uses some non-standard way, it seems – michal.h21 Dec 30 '14 at 20:31
  • @michal.h21 I have indeed seen this report in troubleshooting this error. Would you know if it is possible redefine the definition in the cls file or preamble to apply the recommended fix of \def\pgfsys@svg@newline{{?nl}}? I use so many different computers that every day it's not practical to apply the fix everytimed. Regardless, the root of the problem is not the lack of html use with chemmacros. I included it because I theorized it would be parallel, but it appears that this assumption was incorrect. – EngBIRD Dec 30 '14 at 20:32
  • Best would be if the bug was fixed in pgf, maybe some comment in the bug tracker might caught some attention. Until it is fixed, modifying of the file seems to be the only solution, as chemmacros fail immediately as soon as it is included. no patching can help in this case – michal.h21 Dec 30 '14 at 20:51
  • @michal.h21 - concerning your earlier comment about using a "non-standard way", could you possibly tell me what it might be about the manually defined \newcommand{\degC}{$,^{\circ}\mathrm{C}$ } that is unstandard and subject to problems? – EngBIRD Dec 31 '14 at 20:00
  • what kind of problems does this command have? It compiles as superscripted °C for me. I would rather use siunitx than this macro, althought. – michal.h21 Dec 31 '14 at 20:29
  • @michal.h21 - no error pops up, but the superscript doesn't show up. What is your compile sequence - any special requirements with the desired command line 'early^' type option, and what browser? I would also rather use siunitx but the outputs for me are identical. – EngBIRD Dec 31 '14 at 20:35
  • I use htlatex xhtml,mathml. This creates mathml output for math, which doesn't work in all browsers, but you can use mathjax for support in all browsers: http://tex.stackexchange.com/a/68962/2891 – michal.h21 Dec 31 '14 at 20:54
  • I was contacted by mhchem's author and he got subscripts and superscripts to work. He said he wants to do more changes in order to fully support html, so I suppose that some future version of mhchem will have full tex4ht support – michal.h21 Jan 15 '15 at 10:12
  • Short update: I am about to rewrite mhchem in major parts. The current LaTeX output is distributed throughout the code. I'll try to centralize this, so that a tex4ht output is feasible, correct and maintainable. – mhchem Mar 25 '15 at 21:59
  • @mhchem Thanks, I look forward to it. Thanks for posting the update! – EngBIRD Mar 25 '15 at 22:16
  • I just uploaded mhchem v4.02 that has rudimentary 4ht support. Summary formulae should work fine. Special bonds and reaction arrows are recognizable, but ugly. Complex math with mhchem inside might fail completely. – mhchem Jul 23 '15 at 17:27

0 Answers0