texlive[47115] trunk: lwarp (24mar18)

commits+karl at tug.org commits+karl at tug.org
Sun Mar 25 23:28:55 CEST 2018


Revision: 47115
          http://tug.org/svn/texlive?view=revision&revision=47115
Author:   karl
Date:     2018-03-25 23:28:55 +0200 (Sun, 25 Mar 2018)
Log Message:
-----------
lwarp (24mar18)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/lwarp/lwarpmk.lua
    trunk/Master/texmf-dist/doc/latex/lwarp/README.txt
    trunk/Master/texmf-dist/doc/latex/lwarp/lwarp.pdf
    trunk/Master/texmf-dist/scripts/lwarp/lwarpmk.lua
    trunk/Master/texmf-dist/source/latex/lwarp/lwarp.dtx
    trunk/Master/texmf-dist/source/latex/lwarp/lwarp.ins
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-alltt.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-array.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-axodraw2.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-bigdelim.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-bigstrut.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-bytefield.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-cancel.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-colortbl.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-diagbox.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-epstopdf.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-fancybox.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-fancyvrb.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-framed.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-hyphenat.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-listings.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-luatodonotes.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-mdframed.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-moreverb.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-multirow.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-phfqit.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-relsize.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-siunitx.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-soul.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-textcomp.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-tikz.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-titling.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-verse.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-vwcol.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-xcolor.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-xy.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-zwpagelayout.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp.sty

Added Paths:
-----------
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemfig.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemformula.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemgreek.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemmacros.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemnum.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-epstopdf-base.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-grid.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-ltxgrid.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-mhchem.sty
    trunk/Master/texmf-dist/tex/latex/lwarp/lwarp_baseline_marker.png

Modified: trunk/Build/source/texk/texlive/linked_scripts/lwarp/lwarpmk.lua
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/lwarp/lwarpmk.lua	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Build/source/texk/texlive/linked_scripts/lwarp/lwarpmk.lua	2018-03-25 21:28:55 UTC (rev 47115)
@@ -4,7 +4,7 @@
 
 -- Print the usage of the lwarpmk command:
 
-printversion = "v0.50"
+printversion = "v0.51"
 
 function printhelp ()
 print ("lwarpmk: Use lwarpmk -h or lwarpmk --help for help.") ;
@@ -368,11 +368,11 @@
     "lateximages" .. dirslash .."lateximagetemp-%d" .. ".pdf" ..
     seqname ..
 -- Crop the image:
-"pdfcrop  lateximages" .. dirslash .. "lateximagetemp-" .. lwimgpage .. ".pdf " ..
+"pdfcrop  --hires  lateximages" .. dirslash .. "lateximagetemp-" .. lwimgpage .. ".pdf " ..
     "lateximages" .. dirslash .. lwimgname .. ".pdf" ..
     seqname ..
 -- Convert the image to svg:
-"pdftocairo -svg lateximages" .. dirslash .. lwimgname .. ".pdf " ..
+"pdftocairo -svg  -noshrink  lateximages" .. dirslash .. lwimgname .. ".pdf " ..
     "lateximages" .. dirslash .. lwimgname ..".svg" ..
     seqname ..
 -- Remove the temporary files:

Modified: trunk/Master/texmf-dist/doc/latex/lwarp/README.txt
===================================================================
--- trunk/Master/texmf-dist/doc/latex/lwarp/README.txt	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/doc/latex/lwarp/README.txt	2018-03-25 21:28:55 UTC (rev 47115)
@@ -1,14 +1,17 @@
 
-LaTeX lwarp package v0.50   README.txt
+LaTeX lwarp package v0.51   README.txt
 
 Files included are:
 
+lwarp.dtx: The documented source code.
+lwarp.ins: The documentation driver.
 lwarp.pdf: The documentation.
 lwarp_tutorial.txt: More documentation.  A sample tutorial.
 lwarpmk.lua: A utility program which compiles print or HTML versions.
 lwarp_mathjax.txt: A script inserted when MathJax is used.
-lwarp.dtx: The documented source code.
-lwarp.ins: The documentation driver.
+lwarp_baseline_marker.png: A tiny transparent image used to
+    improve SVG math width and baselines, to be located in
+    tex/latex/lwarp and thus be found by kpsewhich.
 
 Derived by compiling lwarp.ins:
 lwarp.sty: The lwarp package.

Modified: trunk/Master/texmf-dist/doc/latex/lwarp/lwarp.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/scripts/lwarp/lwarpmk.lua
===================================================================
--- trunk/Master/texmf-dist/scripts/lwarp/lwarpmk.lua	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/scripts/lwarp/lwarpmk.lua	2018-03-25 21:28:55 UTC (rev 47115)
@@ -4,7 +4,7 @@
 
 -- Print the usage of the lwarpmk command:
 
-printversion = "v0.50"
+printversion = "v0.51"
 
 function printhelp ()
 print ("lwarpmk: Use lwarpmk -h or lwarpmk --help for help.") ;
@@ -368,11 +368,11 @@
     "lateximages" .. dirslash .."lateximagetemp-%d" .. ".pdf" ..
     seqname ..
 -- Crop the image:
-"pdfcrop  lateximages" .. dirslash .. "lateximagetemp-" .. lwimgpage .. ".pdf " ..
+"pdfcrop  --hires  lateximages" .. dirslash .. "lateximagetemp-" .. lwimgpage .. ".pdf " ..
     "lateximages" .. dirslash .. lwimgname .. ".pdf" ..
     seqname ..
 -- Convert the image to svg:
-"pdftocairo -svg lateximages" .. dirslash .. lwimgname .. ".pdf " ..
+"pdftocairo -svg  -noshrink  lateximages" .. dirslash .. lwimgname .. ".pdf " ..
     "lateximages" .. dirslash .. lwimgname ..".svg" ..
     seqname ..
 -- Remove the temporary files:

Modified: trunk/Master/texmf-dist/source/latex/lwarp/lwarp.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/lwarp/lwarp.dtx	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/source/latex/lwarp/lwarp.dtx	2018-03-25 21:28:55 UTC (rev 47115)
@@ -16,7 +16,7 @@
 % \iffalse
 %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
 %<package>\ProvidesPackage{lwarp}
-%<package>    [2018/03/03 v0.50  Allows LaTeX to directly produce HTML5 output.]
+%<package>    [2018/03/24 v0.51  Allows LaTeX to directly produce HTML5 output.]
 %
 %<*driver>
 \documentclass{ltxdoc}
@@ -265,11 +265,11 @@
 
 
 \providerobustcmd*{\lmacro}[1]{\textbackslash#1}
-\providerobustcmd*{\cmds}[1]{\mbox{\texttt{#1}}}
+\providerobustcmd*{\cmds}[1]{\mbox{\texttt{\textbf{\textsl{#1}}}}}
 \providerobustcmd*{\env}[1]{\mbox{\texttt{#1}}}
 \providerobustcmd*{\ctr}[1]{\mbox{\texttt{#1}}}
-\providerobustcmd*{\pkg}[1]{\mbox{\textsf{#1}}}
-\providerobustcmd*{\prog}[1]{\mbox{\textsf{#1}}}
+\providerobustcmd*{\pkg}[1]{\mbox{\textbf{\textsf{#1}}}}
+\providerobustcmd*{\prog}[1]{\mbox{\textbf{\textsf{#1}}}}
 \providerobustcmd*{\progcode}[1]{\mbox{\texttt{#1}}}
 \providerobustcmd*{\optn}[1]{\mbox{\texttt{#1}}}
 \providerobustcmd*{\filenm}[1]{\mbox{\texttt{#1}}}
@@ -381,6 +381,19 @@
 
 % The following text is used in multiple places in the documentation:
 
+\newcommand{\needhelp}{
+\begin{minipage}{\linewidth}
+\hrule\smallskip
+\small
+The index to this document contains several hundred
+custom entries.
+Also included are automated entries for each package, macro, environment,
+counter, boolean, and other objects; individually and also sorted by category.
+A \nameref{sec:troubleshooting} section is also available.
+\hrule
+\end{minipage}\margintag{Need help?}
+}
+
 \newcommand{\usedbykomascript}{
 This package may be loaded standalone, but
 is also loaded automatically if \pkg{koma-script} classes are in use.
@@ -418,21 +431,7 @@
 code apply to the generation of \HTML, print, or both forms of output.
 }
 
-\newcommand{\limitssectioningmath}{%
-When using \SVG\ math in sectioning commands, \watchout[math in \cs{section}]
-use \cs{(} and \cs{)} to delimit math
-instead of \$:
-\begin{sourcedisplay}
-\cs{section}\{Section name with math \cs{(}1+2=3\cs{)}\}
-\end{sourcedisplay}
-\index{section>math in heading}
-\index{math>in section heading}
-}
 
-\newcommand{\limitssectioning}{%
-\limitssectioningmath
-}
-
 \newcommand{\limitscpageref}{\pkg{cleveref} and \pkg{varioref} are supported,
 \watchout[\pkg{cleveref} page numbers]
 but printed page numbers do not map to \HTML,
@@ -832,7 +831,8 @@
 
 
 \newcommand{\limitslateximagefontsize}{%
-The size of the math and text used
+For the \env{lateximage} environment,
+the size of the math and text used
 \margintag{SVG image font size}
 in the \SVG\ image may be adjusted
 \index{font>size --- lateximage}%
@@ -844,6 +844,29 @@
 }
 
 
+\newcommand*{\describedisplaymathother}{
+\DescribeMacro{\displaymathnormal}
+By default, or when selecting \cs{displaymathnormal},
+math display environments print their contents in \brand{Mathjax},
+and render their contents in \SVG\ math as well as
+use their contents in the \attribute{alt} tag of \HTML\ output.
+To do so, the contents are loaded into a macro for reuse.
+In some cases, such as complicated \tikz\ pictures, compilation will fail.
+
+\DescribeMacro{\displaymathother}
+When selecting \cs{displaymathother},
+it is assumed that the contents are more complicated than ``pure''
+math.
+An example is an elaborate \tikz\ picture, which will not render in \brand{MathJax} and
+will not make sense as an \HTML\ \attribute{alt} tag.
+In this mode, \brand{MathJax} is turned off,
+math display environments become \SVG\ images, even for 
+\brand{MathJax}, and the \HTML\ \attribute{alt} tags become simple messages.
+The contents are internally processed as an environment instead of a macro argument,
+so complicated objects such as \tikz\ pictures are more likely to compile successfully.
+}
+
+
 \newcommand{\limitsmath}{%
 
 \subsubsection{Rendering tradeoffs}
@@ -999,6 +1022,20 @@
 \end{itemize}
 }
 
+\newcommand{\limitschemformula}{%
+\pkg{chemformula} works best without \brand{MathJax}.
+\watchout[\pkg{chemformula} with \brand{MathJax}]
+If \brand{MathJax} is used,
+\cs{displaymathother} must be used before \env{array}, and then
+\cs{displaymathnormal} may be used after.
+(The \pkg{chemformula} package adapts to \env{array},
+but does not know about \brand{Mathjax}, and
+\brand{MathJax} does not know about \pkg{chemformula}.)
+
+While using \brand{Mathjax}, \cs{displaymathother} may also be used
+for other forms of display and inline math which contain \pkg{chemformula} expressions.
+}
+
 \newcommand{\limitsntheorem}{%
 This conversion is not total.
 \watchout[Font control]
@@ -1078,22 +1115,23 @@
 For font-proportional image sizes, use \texttt{ex} or \texttt{em}.
 For fixed-sized images, use
 \texttt{cm}, \texttt{mm}, \texttt{in}, \texttt{pt}, or \texttt{pc}.
-Use the keys \cmds{width=.5\lmacro{linewidth}},
+Use the keys \optn{width=.5\lmacro{linewidth}},
 or similar for \cs{textwidth} or \cs{textheight}
 to give fixed-sized images proportional to a 6 by 9 inch text area.
+Do not use the \optn{scale} option, since it is not well supported by \HTML\ browsers.
 
-\cs{includegraphics} accepts \texttt{width} and \texttt{height},
+\cs{includegraphics} accepts \optn{width} and \optn{height},
 \margintag{options}
-\texttt{origin}, \texttt{rotate} and \texttt{scale},
-plus a new \texttt{class} key.
+\optn{origin}, \optn{rotate} and \optn{scale},
+plus a new \optn{class} key.
 
 With \HTML\ output, \cs{includegraphics} accepts an optional
 \margintag{\HTML\ class}
-\texttt{class=xyz} keyval combination, and if this is given then
+\optn{class=xyz} keyval combination, and if this is given then
 the \HTML\ output will include that class for the image.
 The class is ignored for print output.
 
-\cs{rotatebox} accepts the optional \texttt{origin} key.
+\cs{rotatebox} accepts the optional \optn{origin} key.
 \margintag{\cs{rotatebox}}
 
 \cs{rotatebox}, \cs{scalebox}, and \cs{reflectbox} depend
@@ -1106,21 +1144,26 @@
 }
 
 \newcommand{\limitssvgimages}{%
-\limitssectioningmath
-
-When a math expression, \texttt{picture}, or \tikz\ environment is added or
-\watchout[Adding/removing]
-removed, the \SVG\ images must be re-created with \texttt{lwarpmk limages}
+When a math expression, \env{picture}, or \tikz\ environment is added or
+\watchout[adding/removing]
+removed, the \SVG\ images must be re-created by entering \cmds{lwarpmk limages}
 to maintain the proper image file sequence numbers.
 
 If \HTML\ appears where an \SVG\ image should be,\watchout[\HTML\ instead of images]%
-\index{math>showing as HTML}%
-\index{images>showing as HTML}%
-\index{SVG>images showing as HTML}%
-\index{HTML>in place of SVG images}
+\index{math>appearing as \HTML}%
+\index{images>appearing as \HTML}%
+\index{SVG>images appearing as \HTML}%
+\index{HTML>appearing in \SVG\ images}
 recompile the document one more
 time to get the page numbers back in sync, then remake the images one more time.
 
+Incorrect \SVG\ images will also occur if the document has\watchout[page counter]
+\begin{sourcedisplay}
+\cs{setcounter}\{page\}\{<value>\}
+\end{sourcedisplay}
+The \texttt{page} counter must not be adjusted by the user.
+\index{page>counter}
+
 Expressing math as \SVG\ images has the advantage of representing
 the math exactly as \LaTeX\ would, but has the disadvantage of requiring
 an individual file for each math expression.
@@ -1133,6 +1176,18 @@
 see \cref{sec:tutorialmathjax} to use \brand{MathJax} instead.
 }
 
+\newcommand{\limitstikz}{%
+If using display math with \env{tikzpicture} or \cs{tikz}, along
+\watchout[displaymath and matrices]
+with matrices with the \texttt{\&} character, the document must be modified as follows:
+\begin{sourcedisplay}
+\cs{usepackage}\{tikz\} \\
+\cs{tikzset}\{every picture/.style=\{ampersand replacement=\textbackslash\&\}\} \\
+\end{sourcedisplay}
+and each instance of \texttt{\&} in the \pkg{tikz} expression must be
+replaced with \texttt{\textbackslash\&}.\
+}
+
 \newcommand{\limitsgrffile}{%
 \pkg{grffile} is supported as-is.
 File types known to the browser are displayed, and unknown file types are given a link.
@@ -1163,8 +1218,8 @@
 Print-mode definitions for \cs{colorboxBlock} and \cs{fcolorboxBlock}
 are created by \pkg{lwarp}'s core if \pkg{xcolor} is loaded.
 
-\cs{fcolorbox} and \cs{fcolorboxBlock} allow a background color of \texttt{none},
-\margintag{background: \texttt{none}}
+\cs{fcolorbox} and \cs{fcolorboxBlock} allow a background color of \optn{none},
+\margintag{background: \optn{none}}
 in which case only the frame is drawn, which can be useful for \HTML.
 
 Color definitions, models, and mixing are fully supported
@@ -1172,7 +1227,7 @@
 without any changes required.
 
 \cs{rowcolors} is supported, except that the optional argument is ignored so far.
-\margintag{tables}
+\margintag{colored tables}
 
 \cs{textcolor}, \cs{colorbox}, and \cs{fcolorbox} are supported.
 \margintag{colored text and boxes}
@@ -1184,7 +1239,7 @@
 
 \newcommand{\limitsepstopdf}{%
 When using \pkg{epstopdf} to convert images to \PDF,
-use the \texttt{pdftocairo} utility to also provide an \SVG\ version as well.
+use the \prog{pdftocairo} utility to also provide an \SVG\ version as well.
 In the document, refer to the image filename without a suffix.  The
 \PDF\ version will be used in print output, and the \SVG\ version will
 be used for \HTML.
@@ -1249,8 +1304,8 @@
         \end{tabular}
         \end{sourcedisplay}
         Note that recent versions of \pkg{multirow} include a new optional
-        \margintag{\texttt{vposn}}
-        \texttt{vposn} argument.
+        \margintag{\optn{vposn}}
+        \optn{vposn} argument.
     \item The \pkg{multirow} documentation regarding colored cells recommends using
         a negative number of rows.  This will not work with \pkg{lwarp}, so
         \cs{warpprintonly} and \cs{warpHTMLonly} must be used to make versions for
@@ -1400,8 +1455,8 @@
 \end{sourcedisplay}
 
 Note that recent versions of \pkg{multirow} include a new optional
-\margintag{\texttt{vposn}}
-\texttt{vposn} argument.
+\margintag{\optn{vposn}}
+\optn{vposn} argument.
 }
 
 \newcommand{\limitsresumetabular}{%
@@ -1542,7 +1597,7 @@
 A line of text with an inline minipage
 \watchout[inline]
 or parbox will have the minipage or parbox placed onto its own line,
-because a paragraph is a block element and cannot be made \texttt{inline-block}.
+because a paragraph is a block element and cannot be made \attribute{inline-block}.
 
 Minipages and parboxes will be placed side-by-side in \HTML\
 \margintag{placement}
@@ -1551,7 +1606,7 @@
 Side-by-side minipages may be separated by \cs{quad}, \cs{qquad}, \cs{enskip},
 \margintag{side-by-side}
 \cs{hspace}, \cs{hfill}, or a \cs{rule}.
-When inside a \texttt{center} environment, the result is
+When inside a \env{center} environment, the result is
 similar in print and \HTML.  Paragraph tags are surpressed between
 side-by-side minipages and these spacing commands, but not at the start or end
 of the paragraph.
@@ -1662,7 +1717,7 @@
 border radius, and shadow.
 CSS classes are created for \pkg{mdframed} environments and frame titles.
 
-When used, \pkg{lwarp} loads \pkg{mdframed} in \HTML\ with \texttt{framemethod=none}.
+When used, \pkg{lwarp} loads \pkg{mdframed} in \HTML\ with \optn{framemethod=none}.
 \watchout[loading]
 
 For title font, use
@@ -1680,7 +1735,7 @@
 Since \pkg{lwarp} does not support \cs{bfseries} and friends,
 only one font selection may be made at a time.
 
-\texttt{theoremtitlefont} is not supported, since the following text is not
+\optn{theoremtitlefont} is not supported, since the following text is not
 \margintag{theoremtitlefont}
 in braces in the \pkg{mdframed} source.
 
@@ -1687,7 +1742,7 @@
 Footnotes are currently placed at the bottom of the \HTML\ page.
 \margintag{footnotes}
 
-\texttt{userdefinedwidth} and \texttt{align} are currently ignored.
+\optn{userdefinedwidth} and \optn{align} are currently ignored.
 \margintag{ignored options}
 }
 
@@ -1709,8 +1764,8 @@
 \cs{captionsetup}[table]\{position=top\} \\
 \cs{captionsetup}[figure]\{position=bottom\}
 \end{sourcedisplay}
-Similarly for \texttt{subtable}, \texttt{subfigure},
-and \texttt{longtable}.
+Similarly for \pkg{subtable}, \pkg{subfigure},
+and \pkg{longtable}.
 }
 
 \newcommand{\limitscombiningfloats}{%
@@ -1725,8 +1780,8 @@
 % would appear in the List of Figures/Tables before the enclosing figure/table,
 % therefore \pkg{lwarp} does not place subfigures in the LOF/LOT.
 
-At present, the package options for \texttt{lofdepth} and \texttt{lotdepth}
-\watchout[\texttt{lof/lotdepth}]
+At present, the package options for \optn{lofdepth} and \optn{lotdepth}
+\watchout[\optn{lof/lotdepth}]
 are not working.  These counters must be set separately after the
 package has been loaded.
 
@@ -1767,10 +1822,10 @@
 }
 
 \newcommand{\limitskeyfloat}{%
-If placing a \cs{keyfig}\texttt{[H]} inside a \env{keywrap},
+If placing a \cs{keyfig}\optn{[H]} inside a \env{keywrap},
 \watchout[\env{keywrap}]
 use an absolute width for
-\cs{keyfig}, instead of \texttt{lw}-proportional widths.
+\cs{keyfig}, instead of \optn{lw}-proportional widths.
 (The \optn{[H]} option forces the use of a minipage, which internally adjusts for
 a virtual 6-inch wide minipage, which then corrupts the \optn{lw} option.)
 }
@@ -1778,7 +1833,7 @@
 \newcommand{\limitssiunitx}{%
 Due to \prog{pdftolatex} limitations, fraction output is replaced by symbol
 \margintag{fractions}
-output for \texttt{per-mode} and \texttt{quotient-mode}.
+output for \optn{per-mode} and \optn{quotient-mode}.
 
 Some units will require that the expression be placed inside math mode.
 \watchout[math mode required]
@@ -1810,7 +1865,7 @@
 \margintag{\cs{CaptionSeparator}}
 changed to a dash.  The following may be used to restore it to a colon:
 \begin{sourcedisplay}
-\texttt{\cs{renewcommand}*\{\cs{CaptionSeparator}\}\{:\textasciitilde\}}
+\cs{renewcommand}*\{\cs{CaptionSeparator}\}\{:\textasciitilde\}
 \end{sourcedisplay}
 
 Also when French is used,
@@ -1883,8 +1938,29 @@
 \end{sourcedisplay}
 }
 
+\newcommand*{\describehashing}{%
+If starred, a hashed filename is used.\margintag{image filename hashing}
+\index{hash>SVG image filename}
+\index{file>hashed name}
+\index{images>hashed filenames}
+\index{MD5 hash>SVG image filename}
+If so, the hash is based on the \attribute{alt} tag and also the additional hashing argument.
 
+This may be used to provide an expression with a simple \attribute{alt} tag
+but also enough additional information to provide a unique hash.
 
+An example is when the expression is a complicated \TeX\ expression, which would not
+copy/paste well.  A simplified tag may be used, while the complicated expression is
+duplicated in the additional hashing argument.
+
+Another example is when the expression is simple, but the image depends
+on options.  These options may be decoded into text form and
+included in the additional hashing argument in order to make the hash
+unique according to the set of options, even if the simple \attribute{alt} tag
+is still the same.
+}
+
+
 \newcommand{\osportabilityusage}{%
 \pkg{lwarp} tries to detect which operating system is being used.
 \DescribeProgram{Unix}\DescribeProgram{Mac OS}\DescribeProgram{Linux}
@@ -1925,7 +2001,7 @@
 %<*package>
 % \fi
 %
-% \CheckSum{21481}
+% \CheckSum{22904}
 %
 % \CharacterTable
 % {Upper-case     \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -2017,11 +2093,10 @@
 % \changes{v0.48}{2018/02/14}{\ 2018/02/14}
 % \changes{v0.49}{2018/02/19}{\ 2018/02/19}
 % \changes{v0.50}{2018/03/03}{\ 2018/03/03}
+% \changes{v0.51}{2018/03/24}{\ 2018/03/24}
 
 
 
-
-
 % \GetFileInfo{lwarp.sty}
 %
 % \DoNotIndex{\newcommand,\renewcommand,\addtocounter,\begin,\end,\begingroup,\endgroup}
@@ -2207,9 +2282,35 @@
 % highlighting new features and any special changes which must be made due
 % to improvements or modifications in \pkg{lwarp} itself.
 %
-% For a detailed list of changes, see the Change History on page \pageref{sec:changehistory}.
+% For a detailed list of the most recent changes,
+% see the end of the Change History on page \pageref{sec:changesend}.
 %
 % \begin{description}
+% \item[v0.51:] \
+%   \begin{itemize}
+%       \item Docs: Added \nameref{sec:thingstoavoid}.
+%       \item Docs: Added to \nameref{sec:convertexisting}.
+%       \item Docs: Multiple authors and affiliations with custom classes.
+%           See \cref{sec:authorsaffils}.
+%       \item Docs: \pkg{tikz} with matrices.  See \cref{sec:limitstikz}.
+%       \item Improved \SVG\ math baseline.\margintag{SVG math}
+%       \item Improved \SVG\ math font and color.
+%       \item Faster \SVG\ math rendering.
+%       \item Improved support for display math containing complicated math objects,
+%               such as \pkg{tikz-cd}.  See \cref{sec:displaymathother}.
+%       \item Fix: \cs{addcontentsline} inside \SVG\ math.
+%       \item Fix: SVG math containing an embedded \env{lateximage}.
+%       \item MathJax now handles \cs{ensuremath} in expressions.\margintag{MathJax}
+%       \item Fix: Added \env{alignat} environment. \margintag{misc. fixes}
+%       \item Fix: \pkg{afterpackage} no longer required, which conflicted with \pkg{scrlfile}.
+%       \item Fix: \pkg{titling} \cs{thanks} mark.
+%       \item Fix: \pkg{fancybox} improvements.
+%       \item Fix: \pkg{tikz} \cs{tikz} macro.  (Previously only the \env{tikzpicture} environment worked.)
+%       \item Fix: \pkg{tikz} with optional argument.
+%       \item Added \pkg{mhchem},  \margintag{packages}
+%           \pkg{chemfig}, \pkg{chemformula}, \pkg{chemmacros}, \pkg{chemnum}, \pkg{chemgreek},
+%           \pkg{epstopdf-base}, \pkg{grid}, \pkg{ltxgrid}.
+%   \end{itemize}
 % \item[v0.50:] \
 %   \begin{itemize}
 %       \item \SVG\ math and other \env{lateximage}s now are
@@ -2224,7 +2325,7 @@
 %           already exists.
 %           Display math and other forms of \SVG\ image such as \env{picture} and
 %           \tikz\ still use individual image files which are recreated each time
-%           |lwarpmk limages| is run.
+%           \cmds{lwarpmk limages} is run.
 %       \item Fixes: SVG math and/or \cs{underline} in a sectioning file name.
 %       \item Improved \SVG\ display math and tags.
 %       \item Improved \SVG\ math and \pkg{siunitx} \attribute{alt} tags.
@@ -2515,7 +2616,7 @@
 %   \end{itemize}
 % \item[v0.38:] \
 %   \begin{itemize}
-%   \item Added |lwarpmk print1| and |lwarpmk html1| actions to
+%   \item Added \cmds{lwarpmk print1} and \cmds{lwarpmk html1} actions to
 %       \margintag{forced single-pass compile}
 %       force a compile of the project a single time.
 %       Useful when multiple passes are not needed,
@@ -2701,8 +2802,8 @@
 %		\cs{useLatexmk} & |latexmk| \\
 %		\cs{warpOSwindows} & |OSWindows| \\[2.5ex] \toprule
 %		Old Package Option & New Package Option \\ \midrule
-%		|lwarpmklang| & |IndexLanguage| \\
-%		(new) & |xdyFilename| \\[2.5ex] \toprule
+%		\optn{lwarpmklang} & \optn{IndexLanguage} \\
+%		(new) & \optn{xdyFilename} \\[2.5ex] \toprule
 %		Old Macro & New Macro \\ \midrule
 %		\cs{MetaLanguage} & \cs{HTMLLanguage} \\
 %		\cs{HTMLauthor} & \cs{HTMLAuthor} \\
@@ -2747,7 +2848,7 @@
 %		\item Print mode without \prog{latexmk} now uses \prog{xindy} instead of \prog{makeindex}.
 %		\item \prog{texindy}/\prog{xindy} usage depends on \prog{pdflatex} vs \prog{xelatex}, \prog{lualatex}.
 %		\item For \prog{pdflatex} and \prog{texindy}, the \optn{-C utf8} option is used.  This is
-%			supported in modern distributions, but a customized |lwarpmk.lua| may
+%			supported in modern distributions, but a customized \filenm{lwarpmk.lua} may
 %			need to be created for use with older distributions.
 %		\end{itemize}
 %
@@ -2804,7 +2905,7 @@
 % ^^A 		\pkg{pagenote} now works as per the print version.
 % ^^A 		\pkg{footnote}, \pkg{footnotehyper}, \pkg{footmisc}, \pkg{endnotes},
 % ^^A 		\pkg{marginnote}, and \pkg{sidenotes} are also supported.
-% ^^A 	\item \LaTeX\ labels now are used to track the page numbers of |latexiamge|s.
+% ^^A 	\item \LaTeX\ labels now are used to track the page numbers of |lateximage|s.
 % ^^A 		This allows the correct inclusion of |lateximage|s in footnotes, pagenotes, and endnotes.
 % ^^A 	\item \pkg{cutwin} and \pkg{floatflt} are also supported.
 % ^^A 	\end{itemize}
@@ -2837,7 +2938,7 @@
 % ^^A 		has been replaced with a |lateximages.txt| file, which is parsed
 % ^^A 		by \prog{lwarpmk} to generate lateximages.
 % ^^A 		This does not require any changes in the user's code.
-% ^^A 	\item \brand{Windows} |lwarpmk again| now functions.
+% ^^A 	\item \brand{Windows} \cmds{lwarpmk again} now functions.
 % ^^A 	\item For improved error handling, \pkg{lwarp} now verifies the
 % ^^A 		order in which packages are loaded, and signals an error for misplaced packages.
 % ^^A 		\pkg{inputenc}, \pkg{fontenc}, \pkg{newunicode}, and \pkg{fontspec}
@@ -2979,7 +3080,7 @@
 %
 % \rulebreak
 %
-% Assistance is also provide for modifying the \HTML\ output to suit the creation
+% Assistance is also provided for modifying the \HTML\ output to suit the creation
 % of \EPUB\ documents, and for modifying the \HTML\ output to ease import into
 % a word processor.
 %
@@ -3047,6 +3148,8 @@
 % code used to emulate or replace functions for \HTML\ output.
 %
 %
+%
+%
 % \clearpage
 %
 % \subsection{Supported packages and features}
@@ -3100,9 +3203,9 @@
 %       \pkg{preview},
 %       \pkg{draftwatermark}, \pkg{watermark},
 %       \pkg{everyshi}, \pkg{atbegshi}, \pkg{continue}, \pkg{fwlw}, \pkg{turnthepage},
-%       \pkg{pagesel}, \pkg{blowup}, \pkg{pagegrid}. \\
+%       \pkg{pagesel}, \pkg{blowup}, \pkg{pagegrid}, \pkg{grid}, \pkg{ltxgrid}. \\
 %
-% Sectioning: & Adds \cmds{FileDepth} for splitting the \HTML\ output.
+% Sectioning: & Adds \progcode{FileDepth} for splitting the \HTML\ output.
 % 	Files may be numbered sequentially or named according to section name.
 % 	Common short words and punctuation are removed from the filenames. 
 %	\pkg{titlesec}, \pkg{fncychap}, \pkg{sectsty}, \pkg{section},
@@ -3135,7 +3238,7 @@
 %
 % Margin notes: & \pkg{marginfit}, \pkg{marginfix}, \pkg{scrlayer-notecolumn}. \\
 %
-% Footnotes: & Adds \cmds{FootnoteDepth} to print footnotes at section breaks.
+% Footnotes: & Adds \progcode{FootnoteDepth} to print footnotes at section breaks.
 %   \pkg{footnote}, \pkg{footmisc},
 %	\pkg{marginnote}, \pkg{sidenote}, \pkg{pagenote},
 %   \pkg{endnotes}, \pkg{endheads}, \pkg{footnpag}, \pkg{nccfoots}. \\
@@ -3153,8 +3256,11 @@
 %	\pkg{theorem}, \pkg{amsthm}, \pkg{ntheorem}. \\
 %
 % Additional math: & Math fonts via \SVG\ images, \pkg{resizegather}.
-%   As-is: \pkg{delarray}, \pkg{bm}, \pkg{braket}, etc. \\
+%   As-is: \pkg{delarray}, \pkg{bm}, \pkg{braket}, \pkg{tikz-cd}, etc. \\
 %
+% Display math with \cs{displaymathother}: & %
+%   Complicated math objects in display math, such as \pkg{tikz-cd}, etc. \\
+%
 % \midrule
 %
 % Units and fractions: & \pkg{siunitx}, \pkg{xfrac}, \pkg{nicefrac}, \pkg{units} \\
@@ -3161,12 +3267,15 @@
 %
 % Science and engineering: &
 %   \pkg{listings}, \pkg{algorithmicx}, \pkg{bytefield}, \pkg{axodraw2},
-%   \pkg{phfqit}.
-%   Tested to work with SVG math: \pkg{physics}, \pkg{slashed},
+%   \pkg{phfqit}, \pkg{mhchem},
+%   \pkg{chemfig}, \pkg{chemformula}, \pkg{chemmacros}, \pkg{chemnum}. \pkg{chemgreek}, 
+%   Tested to work with \SVG\ math: \pkg{physics}, \pkg{slashed},
 %       \pkg{heppennames}, \pkg{hepnicenames},
-%       \pkg{simpler-wick}, \pkg{linop}, \pkg{blochsphere}, etc.
+%       \pkg{simpler-wick}, \pkg{linop}, \pkg{blochsphere}, \pkg{elements}, etc.
 %       \emph{(Math-mode packages generally work as-is with \SVG\ math.)} \\
 %
+% \midrule
+%
 % Liberal arts: & \pkg{schemata} \\
 %
 % \midrule
@@ -3189,8 +3298,8 @@
 % \midrule
 %
 % Graphics: & \pkg{graphics} and \pkg{graphicx}.
-%   \cs{includegraphics} supports \cmds{width}, \cmds{height},
-%   \cmds{origin}, \cmds{angle}, and \cmds{scale} tags, and adds \cmds{class}.
+%   \cs{includegraphics} supports \optn{width}, \optn{height},
+%   \optn{origin}, \optn{angle}, and \optn{scale} tags, and adds \optn{class}.
 %   References to \PDF\ files are changed to \SVG, other image types
 %   are accepted as well.
 %   \cs{rotatebox} and \cs{scalebox} are supported as well as \HTML\ can handle.
@@ -3270,7 +3379,7 @@
 %
 % Fonts: & Used as-is.  Appear in \SVG\ math expressions or embedded image environments. \\
 %
-% Symbols: & Native \LaTeX\ diacriticals, \pkg{textcomp}, \pkg{textgreek}. \\
+% Symbols: & Native \LaTeX\ diacriticals, \pkg{textcomp}, \pkg{textgreek}, \pkg{textalpha}. \\
 %
 % \midrule
 %
@@ -3482,7 +3591,7 @@
 %	should be an operating-system executable in the same way that
 %	\prog{pdflatex} or \prog{latexmk} is.  It is possible to have the
 %	\pkg{lwarp} package generate a local copy of \prog{lwarpmk}
-%	called |lwarpmk.lua|.
+%	called \filenm{lwarpmk.lua}.
 %	See \cref{sec:genlatexmk}.
 %
 % \item[\prog{luatex}:] Used by the \prog{lwarpmk} program to simplify and automate document generation.
@@ -3605,7 +3714,7 @@
 %		and click on the button called \textsf{Refresh FNDB}.
 %	\end{enumerate}
 %
-% \item[CTAN \texttt{.dtx} and \texttt{.ins} files:] Another form of \TeX\ package
+% \item[CTAN \filenm{.dtx} and \filenm{.ins} files:] Another form of \TeX\ package
 %	is the |.dtx| and |.ins| source files.  These files are used to create
 %	the documentation and |.sty| files.
 %
@@ -3634,13 +3743,13 @@
 %		and click on the button called \textsf{Refresh FNDB}.
 %
 %	\item See \cref{sec:locallwarpmk} to generate your local copy of \prog{lwarpmk}.
-%	\item Once the local version of |lwarpmk.lua| is installed, it may be made
+%	\item Once the local version of \filenm{lwarpmk.lua} is installed, it may be made
 %		available system-wide as per \cref{sec:installlwarpmk}.
 %	\end{enumerate}
-% \item[Project-local \CTAN\ \texttt{.dtx} and \texttt{.ins} files:] The
+% \item[Project-local \CTAN\ \filenm{.dtx} and \filenm{.ins} files:] The
 %		|.dtx| and |.ins| files may be downloaded to a project
 %		directory, then compiled right there, alongside the
-%		document source files.  The resultant |*.sty| and |lwarpmk.lua| files
+%		document source files.  The resultant |*.sty| and \filenm{lwarpmk.lua} files
 %		may be used as-is, so long as they are in the same directory
 %		as the document source.  This approach is especially useful if
 %		you would like to temporarily test\margintag{Just testing!}\
@@ -3672,7 +3781,7 @@
 %
 %	Otherwise, continue with the following:
 %
-% \item Locate the file |lwarpmk.lua|, which should be in the |scripts| directory
+% \item Locate the file \filenm{lwarpmk.lua}, which should be in the |scripts| directory
 %	of the \TDS\ tree.  On a \TeX\ Live or MiK\TeX\ system you may use
 %	\userentry{kpsewhich lwarpmk.lua}
 %
@@ -3697,7 +3806,7 @@
 %			In this directory you will find programs
 %			such as \prog{pdflatex} and \prog{makeindex}.
 %		\item In the binaries directory,
-%			create a new symbolic link from the binaries directory to |lwarpmk.lua|:
+%			create a new symbolic link from the binaries directory to \filenm{lwarpmk.lua}:
 %			\userentry{ln -s <pathtolwarpmk.lua> lwarpmk}
 %		\item Make the link executable:
 %			\userentry{chmod 0755 lwarpmk}
@@ -3707,7 +3816,7 @@
 %		\item Locate the \TeX\ Live binaries as shown above for Unix.
 %		\item In the binaries directory, make a \emph{copy} of |runscript.exe|
 %			and call it |lwarpmk.exe|
-%			This will call the copy of |lwarpmk.lua|
+%			This will call the copy of \filenm{lwarpmk.lua}
 %			which is in the |scripts| directory of the distribution.
 %		\end{enumerate}
 %	\item [\brand{Windows} MiK\TeX:] Create a new |lwarpmk.bat| file:
@@ -3723,7 +3832,7 @@
 %			{\footnotesize
 %			|texlua "C:\Program Files\MiKTeX 2.9\scripts\lwarp\lwarp.texlua" %*|}
 %		\end{sourcedisplay}
-%			This will call the copy of |lwarpmk.lua|
+%			This will call the copy of \filenm{lwarpmk.lua}
 %			which is in the |scripts| directory of the distribution.
 %		\end{enumerate}
 %	\end{description}
@@ -3738,13 +3847,13 @@
 %	\begin{sourcedisplay}
 %	|\usepackage[lwarpmk]{lwarp}|
 %	\end{sourcedisplay}
-% \item When the tutorial is compiled with \prog{pdflatex}, the file |lwarpmk.lua|
+% \item When the tutorial is compiled with \prog{pdflatex}, the file \filenm{lwarpmk.lua}
 %	will be generated along with the other configuration files.
-% \item |lwarpmk.lua| may be used for this project:
+% \item \filenm{lwarpmk.lua} may be used for this project:
 %	\begin{description}
 %		\item[Unix:] \
 %			\begin{enumerate}
-%			\item Make |lwarpmk.lua| executable: \userentry{chmod 0755 lwarpmk.lua}
+%			\item Make \filenm{lwarpmk.lua} executable: \userentry{chmod 0755 lwarpmk.lua}
 %			\item Compile documents with
 %				\userentry{./lwarpmk.lua html}
 %				\userentry{./lwarpmk.lua print} \quad etc.
@@ -3869,6 +3978,7 @@
 %
 % This section shows an example of how to create an \pkg{lwarp} document.
 %
+% \needhelp
 %
 % \subsection{Starting a new project}
 %
@@ -3928,7 +4038,6 @@
 % the additional helper program \prog{latexmk} will be used to compile the document.)
 %
 %
-%
 % \clearpage
 %
 % \begingroup
@@ -4009,7 +4118,7 @@
 % \label{sec:genlatexmk}
 % When the \optn{lwarpmk} option is given to the \pkg{lwarp} package:
 % \begin{description}
-% \item [|lwarpmk.lua|:] A local copy of the \prog{lwarpmk} utility.
+% \item [\filenm{lwarpmk.lua}:] A local copy of the \prog{lwarpmk} utility.
 %
 %	On Unix-related operating systems this file must be made executable:
 %	\begin{sourcedisplay}
@@ -4056,7 +4165,7 @@
 %	Although, when using the utility \prog{latexmk} (introduced later), the changed date is
 %	ignored and an actual change in contents must occur to cause a recompile.}
 %
-% \item Process the index.\index{index>processing}\footnote{A \texttt{lwarpmk printglossary} command is also
+% \item Process the index.\index{index>processing}\footnote{A \cmds{lwarpmk printglossary} command is also
 %	available to process a glossary produced with the \textsf{glossaries} package.
 %	See \cref{sec:glossaries}.}\footnote{Also see \cref{sec:indextocbibind} for index options.}
 %	\userentry{lwarpmk printindex}
@@ -4292,7 +4401,7 @@
 %	\userentry{lwarpmk print} \quad -and-
 %	\userentry{lwarpmk html}
 %
-% \item Also rememeber to update the indexes and recompile again.
+% \item Also remember to update the indexes and recompile again.
 % \end{enumerate}
 %
 %
@@ -4378,7 +4487,7 @@
 % convert each target to \HTML\ files.
 %
 %
-% \subsection{Converting an existing document}
+% \section{Converting an existing document}
 % \label{sec:convertexisting}
 %
 % \index{modifying>document}
@@ -4387,6 +4496,7 @@
 % \index{document>convert existing}
 %
 % \changes{v0.48}{2018/02/05}{Docs: Converting an existing document.}
+% \changes{v0.51}{2018/03/04}{Docs: Updated Converting an existing document.}
 %
 % To convert an existing document for use with \pkg{lwarp}:
 % \begin{enumerate}
@@ -4400,18 +4510,29 @@
 % \end{enumerate}
 % \item Also modify the document:
 % \begin{enumerate}
-%   \item Change \cs{includegraphics} \PDF\ filenames
-%       from |filename.pdf| to |filename| without a suffix.
-%       Other image formats may be left unmodified,
-%           or may be loaded without a file suffix.
-%   \item Possible changes to \env{tabular} environments:
+%   \item Remove \filenm{.pdf} file extensions.  Change:
+%       \begin{sourcedisplay}
+%       \cs{includegraphics}\{filename.pdf\}
+%       \end{sourcedisplay} to:
+%       \begin{sourcedisplay}
+%       \cs{includegraphics}\{filename\}
+%       \end{sourcedisplay}
+%       Other image formats may have a file extension.
+%   \item Avoid the \optn{scale} option.  Change:
+%       \begin{sourcedisplay}
+%       \cs{includegraphics}[scale=<xx>]
+%       \end{sourcedisplay} to:
+%       \begin{sourcedisplay}
+%       \cs{includegraphics}[width=<yy>\textbackslash{linewidth}]
+%       \end{sourcedisplay}
+%   \item Possible changes to \env{tabular} environments include
 %       |*| columns, \pkg{multirow}, \pkg{longtable}, \pkg{supertabular}, \pkg{xtab},
 %       \pkg{bigdelim}.  See \cref{sec:limitstabular}.
 %   \item Possible option clashes with \pkg{memoir}.  See \cref{sec:limitsmemoir}.
-%   \item Other changes as per \cref{sec:limitations}.
+%   \item Other changes as per \nameref{sec:limitations}, \cref{sec:limitations}.
 % \end{enumerate}
 % \item Create an SVG version of any PDF image.
-% \item Manually compile print version with \prog{pdflatex},
+% \item Manually compile the print version with \prog{pdflatex},
 %           \prog{lualatex}, or \prog{xelatex}.
 % \item |lwarpmk print| to finish the print version.
 % \item |lwarpmk html| to create the \HTML\ version.
@@ -4418,6 +4539,8 @@
 % \item |lwarpmk limages| to create the \SVG\ images of any \SVG\ math, \env{lateximage}, \tikz, etc.
 % \end{enumerate}
 %
+% \needhelp
+%
 % \clearpage
 %
 % \section{Additional details}
@@ -4465,7 +4588,7 @@
 % \index{font>Deja Vu}%
 % \index{Unicode>enhanced coverage}%
 % \index{UTF-8>enhanced coverage}%
-% or other other font packages, which may provide an increased coverage of Unicode mappings.
+% or other font packages, which may provide an increased coverage of Unicode mappings.
 % Avoid bit-mapped fonts.
 %
 % \XeLaTeX{} and \LuaLaTeX{} users must use the \pkg{fontspec} package.
@@ -4549,7 +4672,7 @@
 % well with others.  \XeLaTeX\ or \LuaLaTeX\ are recommended for non-Latin languages.
 %
 % For an older distribution of \LaTeX, it may be necessary to generate a local version of
-% |lwarpmk.lua| and modify it to remove the \optn{-C utf8} option from the \prog{texindy} call.
+% \filenm{lwarpmk.lua} and modify it to remove the \optn{-C utf8} option from the \prog{texindy} call.
 % See \cref{sec:modifylwarpmk}.
 %
 %
@@ -4575,7 +4698,7 @@
 % HTMLFilename & A prefix for the filenames of the remaining web pages. \\
 % IndexLanguage & The \prog{xindy} language option used for index and glossary generation. \\
 % latexmk & Boolean for \prog{lwarpmk} to use \prog{latexmk} for compiling documents. \\
-% lwarpmk & Generate a local copy of |lwarpmk.lua|. \\
+% lwarpmk & Generate a local copy of \filenm{lwarpmk.lua}. \\
 % xdyFilename & Set a custom filename for \prog{xindy}. \\
 % \bottomrule
 % \end{tabular}
@@ -4629,7 +4752,7 @@
 %   See \cref{sec:htmlsettings}.
 %
 % \DescribeOption{lwarpmk}  If you wish to have \pkg{lwarp} generate a local
-%   copy of |lwarpmk.lua| for archival or local-installation purposes,
+%   copy of \filenm{lwarpmk.lua} for archival or local-installation purposes,
 %   compile the print version with the \optn{lwarpmk} option set.
 %   See \cref{sec:handlingpackageoptions}.
 %
@@ -5319,17 +5442,28 @@
 % \changes{v0.14}{2016/03/26}{Docs: Commands for a successful \HTML\ conversion.}
 % \changes{v0.36}{2017/08/11}{Docs: Reorganized: Special cases and limitations.}
 %
-% Also see \cref{sec:troubleshooting}: \nameref{sec:troubleshooting}.
+% Some commonly-used \LaTeX{} expressions should be modified as follows to allow
+% for a smooth conversion to both \HTML\ and print-formatted outputs.
 %
-% Some commonly-used \LaTeX{} expressions should be modified to allow
-% for a smooth conversion to both \HTML\ and print-formatted outputs:
+% \needhelp
 %
+% \subsection{Things to avoid}
+% \label{sec:thingstoavoid}
+% \changes{v0.51}{2018/03/04}{Docs: Things to avoid.}
 %
-% \subsection{Sectioning}
+% In the document, avoid the following:
 %
-% \limitssectioning
+% \begin{description}
+%   \item [\texttt{page} counter:] Do not adjust the \texttt{page} counter.
+%       If doing so is required for the print version, place the
+%       adjustment inside a \env{warpprint} environment.
+%   \item [Custom math environment macros:] Do not use expressions such as
+%       \cs{beq} as a replacement for \texttt{\cs{begin}\{equation\}}.
+%   \item [Custom macros in section, figure, table names:] Custom macros which appear in the
+%       \filenm{.toc}, \filenm{.lof}, and \filenm{.lot} files should be made robust,
+%       using \cs{newrobustcmd} or \cs{robustify} from \pkg{etoolbox}, \pkg{xparse}, etc.
+% \end{description}
 %
-%
 % \subsection{Formatting}
 %
 % \subsubsection{Text formatting}
@@ -5559,6 +5693,25 @@
 % \subsection{Front and back matter}
 % \label{sec:frontbackmatter}
 %
+% \subsubsection{Custom classes with multiple authors and affiliations}
+% \label{sec:authorsaffils}
+% \changes{v0.51}{2018/03/04}{Docs: Multiple authors and affiliations.}
+%
+% Some classes allow multiple authors and affiliations.
+% \index{author>multiple}\index{affiliation>multiple authors}
+% Often it is possible to emulate these using a standard class
+% along with \pkg{authblk}:
+% \begin{sourcedisplay}
+% \%\cs{documentclass}\{customclass\}~\% for print document \\
+% \cs{documentclass}\{article\}~\% for HTML document \\
+% \\
+% \cs{usepackage}\{lwarp\} \\
+% \cs{begin}\{warpHTML\} \\
+% \cs{usepackage}\{authblk\} \\
+% \cs{let}\cs{affiliation}\cs{affil}~\% maybe required \\
+% \cs{end}\{warpHTML\}
+% \end{sourcedisplay}
+%
 % \subsubsection{Starred chapters and sections}
 % \label{sec:forcesectionstar}
 %
@@ -5669,8 +5822,27 @@
 % \label{sec:limitsmath}
 % \limitsmath
 %
+% \subsubsection{Display math}
+% \label{sec:displaymathother}
+% \index{math>\cs{displayingmath}}\index{math>\cs{displayingmore}}
+% \index{display math>complicated objects}
+% \index{math>display with complicated objects}
+% \index{tikz>in display math}
+% \index{math>with \tikz}\index{equation>with \tikz}
+% \index{MathJax>errors}\index{HTML>alt tags}\index{alt tags}
 %
+% \describedisplaymathother
 %
+% \subsubsection{\pkg{chemformula} package}
+% \limitschemformula
+% \index{chemformula>troubleshooting}
+% \index{array>and chemformula}
+% \index{math>and chemformula}
+%
+% \subsubsection{\pkg{mhchem} package}
+%
+% See \cref{sec:mhchem}.
+%
 % \subsubsection{\pkg{ntheorem} package}
 %
 % \DescribePackage{ntheorem}
@@ -5705,6 +5877,14 @@
 % \limitsgraphics
 %
 %
+% \subsubsection{\pkg{tikz} package}
+% \label{sec:limitstikz}
+%
+% \DescribePackage{tikz}
+% \limitstikz
+% \changes{v0.51}{2018/03/18}{Docs: \pkg{tikz} limitations.}
+%
+%
 % \subsubsection{\pkg{grffile} package}
 %
 % \DescribePackage{grffile}
@@ -6458,26 +6638,26 @@
 %
 % \DescribeProgram{lwarpmk}
 % \DescribeFile{lwarpmk.lua}
-% In most installations, |lwarpmk.lua| is an executable file located somewhere
+% In most installations, \filenm{lwarpmk.lua} is an executable file located somewhere
 % \index{lwarpmk>customizing}
 % the operating system knows about, and it is called by typing ``|lwarpmk|'' into
 % a terminal.
 %
-% A project-local copy of |lwarpmk.lua| may be generated, modified, and then used to
+% A project-local copy of \filenm{lwarpmk.lua} may be generated, modified, and then used to
 % compile documents:
 % \begin{enumerate}
 % \item Add the \optn{lwarpmk} option to the \pkg{lwarp} package.
 % \item Recompile the printed version of the document.
-%	The \optn{lwarpmk} option causes \pkg{lwarp} to create a local copy of |lwarpmk.lua|
+%	The \optn{lwarpmk} option causes \pkg{lwarp} to create a local copy of \filenm{lwarpmk.lua}
 % \item The \optn{lwarpmk} option may now be removed from the \pkg{lwarp} package.
-% \item Copy and rename |lwarpmk.lua| to a new file such as |mymake.lua|.
-% \item Modify |mymake.lua| as desired.
-% \item If necessary, make |mymake.lua| executable.
-% \item Use |mymake.lua| instead of |lwarpmk.lua|.
+% \item Copy and rename \filenm{lwarpmk.lua} to a new file such as \filenm{mymake.lua}.
+% \item Modify \filenm{mymake.lua} as desired.
+% \item If necessary, make \filenm{mymake.lua} executable.
+% \item Use \filenm{mymake.lua} instead of \filenm{lwarpmk.lua}.
 % \end{enumerate}
 %
 % To adjust the command-line arguments for compiling the document,
-% look in |mymake.lua| for ``|latexname|''.
+% look in \filenm{mymake.lua} for ``|latexname|''.
 %
 % To adjust the command-line arguments for processing the index,
 % look for ``|xindy|''.
@@ -6522,6 +6702,7 @@
 %
 % \item [Obscure error messages:] ~
 %   \begin{description}
+%       \setlength{\parskip}{1ex}
 %	    \item [Print first:] Be sure that a print version of the document compiles and
 %		    that your document's \LaTeX{} code is correct, before attempting
 %		    to generate an \HTML\ version.
@@ -6556,18 +6737,43 @@
 %           \cs{savebox}, \cs{hbox}, \cs{vbox}, \cs{usebox}, \cs{sbox},
 %           etc., must be modified to work without box commands.
 %
-%           \medskip
-%
-%         If you can locate what used \cs{ensuremath}, have it temporarily set:
+%         If you find something using \cs{ensuremath}, have it temporarily set:
 %         \begin{sourcedisplay}
 %         \cs{LetLtxMacro}\cs{@ensuredmath}\cs{LWR at origensuredmath}
 %         \end{sourcedisplay}
 %         inside a group first.
+%
+%           Also, custom macros which appear inside a section, \watchout[custom macros in section names]
+%           figure, or table name should be
+%           made robust since they appear inside the \filenm{.toc}, \filenm{.lof}, or
+%           \filenm{.lot} files.
+%           Use \cs{newrobustcmd} or \cs{robustify} from \pkg{etoolbox}, \pkg{xparse}, etc.
 %           \index{warning>Improper \cs{prevdepth}.}
 %           \index{Improper \cs{prevdepth}.}
+%       \item[``\texttt{\cs{begin}\{equation\} ended by \cs{end}\{document\}}'':] Do not
+%           \watchout[custom macros for environments]
+%           use custom macros such as \cs{beq} and \cs{eeq} to replace
+%           \begin{sourcedisplay}
+%           \cs{begin}\{equation\} \\
+%           \dots \\
+%           \cs{end}\{equation\}
+%           \end{sourcedisplay}
+%       \item[Complicated objects inside display math:] Some objects, such as \tikz,
+%           \watchout[display math]
+%           may not compile in \pkg{lwarp}'s normal display math emulation.
+%           Insert \cs{displaymathother} before  the display math environment,
+%           and then \cs{displaymathnormal} when displaying ``normal'' math.
+%           See \cref{sec:displaymathother}.
 %   \end{description}
 %
 % \needspace{3\baselineskip}
+% \item [Incorrect \brand{MathJax}:] Some objects do not convert to \brand{Mathjax}.
+%   \watchout[MathJax]
+%   Use \cs{displaymathother} before these objects, then \cs{displaymathnormal} to return
+%   to ``normal'' display math.
+%   See \cref{sec:displaymathother}.
+%
+% \needspace{3\baselineskip}
 % \item [Missing sections:] ~
 %	\begin{itemize}
 %	\item See \cref{sec:filedepth} regarding the
@@ -6613,7 +6819,7 @@
 % \item [Images are appearing in strange places:] ~
 % \index{images>in strange places}
 %	\begin{itemize}
-%	\item |lwarpmk limages| to refresh the |lateximage| images.
+%	\item Enter \cmds{lwarpmk limages} to refresh the \env{lateximage} images.
 %	\end{itemize}
 %
 % \item[SVG images:] \
@@ -6620,6 +6826,7 @@
 %
 % \limitssvgimages
 %
+% \needspace{3\baselineskip}
 % \item [Plain-looking document:] \
 %	\begin{itemize}
 %	\item The document's \CSS\ stylesheet may not be available, or may be
@@ -6671,16 +6878,16 @@
 % \subsection{Compiling the \filenm{lwarp.dtx} file}
 %
 % \begin{description}
-% \item [\texttt{lwarp\_tutorial.tex}:] Copy or link |lwarp_tutorial.txt|
+% \item [\filenm{lwarp\_tutorial.tex}:] Copy or link \filenm{lwarp\_tutorial.txt}
 %		from the \acro{TDS} |doc| directory to the |source| directory,
 %		or wherever you wish to compile the documentation.
-%		This file is included verbatim into the documentation, but is in the |doc|
-%		directory so that it may be found by |texdoc| and copied by the user.
-% \item [Illogical error messages caused by an out-of-sync |lwarp.sty| file:] ~
+%		This file is included verbatim in the documentation, but is in the \filenm{doc}
+%		directory so that it may be found by \prog{texdoc} and copied by the user.
+% \item [Illogical error messages caused by an out-of-sync \filenm{lwarp.sty} file:] ~
 %	\begin{enumerate}
-%	\item Delete the |lwarp.sty| file.
-%	\item |pdflatex lwarp.ins| to generate a new |lwarp.sty| file.
-%	\item |pdflatex lwarp.dtx| to recompile the |lwarp.pdf| documentation.
+%	\item Delete the \filenm{lwarp.sty} file.
+%	\item Enter \cmds{pdflatex lwarp.ins} to generate a new \filenm{lwarp.sty} file.
+%	\item Enter \cmds{pdflatex lwarp.dtx} to recompile the \filenm{lwarp.pdf} documentation.
 %	\end{enumerate}
 %
 % \item [Un-nested environments:]~
@@ -6696,7 +6903,15 @@
 % 
 %
 %
-% \StopEventually{\PrintChanges\PrintIndex}
+% \StopEventually{
+%   \PrintChanges
+%   \phantomsection
+%   \label{sec:changesend}
+%   \PrintIndex
+%   \vfill
+%   For the most recent changes and the start of the Index,
+%   see page \pageref{sec:changesend}.
+% }
 % 
 %
 %
@@ -6720,7 +6935,7 @@
 % Examples include \pkg{xcolor} with its color models and conversion to \HTML\
 % color output, and \pkg{siunitx} which provides many number and unit-formatting
 % options, almost all of which are available in pure-text form, and thus
-% easily used by \cmds{pdftotext}.
+% easily used by \prog{pdftotext}.
 %
 % Packages were emulated where their primary purpose was visual formatting which is not
 % relevent to \HTML\ output.  For example, packages related to sectioning
@@ -7075,13 +7290,18 @@
 % \DescribeBoolean{warpingprint}
 % \DescribeBoolean{warpingHTML}
 % \DescribeBoolean{mathjax}
+% \DescribeBoolean{LWR at origmathjax}
 %
 % Set to true/false depending on the package option selections for
-% print/\HTML/\EPUB\ output and mathsvg/mathjax:
+% print/\HTML/\EPUB\ output and mathsvg/mathjax.
+%
+% \optn{LWR at origmathjax} remembers the original setting to be restored
+% by \cs{displaymathnormal}.
 %    \begin{macrocode}
 \newbool{warpingprint}
 \newbool{warpingHTML}
 \newbool{mathjax}
+\newbool{LWR at origmathjax}
 %    \end{macrocode}
 %
 %
@@ -7143,6 +7363,7 @@
 \DeclareVoidOption{mathsvg}{%
 \PackageInfo{lwarp}{Using option 'mathsvg'}
 \boolfalse{mathjax}%
+\boolfalse{LWR at origmathjax}%
 }
 %    \end{macrocode}
 %
@@ -7155,6 +7376,7 @@
 \DeclareVoidOption{mathjax}{%
 \PackageInfo{lwarp}{Using option 'mathjax'}
 \booltrue{mathjax}%
+\booltrue{LWR at origmathjax}%
 }
 %    \end{macrocode}
 
@@ -7202,11 +7424,11 @@
 
 
 % \DescribeOption{lwarpmk} Tells \pkg{lwarp} to
-%	generate a local copy of \prog{lwarpmk} called |lwarpmk.lua|.
+%	generate a local copy of \prog{lwarpmk} called \filenm{lwarpmk.lua}.
 %	Useful for archiving for future use.
 %	This file may be made executable and acts just like \prog{lwarpmk}.
 %
-% If \optn{lwarpmk} option, creates a local copy of |lwarpmk.lua|:
+% If \optn{lwarpmk} option, creates a local copy of \filenm{lwarpmk.lua}:
 %    \begin{macrocode}
 \newbool{LWR at creatinglwarpmk}
 \boolfalse{LWR at creatinglwarpmk}
@@ -7548,6 +7770,11 @@
 \LWR at notmemoirloadafter{chngpage}
 \LWR at loadafter{chappg}
 \LWR at loadafter{chapterbib}
+\LWR at loadafter{chemfig}
+\LWR at loadafter{chemformula}
+\LWR at loadafter{chemgreek}
+\LWR at loadafter{chemmacros}
+\LWR at loadafter{chemnum}
 \LWR at loadafter{cite}
 \LWR at loadafter{color}
 \LWR at loadafter{colortbl}
@@ -7571,6 +7798,7 @@
 \LWR at loadafter{enumitem}
 \LWR at notmemoirloadafter{epigraph}
 \LWR at loadafter{epstopdf}
+\LWR at loadafter{epstopdf-base}
 \LWR at loadafter{eso-pic}
 \LWR at loadafter{everypage}
 \LWR at loadafter{everyshi}
@@ -7610,6 +7838,7 @@
 % \LWR at loadafter{graphics}% pre-loaded by xunicode
 % \LWR at loadafter{graphicx}% pre-loaded by xunicode
 \LWR at loadafter{grffile}
+\LWR at loadafter{grid}
 \LWR at loadafter{hang}
 \LWR at loadafter{hanging}
 \LWR at loadafter{hypcap}
@@ -7632,6 +7861,7 @@
 \LWR at loadafter{longtable}
 \LWR at loadafter{lscape}
 \LWR at loadafter{ltcaption}
+\LWR at loadafter{ltxgrid}
 \LWR at loadafter{ltxtable}
 \LWR at loadafter{luacolor}
 \LWR at loadafter{luatodonotes}
@@ -7642,6 +7872,7 @@
 \LWR at loadafter{mdframed}
 \LWR at loadafter{memhfixc}
 \LWR at loadafter{metalogo}
+\LWR at loadafter{mhchem}
 \LWR at loadafter{microtype}
 \LWR at loadafter{midfloat}
 \LWR at loadafter{midpage}
@@ -7981,16 +8212,7 @@
 \RequirePackage{xparse}
 %    \end{macrocode}
 
-% \DescribePackage{afterpackage}
-% Used to patch \pkg{titling} to add \cs{AddSubtitlePublished}.
-% Provided by \pkg{scrlfile} or \pkg{afterpackage}.
-% \changes{v0.44}{2017/11/19}{Adjustment for \pkg{koma-script}.}
-%    \begin{macrocode}
-\@ifundefined{AfterPackage}%
-{
-\RequirePackage{afterpackage}
-}{}
-%    \end{macrocode}
+% \changes{v0.51}{2018/03/06}{\pkg{afterpackage}: No longer required.}
 
 %    \begin{macrocode}
 \end{warpall}
@@ -8314,7 +8536,8 @@
 % 
 % \begin{macro}{\LWR at lookforpackagename} \marg{index}
 %
-% If this is a package name, re-direct it to the \pkg{lwarp} version
+% If this is an \pkg{lwarp}-supported package name,
+% re-direct it to the \pkg{lwarp} version
 % by renaming it |lwarp-| followed by the original name.
 %
 % Looks |index| deep into the list of package names, \cs{LWR at requirepackagenames}, and
@@ -8914,7 +9137,14 @@
 %    \begin{macrocode}
 \LetLtxMacro\LWR at origmbox\mbox
 \LetLtxMacro\LWR at origmakebox\makebox
-
+%    \end{macrocode}
+% Some packages redefine \cs{\#}, which is used to generate \HTML, so the original must
+% be remembered here.
+% \changes{v0.51}{2018/03/12}{Fix: Remember original \cs{\#} in case is redefined.}
+%    \begin{macrocode}
+\chardef\LWR at origpound=`\#
+%    \end{macrocode}
+%    \begin{macrocode}
 \let\LWR at origcomma\,
 \let\LWR at origtilde~
 \let\LWR at origenskip\enskip
@@ -9113,12 +9343,12 @@
 \LetLtxMacro{\c}{\LWR at origc}%
 \LetLtxMacro{\d}{\LWR at origd}%
 \LetLtxMacro{\b}{\LWR at origb}%
-}
+}%
 \else% XeLaTeX, LuaLaTeX:
 \newcommand*{\LWR at restoreorigaccents}{%
 \LetLtxMacro{\t}{\LWR at origt}%
-}
-\fi
+}%
+\fi%
 }% AtBeginDocument
 %    \end{macrocode}
 % \end{macro}
@@ -10280,7 +10510,9 @@
 
 
 /* Fancybox */
-div.Btrivlist table tr td { padding: .2ex 0em ; }
+div.Btrivlist table tr td {
+    padding: .2ex 0em ;
+}
 
 
 /* program listing callouts: */
@@ -10406,12 +10638,11 @@
 div.lateximagesource { padding: 0px ; margin: 0px ; display: none; }
 
 img.lateximage{
-    padding: 0px 0px 0px 0px ;
+    padding: 0pt ;
+    margin: 0pt ;
     box-shadow: none ;
     border: none ;
     background: none ;
-    margin: 0px 0px -.15ex 0px ;
-        /* pdfcrop leaves a slight margin, adjust to baseline */
     max-width: 100% ;
     border-radius: 0ex ;
     border: none ;
@@ -10629,8 +10860,6 @@
 }
 
 
-
-
 /* Only display top and bottom navigation if a small screen: */
 /* Hide the sidetoc if a small screen: */
 nav.topnavigation { display:none; }
@@ -11264,6 +11493,7 @@
 % This occurs each time \prog{lwarpmk} used to create \env{lateximage}s.
 %
 % \changes{v0.50}{2018/02/27}{\filenm{lwarp\_one\_limage.txt}: Added.}
+% \changes{v0.51}{2018/03/16}{\filenm{lwarp\_one\_limage.txt}: \prog{pdftocairo} \optn{-noshrink} added.}
 %
 % ^^A *lwarp_one_limage.txt
 %    \begin{macrocode}
@@ -11270,11 +11500,11 @@
 \begin{warpprint}
 \begin{filecontents*}{lwarp_one_limage.txt}
 @echo off
-pdfseparate -f %1 -l %1 %4_html.pdf lateximages\lateximagetemp-%%d.pdf"
-pdfcrop  lateximages\lateximagetemp-%1.pdf lateximages\%3.pdf
-pdftocairo -svg lateximages\%3.pdf lateximages\%3.svg
+pdfseparate -f %1 -l %1 %4_html.pdf lateximages\lateximagetemp-%%d.pdf
+pdfcrop  --hires  lateximages\lateximagetemp-%1.pdf lateximages\%3.pdf
+pdftocairo  -svg -noshrink  lateximages\%3.pdf lateximages\%3.svg
 del lateximages\%3.pdf
-del lateximages\lateximagetemp-%1.pdf"
+del lateximages\lateximagetemp-%1.pdf
 exit
 \end{filecontents*}
 \end{warpprint}
@@ -11438,6 +11668,8 @@
 % \changes{v0.50}{2018/02/28}{\prog{lwarpmk}: Error if \filenm{lateximages.txt} does not exist.}
 % \changes{v0.50}{2018/02/28}{\prog{lwarpmk}: Error if \filenm{lwarpmk.conf} points to \pkg{lwarp}.}
 % \changes{v0.50}{2018/02/28}{\prog{lwarpmk}: Improved error messages.}
+% \changes{v0.51}{2018/03/14}{\prog{lwarpmk}: \prog{pdfcrop}: Restored \optn{hires} option.}
+% \changes{v0.51}{2018/03/16}{\prog{lwarpmk}: \prog{pdftocairo} \optn{-noshrink} added.}
 %
 % ^^A *lwarpmk.lua
 %    \begin{macrocode}
@@ -11448,7 +11680,7 @@
 
 -- Print the usage of the lwarpmk command:
 
-printversion = "v0.50"
+printversion = "v0.51"
 
 function printhelp ()
 print ("lwarpmk: Use lwarpmk -h or lwarpmk --help for help.") ;
@@ -11819,11 +12051,11 @@
     "lateximages" .. dirslash .."lateximagetemp-%d" .. ".pdf" ..
     seqname ..
 -- Crop the image:
-"pdfcrop  lateximages" .. dirslash .. "lateximagetemp-" .. lwimgpage .. ".pdf " ..
+"pdfcrop  --hires  lateximages" .. dirslash .. "lateximagetemp-" .. lwimgpage .. ".pdf " ..
     "lateximages" .. dirslash .. lwimgname .. ".pdf" ..
     seqname ..
 -- Convert the image to svg:
-"pdftocairo -svg lateximages" .. dirslash .. lwimgname .. ".pdf " ..
+"pdftocairo -svg  -noshrink  lateximages" .. dirslash .. lwimgname .. ".pdf " ..
     "lateximages" .. dirslash .. lwimgname ..".svg" ..
     seqname ..
 -- Remove the temporary files:
@@ -12390,7 +12622,7 @@
 % \end{macro}
 % \begin{macro}{\HTMLunicode} \marg{hex\_unicode}
 %    \begin{macrocode}
-\newcommand*{\HTMLunicode}[1]{\HTMLentity{\#x#1}}
+\newcommand*{\HTMLunicode}[1]{\HTMLentity{\LWR at origpound{}x#1}}
 %    \end{macrocode}
 % \end{macro}
 
@@ -12914,7 +13146,7 @@
     \renewrobustcmd*{\FBthinspace}{%
         \begingroup%
         \LWR at FBcancel%
-        \LWR at origampersand\#x202f;% \,
+        \LWR at origampersand\LWR at origpound{}x202f;% \,
         \endgroup%
     }%
     \renewrobustcmd*{\FBguillspace}{%
@@ -12926,7 +13158,7 @@
     \DeclareDocumentCommand{\FBmedkern}{}{%
         \begingroup%
         \LWR at FBcancel%
-        \LWR at origampersand\#x202f;% \,
+        \LWR at origampersand\LWR at origpound{}x202f;% \,
         \endgroup%
     }%
     \DeclareDocumentCommand{\FBthickkern}{}{%
@@ -13053,7 +13285,7 @@
 %
 %    \begin{macrocode}
 \NewDocumentCommand{\LWR at htmlspanclass}{o m +m}{%
-\LWR at traceinfo{LWR at htmlspanclass #2}%
+\LWR at traceinfo{LWR at htmlspanclass |#1|#2|}%
 \LWR at ensuredoingapar%
 \LWR at subhtmlelementclass{span}[#1]{#2}%
 \begin{LWR at nestspan}%
@@ -13159,7 +13391,7 @@
 %
 %    \begin{macrocode}
 \NewDocumentCommand{\LWR at subhtmlelementclass}{m O{} m}{%
-\LWR at traceinfo{LWR at subhtmlelementclass #1 #3}%
+\LWR at traceinfo{LWR at subhtmlelementclass !#1!#2!#3!}%
 \ifblank{#2}%
 {\LWR at htmltag{#1 class="#3"}}% empty option
 {\LWR at htmltag{#1 class="#3" style="#2"}}% non-empty option
@@ -14517,7 +14749,7 @@
     {\textless}{-}[\LWR at thisnewfilename]
 \StrSubstitute{\LWR at thisnewfilename}%
     {\textgreater}{-}[\LWR at thisnewfilename]
-\StrSubstitute{\LWR at thisnewfilename}{\#}{-}[\LWR at thisnewfilename]
+\StrSubstitute{\LWR at thisnewfilename}{\LWR at origpound}{-}[\LWR at thisnewfilename]
 %    \end{macrocode}
 % \changes{v0.45}{2017/12/29}{Fix: Section names with underscores.}
 %    \begin{macrocode}
@@ -14601,6 +14833,24 @@
 % \end{macro}
 
 
+% \begin{macro}{\LWR at nullifymathjaxensuremath}
+% \changes{v0.51}{2018/03/18}{MathJax: Nullifies \cs{ensuremath}.}
+%    \begin{macrocode}
+\newcommand{\LWR at nullifymathjaxensuremath}{%
+\ifbool{mathjax}{
+\LWR at stoppars
+\LWR at htmlcomment{Nullify \textbackslash{}ensuremath for MathJax:}
+
+\(
+\newcommand\ensuremath[1]{##1}
+\)
+\LWR at startpars
+}{}
+}
+%    \end{macrocode}
+% \end{macro}
+
+
 % \begin{macro}{\LWR at newhtmlfile} \marg{section name}
 % \changes{v0.18}{2016/04/23}{side\TOC\ after title, improving responsive design.}
 % \changes{v0.21}{2017/02/22}{Skip title if not given.}
@@ -14755,7 +15005,15 @@
 \LWR at stoppars
 
 %    \end{macrocode}
+%
+% If using MathJax, disable \cs{ensuremath} by printing a nullified
+% definition at the start of each file:
+% \changes{v0.51}{2018/03/18}{MathJax: Nullifies \cs{ensuremath}.}
 %    \begin{macrocode}
+\LWR at nullifymathjaxensuremath
+%    \end{macrocode}
+%
+%    \begin{macrocode}
 \LWR at traceinfo{LWR at newhtmlfile: done}
 }
 %    \end{macrocode}
@@ -15773,6 +16031,16 @@
 % Allow \HTML\ paragraphs to begin:
 %    \begin{macrocode}
 \LWR at startpars
+%    \end{macrocode}
+%
+% If using MathJax, disable \cs{ensuremath} by printing a nullified
+% definition at the start of each file:
+% \changes{v0.51}{2018/03/18}{MathJax: Nullifies \cs{ensuremath}.}
+%    \begin{macrocode}
+\LWR at nullifymathjaxensuremath
+%    \end{macrocode}
+%
+%    \begin{macrocode}
 \LWR at traceinfo{LWR at lwarpStart: done}
 }
 \catcode`\$=3% math shift until lwarp starts
@@ -16339,7 +16607,7 @@
 % \begin{macro}{\@fnsymbol} \marg{counter}
 %
 % Re-defined to use an \HTML\ entity for the double vertical bar symbol.
-% The original definition used \cs{\textbar} which was not being seen by \cmds{pdftotext}.
+% The original definition used \cs{\textbar} which was not being seen by \prog{pdftotext}.
 %
 % \changes{v0.34}{2017/08/07}{Text symbols instead of math.}
 %
@@ -16485,9 +16753,10 @@
 %
 % The default |lwarp.css| has definitions for the |published| and |subtitle| classes.
 %
-% After \pkg{titling} is loaded, \cs{AddSubtitlePublished} is created,
-% which when used then creates a number of additional macros,
-% and also assigns some of the \pkg{titling} hooks.
+% If \pkg{titling} is loaded, \cs{AddSubtitlePublished} creates a number
+% of additional macros, and also assigns some of the \pkg{titling} hooks.
+% If \pkg{titling} is not loaded, \cs{AddSubtitlePublished} creates null macros.
+%
 % Do not use \cs{AddSubtitlePublished} if the user has patched the \pkg{titling}
 % \watchout[\pkg{titling} hooks]
 % hooks for some other reason.
@@ -16507,41 +16776,38 @@
 % \changes{v0.39}{2017/09/05}{Added.}
 %
 %    \begin{macrocode}
-\AfterPackage{titling}{
 \newcommand*{\AddSubtitlePublished}{%
-
-\newcommand{\@published}{}
-
-\newcommand{\published}[1]{\gdef\@published{##1}}
-
-\renewcommand*{\maketitlehooka}{\printpublished}
-
-\newcommand*{\printpublished}{%
-\warpprintonly{\begin{center}\unskip}%
-\begin{BlockClass}{published}%
-\warpprintonly{\large\itshape}%
-\@published%
-\end{BlockClass}%
-\warpprintonly{\end{center}}%
-}
-
-\newcommand{\@subtitle}{}
-
-\newcommand{\subtitle}[1]{\gdef\@subtitle{##1}}
-
-\renewcommand*{\maketitlehookb}{\printsubtitle}
-
-\newcommand*{\printsubtitle}{%
-\warpprintonly{\begin{center}\unskip}%
-\begin{BlockClass}{subtitle}%
-\warpprintonly{\Large\itshape}%
-\@subtitle%
-\end{BlockClass}%
-\warpprintonly{\end{center}}%
-}
-
+\@ifpackageloaded{titling}{% yes titling package
+    \newcommand{\@published}{}%
+    \newcommand{\published}[1]{\gdef\@published{##1}}%
+    \renewcommand*{\maketitlehooka}{\printpublished}%
+    \newcommand*{\printpublished}{%
+        \warpprintonly{\begin{center}\unskip}%
+        \begin{BlockClass}{published}%
+        \warpprintonly{\large\itshape}%
+        \@published%
+        \end{BlockClass}%
+        \warpprintonly{\end{center}}%
+    }%
+    \newcommand{\@subtitle}{}%
+    \newcommand{\subtitle}[1]{\gdef\@subtitle{##1}}%
+    \renewcommand*{\maketitlehookb}{\printsubtitle}%
+    \newcommand*{\printsubtitle}{%
+        \warpprintonly{\begin{center}\unskip}%
+        \begin{BlockClass}{subtitle}%
+        \warpprintonly{\Large\itshape}%
+        \@subtitle%
+        \end{BlockClass}%
+        \warpprintonly{\end{center}}%
+    }%
+}% yes titling package
+{% no titling package
+    \newcommand{\published}[1]{}%
+    \newcommand*{\printpublished}{}%
+    \newcommand{\subtitle}{}%
+    \newcommand*{\printsubtitle}%
+}% no titling package
 }% \AddSubtitlePublished
-}% AfterPackage
 %    \end{macrocode}
 % \end{macro}
 
@@ -16748,11 +17014,16 @@
 %    \end{macrocode}
 
 
-% \begin{macro}{\LWR at atbeginverbatim} \oarg{style} \marg{class}
+% \begin{macro}{\LWR at atbeginverbatim}
+%       \oarg{1: style}
+%       \marg{2: negative \cs{baselineskip} \cs{vspace}}
+%       \marg{3: class}
 %
 % Encloses a verbatim environment with the given \CSS\ class.
+%
+% \changes{v0.51}{2018/03/17}{Adds vertical offset.}
 %    \begin{macrocode}
-\newcommand*{\LWR at atbeginverbatim}[2][]
+\newcommand*{\LWR at atbeginverbatim}[3][]
 {%
 %    \end{macrocode}
 % Avoid excessive space between lines:
@@ -16768,9 +17039,11 @@
 % as loading the \brand{MathJax} script.
 %    \begin{macrocode}
 \ifbool{LWR at verbtags}{%
-    \LWR at htmltag{pre class="#2"
-    \ifthenelse{\equal{#1}{}}{}{style="#1"}%
-}\LWR at orignewline% pre
+    \LWR at htmltag{pre class="#3"
+        \ifthenelse{\equal{#1}{}}{}{style="#1"}%
+    }%
+    \unskip\LWR at origvspace*{-#2\baselineskip}%
+    \LWR at orignewline% pre
 }{}%
 %    \end{macrocode}
 % Use a mono-spaced font to preserve horizontal positioning.
@@ -16832,7 +17105,7 @@
 
 \renewcommand{\verbatim at input}[2]{%
 \ifbool{LWR at verbtags}{\LWR at forcenewpage}{}%
-\LWR at atbeginverbatim{Verbatim}\unskip\LWR at origvspace*{-\baselineskip}%%
+\LWR at atbeginverbatim{3.5}{Verbatim}%
 \LWRV at origverbatim@input{#1}{#2}%
 \unskip\LWR at origvspace*{-\baselineskip}\LWR at afterendverbatim%
 }
@@ -16850,7 +17123,8 @@
 \LWR at traceinfo{Patching verbatim.}
 \AtBeginEnvironment{verbatim}{%
 \LWR at forcenewpage%
-\LWR at atbeginverbatim{verbatim}\unskip\LWR at origvspace*{-2\baselineskip}%
+\LWR at atbeginverbatim{.5}{verbatim}%
+\unskip\LWR at origvspace*{-1.5\baselineskip}%
 }
 \AfterEndEnvironment{verbatim}{%
     \unskip\LWR at origvspace*{-\baselineskip}\LWR at afterendverbatim%
@@ -16871,7 +17145,7 @@
 \LWR at traceinfo{Patching tabbing.}
 \AtBeginEnvironment{tabbing}{%
 \LWR at forcenewpage
-\LWR at atbeginverbatim{tabbing}\unskip\LWR at origvspace*{-\baselineskip}%
+\LWR at atbeginverbatim{3.5}{tabbing}%
 }
 \AfterEndEnvironment{tabbing}{%
     \unskip\LWR at origvspace*{-\baselineskip}\LWR at afterendverbatim%
@@ -17117,8 +17391,9 @@
     \fi
   \fi
 %    \end{macrocode}
+% \changes{v0.51}{2018/03/17}{Restored list label space.}
 %    \begin{macrocode}
-    \makelabel{#1}%
+    \makelabel{#1} % extra space
 %   \sbox\@tempboxa{\makelabel{#1}%
 %   \global\setbox\@labels\hbox{%
 %     \unhbox\@labels
@@ -17316,7 +17591,7 @@
 
 % \begin{macro}{\LWR at patchlists} Patches list environments.
 %
-% \cs{LWr at patchlists} remembers \cs{item} as defined by whatever packages have
+% \cs{LWR at patchlists} remembers \cs{item} as defined by whatever packages have
 %	been loaded, then
 % patches the |itemize|, |enumerate|, and |description| environments and \cs{item}.
 % This works with the native \LaTeX\ environments, as well as
@@ -18642,7 +18917,7 @@
         }{%
             \LWR at htmltag{%
                 tr class="hline" %
-                style="border-top: 1px solid \#\LWR at ruleHTMLcolor "%
+                style="border-top: 1px solid \LWR at origpound\LWR at ruleHTMLcolor "%
             }%
         }%
         \LWR at orignewline%
@@ -18655,7 +18930,7 @@
             }{%
                 \LWR at htmltag{%
                     tr class="tbrule" %
-                    style="border-top: 1px solid \#\LWR at ruleHTMLcolor "%
+                    style="border-top: 1px solid \LWR at origpound\LWR at ruleHTMLcolor "%
                 }%
             }%
             \LWR at orignewline%
@@ -19136,14 +19411,14 @@
 %    \begin{macrocode}
     \ifdefvoid{\LWR at ruleHTMLcolor}{%
         \ifdimcomp{#1}{<}{\LWR at lightrulewidth}%
-        {\#A0A0A0}%
+        {\LWR at origpound{}A0A0A0}%
         {% lightrule or heaver
             \ifdimcomp{#1}{<}{\LWR at heavyrulewidth}%
-            {\#808080}%
+            {\LWR at origpound{}808080}%
             {black}%
         }% lightrule or heavier
     }{%
-        \#\LWR at ruleHTMLcolor%
+        \LWR at origpound\LWR at ruleHTMLcolor%
     }
 }% custom width and/or color
 }
@@ -19214,12 +19489,12 @@
         \ifdefvoid{\LWR at xcolorrowHTMLcolor}{}%
         {% xcolor row color
             \LWR at tdaddstyle%
-            background:\#\LWR at xcolorrowHTMLcolor%
+            background:\LWR at origpound\LWR at xcolorrowHTMLcolor%
         }%
     }%
     {% explicit row color
         \LWR at tdaddstyle%
-        background:\#\LWR at rowHTMLcolor%
+        background:\LWR at origpound\LWR at rowHTMLcolor%
     }%
 }%
 }
@@ -19245,7 +19520,7 @@
     \ifdefvoid{\LWR at ruleHTMLcolor}{}%
     {%
         \LWR at tdaddstyle%
-        border-top: 1px solid \#\LWR at ruleHTMLcolor%
+        border-top: 1px solid \LWR at origpound\LWR at ruleHTMLcolor%
     }{}%
 }{}%
 }
@@ -19282,7 +19557,7 @@
 %    \begin{macrocode}
         \ifdefstring{\LWR at tempone}{tvertbarl}{%
                 \LWR at tdaddstyle%
-                border-left: 1px solid \#\LWR at vertruleHTMLcolor%
+                border-left: 1px solid \LWR at origpound\LWR at vertruleHTMLcolor%
         }{}%
     }{}%
 %    \end{macrocode}
@@ -19294,7 +19569,7 @@
 % Add a custom style if a vertical bar was requested:
 %    \begin{macrocode}
             \LWR at tdaddstyle%
-            border-right: 1px solid \#\LWR at vertruleHTMLcolor%
+            border-right: 1px solid \LWR at origpound\LWR at vertruleHTMLcolor%
     }{}%
 }%
 }
@@ -19313,7 +19588,7 @@
 %    \begin{macrocode}
 \newcommand*{\LWR at subaddtabularcellcolor}[1]{%
 \LWR at htmltag{div class="cellcolor" style="%
-    background:\#{}#1 %
+    background:\LWR at origpound{}{}#1 %
 " }%
 \addtocounter{LWR at cellcolordepth}{1}%
 }
@@ -19550,7 +19825,7 @@
 %    \begin{macrocode}
     \ifbool{LWR at mcolvertbarl}{%
         \LWR at tdaddstyle%
-        border-left: 1px solid \#\LWR at vertruleHTMLcolor%
+        border-left: 1px solid \LWR at origpound\LWR at vertruleHTMLcolor%
     }{}%
 %    \end{macrocode}
 % Right side:
@@ -19557,7 +19832,7 @@
 %    \begin{macrocode}
     \ifbool{LWR at mcolvertbarr}{%
         \LWR at tdaddstyle%
-        border-right: 1px solid \#\LWR at vertruleHTMLcolor%
+        border-right: 1px solid \LWR at origpound\LWR at vertruleHTMLcolor%
     }{}%
 }%
 }
@@ -21021,7 +21296,7 @@
 \LWR at traceinfo{LWR at startref B}%
 \LWR at origmbox{\LWR at htmlrefsectionfilename{#1}}%
 \LWR at traceinfo{LWR at startref C}%
-\#%
+\LWR at origpound%
 %    \end{macrocode}
 % Create the destination id:
 %
@@ -21334,7 +21609,7 @@
 % \item [\cs{<type>}:] Starts the float environment. |\figure| or |\begin{figure}|
 % \item [\cs{end<type>}:] Ends the float environment. |\endfigure| or |\end{figure}|
 % \item [\cs{tf@<ext>}:] The \LaTeX{} file identifier for the output file.
-% \item [\progcode{LWR at have<type>}:] A boolean rememebering whether a \cs{listof} was
+% \item [\progcode{LWR at have<type>}:] A boolean remembering whether a \cs{listof} was
 %	requested for a float of this type.
 % \item [File with extension \filenm{lo<f,t,a-z>}:] An output file containing
 %	the commands to build the
@@ -21481,13 +21756,19 @@
 % Adds a new \element{autoid} anchor.
 % \changes{v0.45}{2017/12/07}{Fix: No anchor if frozen autoid.}
 % \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
+% \changes{v0.51}{2018/03/16}{Fix: No autoid is inside a \env{lateximage}.}
 %    \begin{macrocode}
 \newcommand*{\LWR at newautoidanchor}{%
-\ifbool{LWR at freezethisautoid}{}{%
-    \addtocounter{LWR at thisautoid}{1}%
-    \LWR at htmltag{a id="\LWR at origmbox{autoid-\arabic{LWR at thisautoid}}"}\LWR at htmltag{/a}%
-}%
+\ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}%
+{}%
+{
+    \ifbool{LWR at freezethisautoid}{}{%
+        \addtocounter{LWR at thisautoid}{1}%
+        \LWR at htmltag{a id="\LWR at origmbox{autoid-\arabic{LWR at thisautoid}}"}%
+            \LWR at htmltag{/a}%
+    }%
 }
+}
 %    \end{macrocode}
 % \end{macro}
 
@@ -21696,14 +21977,22 @@
 %
 % \changes{v0.25}{2017/03/16}{Handles theorems.}
 % \changes{v0.44}{2017/11/10}{Automatic \cs{LWR at newfloatanchor}.}
-%
+%f
 %    \begin{macrocode}
 \let\LWR at origaddcontentsline\addcontentsline
 
 \renewcommand*{\addcontentsline}[3]{%
 \ifstrequal{#1}{toc}{}{% not TOC
-    \LWR at newautoidanchor%
-    \ifthenelse{\equal{#1}{thm}}{\csdef{ext@#2}{thm}}{}%
+%    \end{macrocode}
+% \changes{v0.51}{2018/03/11}{No anchor ID if inside \SVG\ image.}
+%    \begin{macrocode}
+\ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}%
+    {}
+    {\LWR at newautoidanchor}%
+%    \end{macrocode}
+% \changes{v0.51}{2018/03/11}{Add missing support for float mechanism if necessary.}
+%    \begin{macrocode}
+    \ifcsvoid{ext@#2}{\csdef{ext@#2}{#1}}{}%
     \addtocontents{\@nameuse{ext@#2}}{%
         \protect\LWRsetnextfloat%
         {\arabic{LWR at latestautopage}}%
@@ -22111,7 +22400,7 @@
 % \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
 %    \begin{macrocode}
     \LWR at subhyperrefclass{%
-        \LWR at htmlrefsectionfilename{autopage-#4}\#\LWR at origmbox{autosec-#4}%
+        \LWR at htmlrefsectionfilename{autopage-#4}\LWR at origpound\LWR at origmbox{autosec-#4}%
     }{#3}{toc#2}%
     \LWR at stoppars%
 }
@@ -22176,7 +22465,7 @@
 %    \begin{macrocode}
     \LWR at subhyperrefclass{%
     \LWR at htmlrefsectionfilename{autopage-\arabic{LWR at nextautopage}}%
-    \#\LWR at origmbox{autoid-\arabic{LWR at nextautoid}}}%
+    \LWR at origpound\LWR at origmbox{autoid-\arabic{LWR at nextautoid}}}%
     {#4}{toc#2}%
     \LWR at stoppars%
 }{}%
@@ -22566,9 +22855,9 @@
 %    \end{macrocode}
 % \changes{v0.50}{2018/02/22}{Fix: \cs{centering}, etc. in \SVG\ math, \env{lateximage}, \tikz.}
 %    \begin{macrocode}
-\let\raggedright\LWR at origraggedright
-\let\raggedleft\LWR at origraggedleft
-\let\centering\LWR at origcentering
+\let\raggedright\LWR at origraggedright%
+\let\raggedleft\LWR at origraggedleft%
+\let\centering\LWR at origcentering%
 %    \end{macrocode}
 %    \begin{macrocode}
 \let\,\LWR at origcomma% disable HTML short unbreakable space
@@ -22649,11 +22938,6 @@
 % \changes{v0.42}{2017/10/16}{Improved \cs{ensuremath}.}
 %    \begin{macrocode}
 \LetLtxMacro\@ensuredmath\LWR at origensuredmath%
-%    \end{macrocode}
-% \changes{v0.43}{2017/10/31}{Fix: Improved math inside lateximages.}
-%    \begin{macrocode}
-\csletcs{equation*}{LWR at origequationstar}%
-\csletcs{endequation*}{LWR at origendequationstar}%
 %
 \LWR at restoreorigaccents%
 \LWR at restoreoriglists%
@@ -22678,8 +22962,12 @@
 %
 % \limitsmath
 %
+% \subsubsection{Display math}
 %
+% \describedisplaymathother
 %
+%
+%
 % \subsection{Inline and display math}
 %
 %
@@ -22689,14 +22977,33 @@
 %    \end{macrocode}
 
 
+%
+% \DescribeCounter{LWR at externalfilecnt}
+% Counter for the external files which are generated and then referenced from the \HTML:
+%    \begin{macrocode}
+\newcounter{LWR at externalfilecnt}
+%    \end{macrocode}
+
+
+% \DescribeBoolean{LWR at indisplaymathimage}
+% True if processing display math for \SVG\ output.
+% Inside a \env{lateximage}, display math is only set to print-mode output
+% if |LWR at indisplaymathimage| is false.
+% Used to avoid nullifying display math before it has been completed.
+%    \begin{macrocode}
+\newbool{LWR at indisplaymathimage}
+%    \end{macrocode}
+
+
 % \DescribeMacro{\$}
 %	Plain dollar signs appearing in the \HTML\ output may be interpreted
 %	by \brand{MathJax} to be math shifts.
-%	For a plain text dollar |\$|, print it inside a span to avoid
+%	For a plain text dollar |\$|, use an \HTML\ entity to avoid
 %	it being interpreted by \brand{MathJax}, unless are inside a lateximage,
 %	in which case it will not be seen by \brand{MathJax}.
 % \changes{v0.19}{2016/06/08}{Avoids \brand{MathJax}.}
 % \changes{v0.26}{2017/03/30}{Dollar span avoided in a lateximage.}
+% \changes{v0.51}{2018/03/23}{HTML entity used for text dollar.}
 %    \begin{macrocode}
 \let\LWR at origtextdollar\$
 
@@ -22703,99 +23010,71 @@
 \renewcommand*{\$}{%
 \ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}%
 {\LWR at origtextdollar}%
-{\LWR at htmltagc{span}\LWR at origtextdollar\LWR at htmltagc{/span}}%
+{\HTMLentity{dollar}}%
 }
 %    \end{macrocode}
 
 
-
+% \DescribeFile{lwarp_baseline_marker.png}
+% A marker to be used to help \prog{pdfcrop} identify the inline math baseline
+% and width.  If either \pkg{graphicx} or \pkg{graphics} is loaded, this marker is
+% placed at the lower left and lower right corners of the inline math.
+% \prog{pdfcrop} is then able to identify the width of the image, and also
+% the height of an image such as a horizontal dash which does not
+% otherwise touch the baseline.
 %
-% \DescribeCounter{LWR at externalfilecnt}
-% Counter for the external files which are generated and then referenced from the \HTML:
-%    \begin{macrocode}
-\newcounter{LWR at externalfilecnt}
-%    \end{macrocode}
-
-
-
-%    \begin{macrocode}
-\LetLtxMacro\LWR at origdollar$
-\LetLtxMacro\LWR at secondorigdollar$% balance for editor syntax highlighting
-%    \end{macrocode}
-
-%    \begin{macrocode}
-\LetLtxMacro\LWR at origopenparen\(
-\LetLtxMacro\LWR at origcloseparen\)
-\LetLtxMacro\LWR at origopenbracket\[
-\LetLtxMacro\LWR at origclosebracket\]
-%    \end{macrocode}
-
-% \DescribeObject{\$}
-% \DescribeObject{\$\$}
-% Redefine the dollar sign to place math inside a \env{lateximage}, or use \brand{MathJax}:
-%    \begin{macrocode}
-\begingroup
-\catcode`\$=\active%
-\protected\gdef${\@ifnextchar$\LWR at doubledollar\LWR at singledollar}%
-%    \end{macrocode}
-
-
-% \begin{macro}{\LWR at doubledollar}
+% A marker with alpha or opacity of 0\% is not registered by \prog{pdfcrop}, so
+% the marker is a small square block of 1\% alpha, which seems to work while still being
+% effectively invisible in the final SVG image.
 %
-% \changes{v0.19}{2016/05/25}{\brand{MathJax} support.}
-% \changes{v0.42}{2017/10/16}{Improved \cs{ensuremath}.}
-% \changes{v0.42}{2017/10/16}{Improved line spacing with mathjax.}
+% If \pkg{graphicx} is loaded, this marker is sized as a tiny 1\,sp square.
+% If \pkg{graphics} is loaded, this marker is used at its default size of around
+% .25\,pt.
+% If neither graphics package is loaded, the marker is replaced by a 10\,sp horizontal
+% space, and there is no assistance for determining baseline or width of the inline
+% math image.
+% The best results are obtained when using \pkg{graphicx}.
 %
-% Redefine the double dollar sign to place math inside a \env{lateximage}, or use \brand{MathJax}:
+% \begin{macro}{\LWR at addbaselinemarker} Places a small marker in an \SVG\ inline image.
+% If \pkg{graphics} or \pkg{graphicx} are loaded, the marker is a mostly transparent
+% image.
+% If neither is loaded, no marker is used.
+% \changes{v0.51}{2018/03/16}{Improved \SVG\ math baseline.}
 %    \begin{macrocode}
-\protected\gdef\LWR at doubledollar$#1$${
-%    \end{macrocode}
-% If \brand{MathJax} or formatting for a word processor, print the \LaTeX\ expression:
-% \changes{v0.42}{2017/10/26}{If \progcode{FormatWP} print LaTeX expression.}
-%    \begin{macrocode}
-\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
-%    \end{macrocode}
-% For \brand{MathJax}, print the math between |\[| and |\]|:
-%    \begin{macrocode}
-{
+\AtBeginDocument{
 
-        \textbackslash[%
-        \LWR at HTMLsanitize{#1}%
-        \textbackslash]
+\@ifpackageloaded{graphicx}{
+    \newcommand*{\LWR at addbaselinemarker}{%
+        \LWR at origincludegraphics[%
+            width=10sp,height=10sp%
+        ]{lwarp_baseline_marker.png}%
+    }
+}{
+    \@ifpackageloaded{graphics}{
+        \newcommand*{\LWR at addbaselinemarker}{%
+            \LWR at origincludegraphics{lwarp_baseline_marker.png}%
+        }
+    }{
+        \newcommand*{\LWR at addbaselinemarker}{%
+            \hspace*{10sp}%
+        }
+    }
+}
 
-}% mathjax
+}% AtBeginDocument
 %    \end{macrocode}
-% For SVG, print the math inside a \env{lateximage},
-%   with an \element{alt} tag of the \LaTeX\ code:
-% \changes{v0.50}{2018/02/24}{Improved \SVG\ math \attribute{alt} tags.}
-% \changes{v0.50}{2018/03/02}{Improved \SVG\ math display.}
-%    \begin{macrocode}
-{% not mathjax
+% \end{macro}
 
-        \begin{BlockClass}{displaymath}
-        \begin{lateximage}%
-        [%
-            \textbackslash{[} % extra space
-            \LWR at HTMLsanitize{#1} % extra space
-            \textbackslash{]}%
-        ]%
-        \LWR at origdollar\LWR at origdollar#1\LWR at origdollar\LWR at origdollar%
-        \end{lateximage}%
-        \end{BlockClass}
 
-}% not mathjax
-}%
-%    \end{macrocode}
-% \end{macro}
+% \begin{macro}{\LWR at subsingledollar} * \marg{2: alt text} \marg{3: add'l hashing}
+%                                               \marg{4: math expression}
 %
+% For inline math.
+% Uses MathJax, or for \SVG\ math the image is measured and ajusted to the baseline
+% of the \HTML\ output, and placed inside a \env{lateximage}.
 %
+% \describehashing
 %
-% \begin{macro}{\LWR at subsingledollar} \marg{alt text} \marg{math expression}
-% Redefine the single dollar sign to place math inside a \env{lateximage},
-% or use \brand{MathJax}:
-% If the \attribute{alt} text is empty, the math expression is used
-% for the \attribute{alt} text.
-%
 % \changes{v0.19}{2016/05/25}{\brand{MathJax} support.}
 % \changes{v0.42}{2017/10/26}{If \progcode{FormatWP} print LaTeX expression.}
 % \changes{v0.47}{2018/01/24}{Added \SVG\ math image baseline adjust and em sizing.}
@@ -22806,16 +23085,27 @@
 \newlength{\LWR at singledollarheight}
 \newlength{\LWR at singledollardepth}
 
-\protected\gdef\LWR at subsingledollar#1#2{%
+\newsavebox{\LWR at singledollarbox}
+
+\NewDocumentCommand{\LWR at subsingledollar}{s m m m}{%
+%    \end{macrocode}
+%    \begin{macrocode}
+\ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}%
+{%
+    #4% contents
+}%
+{% not in a lateximage
 \begingroup%
 %    \end{macrocode}
 % MathJax cannot parse the often complicated \TeX\ expressions which
 % appear in the various uses of \cs{ensuredmath}.
-% \cs{ensuremath} forces the \attribute{alt} tag to ``|math image|''.
+% \cs{ensuremath} forces the \attribute{alt} tag to ``|(math image)|''.
 % If this is the case, force the use of a \env{lateximage} even if MathJax.
 % Likewise for \pkg{siunitx} if |parse-numbers=false|.
 %
-% If MathJax, or if formatting math for a word processor, print the math expression.
+% If MathJax, or if formatting math for a word processor, and not \cs{ensuredmath},
+% print the math expression.
+% \changes{v0.51}{2018/03/11}{Fix: \cs{ensuredmath} inside \SVG\ image.}
 %    \begin{macrocode}
 \ifboolexpr{%
     (
@@ -22822,13 +23112,13 @@
         bool{mathjax} or
         ( bool{FormatWP} and bool{WPMarkMath} )
     ) and
-    ( not test { \ifstrequal {#1} {math image} } )
+    ( not test { \ifstrequal {#2} {(math image)} } )% from \ensuredmath
 }%
 %    \end{macrocode}
 % For \brand{MathJax}, print the math between |\(| and |\)|:
 %    \begin{macrocode}
 {%
-    {\textbackslash(\LWR at HTMLsanitize{#2}\textbackslash)}%
+    {\textbackslash(\LWR at HTMLsanitize{#4}\textbackslash)}%
 }% mathjax
 %    \end{macrocode}
 % For SVG, print the math inside a \env{lateximage},
@@ -22838,53 +23128,107 @@
 {% not mathjax
 %    \end{macrocode}
 % Measure the depth, width, and height of the math image:
+% \changes{v0.51}{2018/03/04}{Fix: SVG math with enclosed \env{lateximage}.}
 %    \begin{macrocode}
+    \begingroup%
+%    \end{macrocode}
+% Temporarily disable formatting while measuring the image parameters:
+%    \begin{macrocode}
     \LWR at restoreorigformatting%
+    \RenewDocumentEnvironment{lateximage}{s o o o}{}{}% inside group
     \LWR at orignormalsize%
-    \global\setlength{\LWR at singledollardepth}{\depthof{%
-        \LWR at origdollar#2\LWR at origdollar%
-    }*\real{.8}}%
-    \global\setlength{\LWR at singledollarwidth}{\widthof{%
-        \LWR at origdollar#2\LWR at origdollar%
-    }*\real{.8}}%
-    \global\setlength{\LWR at singledollarheight}{\totalheightof{%
-        \LWR at origdollar#2\LWR at origdollar%
-    }*\real{.8}}%
 %    \end{macrocode}
-% \changes{v0.49}{2018/02/18}{Fix: Incorrect \PDF\ output size corrupted \HTML.}
+% Temporarily set font for the \HTML\ \PDF\ output:
+% \changes{v0.51}{2018/03/14}{Fix: Honors text font around \SVG\ math.}
 %    \begin{macrocode}
-    \LWR at origscriptsize%
+    \csuse{LWR at orig\LWR at f@family family}%
+    \csuse{LWR at orig\LWR at f@series series}%
+    \csuse{LWR at orig\LWR at f@shape shape}%
 %    \end{macrocode}
+% |lateximagedepth| must be nested to avoid generating paragraph tags.
+% \AmS\ math modifies the \cs{text} macro such that \cs{addtocounter} does not
+% always occur as expected.  Lower-level code is used instead.
+%    \begin{macrocode}
+    \global\advance\c at LWR@lateximagedepth 1\relax%
+%    \end{macrocode}
+% Typeset and save the contents:
+% \changes{v0.51}{2018/03/07}{Fix: \env{lateximage} inside \AmS\ \cs{text}.}
+% \changes{v0.51}{2018/03/12}{Typeset \SVG\ math only once during measurement.}
+%    \begin{macrocode}
+    \global\sbox{\LWR at singledollarbox}{#4}%
+%    \end{macrocode}
+% Add a small and almost transparent marker at the depth of the image.
 %
+% A math minus sign has the same depth as a plus, even though it does not draw
+% anything below the baseline.  This means that \prog{pdfcrop} would crop the image
+% without depth.  The marker below the baseline is seen by \prog{pdfcrop}
+% and preserves the depth.
+% \changes{v0.51}{2018/03/16}{Improved \SVG\ math baseline.}
+%    \begin{macrocode}
+    \global\sbox{\LWR at singledollarbox}{%
+        \usebox{\LWR at singledollarbox}%
+        \hspace*{-10sp}%
+        \raisebox{-\dp\LWR at singledollarbox}{%
+            \LWR at addbaselinemarker%
+        }%
+    }%
+%    \end{macrocode}
+% More low-level code to undo the counter change.
+%    \begin{macrocode}
+    \global\advance\c at LWR@lateximagedepth -1\relax% Due to AmS \text macro.
+%    \end{macrocode}
+% Measure the depth:
+%    \begin{macrocode}
+    \setlength{\LWR at singledollardepth}{.70\dp\LWR at singledollarbox}%
+%    \end{macrocode}
+% Make the length a global change:
+%    \begin{macrocode}
+    \global\LWR at singledollardepth=\LWR at singledollardepth%
+%    \end{macrocode}
+% Likewise for width:
+%    \begin{macrocode}
+    \setlength{\LWR at singledollarwidth}{.70\wd\LWR at singledollarbox}%
+    \global\LWR at singledollarwidth=\LWR at singledollarwidth%
+%    \end{macrocode}
+% Likewise for total height:
+%    \begin{macrocode}
+    \setlength{\LWR at singledollarheight}{.70\ht\LWR at singledollarbox}%
+    \addtolength{\LWR at singledollarheight}{.70\dp\LWR at singledollarbox}%
+    \global\LWR at singledollarheight=\LWR at singledollarheight%
+%    \end{macrocode}
+%    \begin{macrocode}
+    \endgroup%
+%    \end{macrocode}
+%
 % Set a style for the the height or width.
 % The |em| unit is used so that the math scales according to the
 % user's selected font size.
-% Start with the larger of width or height:
+%
+% Start with the greater of the width or the height, biased towards the width:
 %    \begin{macrocode}
-    \ifdimgreater{\LWR at singledollarwidth}{\LWR at singledollarheight}{%
+    \ifdimgreater{\LWR at singledollarwidth}{.7\LWR at singledollarheight}{%
         \def\LWR at singledollarstyle{%
             width:\LWR at convertto{em}{\the\LWR at singledollarwidth} em%
         }%
     }{%
         \def\LWR at singledollarstyle{%
-            height:\LWR at convertto{em}{\the\LWR at singledollarheight }em%
+            height:\LWR at convertto{em}{\the\LWR at singledollarheight} em%
         }%
     }%
 %    \end{macrocode}
-% If narrow width, use the height.  Single-letter variables look best if they all are
-% scaled according to height.
+% If a very narrow width, use the height.
 %    \begin{macrocode}
-    \ifdimless{\LWR at singledollarwidth}{.8em}%
+    \ifdimless{\LWR at singledollarwidth}{.2em}%
     {%
         \def\LWR at singledollarstyle{%
-            height:\LWR at convertto{em}{\the\LWR at singledollarheight }em%
+            height:\LWR at convertto{em}{\the\LWR at singledollarheight} em%
         }%
     }%
     {}%
 %    \end{macrocode}
-% If extremely wide and short, use the width:
+% If very wide and short, use the width:
 %    \begin{macrocode}
-    \ifdimless{\LWR at singledollarheight}{.3em}%
+    \ifdimless{\LWR at singledollarheight}{.2em}%
     {%
         \def\LWR at singledollarstyle{%
             width:\LWR at convertto{em}{\the\LWR at singledollarwidth} em%
@@ -22895,7 +23239,7 @@
 % If there is significant text depth, add the depth to the style.
 % \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
 %    \begin{macrocode}
-    \ifdimgreater{\LWR at singledollardepth}{0.01em}{%
+    \ifdimgreater{\LWR at singledollardepth}{0.05ex}{%
         \def\LWR at singledollardepthstyle{%
             \ ; % extra space
             \LWR at origmbox{%
@@ -22909,33 +23253,162 @@
 % Create the \env{lateximage} using the alternate tag and the computed
 % size and depth.
 % The star causes \env{lateximage} to use an MD5 hash as the filename.
+% When hashing, also include the current font and color in the hash.
 % \changes{v0.50}{2018/02/22}{MD5 hash avoids duplicate \SVG\ math.}
 %    \begin{macrocode}
-    \ifblank{#1}{%
-        \begin{lateximage}*%
-            [%
-                \textbackslash( %
-                \LWR at HTMLsanitize{#2} % extra space
-                \textbackslash)%
+    \IfValueTF{#1}{%
+        \LWR at findcurrenttextcolor% sets \LWR at tempcolor
+        \begin{lateximage}*% use hashing
+            [#2]% alt
+            [% addl' hashing
+                #3%
+                FM\LWR at f@family%
+                SR\LWR at f@series%
+                SH\LWR at f@shape%
+                CL\LWR at tempcolor%
             ]%
-            [\LWR at singledollarstyle \LWR at singledollardepthstyle]%
+            [\LWR at singledollarstyle \LWR at singledollardepthstyle]% CSS
     }{%
-        \begin{lateximage}%
-            [#1]%
-            [\LWR at singledollarstyle \LWR at singledollardepthstyle]%
+        \begin{lateximage}% no hashing
+            [#2]% alt
+            []% no add'l hashing
+            [\LWR at singledollarstyle \LWR at singledollardepthstyle]% CSS
     }%
-    \LWR at origdollar#2\LWR at origdollar%
+%    \end{macrocode}
+% Place small and almost transparent markers on the baseline
+% at the left and right edges of the image.
+% These markers are seen by \prog{pdfcrop},
+% and force vertically-centered objects such as a dash
+% to be raised off the baseline in the cropped image,
+% and also force the total width and left \spslash right margins to be correct.
+% (Except that in some fonts a character may exceed the bounding box, and thus
+% may appear wider than expected when converted to an image.)
+% \changes{v0.51}{2018/03/10}{SVG math baseline improved with invisible rule at corner.}
+%    \begin{macrocode}
+    \LWR at addbaselinemarker%
+    \hspace*{-10sp}%
+%    \end{macrocode}
+% Typeset the contents:
+%    \begin{macrocode}
+    \usebox{\LWR at singledollarbox}%
+%    \end{macrocode}
+% The closing baseline marker:
+%    \begin{macrocode}
+    \hspace*{-10sp}%
+    \LWR at addbaselinemarker%
+%    \end{macrocode}
+%    \begin{macrocode}
     \end{lateximage}%
-}%
+%
+}% not mathjax
 \endgroup%
+}% not in a lateximage
 }
 %    \end{macrocode}
 % \end{macro}
 
+
+%    \begin{macrocode}
+\LetLtxMacro\LWR at origdollar$
+\LetLtxMacro\LWR at secondorigdollar$% balance for editor syntax highlighting
+%    \end{macrocode}
+
+%    \begin{macrocode}
+\LetLtxMacro\LWR at origopenparen\(
+\LetLtxMacro\LWR at origcloseparen\)
+\LetLtxMacro\LWR at origopenbracket\[
+\LetLtxMacro\LWR at origclosebracket\]
+%    \end{macrocode}
+
+% \DescribeObject{\$}
+% \DescribeObject{\$\$}
+% Redefine the dollar sign to place math inside a \env{lateximage},
+% or use \brand{MathJax}:
+%    \begin{macrocode}
+\begingroup
+\catcode`\$=\active%
+\protected\gdef${\@ifnextchar$\LWR at doubledollar\LWR at singledollar}%
+%    \end{macrocode}
+
+% Used by \pkg{chemformula} to escape single-dollar math:
+%    \begin{macrocode}
+\protected\gdef\LWR at newsingledollar{\@ifnextchar$\LWR at doubledollar\LWR at singledollar}%
+%    \end{macrocode}
+
+
+% \begin{macro}{\LWR at doubledollar}
+%
+% \changes{v0.42}{2017/10/16}{Improved \cs{ensuremath}.}
+%
+% Redefine the double dollar sign to place math inside a \env{lateximage}, or use \brand{MathJax}:
+%    \begin{macrocode}
+\protected\gdef\LWR at doubledollar$#1$${%
+%    \end{macrocode}
+% If \brand{MathJax} or formatting for a word processor, print the \LaTeX\ expression:
+% \changes{v0.19}{2016/05/25}{\brand{MathJax} support.}
+% \changes{v0.42}{2017/10/26}{If \progcode{FormatWP} print LaTeX expression.}
+%    \begin{macrocode}
+\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
+%    \end{macrocode}
+% For \brand{MathJax}, print the math between |\[| and |\]|:
+% \changes{v0.42}{2017/10/16}{Improved line spacing with mathjax.}
+%    \begin{macrocode}
+{
+
+    \textbackslash[%
+    \LWR at HTMLsanitize{#1}%
+    \textbackslash]
+
+}% mathjax
+%    \end{macrocode}
+% For SVG, print the math inside a \env{lateximage},
+%   with an \element{alt} tag of the \LaTeX\ code:
+% \changes{v0.50}{2018/02/24}{Improved \SVG\ math \attribute{alt} tags.}
+% \changes{v0.50}{2018/03/02}{Improved \SVG\ math display.}
+% \changes{v0.51}{2018/03/11}{Fix: \cs{addcontentsline} inside \SVG\ math.  Provides an autoid anchor.}
+%    \begin{macrocode}
+{% not mathjax
+    \begin{BlockClass}{displaymath}%
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
+    \begin{lateximage}%
+    [%
+        \textbackslash{[} % extra space
+        \LWR at HTMLsanitize{#1} % extra space
+        \textbackslash{]}%
+    ]%
+    \LWR at origdollar\LWR at origdollar#1\LWR at origdollar\LWR at origdollar%
+    \end{lateximage}%
+    \end{BlockClass}%
+}% not mathjax
+}%
+%    \end{macrocode}
+% \end{macro}
+%
+%
+%
 % \begin{macro}{\LWR at singledollar} \marg{alt text} \marg{math expression}
 %    \begin{macrocode}
 \protected\gdef\LWR at singledollar#1${%
-\LWR at subsingledollar{}{#1}%
+\ifbool{mathjax}{%
+\LWR at subsingledollar*%
+    {% alt tag
+        \textbackslash( %
+        \LWR at HTMLsanitize{#1} % extra space
+        \textbackslash)%
+    }%
+    {singledollar}% add'l hashing
+    {#1}% contents
+}{% not mathjax
+\LWR at subsingledollar*%
+    {% alt tag
+        \textbackslash( %
+        \LWR at HTMLsanitize{#1} % extra space
+        \textbackslash)%
+    }%
+    {singledollar}% add'l hashing
+    {\LWR at origensuredmath{#1}}% contents
+}% not mathjax
 }
 %    \end{macrocode}
 % \end{macro}
@@ -22949,12 +23422,14 @@
 \protected\gdef\[#1\]{$$#1$$}
 
 \endgroup
+
+\LetLtxMacro\LWR at openbracketnormal\[
+\LetLtxMacro\LWR at closebracketnormal\]
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
 
 
-
 % \begin{macro}{\@ensuredmath} \marg{expression}
 %
 % \changes{v0.42}{2017/10/16}{Improved \cs{ensuremath}.}
@@ -22968,11 +23443,13 @@
 %    \end{macrocode}
 % If MathJax, a \env{lateximage} is used, since \cs{ensuremath} is
 % often used for complex \TeX\ expressions which MathJax may not render.
+% If \SVG\ math, a hashed file is used with a simple \attribute{alt} tag, but
+% additional hashing provided by the contents.
+% \changes{v0.51}{2018/02/24}{Hashes \cs{ensuremath}.}
 %    \begin{macrocode}
-%     \begin{lateximage}[math image]
-%     \LWR at origensuredmath{#1}
-%     \end{lateximage}
-    \LWR at subsingledollar{math image}{\relax#1}%
+    \LWR at subsingledollar*{(math image)}{\LWR at HTMLsanitize{#1}}{\relax%
+        \LWR at origensuredmath{#1}%
+    }%
 }{% SVG math
 %    \end{macrocode}
 % If already inside a \env{lateximage} in math mode, continue as-is.
@@ -22981,11 +23458,16 @@
     \LWR at origensuredmath{#1}%
 \else%
 %    \end{macrocode}
-% Create an inline math \env{lateximage},
-% but don't use the expression as the \attribute{alt} tag, since
-% the expression may be complex internal code used to draw a math expression.
+% Create an inline math \env{lateximage} with a simple \attribute{alt} tag
+% and additional hashing according to the contents.
 %    \begin{macrocode}
-    \LWR at subsingledollar{math image}{\relax#1}%
+    \ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}%
+    {\LWR at origensuredmath{#1}}%
+    {%
+        \LWR at subsingledollar*{(math image)}{\LWR at HTMLsanitize{#1}}{%
+            \LWR at origensuredmath{#1}%
+        }%
+    }%
 \fi%
 }%
 }
@@ -23009,16 +23491,70 @@
 %    \end{macrocode}
 % \end{environment}
 %
-% \begin{environment}{displaymath}
+% \begin{environment}{LWR at displaymathnormal}
 % Set math mode then typeset the body of what was between the begin/end.
 % See the \pkg{environ} package for \cs{BODY}.
 %    \begin{macrocode}
-\NewEnviron{displaymath}{\expandafter\[\BODY\]\@ignoretrue}
+\NewEnviron{LWR at displaymathnormal}{\expandafter\[\BODY\]\@ignoretrue}
 %    \end{macrocode}
 % \end{environment}
 
 
+% Set the default displaymath to the normal version:
+%    \begin{macrocode}
+\LetLtxMacro\[\LWR at openbracketnormal%
+\LetLtxMacro\]\LWR at closebracketnormal%
+\LetLtxMacro\displaymath\LWR at displaymathnormal%
+\LetLtxMacro\enddisplaymath\endLWR at displaymathnormal%
+%    \end{macrocode}
+%
+%
+% \begin{environment}{LWR at displaymathother}
+% A version of \env{displaymath} which can handle complicated objects,
+% but does not supply \brand{MathJax} or \HTML\ \attribute{alt} tags.
+% \changes{v0.51}{2018/03/21}{Processing for complicated display math.}
+%    \begin{macrocode}
+\newenvironment{LWR at displaymathother}
+{%
+    \begin{BlockClass}{displaymath}%
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
+    \begin{lateximage}%
+    [(display math)]%
+    \LWR at origdollar\LWR at origdollar%
+}
+{%
+    \LWR at origdollar\LWR at origdollar%
+    \end{lateximage}%
+    \end{BlockClass}%
+}
+%    \end{macrocode}
+% \end{environment}
+%
+%
+% \begin{environment}{LWR at equationother}
+% A version of \env{displaymath} which can handle complicated objects,
+% but does not supply \brand{MathJax} or \HTML\ \attribute{alt} tags.
+% \changes{v0.51}{2018/03/21}{Processing for complicated display math.}
+%    \begin{macrocode}
+\newenvironment{LWR at equationother}
+{%
+    \begin{BlockClass}{displaymathnumbered}%
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
+    \begin{lateximage}%
+    [(display math)]%
+    \LWR at origequation%
+}
+{%
+    \LWR at origendequation%
+    \end{lateximage}%
+    \end{BlockClass}%
+}
+%    \end{macrocode}
+% \end{environment}
 
+
 % \subsection{\brand{MathJax} support}
 % \changes{v0.19}{2016/05/25}{\brand{MathJax} support added.}
 %
@@ -23213,8 +23749,11 @@
 %    \end{macrocode}
 % Begin the \env{lateximage} with an \element{alt} tag containing the math source:
 % \changes{v0.50}{2018/03/02}{Improved \SVG\ math display.}
+% \changes{v0.51}{2018/03/11}{Fix: \cs{addcontentsline} inside \SVG\ math.  Provides an autoid anchor.}
 %    \begin{macrocode}
     \begin{BlockClass}{displaymathnumbered}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[%
         (\LWR at equationtag) \textbackslash{begin\{equation\}} % extra space
         \LWR at HTMLsanitizeexpand{\detokenize\expandafter{\BODY}} % extra space
@@ -23242,6 +23781,9 @@
     }{}%
 
 ]
+
+\LetLtxMacro\LWR at equationnormal\equation
+\LetLtxMacro\LWR at endequationnormal\endequation
 %    \end{macrocode}
 % \end{environment}
 
@@ -23250,15 +23792,99 @@
 %    \begin{macrocode}
 \csletcs{LWR at origequationstar}{equation*}
 \csletcs{LWR at origendequationstar}{endequation*}
+
 \renewenvironment*{equation*}
 {\displaymath}
 {\enddisplaymath}
+
+\csletcs{LWR at equationnormalstar}{equation*}
+\csletcs{LWR at endequationnormalstar}{endequation*}
 %    \end{macrocode}
 % \end{environment}
 
 
+% Remember the ``less'' version of \env{equation}, which use \brand{MathJax}
+% and \attribute{alt} tags, but does not support complicated contents such as
+% some \tikz\ expressions.
+%    \begin{macrocode}
+\LetLtxMacro\LWR at equationless\equation
+\LetLtxMacro\LWR at endequationless\endequation
+\csletcs{LWR at equationlessstar}{equation*}
+\csletcs{LWR at endequationlessstar}{endequation*}
+%    \end{macrocode}
 
 
+% \subsection{\cs{displaymathnormal} and \cs{displaymathother}}
+%
+% \describedisplaymathother
+%
+% \begin{macro}{\displaymathnormal} Use when display math environments have simple
+% math which is to sent to \brand{MathJax} or included in \HTML\ \attribute{alt} tags.
+% \margintag{simple math objects}
+% \changes{v0.51}{2018/03/21}{Processing for complicated display math.}
+%    \begin{macrocode}
+\newcommand*{\displaymathnormal}{%
+\ifbool{LWR at origmathjax}{\booltrue{mathjax}}{\boolfalse{mathjax}}%
+\LetLtxMacro\[\LWR at openbracketnormal%
+\LetLtxMacro\]\LWR at closebracketnormal%
+\LetLtxMacro\displaymath\LWR at displaymathnormal%
+\LetLtxMacro\enddisplaymath\endLWR at displaymathnormal%
+\LetLtxMacro\equation\LWR at equationnormal%
+\LetLtxMacro\endequation\LWR at endequationnormal%
+\csletcs{equation*}{LWR at equationnormalstar}%
+\csletcs{endequation*}{LWR at endequationnormalstar}%
+}
+%    \end{macrocode}
+% \end{macro}
+
+
+% \begin{macro}{\displaymathother} Use when display math environments have complicated
+% objects which will not work with MathJax or should not be
+% included in \HTML\ \attribute{alt} tags. \margintag{complicated math objects}
+% Complicated contents are more likely to compile correctly.
+% \changes{v0.51}{2018/03/21}{Processing for complicated display math.}
+%    \begin{macrocode}
+\newcommand*{\displaymathother}{%
+\boolfalse{mathjax}%
+\LetLtxMacro\displaymath\LWR at displaymathother%
+\LetLtxMacro\enddisplaymath\endLWR at displaymathother%
+\LetLtxMacro\[\LWR at displaymathother%
+\LetLtxMacro\]\endLWR at displaymathother%
+\LetLtxMacro\equation\LWR at equationother%
+\LetLtxMacro\endequation\endLWR at equationother%
+\csletcs{equation*}{displaymath}%
+\csletcs{endequation*}{enddisplaymath}%
+}
+%    \end{macrocode}
+% \end{macro}
+
+%    \begin{macrocode}
+\end{warpHTML}
+%    \end{macrocode}
+
+
+% \codeprint
+%    \begin{macrocode}
+\begin{warpprint}
+%    \end{macrocode}
+
+% Print-mode versions:
+%    \begin{macrocode}
+\newcommand*{\displaymathnormal}{}
+\newcommand*{\displaymathother}{}
+%    \end{macrocode}
+
+%    \begin{macrocode}
+\end{warpprint}
+%    \end{macrocode}
+
+
+% \codehtml
+%    \begin{macrocode}
+\begin{warpHTML}
+%    \end{macrocode}
+
+
 % \subsection{AMS Math environments}
 % \changes{v0.19}{2016/05/25}{\brand{MathJax} support added.}
 %
@@ -23448,8 +24074,11 @@
 %	an \attribute{alt} attribute containing sanitized copy of the source code:
 % \changes{v0.42}{2017/10/12}{Fix: Numbering and naming AMS math environments.}
 % \changes{v0.50}{2018/03/02}{Improved \SVG\ math display.}
+% \changes{v0.51}{2018/03/11}{Fix: \cs{addcontentsline} inside \SVG\ math.  Provides an autoid anchor.}
 %    \begin{macrocode}
-        \begin{BlockClass}{displaymathnumbered}
+        \begin{BlockClass}{displaymathnumbered}%
+        \LWR at newautoidanchor%
+        \booltrue{LWR at indisplaymathimage}%
         \begin{lateximage}[(\LWR at startingequationtag--\LWR at equationtag)
             \LWR at addmathjax{eqnarray}{\BODY}]
 %    \end{macrocode}
@@ -23465,8 +24094,11 @@
 %    \end{macrocode}
 % If not numbered, do the same, but an extra \cs{nonumber} seems to be required:
 % \changes{v0.50}{2018/03/02}{Improved \SVG\ math display.}
+% \changes{v0.51}{2018/03/11}{Fix: \cs{addcontentsline} inside \SVG\ math.  Provides an autoid anchor.}
 %    \begin{macrocode}
         \begin{BlockClass}{displaymath}
+        \LWR at newautoidanchor%
+        \booltrue{LWR at indisplaymathimage}%
         \begin{lateximage}[\LWR at addmathjax{eqnarray*}{\BODY}]
         \LWR at origeqnarray
         \BODY
@@ -23506,6 +24138,7 @@
 %
 % \changes{v0.44}{2017/11/16}{AMS environments: Fix: Groups for \env{lateximage}s.}
 % \changes{v0.50}{2018/03/01}{AMS environments: Improved \SVG\ math display.}
+% \changes{v0.51}{2018/03/11}{AMS environments: Fix: \cs{addcontentsline} inside \SVG\ math.  Provides an autoid anchor.}
 %
 % \begin{environment}{multline}
 %    \begin{macrocode}
@@ -23519,6 +24152,8 @@
 }
 {
     \begin{BlockClass}{displaymathnumbered}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbodynumbered{multline}]
 }
 }
@@ -23550,6 +24185,8 @@
 }
 {
     \begin{BlockClass}{displaymath}
+    \LWR at newautoidanchor
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbody{multline*}]
 }
 }
@@ -23581,7 +24218,9 @@
     \LWR at beginhideamsmath
 }
 {
-     \begin{BlockClass}{displaymathnumbered}
+    \begin{BlockClass}{displaymathnumbered}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbodynumbered{gather}]
 }
 }
@@ -23611,6 +24250,8 @@
 }
 {
     \begin{BlockClass}{displaymath}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbody{gather*}]
 }
 }
@@ -23640,7 +24281,9 @@
     \LWR at beginhideamsmath
 }
 {
-     \begin{BlockClass}{displaymathnumbered}
+    \begin{BlockClass}{displaymathnumbered}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbodynumbered{align}]
 }
 }
@@ -23671,6 +24314,8 @@
 }
 {
     \begin{BlockClass}{displaymath}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbody{align*}]
 }
 }
@@ -23701,6 +24346,8 @@
 }
 {
     \begin{BlockClass}{displaymathnumbered}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbodynumbered{flalign}]
 }
 }
@@ -23731,6 +24378,8 @@
 }
 {
     \begin{BlockClass}{displaymath}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbody{flalign*}]
 }
 }
@@ -23748,7 +24397,73 @@
 %    \end{macrocode}
 % \end{environment}
 
+
+% \begin{environment}{alignat}
+% \changes{v0.51}{2018/03/11}{Fix: Added.}
 %    \begin{macrocode}
+\BeforeBeginEnvironment{alignat}{
+
+\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
+{
+    \LWR at syncmathjax
+    \boolfalse{LWR at amsmultline}
+    \LWR at beginhideamsmath
+}
+{
+    \begin{BlockClass}{displaymathnumbered}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
+    \begin{lateximage}[\LWR at amsmathbodynumbered{alignat}]
+}
+}
+
+\AfterEndEnvironment{alignat}{
+
+\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
+{
+    \LWR at endhideamsmath
+    \LWR at addmathjax{alignat}{\the\@envbody}
+}
+{\end{lateximage}\end{BlockClass}}
+
+}
+%    \end{macrocode}
+% \end{environment}
+
+
+% \begin{environment}{alignat*}
+%    \begin{macrocode}
+\BeforeBeginEnvironment{alignat*}{
+
+\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
+{
+    \LWR at syncmathjax
+    \boolfalse{LWR at amsmultline}
+    \LWR at beginhideamsmath
+}
+{
+    \begin{BlockClass}{displaymath}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
+    \begin{lateximage}[\LWR at amsmathbody{alignat*}]
+}
+}
+
+\AfterEndEnvironment{alignat*}{
+
+\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
+{
+    \LWR at endhideamsmath
+    \LWR at addmathjax{alignat*}{\the\@envbody}
+}
+{\end{lateximage}\end{BlockClass}}
+
+}
+%    \end{macrocode}
+% \end{environment}
+
+
+%    \begin{macrocode}
 \end{warpHTML}
 %    \end{macrocode}
 
@@ -23863,8 +24578,9 @@
 
 % \begin{macro}{\LWR at HTMLsanitize} \marg{text}
 %
-% Math expressions are converted to |lateximage|s, and some math environments may contain
-% ``\&'', ``\textless'', or ``\textgreater'', which should not be allowed
+% Math expressions are converted to |lateximage|s,
+% and some math environments may contain
+% |&|, |<|, or |>|, which should not be allowed
 % inside an \HTML\ \element{alt} tag, so must convert them to \HTML\ entities.
 %
 % Two versions follow, depending on expansion needs.
@@ -23871,26 +24587,45 @@
 % There may be a better way\dots
 %
 % \changes{v0.36}{2017/08/16}{Fix for \pkg{babel-french}.}
-%
+% \changes{v0.51}{2018/03/07}{Fix: Escapes double quotes.}
 %    \begin{macrocode}
-\newcommand{\LWR at HTMLsanitize}[1]{%
+\newrobustcmd{\LWR at HTMLsanitize}[1]{%
+%    \end{macrocode}
+% Cancel French \pkg{babel} character handling,
+% and fully expand the strings:
+%    \begin{macrocode}
 \begingroup%
 \LWR at FBcancel%
+\fullexpandarg%
+%    \end{macrocode}
+% The |&|, |<|, and |>| may be interpreted by the browser:
+%    \begin{macrocode}
 \protect\StrSubstitute{\detokenize{#1}}%
-{\detokenize{&}}%
-{\detokenize{&}}[\LWR at strresult]%
+{\detokenize{&}}{\detokenize{&}}[\LWR at strresult]%
+%    \end{macrocode}
+%    \begin{macrocode}
 \protect\StrSubstitute{\detokenize\expandafter{\LWR at strresult}}%
-{\detokenize{<}}%
-{\detokenize{<}}%
-[\LWR at strresult]%
+{\detokenize{<}}{\detokenize{<}}[\LWR at strresult]%
+%    \end{macrocode}
+%    \begin{macrocode}
 \protect\StrSubstitute{\detokenize\expandafter{\LWR at strresult}}%
-{\detokenize{>}}%
-{\detokenize{>}}%
-[\LWR at strresult]%
+{\detokenize{>}}{\detokenize{>}}[\LWR at strresult]%
+%    \end{macrocode}
+% The double quote occasionally causes problems.
+%    \begin{macrocode}
 \protect\StrSubstitute{\detokenize\expandafter{\LWR at strresult}}%
-{\detokenize{##}}%
-{\#}%
-[\LWR at strresult]%
+{\detokenize{"}}{\detokenize{"}}[\LWR at strresult]%
+%    \end{macrocode}
+% MathJax allows expressions to be defined with \cs{newcommand}.
+% These expressions would appear with |##| for each argument,
+% and each must be changed to a single |#|.
+% This must be done after all the above changes.
+% Attempting another conversion after this causes an error upon further expansion.
+%    \begin{macrocode}
+\protect\StrSubstitute{\detokenize\expandafter{\LWR at strresult}}%
+{\detokenize{##}}{\LWR at origpound}[\LWR at strresult]%
+%    \end{macrocode}
+%    \begin{macrocode}
 \LWR at strresult%
 \endgroup%
 }
@@ -23897,28 +24632,44 @@
 %    \end{macrocode}
 % \end{macro}
 
+
 % \begin{macro}{\LWR at HTMLsanitizeexpand} \marg{text}
 %
 % This version expands the argument before sanitizing it.
 %
 % \changes{v0.36}{2017/08/16}{Fix for \pkg{babel-french}.}
-%
+% \changes{v0.51}{2018/03/07}{Fix: Escapes double quotes.}
 %    \begin{macrocode}
-\newcommand{\LWR at HTMLsanitizeexpand}[1]{%
+\newrobustcmd{\LWR at HTMLsanitizeexpand}[1]{%
+%    \end{macrocode}
+% Cancel French \pkg{babel} character handling,
+% and fully expand the strings:
+%    \begin{macrocode}
 \begingroup%
 \LWR at FBcancel%
+\fullexpandarg%
+%    \end{macrocode}
+% The difference between this and \cs{LWR at HTMLsanitize} (without ``expand'')
+% is the following \cs{expandafter}:
+%    \begin{macrocode}
 \protect\StrSubstitute{\detokenize\expandafter{#1}}%
-{\detokenize{&}}%
-{\detokenize{&}}%
-[\LWR at strresult]%
+{\detokenize{&}}{\detokenize{&}}[\LWR at strresult]%
+%    \end{macrocode}
+%    \begin{macrocode}
 \protect\StrSubstitute{\detokenize\expandafter{\LWR at strresult}}%
-{\detokenize{<}}%
-{\detokenize{<}}%
-[\LWR at strresult]%
+{\detokenize{<}}{\detokenize{<}}[\LWR at strresult]%
+%    \end{macrocode}
+%    \begin{macrocode}
 \protect\StrSubstitute{\detokenize\expandafter{\LWR at strresult}}%
-{\detokenize{>}}%
-{\detokenize{>}}%
-[\LWR at strresult]%
+{\detokenize{>}}{\detokenize{>}}[\LWR at strresult]%
+%    \end{macrocode}
+%    \begin{macrocode}
+\protect\StrSubstitute{\detokenize\expandafter{\LWR at strresult}}%
+{\detokenize{"}}{\detokenize{"}}[\LWR at strresult]%
+%    \end{macrocode}
+% \cs{LWR at HTMLsanitizeexpand} is not used for defining new MathJax macros,
+% so the |##| conversion is not needed here.
+%    \begin{macrocode}
 \LWR at strresult%
 \endgroup%
 }
@@ -24043,7 +24794,7 @@
 
 % \begin{macro}{\LWR at amsmathbodynumbered} \marg{envname} \qquad
 %   For use inside the optional argument to a \env{lateximage}
-%   to add the contents of a AMS math environment to the \element{alt} tag,
+%   to add the contents of a AMS math environment to the \attribute{alt} tag,
 %   prefixed by the equation numbers.
 %
 % \changes{v0.42}{2017/10/12}{Fix: Numbering and naming AMS math environments.}
@@ -24062,17 +24813,14 @@
 
 % \subsection{\env{lateximage}}
 
-% \begin{environment}{lateximage} * \oarg{\element{alt} tag} \oarg{CSS style}
+% \begin{environment}{lateximage} * \oarg{2: \element{alt} tag}
+%                                       \oarg{3: add'l hashing} \oarg{4: CSS style}
 %
 % Typesets the contents and then renders the result as an \SVG\ file.
 %
 % The optional \element{alt} tag is included in the \HTML\ code for use with copy/paste.
 %
-% The starred version also uses the \element{alt} tag to create an MD5 hash which is
-% used as the image's filename.  This is used for \SVG\ math expressions, and
-% may also be of some use for the document creator.
-% The use of the hash for the filename means that identical expressions will all share a
-% single file, and the file must be converted to \SVG\ only a single time.
+% \describehashing
 %
 % \changes{v0.18}{2016/05/18}{Surpress extra space.}
 % \changes{v0.18}{2016/05/18}{pdfcrop: -{}-hires added.}
@@ -24085,22 +24833,28 @@
 % \changes{v0.36}{2017/08/16}{Footnotes appear in regular text instead of
 %       the \protect\env{lateximage} \protect\env{minipage}.}
 % \changes{v0.47}{2018/01/24}{Added \CSS\ style option.}
+% \changes{v0.51}{2018/03/07}{Added additional hashing option.}
 %
 %    \begin{macrocode}
 \catcode`\$=\active%
 
-\NewDocumentEnvironment{lateximage}{s O{image} O{}}
+\NewDocumentEnvironment{lateximage}{s O{(image)} O{} O{}}
 {%
 \LWR at traceinfo{lateximage: starting on \jobname.pdf page \arabic{page}}%
+\LWR at traceinfo{lateximage: entering depth is \arabic{LWR at lateximagedepth}}%
 %    \end{macrocode}
 % Nested |lateximage|s remain one large |lateximage|:
 %    \begin{macrocode}
-\ifthenelse{\cnttest{\value{LWR at lateximagedepth}}{>}{0}}%
+\ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}%
 %    \end{macrocode}
-% If nesting inside an already-existing lateximage, simply record one more level:
+% If nesting inside an already-existing lateximage, simply record one more level.
+% \AmS\ packages redefine \cs{addtocounter} to do nothing if inside a \cs{text},
+% so lower-level \TeX\ macros are used for tracking nested \env{lateximage}s.
+% \changes{v0.51}{2018/03/07}{Fix: \env{lateximage} inside \AmS\ \cs{text}.}
 %    \begin{macrocode}
 {%
-    \addtocounter{LWR at lateximagedepth}{1}%
+%     \addtocounter{LWR at lateximagedepth}{1}%
+    \global\advance\c at LWR@lateximagedepth 1\relax% Due to AmS \text macro.
 }%
 %    \end{macrocode}
 % Otherwise, this is the outer-most lateximage:
@@ -24111,6 +24865,7 @@
 % printed in a multi-equation environment:
 % \changes{v0.42}{2017/10/12}{Fix: Numbering and naming AMS math environments.}
 %    \begin{macrocode}
+\LWR at traceinfo{lateximage: starting outer-most lateximage}%
     \setcounter{LWR at startingequation}{\value{equation}}%
     \addtocounter{LWR at startingequation}{1}%
     \booltrue{LWR at isstartingequation}%
@@ -24145,7 +24900,7 @@
 % Create an \HTML\ span which will hold the comment which contains the \prog{pdftotext} translation
 % of the image's page, and also will hold the link to the |.svg| file:
 %    \begin{macrocode}
-    \LWR at htmltag{span id="lateximage\arabic{LWR at lateximagenumber}" %
+    \LWR at htmltag{span id="lateximage\arabic{LWR at lateximagenumber}" % extra space
     class="lateximagesource"}%
 %    \end{macrocode}
 % Write instructions to the |lateximages.txt| file:
@@ -24154,8 +24909,10 @@
     \LWR at traceinfo{lateximage: about to write to lateximages.txt}%
     \IfBooleanTF{#1}% starred
     {% hash
-        \LWR at traceinfo{lateximage: hash true}%
-        \edef\LWR at hashedname{\LWR at mdfive{\detokenize\expandafter{#2}}}%
+        \LWR at traceinfo{lateximage: hash true, adding !#2!#3!}%
+        \edef\LWR at hashedname{%
+            \LWR at mdfive{\detokenize\expandafter{#2}-!-#3}%
+        }%
         \LWR at traceinfo{lateximage: hash is \LWR at hashedname}%
         \immediate\write\LWR at lateximagesfile{%
             |\arabic{LWR at LIpage}|true|\LWR at hashedname|%
@@ -24175,9 +24932,11 @@
     \LWR at traceinfo{lateximage: about to create open comment}%
     \LWR at htmlopencomment%
 %    \end{macrocode}
-% One level deeper:
+% One level deeper.  At this outer-most \env{lateximage}, it is known
+% that this is not being used inside an \AmS\ \cs{text}, since the outer-most
+% level will never be in math mode.
 %    \begin{macrocode}
-    \addtocounter{LWR at lateximagedepth}{1}%
+     \addtocounter{LWR at lateximagedepth}{1}%
 %    \end{macrocode}
 % Start the new \PDF\ page:
 %    \begin{macrocode}
@@ -24216,8 +24975,25 @@
     \catcode`\$=3% math shift
     \LetLtxMacro\(\LWR at origopenparen%
     \LetLtxMacro\)\LWR at origcloseparen%
-    \LetLtxMacro\[\LWR at origopenbracket%
-    \LetLtxMacro\]\LWR at origclosebracket%
+%    \end{macrocode}
+% Only enable print-mode display math if are not already inside display math:
+% \changes{v0.51}{2018/03/21}{Processing for complicated display math.}
+%    \begin{macrocode}
+    \ifbool{LWR at indisplaymathimage}{}{% not in display math
+        \LetLtxMacro\[\LWR at origopenbracket%
+        \LetLtxMacro\]\LWR at origclosebracket%
+        \let\equation\LWR at origequation%
+        \let\endequation\LWR at origendequation%
+        \csletcs{equation*}{LWR at origequationstar}%
+        \csletcs{endequation*}{LWR at origendequationstar}%
+    }% not in display math
+%    \end{macrocode}
+% For \pkg{chemformula}:
+%    \begin{macrocode}
+    \LetLtxMacro\LWR at newsingledollar$%
+    \LetLtxMacro\LWR at newsingledollar$% syntax highlighting
+%    \end{macrocode}
+%    \begin{macrocode}
 }% end of outer-most lateximage
 \LWR at traceinfo{lateximage: finished start of environment}%
 }% end of \begin{lateximage}
@@ -24228,15 +25004,20 @@
 %
 %    \begin{macrocode}
 {% start of \end{lateximage}
-\LWR at traceinfo{lateximage: starting end of environment}%
+\LWR at traceinfo{lateximage: starting end of lateximage}%
 %    \end{macrocode}
 % Nested more than one deep?
 %    \begin{macrocode}
-\ifthenelse{\cnttest{\value{LWR at lateximagedepth}}{>}{1}}%
+\LWR at traceinfo{lateximage: internal depth was \arabic{LWR at lateximagedepth}}%
+\ifnumcomp{\value{LWR at lateximagedepth}}{>}{1}%
 %    \end{macrocode}
-% If nesting inside an already-existing lateximage, simply record one more level:
+% If nesting inside an already existing lateximage, simply record one less level.
+% Uses a lower-level \TeX\ macro due to \AmS\ \cs{text} change of \cs{addtocounter}.
 %    \begin{macrocode}
-{\addtocounter{LWR at lateximagedepth}{-1}}%
+{%
+    \LWR at traceinfo{lateximage: unnesting}%
+    \global\advance\c at LWR@lateximagedepth -1\relax%
+}%
 %    \end{macrocode}
 % If this is the outer-most lateximage:
 %    \begin{macrocode}
@@ -24244,6 +25025,7 @@
 %    \end{macrocode}
 % Finish the lateximage minipage and start a new \PDF\ page:
 %    \begin{macrocode}
+\LWR at traceinfo{lateximage: ending outer-most lateximage}%
     \LWR at origendminipage%
     \LWR at orignewpage%
     \LWR at origscriptsize%
@@ -24264,7 +25046,7 @@
         {%
             lateximages\OSPathSymbol%
             \LWR at origmbox{\LWR at hashedname}%
-        }{svg}{#3}%
+        }{svg}{#4}%
     }% hash
     {% no hash
         \LWR at subinlineimage[#2]{lateximage}%
@@ -24271,7 +25053,7 @@
         {%
             lateximages\OSPathSymbol%
             \LWR at origmbox{lateximage-\theLWR at externalfilecnt}%
-        }{svg}{#3}%
+        }{svg}{#4}%
     }% no hash
 %    \end{macrocode}
 % Be sure that are doing a paragraph:
@@ -24284,12 +25066,13 @@
     \ifbool{HTMLDebugComments}{%
         \LWR at htmlcomment{End of lateximage}%
     }{}%
-% \LWR at orignewline% Removed to prevent extra space.
 %    \end{macrocode}
-% Undo one lateximage level:
+% Undo one lateximage level.
+% This is not inside an \AmS\ \cs{text}, so regular \cs{addtocounter} may be used here.
 %    \begin{macrocode}
     \addtocounter{LWR at lateximagedepth}{-1}%
 }% end of outer-most lateximage
+\LWR at traceinfo{lateximage: exiting depth is \arabic{LWR at lateximagedepth}}%
 \LWR at traceinfo{lateximage: done}%
 }%
 \catcode`\$=3% math shift
@@ -24308,7 +25091,7 @@
 %
 % \changes{v0.48}{2018/02/02}{Print mode boxed to natural width.}
 %    \begin{macrocode}
-\NewDocumentEnvironment{lateximage}{s o o}
+\NewDocumentEnvironment{lateximage}{s o o o}
     {\begin{varwidth}[b]{\linewidth}}
     {\end{varwidth}}
 %    \end{macrocode}
@@ -24467,14 +25250,14 @@
 \newrobustcmd{\LWR at siunitx@textdegree}{\HTMLentity{deg}}
 \newrobustcmd{\LWR at siunitx@textprime}{\HTMLunicode{2032}}
 \newrobustcmd{\LWR at siunitx@textdblprime}{\HTMLunicode{2033}}
-\newrobustcmd{\LWR at siunitx@textplanckbar}{\text{\HTMLunicode{0127}}}
+\newrobustcmd{\LWR at siunitx@textplanckbar}{\text{\textit{\HTMLunicode{0127}}}}
 
-\appto\LWR at restoreorigformatting{
-\renewrobustcmd{\LWR at siunitx@textcelsius}{\text{\ensuremath{^\circ}C}}
-\renewrobustcmd{\LWR at siunitx@textdegree}{\text{\ensuremath{^\circ}}}
-\renewrobustcmd{\LWR at siunitx@textprime}{\text{\ensuremath{^\prime}}}
-\renewrobustcmd{\LWR at siunitx@textdblprime}{\text{\ensuremath{^{\prime\prime}}}}
-\renewrobustcmd{\LWR at siunitx@textplanckbar}{\text{\ensuremath{\hbar}}}
+\appto\LWR at restoreorigformatting{%
+\renewrobustcmd{\LWR at siunitx@textcelsius}{\text{\ensuremath{^\circ}C}}%
+\renewrobustcmd{\LWR at siunitx@textdegree}{\text{\ensuremath{^\circ}}}%
+\renewrobustcmd{\LWR at siunitx@textprime}{\text{\ensuremath{^\prime}}}%
+\renewrobustcmd{\LWR at siunitx@textdblprime}{\text{\ensuremath{^{\prime\prime}}}}%
+\renewrobustcmd{\LWR at siunitx@textplanckbar}{\text{\ensuremath{\hbar}}}%
 }
 
 \PassOptionsToPackage{
@@ -24722,7 +25505,7 @@
 \LetLtxMacro\endfcolorminipage\endLWRprint at fcolorminipage%
 }
 
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \LWR at restoreorigprintxcolor%
 }
 %    \end{macrocode}
@@ -24743,10 +25526,58 @@
 
 
 
+% \section{Chemmacros environments}
+% \label{sec:chemmacrosprintenvs}
+%
+% \cs{makepolymerdelims} and redox reactions must be enclosed in a \env{lateximage}
+% during \HTML\ output.
+% These environments are provided here in print mode, and in the \pkg{chemmacros}
+% code in \HTML\ mode, as a high-level semantic syntax which automatically embeds the
+% contents in a \env{lateximage} with an appropriate \attribute{alt} tag.
+%
+% \codeprint
+%
+%    \begin{macrocode}
+\begin{warpprint}
+%    \end{macrocode}
 
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifpackageloaded{chemmacros}{
+%    \end{macrocode}
+%
+% \begin{noindenvironment}{polymerdelims}
+%    \begin{macrocode}
+\DeclareDocumentEnvironment{polymerdelims}{}
+    {}{}
+%    \end{macrocode}
+% \end{noindenvironment}
 
+% \begin{noindenvironment}{redoxreaction} \marg{space above} \marg{space below}
+%
+% For print output, extra space is include above and below the image, and
+% a \env{lateximage} is not necessary.
+% This extra space must be enforced, even inside a float, so zero-width rules are used.
+%
+% For the \HTML\ version, see \cref{sec:chemmacroshtmlenvs}.
+%    \begin{macrocode}
+\DeclareDocumentEnvironment{redoxreaction}{m m}
+    {\rule{0pt}{#1}}{\rule[-#2]{0pt}{#2}}
+%    \end{macrocode}
+% \end{noindenvironment}
+%
+%    \begin{macrocode}
+}{}% chemmacros
+}% AtBeginDocument
+%    \end{macrocode}
 
+%    \begin{macrocode}
+\end{warpprint}
+%    \end{macrocode}
 
+
+
+
 % \section{Cleveref}
 % \label{sec:cleveref}
 
@@ -25837,7 +26668,7 @@
 %    \begin{macrocode}
 \def\(##1\){}%
 \def\[##1\]{}%
-\renewcommand{\LWR at subsingledollar}[2]{}
+\RenewDocumentCommand{\LWR at subsingledollar}{s m m m}{}
 }
 %    \end{macrocode}
 % \end{macro}
@@ -26028,7 +26859,51 @@
 % \end{macro}
 
 
+% \begin{macro}{\LWR at currenttextcolor}
+% The color to use for text and \cs{rule}, defaulting to black:
+%
+% \changes{v0.36}{2017/08/16}{Fix for \cs{rule} when \pkg{xcolor} not loaded.}
+%
 %    \begin{macrocode}
+\newcommand*{\LWR at currenttextcolor}{black}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\LWR at tempcolor}
+% \begin{macro}{\LWR at tempcolortwo}
+% The color converted to \HTML\ colorspace.
+%    \begin{macrocode}
+\newcommand*{\LWR at tempcolor}{}
+\newcommand*{\LWR at tempcolortwo}{}
+%    \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+% \begin{macro}{\LWR at findcurrenttextcolor}
+% \changes{v0.51}{2018/03/14}{Added \cs{LWR at findcurrenttextcolor} when no \pkg{xcolor}.}
+% Sets \cs{LWR at tempcolor} to the current color.
+%    \begin{macrocode}
+\newcommand*{\LWR at findcurrenttextcolor}{%
+\renewcommand{\LWR at tempcolor}{black}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\LWR at textcurrentcolor} \marg{text}
+% Like \cs{textcolor} but uses the current \cs{color} instead.
+% \changes{v0.51}{2018/03/11}{\pkg{xcolor}: \cs{LWR at textcurrentcolor} if \pkg{xcolor} not loaded.}
+%    \begin{macrocode}
+\NewDocumentCommand{\LWR at textcurrentcolor}{m}{%
+    \renewcommand*{\LWR at currenttextcolor}{black}%
+    #1%
+}
+%    \end{macrocode}
+% \end{macro}
+
+
+%    \begin{macrocode}
 \end{warpHTML}
 %    \end{macrocode}
 
@@ -26388,19 +27263,8 @@
 % \end{macro}
 %
 %
-% \begin{macro}{\LWR at currenttextcolor}
-% The color to use for text and \cs{rule}, defaulting to black:
 %
-% \changes{v0.36}{2017/08/16}{Fix for \cs{rule} when \pkg{xcolor} not loaded.}
 %
-%    \begin{macrocode}
-\newcommand*{\LWR at currenttextcolor}{black}
-%    \end{macrocode}
-% \end{macro}
-%
-%
-%
-%
 % \begin{macro}{\LWR at rule} \oarg{raise} \marg{width} \marg{height}
 %
 % Handles special minipage \& horizontal space interactions.
@@ -27518,7 +28382,7 @@
 \LWR at traceinfo{Patching alltt.}
 \AtBeginEnvironment{alltt}{%
 \LWR at forcenewpage
-\LWR at atbeginverbatim{alltt}\unskip\LWR at origvspace*{-\baselineskip}%
+\LWR at atbeginverbatim{3.5}{alltt}%
 }
 \AfterEndEnvironment{alltt}{\unskip\LWR at origvspace*{-\baselineskip}\LWR at afterendverbatim}
 }
@@ -27923,7 +28787,7 @@
 \let\LWR at origfirsthline\firsthline
 \let\LWR at origlasthline\lasthline
 
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \let\firsthline\LWR at origfirsthline%
 \let\lasthline\LWR at origlasthline%
 }
@@ -28065,7 +28929,7 @@
 %    \end{macrocode}
 
 %    \begin{macrocode}
-\BeforeBeginEnvironment{axopicture}{\begin{lateximage}[axopicture]}
+\BeforeBeginEnvironment{axopicture}{\begin{lateximage}[(axopicture)]}
 
 \AfterEndEnvironment{axopicture}{\end{lateximage}}
 %    \end{macrocode}
@@ -28213,7 +29077,7 @@
 %    \end{macrocode}
 % When entering a \env{lateximage}, restore the print-mode versions:
 %    \begin{macrocode}
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \LetLtxMacro{\ldelim}{\LWR at origldelim}%
 \LetLtxMacro{\rdelim}{\LWR at origrdelim}%
 }
@@ -28255,7 +29119,7 @@
 
 \renewcommand\bigstrut[1][x]{}
 
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \LetLtxMacro{\bigstrut}{\LWR at origbigstrut}%
 }
 %    \end{macrocode}
@@ -28515,7 +29379,7 @@
 %    \end{macrocode}
 
 %    \begin{macrocode}
-\BeforeBeginEnvironment{bytefield}{\begin{lateximage}[bytefield]}
+\BeforeBeginEnvironment{bytefield}{\begin{lateximage}[(bytefield)]}
 
 \AfterEndEnvironment{bytefield}{\end{lateximage}}
 %    \end{macrocode}
@@ -28554,7 +29418,7 @@
 \LetLtxMacro\LWR at origbcancel\bcancel
 \LetLtxMacro\LWR at origxcancel\xcancel
 
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \LetLtxMacro\cancel\LWR at origcancel%
 \LetLtxMacro\bcancel\LWR at origbcancel%
 \LetLtxMacro\xcancel\LWR at origxcancel%
@@ -28570,7 +29434,7 @@
 \newcommand{\LWR at cancelcolor}[5]{%
 \ifcsempty{#2}%
 {\LWR at HTMLtextstyle{#5}{#3}{#1}}%
-{\LWR at htmlspanclass[#5;#4:\#\LWR at tempcolor]{#3}{#1}}%
+{\LWR at htmlspanclass[#5;#4:\LWR at origpound\LWR at tempcolor]{#3}{#1}}%
 }
 %    \end{macrocode}
 % \end{noindmacro}
@@ -29024,6 +29888,1548 @@
 %
 %
 % \iffalse
+%<*chemfig>
+% \fi
+%
+% \part{lwarp-chemfig.sty}
+
+% \section{chemfig}
+%
+% \credits{Christian Tellechea}
+%
+% \DescribePackage{chemfig}
+% \pkg{chemfig} is patched for use by \pkg{lwarp}.
+%
+% The images are not hashed because they depend on external settings which
+% may be changed at any time, and are unlikely to be reused inline anyhow.
+%
+% \changes{v0.51}{2018/03/04}{\pkg{chemfig}: Added.}
+%
+% \codehtml
+%
+%    \begin{macrocode}
+\LWR at ProvidesPackagePass{chemfig}
+%    \end{macrocode}
+
+%    \begin{macrocode}
+\LetLtxMacro\LWR at chemfig@origchemfig\chemfig
+
+\DeclareDocumentCommand\chemfig{s O{} O{} m}{%
+    \begin{lateximage}[(chemfig)]%
+    \IfBooleanTF{#1}{%
+        \LWR at chemfig@origchemfig*[#2][#3]{#4}%
+    }{%
+        \LWR at chemfig@origchemfig[#2][#3]{#4}%
+    }
+    \end{lateximage}%
+}
+
+\LetLtxMacro\LWR at chemfig@origCF at lewis@b\CF at lewis@b
+
+\def\CF at lewis@b#1#2{%
+\begin{lateximage}[(chemfig)]%
+\LWR at chemfig@origCF at lewis@b{#1}{#2}%
+\end{lateximage}%
+}
+
+\preto{\schemestart}{\begin{lateximage}[(chemfig)]}
+\appto{\CF at schemestop}{\end{lateximage}}
+
+\LetLtxMacro\LWR at chemfig@origchemleft\chemleft
+
+\def\chemleft#1#2\chemright#3{%
+\begin{lateximage}[(chemfig)]%
+\LWR at chemfig@origchemleft#1#2\chemright#3%
+\end{lateximage}%
+}
+
+\LetLtxMacro\LWR at chemfig@origchemup\chemup
+
+\def\chemup#1#2\chemdown#3{%
+\begin{lateximage}[(chemfig)]%
+\LWR at chemfig@origchemup#1#2\chemdown#3%
+\end{lateximage}%
+}
+%    \end{macrocode}
+
+% \iffalse
+%</chemfig>
+% \fi
+%
+%
+%
+% \iffalse
+%<*chemformula>
+% \fi
+%
+% \part{lwarp-chemformula.sty}
+
+% \section{chemformula}
+%
+% \credits{Clemens Niederberger}
+%
+% \DescribePackage{chemformula}
+% \pkg{chemformula} is patched for use by \pkg{lwarp}.
+%
+% The \SVG\ images are hashed according to contents and local options.
+% Global options are assumed to be constant document-wide.
+%
+% \limitschemformula
+%
+% \changes{v0.51}{2018/03/05}{\pkg{chemformula}: Added.}
+%
+% \codehtml
+%
+%    \begin{macrocode}
+\LWR at ProvidesPackagePass{chemformula}[2017/03/23]
+%    \end{macrocode}
+
+%    \begin{macrocode}
+\ExplSyntaxOn
+%    \end{macrocode}
+%
+% \begin{noindmacro}{\ch}
+% Enclose in an inline \SVG\ image or MathJax.
+% The \attribute{alt} tag is is the contents of the \cs{ch} expression.
+% The filename is hashed, and also has additional hashing information based on
+% the local options.
+%    \begin{macrocode}
+\RenewDocumentCommand \ch { O{}m }
+  {%
+%    \end{macrocode}
+% To work inside \env{align} with \cs{displaymathother}, a simple version
+% must be used to work with \pkg{chemformula}'s adaptation to \env{align}.
+%    \begin{macrocode}
+    \ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}%  lwarp
+    {
+        \chemformula_ch:nn {#1} {#2}%   original
+    }
+%    \end{macrocode}
+% If used as the outer level, must temporarily ensure \brand{MathJax} is disabled:
+%    \begin{macrocode}
+    {
+        \begingroup%
+        \boolfalse{mathjax}%
+%    \end{macrocode}
+% An inline image is used, adjusted for the baseline:
+%    \begin{macrocode}
+        \LWR at subsingledollar*{% lwarp
+            \textbackslash{}ch\{\LWR at HTMLsanitize{#2}\}% alt text
+        }{%
+            \LWR at HTMLsanitize{#1}% add'l hashing
+        }%
+        {%
+            \chemformula_ch:nn {#1} {#2}%   original
+        }%
+        \endgroup%
+    }
+  }
+%    \end{macrocode}
+% \end{noindmacro}
+%
+% \begin{noindmacro}{\chcpd}
+% Similar to \cs{ch}.
+%    \begin{macrocode}
+\cs_gset_protected:Npn \chemformula_chcpd:nn #1#2
+  {
+    \begingroup%
+    \boolfalse{mathjax}%
+    \LWR at subsingledollar*{% lwarp
+        \textbackslash{}chcpd\{\LWR at HTMLsanitize{#2}\}%
+    }{%
+        \LWR at HTMLsanitize{#1}%
+    }{% original
+    \group_begin:
+      \tl_if_blank:nF {#2}
+        {
+          \keys_set:nn {chemformula} {#1}
+          \__chemformula_save_catcodes:
+          \__chemformula_sanitize:Nn
+            \l__chemformula_chemformula_tmpa_tl
+            {#2}
+          \__chemformula_input_compound_no_check:NV
+            \l__chemformula_compound_tl
+            \l__chemformula_chemformula_tmpa_tl
+          \__chemformula_prepare_output:N \l__chemformula_compound_tl
+          \chemformula_write:V \l__chemformula_compound_tl
+        }
+    \group_end:
+    }
+    \endgroup
+  }
+%    \end{macrocode}
+% \end{noindmacro}
+%
+% \begin{noindmacro}{\charrow}
+% If standalone, appears in a regular \env{lateximage}.
+%    \begin{macrocode}
+\RenewDocumentCommand \charrow { mO{}O{} }
+{
+    \begin{lateximage}[(charrow)]
+    \group_begin:
+      \__chemformula_draw_arrow:nnn {#1} {#2} {#3}
+    \group_end:
+    \end{lateximage}
+}
+%    \end{macrocode}
+% \end{noindmacro}
+%
+% \begin{noindmacro}{\chname}
+% If standalone, appears in a regular \env{lateximage}, hashed according to contents.
+%    \begin{macrocode}
+\RenewDocumentCommand \chname { R(){}R(){} }
+  {
+    \begin{lateximage}*[%
+        \textbackslash{}chname(\LWR at HTMLsanitize{#1})(\LWR at HTMLsanitize{#2})
+    ]%
+        \chemformula_chwritebelow:nn {#1} {#2}
+    \end{lateximage}
+  }
+%    \end{macrocode}
+% \end{noindmacro}
+%
+% \begin{noindmacro}{\chlewis}
+% Placed inline, hashed according to contents and options.
+%    \begin{macrocode}
+\RenewDocumentCommand \chlewis { O{}mm }
+  {
+    \begingroup%
+    \boolfalse{mathjax}%
+    \LWR at subsingledollar*{\textbackslash{}chlewis\{#2\}\{#3\}}{#1}{
+        \chemformula_lewis:nnn {#1} {#2} {#3}
+    }
+    \endgroup%
+  }
+%    \end{macrocode}
+% \end{noindmacro}
+%
+%
+% \pkg{lwarp} redefines the |$| character, so special handling is required
+% to escape math expressions inside \cs{ch}.
+%
+% This boolean tracks a new kind of escaped math:
+%    \begin{macrocode}
+\bool_new:N      \l__chemformula_first_last_LWRdollar_bool
+%    \end{macrocode}
+%
+% \begin{noindmacro}{\chemformula\_input\_escape\_math} \\
+%
+% Adds additional escaping for the new dollar definition:
+%    \begin{macrocode}
+\cs_gset_protected:Npn \__chemformula_input_escape_math:n #1
+  {
+    \__chemformula_first_last_math:n {#1}
+    \bool_if:NT \l__chemformula_first_last_dollar_bool
+      {
+        \bool_set_true:N \l__chemformula_first_last_math_bool
+        \__chemformula_read_escape_dollar:w #1 \q_nil
+      }
+    \bool_if:NT \l__chemformula_first_last_mathbraces_bool
+      {
+        \bool_set_true:N \l__chemformula_first_last_math_bool
+        \__chemformula_read_escape_mathbraces:w #1 \q_nil
+      }
+%    \end{macrocode}
+% Added by \pkg{lwarp}:
+%    \begin{macrocode}
+    \bool_if:NT \l__chemformula_first_last_LWRdollar_bool%      lwarp
+      {
+        \bool_set_true:N \l__chemformula_first_last_math_bool%  lwarp
+        \__chemformula_read_escape_LWRdollar:w #1 \q_nil%       lwarp
+      }
+  }
+%    \end{macrocode}
+% \end{noindmacro}
+%
+% \begin{noindmacro}{\chemformula\_read\_escape\_LWRdollar} \\
+%
+% The following parses the contents inside the new dollars.
+%
+% \pkg{lwarp} keeps the dollar as its original math shift until the document
+% starts.
+% While \pkg{chemmacros} is being patched, the dollar must temporarily
+% be set to its new meaning during the following definition.
+%
+%    \begin{macrocode}
+\begingroup
+\catcode`\$=\active
+
+\cs_new_protected:Npn \__chemformula_read_escape_LWRdollar:w $#1$ \q_nil
+{
+    \__chemformula_read_escape_math:n {#1}
+}
+
+\endgroup
+%    \end{macrocode}
+% \end{noindmacro}
+%
+%
+% \begin{noindmacro}{\chemformula\_bool\_set\_if\_first\_last} \\
+%
+% The following looks at the first and last tokens for delimiters to escape
+% math inside \cs{ch}.
+% The original definition is modified to look for the
+% control sequences which are used by the new meaning of |$|.
+%    \begin{macrocode}
+\cs_new_protected:Npn \__chemformula_bool_cs_set_if_first_last:NnNN #1#2#3#4
+  {
+    \int_zero:N \l__chemformula_tmpa_int
+    \int_zero:N \l__chemformula_tmpb_int
+    \int_set:Nn \l__chemformula_tmpa_int { \tl_count:n {#2} }
+    \tl_map_inline:nn {#2}
+      {
+        \int_incr:N \l__chemformula_tmpb_int
+        \int_compare:nT { \l__chemformula_tmpb_int = 1 }
+          {
+%    \end{macrocode}
+% At the start, the |cs_| version compares control sequences:
+%    \begin{macrocode}
+            \ifdefstrequal{##1}{#3}% lwarp
+                {
+                    \bool_set_true:N #1
+                }% lwarp
+                {}
+          }
+%    \end{macrocode}
+% At the end, compare more control sequences:
+%    \begin{macrocode}
+        \int_compare:nT { \l__chemformula_tmpb_int = \l__chemformula_tmpa_int }
+          {
+            \ifdefstrequal{##1}{#4}
+                {}
+                {
+                    \bool_set_false:N #1
+                }
+          }
+      }
+  }
+%    \end{macrocode}
+% \end{noindmacro}
+%
+%
+% \begin{noindmacro}{\chemformula\_first\_last\_math} \\
+%
+% Modified to check for the new meaning of |$| at first/last:
+%    \begin{macrocode}
+\cs_gset_protected:Npn \__chemformula_first_last_math:n #1
+  {
+    \bool_set_false:N \l__chemformula_first_last_math_bool
+    \bool_set_false:N \l__chemformula_first_last_dollar_bool
+    \bool_set_false:N \l__chemformula_first_last_LWRdollar_bool%    lwarp
+    \bool_set_false:N \l__chemformula_first_last_mathbraces_bool
+    \__chemformula_bool_set_if_first_last:Nnnn
+      \l__chemformula_first_last_dollar_bool
+      {#1}
+      { $ } { $ }
+    \bool_if:NF \l__chemformula_first_last_dollar_bool
+      {
+        \__chemformula_bool_set_if_first_last:Nnnn
+          \l__chemformula_first_last_mathbraces_bool
+          {#1}
+          { \( } { \) }
+%    \end{macrocode}
+% Added by \pkg{lwarp}:
+%    \begin{macrocode}
+          \bool_if:NF \l__chemformula_first_last_mathbraces_bool%   lwarp
+            {
+                \__chemformula_bool_cs_set_if_first_last:NnNN
+                \l__chemformula_first_last_LWRdollar_bool
+                {#1}
+                { \LWR at newsingledollar } { \LWR at newsingledollar }
+            }%  lwarp
+      }
+  }
+%    \end{macrocode}
+% \end{noindmacro}
+%
+%
+%    \begin{macrocode}
+\ExplSyntaxOff
+%    \end{macrocode}
+%
+% \iffalse
+%</chemformula>
+% \fi
+%
+%
+%
+% \iffalse
+%<*chemgreek>
+% \fi
+%
+% \part{lwarp-chemgreek.sty}
+
+% \section{chemgreek}
+%
+% \credits{Clemens Niederberger}
+%
+% \DescribePackage{chemgreek}
+% \pkg{chemgreek} is patched for use by \pkg{lwarp}.
+%
+% To use text-mode symbols, \margintag{Greek symbols}
+% use packages \pkg{textalpha} or \pkg{textgreek}.
+% Using the other packages supported by \pkg{chemgreek} \watchout[package selection]
+% will result in math-mode greek characters,
+% which will result in \SVG\ images being used.
+% These images will be hashed.
+% \index{chemistry>Greek symbols}
+% \index{Greek>chemistry symbols}
+%
+% If using \XeLaTeX\ or \LuaLaTeX, select the |fontspec| mapping:\watchout[\XeLaTeX, \LuaLaTeX]
+% \begin{sourcedisplay}
+% \cs{selectchemgreekmapping}\{fontspec\}
+% \end{sourcedisplay}
+%
+%
+% \changes{v0.51}{2018/03/08}{\pkg{chemgreek}: Added.}
+%
+% \codehtml
+%
+%    \begin{macrocode}
+\LWR at ProvidesPackagePass{chemgreek}[2016/02/10]
+%    \end{macrocode}
+
+%    \begin{macrocode}
+\ExplSyntaxOn
+
+\cs_undefine:N \chemgreek_text:n
+
+\cs_new_protected:Npn \chemgreek_text:n #1
+  { { \text {#1} } }
+
+\appto\LWR at restoreorigformatting{%
+\cs_set_protected:Npn \chemgreek_text:n #1%
+  { \ensuremath { \text {#1} } }%
+}
+
+\ExplSyntaxOff
+%    \end{macrocode}
+
+% \iffalse
+%</chemgreek>
+% \fi
+%
+%
+%
+%
+% \iffalse
+%<*chemmacros>
+% \fi
+%
+% \part{lwarp-chemmacros.sty}
+
+% \section{chemmacros}
+%
+% \credits{Clemens Niederberger}
+%
+% \DescribePackage{chemmacros}
+% \pkg{chemmacros} is patched for use by \pkg{lwarp}.
+%
+% \changes{v0.51}{2018/03/13}{\pkg{chemmacros}: Added.}
+%
+% \codehtml
+%
+%    \begin{macrocode}
+\LWR at ProvidesPackagePass{chemmacros}
+%    \end{macrocode}
+%
+% SVG file hashing assumes that the relevent options are constant for the entire document.
+%
+% \subsection{Changes to the user's document}
+%
+% When using \cs{makepolymerdelims}, \watchout[\cs{makepolymerdelims}]
+% enclose the entire expression inside a \env{polymerdelims} environment,
+% such as (from the \pkg{chemmacros} manual):
+%
+% \begin{Verbatim}[gobble=2]
+% \begin{polymerdelims}
+% \chemfig{-[@{op,.75}]CH_2-CH(-[6]Cl)-[@{cl,0.25}]}
+% \makepolymerdelims{5pt}[27pt]{op}{cl}
+% \end{polymerdelims}
+% \end{Verbatim}
+%
+% \hrule
+%
+% Redox reactions must be enclosed inside
+% a \env{redoxreaction} environment. \watchout[redox reactions]
+% For print output, extra space must be included above and/or below the result,
+% so they are declared as arguments to the environment, instead of
+% being manually entered as per the \pkg{chemmacros} manual.
+% For \HTML\ output, the extra space is ignored and a \env{lateximage} is used instead.
+% \begin{Verbatim}[gobble=2]
+% \begin{redoxreaction}{7mm}{7mm}
+% \OX{a,Na} $\rightarrow$ \OX{b,Na}\pch\redox(a,b){oxidation}
+% \end{redoxreaction}
+% \end{Verbatim}
+%
+% \subsection{Code}
+%
+%
+% \subsection{Loading modules}
+%
+% Patching \pkg{chemmacros} modules must be done \cs{AtBeginDocument},
+% since modules are invoked by the user in the preamble, and each patch is
+% only done if the module is loaded.
+%
+%    \begin{macrocode}
+\ExplSyntaxOn
+
+\newcommand{\@ifchemmacrosmoduleloaded}[1]{%
+\@ifl at aded{\c__chemmacros_module_extension_tl}{\c__chemmacros_module_prefix_tl.#1}%
+}
+
+\ExplSyntaxOff
+%    \end{macrocode}
+%
+%
+% \subsection{New environments}
+% \label{sec:chemmacroshtmlenvs}
+%
+% \cs{makepolymerdelims} and redox reactions must be enclosed in a \env{lateximage}
+% during \HTML\ output.
+% These environments are provided here in \HTML\ mode, and in the \pkg{lwarp} core
+% in print mode, as a high-level semantic syntax which automatically embeds the
+% contents in a \env{lateximage} with an appropriate \attribute{alt} tag.
+%
+% \begin{noindenvironment}{polymerdelims}
+%    \begin{macrocode}
+\DeclareDocumentEnvironment{polymerdelims}{}
+{\begin{lateximage}[(polymer)]}
+{\end{lateximage}}
+%    \end{macrocode}
+% \end{noindenvironment}
+
+% \begin{noindenvironment}{redoxreaction} \marg{space above} \marg{space below}
+%
+% For \HTML\ output, the above and below space is ignored, and a \env{lateximage}
+% is used instead.
+% For the print output version, see \cref{sec:chemmacrosprintenvs}.
+%    \begin{macrocode}
+\DeclareDocumentEnvironment{redoxreaction}{m m}
+{\begin{lateximage}[(redox~reaction)]}
+{\end{lateximage}}
+%    \end{macrocode}
+% \end{noindenvironment}
+%
+%
+%    \begin{macrocode}
+\ExplSyntaxOn
+%    \end{macrocode}
+%
+%
+% \subsection{Acid-base}
+%
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{acid-base}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~acid-base}
+
+\cs_gset_protected:Npn \chemmacros_p:n #1
+  {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{
+        \textbackslash{}p\{\LWR at HTMLsanitize{#1}\}
+    }{
+        chemmacrosp\LWR at HTMLsanitize{#1}
+    }{
+    \group_begin:
+      \mbox
+        {
+          \chemmacros_p_style:n {p}
+          \ensuremath {#1}
+        }
+    \group_end:
+    }
+    \endgroup
+  }
+
+\RenewDocumentCommand \pH  {} {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}pH}{chemmacros}{
+        \chemmacros_p:n { \chemmacros_chemformula:n {H} }
+    }
+    \endgroup
+}
+
+\RenewDocumentCommand \pOH {} {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}pOH}{chemmacros}{
+        \chemmacros_p:n { \chemmacros_chemformula:n {OH} }
+    }
+    \endgroup
+}
+
+\RenewDocumentCommand \pKa {O{}}
+  {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}pKa{[}#1{]}}{chemmacros #1}{
+        \chemmacros_p:n
+        {
+            \Ka \ifblank {#1} {}
+            { {} \c_math_subscript_token { \chemmacros_bold:n {#1} } }
+        }
+    }
+    \endgroup
+  }
+
+\RenewDocumentCommand \pKb {O{}}
+  {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}pKb{[}#1{]}}{chemmacros #1}{
+        \chemmacros_p:n
+        {
+            \Kb \ifblank {#1} {}
+            { {} \c_math_subscript_token { \chemmacros_bold:n {#1} } }
+        }
+    }
+    \endgroup
+  }
+
+\LetLtxMacro\LWR at chemmacros@origKa\Ka
+\renewcommand*{\Ka}{%
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}Ka}{chemmacros}{%
+        \LWR at chemmacros@origKa%
+    }%
+    \endgroup
+}
+
+\LetLtxMacro\LWR at chemmacros@origKb\Kb
+\renewcommand*{\Kb}{%
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}Kb}{chemmacros}{%
+        \LWR at chemmacros@origKb%
+    }%
+    \endgroup
+}
+
+\LetLtxMacro\LWR at chemmacros@origKw\Kw
+\renewcommand*{\Kw}{%
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}Kw}{chemmacros}{
+        \LWR at chemmacros@origKw
+    }
+    \endgroup
+}
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+%    \end{macrocode}
+%
+%
+% \subsection{Charges}
+%
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{charges}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~charges}
+
+\cs_gset_protected:Npn \fplus  {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}fplus}{chemmacros}
+    { \LWR at origensuredmath{\chemformula_fplus:}  }
+    \endgroup
+}
+\cs_gset_protected:Npn \fminus {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}fminus}{chemmacros}
+    { \LWR at origensuredmath{\chemformula_fminus:} }
+    \endgroup
+}
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+%    \end{macrocode}
+%
+%
+% \subsection{Nomenclature}
+%
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{nomenclature}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~nomenclature}
+
+\cs_gset_protected:Npn \chemmacros_charge:n #1
+  {
+    \ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}
+    {\chemmacros_chemformula:n { {}^{#1} }}
+    {
+        \ifmmode
+            {\chemmacros_chemformula:n { {}^{#1} }}
+        \else
+            { \textsuperscript{\ensuremath{#1}} }
+        \fi
+    }
+  }
+
+
+\LetLtxMacro\LWR at chemmacros@origchemprime\chemprime
+
+\protected\def\chemprime { \HTMLunicode{2032} }
+
+\appto\LWR at restoreorigformatting{%
+\LetLtxMacro\chemprime\LWR at chemmacros@origchemprime%
+}
+%    \end{macrocode}
+%
+% ^^A \RenewChemIUPAC \chemprime { \HTMLunicode{2032} }
+%
+%    \begin{macrocode}
+\ChemCompatibilityFrom{5.8}
+\cs_gset_protected:Npn \__chemmacros_cip:n #1
+  {
+    \tl_set:Nn \l__chemmacros_tmpa_tl {#1}
+    \int_step_inline:nnnn {0} {1} {9}
+      {
+        \tl_replace_all:Nnn \l__chemmacros_tmpa_tl
+          {##1}
+          { { \l__chemmacros_cip_number_tl ##1} }
+      }
+    {
+        \l__chemmacros_cip_inner_tl
+        \LWR at textcurrentcolor{\LWR at textcurrentfont{% lwarp
+            \l__chemmacros_tmpa_tl
+        }}% lwarp
+    }
+  }
+\EndChemCompatibility
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\RenewDocumentCommand \Sconf { O{S} } {
+\begin{lateximage}[\textbackslash{}Sconf{[}#1{]}]
+    \chemmacros_sconf:n {#1}
+\end{lateximage}
+}
+
+\RenewDocumentCommand \Rconf { O{R} } {
+\begin{lateximage}[\textbackslash{}Rconf{[}#1{]}]
+    \chemmacros_rconf:n {#1}
+\end{lateximage}
+}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\cs_gset_protected:Npn \chemmacros_hapto:n #1
+  {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}hapto\{#1\}}{chemmacros}{
+        \chemmacros_coordination_symbol:nnnn
+        { \l__chemmacros_coord_use_hyphen_bool }
+        {
+            \chemmacros_if_compatibility:nnTF {>} {5.7}
+            { \c_true_bool }
+            { \c_false_bool }
+        }
+        { \chemeta }
+        {#1}
+    }
+    \endgroup
+  }
+
+\cs_gset_protected:Npn \chemmacros_dento:n #1
+  {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}dento\{#1\}}{chemmacros}{
+        \chemmacros_coordination_symbol:nnnn
+        { \l__chemmacros_coord_use_hyphen_bool }
+        {
+            \chemmacros_if_compatibility:nnTF {>} {5.7}
+            { \c_true_bool }
+            { \c_false_bool }
+        }
+        { \chemkappa }
+        {#1}
+    }
+    \endgroup
+  }
+
+\cs_gset_protected:Npn \chemmacros_bridge:n #1
+  {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}bridge\{#1\}}{chemmacros}{
+        \chemmacros_coordination_symbol:nnnn
+        { \l__chemmacros_coord_use_hyphen_bool }
+        { \l__chemmacros_bridge_super_bool }
+        { \chemmu }
+        {#1}
+    }
+    \endgroup
+  }
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+%    \end{macrocode}
+%
+%
+% \subsection{Particles}
+%
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{particles}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~particles}
+
+\cs_gset_protected:Npn \chemmacros_declare_nucleophile:Nn #1#2
+  {
+    \cs_set_protected:cpn {__chemmacros_ \chemmacros_remove_backslash:N #1:}
+      {
+        \bool_if:NTF \l__chemmacros_nucleophile_elpair_bool
+          {
+            \chemmacros_elpair:n { #2 }
+            \chemmacros_if_compatibility:nnT {>=} {5.3}
+              { \skip_horizontal:N \l__chemmacros_nucleophile_dim }
+            \chemmacros_chemformula:n { {}^{-} }
+          }
+          { \chemmacros_chemformula:n { #2^{-} } }
+      }
+    \DeclareDocumentCommand #1 {o}
+      {%
+        \begin{lateximage}%
+        \group_begin:%
+          \IfNoValueF {##1}%
+            { \chemmacros_set_keys:nn {particles} {##1} }%
+          \use:c {__chemmacros_ \chemmacros_remove_backslash:N #1:}%
+        \group_end:%
+        \end{lateximage}%
+      }
+  }
+
+\RenewChemNucleophile \Nuc {Nu}
+\RenewChemNucleophile \ba  {ba}
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+%    \end{macrocode}
+%
+%
+% \subsection{Phases}
+%
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{phases}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~phases}
+
+\cs_undefine:N \chemmacros_phase:n
+\cs_new_protected:Npn \chemmacros_phase:n #1
+  {
+    \chemmacros_leave_vmode:
+    \bool_if:NTF \l__chemmacros_phases_sub_bool
+      {
+        \ifnumequal{\value{LWR at lateximagedepth}}{0}
+        {
+            \textsubscript{ (#1) }
+        }
+        {
+            \chemformula_subscript:n { (#1) }
+        }
+      }
+      {
+        \skip_horizontal:N \l__chemmacros_phases_space_dim
+        \chemmacros_text:n { (#1) }
+      }
+  }
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+%    \end{macrocode}
+%
+% \subsection{Mechanisms}
+%
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{mechanisms}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~mechanisms}
+
+\chemmacros_define_keys:nn {textmechanisms}
+  {
+    type      .choice: ,
+    type /    .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { S }
+          {
+              \textsubscript{N}
+          }
+          { }
+      } ,
+    type / 1  .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { S }
+          {
+              \textsubscript{N}
+            1
+          }
+          { }
+      } ,
+    type / 2  .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { S }
+          {
+              \textsubscript{N}
+            2
+          }
+          { }
+      } ,
+    type / se .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { S }
+          {
+              \textsubscript{E}
+          }
+          { }
+      } ,
+    type / 1e .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { S }
+          {
+              \textsubscript{E}
+            1
+          }
+          { }
+      } ,
+    type / 2e .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { S }
+          {
+              \textsubscript{E}
+            2
+          }
+          { }
+      } ,
+    type / ar .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { S }
+          {
+              \textsubscript{E}
+          }
+          { Ar - }
+      } ,
+    type / e  .code:n    =
+      { \__chemmacros_set_mechanisms:nnn { E } { } { } } ,
+    type / e1 .code:n    =
+      { \__chemmacros_set_mechanisms:nnn { E } { 1 } { } } ,
+    type / e2 .code:n    =
+      { \__chemmacros_set_mechanisms:nnn { E } { 2 } { } } ,
+    type / cb .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { E }
+          {
+            1
+              \textsubscript{cb}
+          }
+          { }
+      } ,
+    type      .default:n = 
+  }
+
+\cs_gset_protected:Npn \chemmacros_mechanisms:n #1
+  {
+    \tl_if_blank:nTF {#1}
+      { \chemmacros_set_keys:nn {textmechanisms} { type } }
+      { \chemmacros_set_keys:nn {textmechanisms} { type = #1 } }
+    \mbox
+      {
+        \tl_use:N \l__chemmacros_mechanisms_ar_tl
+        \tl_use:N \l__chemmacros_mechanisms_type_tl
+        \tl_use:N \l__chemmacros_mechanisms_mol_tl
+      }
+  }
+
+\appto\LWR at restoreorigformatting{%
+\cs_set_protected:Npn \chemmacros_mechanisms:n #1%
+  {%
+    \tl_if_blank:nTF {#1}%
+      { \chemmacros_set_keys:nn {mechanisms} { type } }%
+      { \chemmacros_set_keys:nn {mechanisms} { type = #1 } }%
+    \mbox%
+      {%
+        \tl_use:N \l__chemmacros_mechanisms_ar_tl%
+        \tl_use:N \l__chemmacros_mechanisms_type_tl%
+        \tl_use:N \l__chemmacros_mechanisms_mol_tl%
+      }%
+  }%
+}
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+%    \end{macrocode}
+%
+% \subsection{Newman}
+%
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{newman}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~newman}
+
+\RenewDocumentCommand \newman {od()m}%
+  {
+    \IfValueTF{#2}
+    {\begin{lateximage}[\textbackslash{}newman(#2)\{#3\}]}
+    {\begin{lateximage}[\textbackslash{}newman\{#3\}]}
+    \group_begin:
+      \IfNoValueF  {#1} { \chemmacros_set_keys:nn {newman} {#1} }
+      \IfNoValueTF {#2}
+        { \chemmacros_newman:nn {  } {#3} }
+        { \chemmacros_newman:nn {#2} {#3} }
+    \group_end:
+    \end{lateximage}
+  }%
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+%    \end{macrocode}
+%
+% \subsection{Orbital}
+%
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{orbital}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~orbital}
+
+\RenewDocumentCommand \orbital {om}
+  {
+    \IfValueTF{#1}
+    {
+        \begin{lateximage}[%
+            \textbackslash{}orbital{[}\LWR at HTMLsanitize{#1}{]}\{#2\}%
+        ][][margin-left: 1em ; margin-right: 1em]
+    }
+    {
+        \begin{lateximage}[%
+            \textbackslash{}orbital\{#2\}%
+        ][][margin-left: 1em ; margin-right: 1em]
+    }
+    \group_begin:
+      \chemmacros_set_keys:nn {orbital/type} {#2}
+      \IfNoValueTF {#1}
+        { \chemmacros_orbital:n {  } }
+        { \chemmacros_orbital:n {#1} }
+    \group_end:
+    \end{lateximage}
+  }
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+%    \end{macrocode}
+%
+%
+% \subsection{Reactions}
+%
+% \begin{noindmacro}{\chemmacros\_declare\_reaction\_env} \\
+%   \hspace*{2em} \marg{chem} \marg{math} \marg{args number} \marg{argument list (\{\#2\}\{\#3\}...)}
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{reactions}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~orbital}
+
+\cs_gset_protected:Npn \chemmacros_declare_reaction_env:nnnn #1#2#3#4
+  {
+    \exp_args:Nnx \DeclareDocumentEnvironment {#1} { O{} \prg_replicate:nn {#3+0} {m} }
+      {
+        \boolfalse{mathjax}%    lwarp
+        \chemmacros_add_reaction_description:n {##1}
+        \__chemmacros_begin_reaction:
+        \chemmacros_reaction_read:nnw {#2} {#4}
+      }
+      {
+        \__chemmacros_end_reaction:
+      }
+  }
+\cs_generate_variant:Nn \chemmacros_declare_reaction_env:nnnn {nnnV}
+
+\RenewChemReaction {reaction}   {equation}
+\RenewChemReaction {reaction*}  {equation*}
+\RenewChemReaction {reactions}  {align}
+\RenewChemReaction {reactions*} {align*}
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+%    \end{macrocode}
+% \end{noindmacro}
+%
+%
+% \subsection{Redox}
+%
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{redox}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~redox}
+
+\NewDocumentCommand \LWR at chemmacros@ox { s m >{\SplitArgument{1}{,}}m }
+  {
+    \IfBooleanTF {#1}
+      { \chemmacros_ox:nnnn {#1} {#2} #3 }
+      { \chemmacros_ox:nnnn {  } {#2} #3 }
+  }
+
+\RenewDocumentCommand \ox { s O{} m }
+  {
+    \begingroup
+    \boolfalse{mathjax}
+    \IfBooleanTF {#1}
+      {
+        \LWR at subsingledollar*{% yes hash
+            \textbackslash{}ox*\{\LWR at HTMLsanitize{#3}\}% alt
+        }{%
+            star \LWR at HTMLsanitize{#2}% addl' hashing with star
+        }{%
+            \LWR at chemmacros@ox* {#2} {#3}% contents
+        }%
+      }
+      {
+        \LWR at subsingledollar*{% yes hash
+            \textbackslash{}ox*\{\LWR at HTMLsanitize{#3}\}% alt
+        }{%
+            \LWR at HTMLsanitize{#2}% addl' hashing without star
+        }{%
+            \LWR at chemmacros@ox {#2} {#3}% contents
+        }%
+      }
+    \endgroup
+  }
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+%    \end{macrocode}
+%
+% \subsection{Scheme}
+%
+% Bug fix for  \pkg{chemmacros} when using \pkg{newfloat}:
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{scheme}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~scheme}
+
+\ifdefstring{\schemename}{los}{
+\SetupFloatingEnvironment{scheme}{
+name = \chemmacros_translate:n {scheme-name}
+}
+}{}
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+%    \end{macrocode}
+%
+% \subsection{Spectroscopy}
+%
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{spectroscopy}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~spectroscopy}
+
+\ChemCompatibilityTo{5.8}
+\cs_gset_protected:Npn \__chemmacros_nmr_base:nn #1#2
+  {
+    \tl_if_blank:VF \g__chemmacros_nmr_element_coupled_tl
+      {
+        \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl { \{ }
+        \tl_put_right:Nn \g__chemmacros_nmr_element_coupled_tl { \} }
+      }
+    \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl {#2}
+%     \chemmacros_chemformula:n { ^{#1} }
+    \textsuperscript{#1}
+    \bool_if:NTF \l__chemmacros_nmr_parse_bool
+      { \chemformula_ch:nV {} \g__chemmacros_nmr_element_coupled_tl }
+      { \chemmacros_chemformula:V \g__chemmacros_nmr_element_coupled_tl }
+    \tl_use:N \l__chemmacros_nmr_element_method_connector_tl
+    \tl_use:N \l__chemmacros_nmr_method_tl
+  }
+\EndChemCompatibility
+\ChemCompatibilityFrom{5.8}
+\cs_gset_protected:Npn \__chemmacros_nmr_base:nn #1#2
+  {
+    \group_begin:
+      \tl_use:N \l__chemmacros_nmr_base_format_tl
+      \tl_if_blank:VF \g__chemmacros_nmr_element_coupled_tl
+        {
+          \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl { \{ }
+          \tl_put_right:Nn \g__chemmacros_nmr_element_coupled_tl { \} }
+        }
+      \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl {#2}
+%       \chemmacros_chemformula:n { ^{#1} }
+      \textsuperscript{#1}
+      \tl_if_blank:VF \g__chemmacros_nmr_element_coupled_tl
+        {
+          \bool_if:NTF \l__chemmacros_nmr_parse_bool
+            { \chemformula_ch:nV {} \g__chemmacros_nmr_element_coupled_tl }
+            { \chemmacros_chemformula:V \g__chemmacros_nmr_element_coupled_tl }
+        }
+      \tl_use:N \l__chemmacros_nmr_element_method_connector_tl
+      \tl_use:N \l__chemmacros_nmr_method_tl
+    \group_end:
+  }
+\EndChemCompatibility
+
+
+\cs_gset_protected:Npn \chemmacros_nmr_position:n #1
+  {
+    \chemmacros_chemformula:x
+      {
+        \exp_not:V \g__chemmacros_nmr_element_tl
+        \bool_if:NF \l__chemmacros_nmr_position_side_bool
+          {
+            \tl_if_eq:NnTF \l__chemmacros_nmr_position_tl {^}% lwarp
+            { \textsuperscript{\exp_not:n { {#1} }} }% lwarp
+            { \textsubscript{\exp_not:n { {#1} }} }% lwarp
+%             \exp_not:V \l__chemmacros_nmr_position_tl
+%             \exp_not:n { {#1} }
+          }
+      }
+    \bool_if:NT \l__chemmacros_nmr_position_side_bool
+      {
+        \tl_use:N \l__chemmacros_nmr_position_tl
+        \__chemmacros_nmr_position:n {#1}
+      }
+  }
+
+\cs_gset_protected:Npn \__chemmacros_nmr_coupling:w (#1;#2)
+  {
+    \tl_set:Nn \l__chemmacros_nmr_coupling_bonds_tl
+      {
+        \l__chemmacros_nmr_coupling_bonds_pre_tl
+        #1
+        \l__chemmacros_nmr_coupling_bonds_post_tl
+      }
+    \bool_if:NTF \l__chemmacros_nmr_coupling_nuclei_sub_bool
+      {
+        \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl
+          {
+%             \c_math_subscript_token
+            \textsubscript% lwarp
+              {
+                \l__chemmacros_nmr_coupling_nuclei_pre_tl
+                \chemmacros_chemformula:n {#2}
+                \l__chemmacros_nmr_coupling_nuclei_post_tl
+              }
+          }
+      }
+      {
+        \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl
+          {
+            \l__chemmacros_nmr_coupling_nuclei_pre_tl
+            \chemmacros_chemformula:n {#2}
+            \l__chemmacros_nmr_coupling_nuclei_post_tl
+          }
+      }
+    \__chemmacros_nmr_coupling_aux_i:w
+  }
+
+\AfterEndPreamble{% After \AtBeginDocument
+% \NMR{<num>,<elem>}(<num>,<unit>)[<solvent>] ALL arguments are optional
+% \NMR* same but without ": $\delta$" at end
+\cs_gset_protected:Npn \chemmacros_nmr:nnnn #1#2#3#4
+    {
+    \bool_if:NT \l__chemmacros_nmr_list_bool { \item \scan_stop: }
+    \group_begin:
+        \chemmacros_leave_vmode:
+        \bool_set_false:N \l__chemmacros_nmr_frequency_bool
+        \bool_set_false:N \l__chemmacros_nmr_solvent_bool
+        \tl_if_empty:nF {#3}
+        { \bool_set_true:N \l__chemmacros_nmr_frequency_bool }
+        \tl_if_empty:nF {#4}
+        { \bool_set_true:N \l__chemmacros_nmr_solvent_bool }
+        \bool_if:nT
+        {
+            \l__chemmacros_nmr_frequency_bool
+            ||
+            \l__chemmacros_nmr_solvent_bool
+        }
+        { \bool_set_true:N \l__chemmacros_nmr_delimiters_bool }
+        \bool_if:nT
+        {
+            \l__chemmacros_nmr_frequency_bool
+            &&
+            \l__chemmacros_nmr_solvent_bool
+        }
+        { \bool_set_true:N \l__chemmacros_nmr_comma_bool }
+        \tl_if_empty:nTF {#2}
+        {
+            \__chemmacros_nmr_nucleus:VV
+            \l__chemmacros_nmr_isotope_default_tl
+            \l__chemmacros_nmr_element_default_tl
+        }
+        { \__chemmacros_nmr_nucleus:w #2 \q_stop }
+        \mode_if_math:TF
+        {
+            \text
+            {
+                \group_begin:
+                \tl_use:N \l__chemmacros_nmr_format_tl
+\LWR at textcurrentcolor{\LWR at textcurrentfont{% lwarp
+                \__chemmacros_nmr_base:VV
+                    \g__chemmacros_nmr_isotope_tl
+                    \g__chemmacros_nmr_element_tl
+                \bool_if:NT \l__chemmacros_nmr_delimiters_bool
+                    { ~ ( }
+                \bool_if:NT \l__chemmacros_nmr_frequency_bool
+                    { \__chemmacros_nmr_frequency:n {#3} }
+                \bool_if:NT \l__chemmacros_nmr_comma_bool
+                    { , ~ }
+                \bool_if:NT \l__chemmacros_nmr_solvent_bool
+                    { \chemmacros_chemformula:n {#4} }
+                \bool_if:NT \l__chemmacros_nmr_delimiters_bool
+                    { ) }
+                \tl_if_blank:nT {#1} {:~}
+}}% lwarp
+                \group_end:
+            }
+            \tl_if_blank:nT {#1}
+            {
+                \delta
+                \text { \l__chemmacros_nmr_delta_tl }
+                \bool_if:NT \l__chemmacros_nmr_use_equal_bool {=}
+            }
+        }
+        {
+            \group_begin:
+            \tl_use:N \l__chemmacros_nmr_format_tl
+\LWR at textcurrentcolor{\LWR at textcurrentfont{% lwarp
+            \__chemmacros_nmr_base:VV
+                \g__chemmacros_nmr_isotope_tl
+                \g__chemmacros_nmr_element_tl
+            \bool_if:NT \l__chemmacros_nmr_delimiters_bool
+                {~(}
+            \bool_if:NT \l__chemmacros_nmr_frequency_bool
+                { \__chemmacros_nmr_frequency:n {#3} }
+            \bool_if:NT \l__chemmacros_nmr_comma_bool
+                {,~}
+            \bool_if:NT \l__chemmacros_nmr_solvent_bool
+                {
+                \bool_if:NTF \l__chemmacros_nmr_parse_bool
+                    { \chemformula_ch:nn { } {#4} }
+                    {#4}
+                }
+            \bool_if:NT \l__chemmacros_nmr_delimiters_bool
+                {)}
+}}% lwarp
+            \tl_if_blank:nT {#1} {:}
+            \group_end:
+            \tl_if_blank:nT {#1}
+            {
+                \tl_use:N \c_space_tl
+                \c_math_toggle_token
+                \delta
+                \c_math_toggle_token
+                \l__chemmacros_nmr_delta_tl
+                \bool_if:NT \l__chemmacros_nmr_use_equal_bool {~=}
+            }
+        }
+    \group_end:
+    }
+}% AfterEndPremble
+
+
+\RenewDocumentCommand \chemmacros_data:w { smo }
+  {
+    \bool_if:NT \l__chemmacros_nmr_list_bool { \item }
+      {
+%         \tl_use:N \l__chemmacros_nmr_format_tl #2
+        \tl_use:N \l__chemmacros_nmr_format_tl
+        \LWR at textcurrentcolor{\LWR at textcurrentfont{% lwarp
+            #2
+            \IfNoValueF {#3} { ~ ( #3 ) }
+            \IfBooleanT {#1} { \bool_if:NT \l__chemmacros_nmr_use_equal_bool { : } }
+        }}% lwarp
+      }
+    \IfBooleanF {#1} { \bool_if:NT \l__chemmacros_nmr_use_equal_bool { ~ = } }
+  }
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+%    \end{macrocode}
+%
+% \subsection{Thermodynamics}
+%
+%    \begin{macrocode}
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{thermodynamics}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~thermodynamics}
+
+\cs_gset_protected:Npn \chemmacros_state:nn #1#2
+  {
+    \group_begin:
+      \boolfalse{mathjax}
+      \chemmacros_set_keys:nn {thermodynamics} {#1}
+        \LWR at subsingledollar*{% yes hashing
+            \textbackslash{}state\{\LWR at HTMLsanitize{#2}\}% alt
+        }{%
+            chemmacros_state% add'l hashing
+            #1% options
+            LSP \tl_use:N \l__chemmacros_state_sp_left_tl% super/subscripts
+            LSB \tl_use:N \l__chemmacros_state_sb_left_tl
+            RSP \tl_use:N \l__chemmacros_state_sp_right_tl
+            RSB \tl_use:N \l__chemmacros_state_sb_right_tl
+        }
+        {
+         \LWR at origensuredmath{
+          \chemmacros_text:V \l__chemmacros_state_pre_tl
+          \c_math_superscript_token
+            { \chemmacros_text:V \l__chemmacros_state_sp_left_tl }
+%    \end{macrocode}
+% Only add the subscripts if they are being used.
+% This avoids causing an incorrect depth, as the empty subscript will be
+% measured by \TeX\ but cropped out by \prog{pdfcrop}.
+%    \begin{macrocode}
+          \tl_if_empty:NTF \l__chemmacros_state_sb_left_tl
+          {}
+          {
+            \c_math_subscript_token
+            { \chemmacros_text:V \l__chemmacros_state_sb_left_tl }
+          }
+          #2
+          \c_math_superscript_token
+            { \chemmacros_text:V \l__chemmacros_state_sp_right_tl }
+          \tl_if_empty:NTF \l__chemmacros_state_sb_right_tl
+          {}
+          {
+            \c_math_subscript_token
+            { \chemmacros_text:V \l__chemmacros_state_sb_right_tl }
+          }
+          \chemmacros_text:V \l__chemmacros_state_post_tl
+         }
+        }
+    \group_end:
+  }
+\cs_generate_variant:Nn \chemmacros_state:nn { nV }
+
+\cs_gset_protected:Npn \chemmacros_declare_state:Nn #1#2
+  {
+    \chemmacros_define_keys:xn
+      {thermodynamics/\chemmacros_remove_backslash:N #1}
+      {
+        pre               .meta:nn = {chemmacros/thermodynamics} { pre = ##1 } ,
+        post              .meta:nn = {chemmacros/thermodynamics} { post = ##1 } ,
+        superscript-left  .meta:nn = {chemmacros/thermodynamics} { superscript-left = ##1 } ,
+        superscript-right .meta:nn = {chemmacros/thermodynamics} { superscript-right = ##1 } ,
+        superscript       .meta:n  = { superscript-right = ##1 } ,
+        subscript-left    .meta:nn = {chemmacros/thermodynamics} { subscript-left = ##1 } ,
+        subscript-right   .meta:nn = {chemmacros/thermodynamics} { subscript-right = ##1 } ,
+        subscript         .meta:n     = { subscript-left = ##1 } ,
+        subscript-pos     .choices:nn =
+          { left , right }
+          { \tl_set_eq:NN \l__chemmacros_state_sb_pos_tl \l_keys_choice_tl } ,
+        symbol            .tl_set:N = \l__chemmacros_state_symbol_tl ,
+        unit              .tl_set:N = \l__chemmacros_state_unit_tl
+      }
+    \DeclareDocumentCommand #1 { sO{}D(){}m }
+      {
+        \group_begin:
+          \chemmacros_set_keys:xn
+            {thermodynamics/\chemmacros_remove_backslash:N #1}
+            {#2}
+          \tl_if_blank:nF {##3}
+            {
+              \chemmacros_set_keys:nx {thermodynamics}
+                { subscript-\l__chemmacros_state_sb_pos_tl = \exp_not:n {##3} }
+            }
+              \chemmacros_state:nV {##2} \l__chemmacros_state_symbol_tl
+              \chemmacros_set_keys_groups:nnn {thermodynamics} {variables} {##2}
+              \IfBooleanF {##1} {  = ~ \SI {##4} { \l__chemmacros_state_unit_tl } }
+        \group_end:
+      }
+  }
+%    \end{macrocode}
+%
+% The pre-existing macros are redefined with the new definition:
+%    \begin{macrocode}
+\RenewChemState \enthalpy { symbol = H , unit = \kilo\joule\per\mole }
+\RenewChemState \entropy  { symbol = S , unit = \joule\per\kelvin\per\mole , pre = }
+\RenewChemState \gibbs    { symbol = G , unit = \kilo\joule\per\mole }
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\ExplSyntaxOff
+%    \end{macrocode}
+
+% \iffalse
+%</chemmacros>
+% \fi
+%
+%
+%
+%
+% \iffalse
+%<*chemnum>
+% \fi
+%
+% \part{lwarp-chemnum.sty}
+
+% \section{chemnum}
+%
+% \credits{Clemens Niederberger}
+%
+% \DescribePackage{chemnum}
+% \pkg{chemnum} is patched for use by \pkg{lwarp}.
+%
+% \changes{v0.51}{2018/03/04}{\pkg{chemnum}: Added.}
+%
+% \codehtml
+%
+%    \begin{macrocode}
+\LWR at ProvidesPackagePass{chemnum}
+%    \end{macrocode}
+
+%    \begin{macrocode}
+\ExplSyntaxOn
+
+\cs_undefine:N \chemnum_compound_write:n
+\cs_new_protected:Npn \chemnum_compound_write:n #1
+  {
+    \chemnum_get_compound_property:nn {#1} {pre-main-label-code}
+    \group_begin:
+      \bool_if:NTF \l__chemnum_compound_local_bool
+        { \l__chemnum_local_label_format_tl }
+        { \chemnum_get_compound_property:nn {#1} {label-format} }
+      {
+        \LWR at textcurrentfont{
+            \chemnum_get_compound_property:nn {#1} {counter-representation}
+        }
+      }
+    \group_end:
+    \chemnum_get_compound_property:nn {#1} {post-main-label-code}
+  }
+
+\cs_undefine:N \chemnum_subcompound_write:nn
+\cs_new_protected:Npn \chemnum_subcompound_write:nn #1#2
+  {
+    \group_begin:
+      \bool_if:NTF \l__chemnum_compound_local_bool
+        { \l__chemnum_local_label_format_tl }
+        { \chemnum_get_compound_property:nn {#1} {label-format} }
+      {
+        \LWR at textcurrentfont{
+            \chemnum_get_subcompound_property:nnn {#1} {#2}
+            {counter-representation}
+        }
+      }
+    \group_end:
+  }
+
+\ExplSyntaxOff
+%    \end{macrocode}
+
+% \iffalse
+%</chemnum>
+% \fi
+%
+%
+%
+%
+% \iffalse
 %<*cite>
 % \fi
 %
@@ -29128,12 +31534,12 @@
 \LetLtxMacro\LWR at origarrayrulecolor\arrayrulecolor
 \LetLtxMacro\LWR at origdoublerulesepcolor\doublerulesepcolor
 
-\appto{\LWR at restoreorigformatting}{%
-\LetLtxMacro\columncolor\LWR at origcolumncolor
-\LetLtxMacro\rowcolor\LWR at origrowcolor
-\LetLtxMacro\cellcolor\LWR at origcellcolor
-\LetLtxMacro\arrayrulecolor\LWR at origarrayrulecolor
-\LetLtxMacro\doublerulesepcolor\LWR at origdoublerulesepcolor
+\appto\LWR at restoreorigformatting{%
+\LetLtxMacro\columncolor\LWR at origcolumncolor%
+\LetLtxMacro\rowcolor\LWR at origrowcolor%
+\LetLtxMacro\cellcolor\LWR at origcellcolor%
+\LetLtxMacro\arrayrulecolor\LWR at origarrayrulecolor%
+\LetLtxMacro\doublerulesepcolor\LWR at origdoublerulesepcolor%
 }
 %    \end{macrocode}
 
@@ -29499,9 +31905,9 @@
 \LetLtxMacro\LWR at origdiagbox@double\diagbox at double
 \LetLtxMacro\LWR at origdiagbox@triple\diagbox at triple
 
-\appto\LWR at restoreorigformatting{
-\LetLtxMacro\diagbox at double\LWR at origdiagbox@double
-\LetLtxMacro\diagbox at triple\LWR at origdiagbox@triple
+\appto\LWR at restoreorigformatting{%
+\LetLtxMacro\diagbox at double\LWR at origdiagbox@double%
+\LetLtxMacro\diagbox at triple\LWR at origdiagbox@triple%
 }
 %    \end{macrocode}
 
@@ -30148,9 +32554,9 @@
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\newcommand*{\epstopdfsetup}[1]{}
-\newcommand*{\epstopdfcall}[1]{}
-\newcommand*{\epstopdfDeclareGraphicsRule}[4]{}
+\providecommand*{\epstopdfsetup}[1]{}
+\providecommand*{\epstopdfcall}[1]{}
+\providecommand*{\epstopdfDeclareGraphicsRule}[4]{}
 %    \end{macrocode}
 %
 % \iffalse
@@ -30159,9 +32565,42 @@
 %
 %
 %
+% \iffalse
+%<*epstopdf-base>
+% \fi
 %
+% \part{lwarp-epstopdf-base.sty}
 %
+% \section{epstopdf-base}
+%
+% \DescribePackage{epstopdf-base}
+% \pkg{epstopdf-base} is ignored.
+%
+% Filenames should be used without a suffix so that
+% \SVG, \PNG, or \JPG\ versions of the file will be used for \HTML\ output.
+%
+% \changes{v0.51}{2018/03/03}{\pkg{epstopdf-base}: Added.}
+%
+% \codehtml
+%
+%    \begin{macrocode}
+\LWR at ProvidesPackageDrop{epstopdf-base}[2016/05/15]
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\providecommand*{\epstopdfsetup}[1]{}
+\providecommand*{\epstopdfcall}[1]{}
+\providecommand*{\epstopdfDeclareGraphicsRule}[4]{}
+%    \end{macrocode}
+%
 % \iffalse
+%</epstopdf-base>
+% \fi
+%
+%
+%
+%
+% \iffalse
 %<*eso-pic>
 % \fi
 %
@@ -30416,13 +32855,22 @@
 }
 %    \end{macrocode}
 %
-% \env{Btrivlist} is enclosed in an \HTML\ block:
+% \env{Btrivlist} is enclosed in an \HTML\ block.
+% This is a tabular, and does not use \cs{item}.
 %
+% \begin{noindmacro}{Btrivlist} \marg{l/c/r} \oarg{t/c/b}
 %    \begin{macrocode}
 \RenewDocumentEnvironment{Btrivlist}{m o}
-{\begin{BlockClass}{Btrivlist}\tabular{#1}}
-{\endtabular\end{BlockClass}}
+{%
+    \begin{BlockClass}{Btrivlist}%
+    \tabular{#1}%
+}
+{%
+    \endtabular%
+    \end{BlockClass}%
+}
 %    \end{macrocode}
+% \end{noindmacro}
 %
 % \env{Btrivlist} is also neutralized when used inside a span:
 %
@@ -30429,7 +32877,6 @@
 %    \begin{macrocode}
 \AtBeginEnvironment{LWR at nestspan}{%
 \RenewDocumentEnvironment{Btrivlist}{m o}{}{}%
-\RenewDocumentCommand{\LWR at origitem}{d()}{\LWRFB at origitem}%
 }
 %    \end{macrocode}
 %
@@ -30439,12 +32886,32 @@
 %    \begin{macrocode}
 \let\LWRFB at origitemizeitem\LWR at itemizeitem
 \let\LWRFB at origdescitem\LWR at descitem
-\LetLtxMacro{\LWRFB at origitem}{\LWR at origitem}
 
-\RenewDocumentCommand{\LWR at itemizeitem}{d()}{\LWRFB at origitemizeitem}
-\RenewDocumentCommand{\LWR at descitem}{d()}{\LWRFB at origdescitem}
+\RenewDocumentCommand{\LWR at itemizeitem}{d()o}{%
+    \IfValueTF{#2}{%
+        \LWRFB at origitemizeitem[#2]%
+    }{%
+        \LWRFB at origitemizeitem%
+    }%
+}
+
+\RenewDocumentCommand{\LWR at descitem}{d()o}{%
+    \IfValueTF{#2}{%
+        \LWRFB at origdescitem[#2]~%
+    }{%
+        \LWRFB at origdescitem%
+    }%
+}
 %    \end{macrocode}
 %
+% \changes{v0.51}{2018/03/17}{\pkg{fancybox}: Fix: Optional tag for \cs{item} in a span.}
+%    \begin{macrocode}
+\RenewDocumentCommand{\LWR at nestspanitem}{d()}{%
+\if at newlist\else{\LWR at htmltagc{br /}}\fi%
+\LWR at origitem%
+}
+%    \end{macrocode}
+%
 % The various boxed lists become regular lists:
 %
 %    \begin{macrocode}
@@ -30482,7 +32949,7 @@
 %    \begin{macrocode}
 \let\LWRFB at UseVerbatim\UseVerbatim
 \renewcommand*{\UseVerbatim}[1]{%
-\LWR at atbeginverbatim{Verbatim}\unskip\LWR at origvspace*{-.5\baselineskip}%%
+\LWR at atbeginverbatim{3.5}{Verbatim}%
 \LWRFB at UseVerbatim{#1}%
 \LWR at afterendverbatim%
 }
@@ -30490,7 +32957,7 @@
 \let\LWRFB at LUseVerbatim\LUseVerbatim
 
 \renewcommand*{\LUseVerbatim}[1]{%
-\LWR at atbeginverbatim{LVerbatim}%\unskip\LWR at origvspace*{-\baselineskip}%%
+\LWR at atbeginverbatim{3.5}{LVerbatim}%
 \noindent%
 \LWRFB at LUseVerbatim{#1}%
 \LWR at afterendverbatim%
@@ -30497,7 +32964,7 @@
 }
 
 \def\@BUseVerbatim[#1]#2{%
-\LWR at atbeginverbatim{BVerbatim}\unskip\LWR at origvspace*{-.5\baselineskip}%%
+\LWR at atbeginverbatim{3.5}{BVerbatim}%
 \LWRFB at UseVerbatim{#2}%
 \LWR at afterendverbatim%
 }
@@ -30747,7 +33214,7 @@
 % Adds \HTML\ formatting:
 %    \begin{macrocode}
 \def\FV at BUseVerbatim#1{%
-    \LWR at atbeginverbatim[\LWR at FVstyle]{verbatim}%
+    \LWR at atbeginverbatim[\LWR at FVstyle]{.5}{verbatim}%
     \FV at BVerbatimBegin#1\FV at BVerbatimEnd%
     \LWR at afterendverbatim%
 }
@@ -30767,7 +33234,7 @@
 \newcommand*{\LWR at fvstartnone}{%
 \LWR at traceinfo{fvstartnone}%
 % \hbox to\z@{
-\LWR at atbeginverbatim[\LWR at FVstyle]{verbatim}%
+\LWR at atbeginverbatim[\LWR at FVstyle]{.5}{verbatim}%
 % }%
 }
 
@@ -30820,7 +33287,8 @@
 \newcommand*{\LWR at FVborderstyle}[1]{%
 padding#1: \strip at pt\dimexpr \FV at FrameSep\relax\relax pt ; %
 \LWR at FVfindbordercolor %
-border#1: \strip at pt\dimexpr \FV at FrameRule\relax\relax pt solid \#\LWR at tempcolor ; %
+border#1: \strip at pt\dimexpr \FV at FrameRule\relax\relax pt %
+solid \LWR at origpound\LWR at tempcolor ; %
 }
 
 \def\FV at Frame@none{%
@@ -30899,7 +33367,10 @@
         \ifx\FV at LabelPositionTopLine\relax
         \else
         \LWR at FVfindbordercolor
-        \LWR at htmltagc{div class="fancyvrblabel" style="color: \#\LWR at tempcolor"}
+        \LWR at htmltagc{%
+            div class="fancyvrblabel" % extra space
+                style="color: \LWR at origpound\LWR at tempcolor"%
+        }
         \LWR at origtextrm{\FV at LabelBegin}% \textrm preserves emdash
         \LWR at htmltagc{/div}
         \fi
@@ -30909,7 +33380,10 @@
         \else
         \LWR at FVfindbordercolor
 
-        \LWR at htmltagc{div class="fancyvrblabel" style="color: \#\LWR at tempcolor"}
+        \LWR at htmltagc{%
+            div class="fancyvrblabel" % extra space
+                style="color: \LWR at origpound\LWR at tempcolor"%
+        }
         \LWR at origtextrm{\FV at LabelEnd}
         \LWR at htmltagc{/div}
         \fi
@@ -30945,7 +33419,7 @@
 \AtBeginEnvironment{BVerbatim}
 {%
 \LWR at forcenewpage% instead of \preto
-\LWR at atbeginverbatim{bverbatim}%
+\LWR at atbeginverbatim{0}{bverbatim}%
 }
 
 \AfterEndEnvironment{BVerbatim}
@@ -32299,7 +34773,7 @@
 \renewenvironment{shaded}{%
 \convertcolorspec{named}{shadecolor}{HTML}\LWR at tempcolor%
 \LWR at forcenewpage
-\BlockClass[background: \#\LWR at tempcolor]{shaded}%
+\BlockClass[background: \LWR at origpound\LWR at tempcolor]{shaded}%
 }
 {\endBlockClass}
 
@@ -32306,7 +34780,7 @@
 \renewenvironment{shaded*}{%
 \convertcolorspec{named}{shadecolor}{HTML}\LWR at tempcolor%
 \LWR at forcenewpage
-\BlockClass[background: \#\LWR at tempcolor]{shaded}%
+\BlockClass[background: \LWR at origpound\LWR at tempcolor]{shaded}%
 }
 {\endBlockClass}
 
@@ -32323,7 +34797,7 @@
 \renewenvironment{snugshade}{%
 \convertcolorspec{named}{shadecolor}{HTML}\LWR at tempcolor%
 \LWR at forcenewpage
-\BlockClass[background: \#\LWR at tempcolor]{snugframed}%
+\BlockClass[background: \LWR at origpound\LWR at tempcolor]{snugframed}%
 }
 {\endBlockClass}
 
@@ -32330,7 +34804,7 @@
 \renewenvironment{snugshade*}{%
 \convertcolorspec{named}{shadecolor}{HTML}\LWR at tempcolor%
 \LWR at forcenewpage
-\BlockClass[background: \#\LWR at tempcolor]{snugframed}%
+\BlockClass[background: \LWR at origpound\LWR at tempcolor]{snugframed}%
 }
 {\endBlockClass}
 
@@ -32352,9 +34826,9 @@
 \renewcommand{\CustomFBox}[7]{%
 \convertcolorspec{named}{TFFrameColor}{HTML}\LWR at tempcolor%
 \LWR at forcenewpage
-\begin{BlockClass}[border: 3px solid \#\LWR at tempcolor]{framed}%
+\begin{BlockClass}[border: 3px solid \LWR at origpound\LWR at tempcolor]{framed}%
 \ifthenelse{\isempty{#1}}{}{% not empty
-    \begin{BlockClass}[background: \#\LWR at tempcolor]{framedtitle}%
+    \begin{BlockClass}[background: \LWR at origpound\LWR at tempcolor]{framedtitle}%
     \textcolor{TFTitleColor}{\textbf{#1}}%
     \end{BlockClass}
 }% not empty
@@ -32363,7 +34837,7 @@
 
 \ifthenelse{\isempty{#2}}{}{% not empty
     \convertcolorspec{named}{TFFrameColor}{HTML}\LWR at tempcolor%
-    \begin{BlockClass}[background: \#\LWR at tempcolor]{framedtitle}%
+    \begin{BlockClass}[background: \LWR at origpound\LWR at tempcolor]{framedtitle}%
     \textcolor{TFTitleColor}{\textbf{#2}}%
     \end{BlockClass}
 }% not empty
@@ -33356,7 +35830,39 @@
 %
 %
 %
+%
+%
 % \iffalse
+%<*grid>
+% \fi
+%
+% \part{lwarp-grid.sty}
+%
+% \section{grid}
+%
+% \DescribePackage{grid}
+% \pkg{grid} is ignored.
+%
+% \changes{v0.51}{2018/03/08}{\pkg{grid}: Added.}
+%
+% \codehtml
+%
+%    \begin{macrocode}
+\LWR at ProvidesPackageDrop{grid}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\newenvironment*{gridenv}{}{}
+%    \end{macrocode}
+%
+% \iffalse
+%</grid>
+% \fi
+%
+%
+%
+%
+% \iffalse
 %<*hang>
 % \fi
 %
@@ -34048,15 +36554,15 @@
 \renewrobustcmd{\colonhyp}{:}
 \renewrobustcmd{\hyp}{-}
 
-\appto\LWR at restoreorigformatting{
-\LetLtxMacro\textnhtt\LWRHYNAT at origtextnhtt
-\LetLtxMacro\nhttfamily\LWRHYNAT at orignhttfamily
-\LetLtxMacro\nohyphens\LWRHYNAT at orignohyphens
-\LetLtxMacro\bshyp\LWRHYNAT at origbshyp
-\LetLtxMacro\fshyp\LWRHYNAT at origfshyp
-\LetLtxMacro\dothyp\LWRHYNAT at origdothyp
-\LetLtxMacro\colonhyp\LWRHYNAT at origcolonhyp
-\LetLtxMacro\hyp\LWRHYNAT at orighyp
+\appto\LWR at restoreorigformatting{%
+\LetLtxMacro\textnhtt\LWRHYNAT at origtextnhtt%
+\LetLtxMacro\nhttfamily\LWRHYNAT at orignhttfamily%
+\LetLtxMacro\nohyphens\LWRHYNAT at orignohyphens%
+\LetLtxMacro\bshyp\LWRHYNAT at origbshyp%
+\LetLtxMacro\fshyp\LWRHYNAT at origfshyp%
+\LetLtxMacro\dothyp\LWRHYNAT at origdothyp%
+\LetLtxMacro\colonhyp\LWRHYNAT at origcolonhyp%
+\LetLtxMacro\hyp\LWRHYNAT at orighyp%
 }
 %    \end{macrocode}
 %
@@ -34818,11 +37324,23 @@
 %    \begin{macrocode}
 \renewcommand{\lst at Init}[1]{%
 %    \end{macrocode}
+%
 % First, perform the \pkg{listings} initialization:
+%
+% \changes{v0.51}{2018/03/17}{\pkg{listings}: Forces cleared options.}
 %    \begin{macrocode}
 \LWR at traceinfo{lst at Init}%
 \renewcommand*{\@captype}{lstlisting}%
-\LWR at origlst@Init{#1}%
+\let\lst at aboveskip\z@\let\lst at belowskip\z@%
+\gdef\lst at boxpos{t}%
+\let\lst at frame\@empty
+    \let\lst at frametshape\@empty
+    \let\lst at framershape\@empty
+    \let\lst at framebshape\@empty
+    \let\lst at framelshape\@empty
+\lstframe@\lst at frameround ffff\relax%
+\lst at multicols\@empty%
+\LWR at origlst@Init{#1}\relax%
 \LWR at traceinfo{finished origlst at Init}%
 \lst at ifdisplaystyle%
 %    \end{macrocode}
@@ -34835,7 +37353,7 @@
 \LWR at traceinfo{About to create verbatim.}%
 \let\lsthk at EveryPar\relax%
 \LWR at forcenewpage
-\LWR at atbeginverbatim{programlisting}%
+\LWR at atbeginverbatim{2.5}{programlisting}%
 
 \let\lsthk at EveryPar\LWR at origlsthkEveryPar%
 \else%
@@ -35177,7 +37695,43 @@
 %
 %
 %
+%
+%
 % \iffalse
+%<*ltxgrid>
+% \fi
+%
+% \part{lwarp-ltxgrid.sty}
+%
+% \section{ltxgrid}
+%
+% \DescribePackage{ltxgrid}
+% \pkg{ltxgrid} is ignored.
+%
+% \changes{v0.51}{2018/03/08}{\pkg{ltxgrid}: Added.}
+%
+% \codehtml
+%
+%    \begin{macrocode}
+\LWR at ProvidesPackageDrop{ltxgrid}
+%    \end{macrocode}
+%
+%    \begin{macrocode}
+\newcommand*{\onecolumngrid}{}
+\newcommand*{\twocolumngrid}{}
+\newcommand*{\removestuff}{}
+\newcommand*{\addstuff}[2]{}
+\newcommand*{\replacestuff}[2]{}
+%    \end{macrocode}
+%
+% \iffalse
+%</ltxgrid>
+% \fi
+%
+%
+%
+%
+% \iffalse
 %<*ltxtable>
 % \fi
 %
@@ -35356,7 +37910,7 @@
 
 
 \DeclareDocumentCommand{\todonotes at textmark@highlight}{m}{%
-\InlineClass[background:\#B3FFB3]{highlight}{#1}%
+\InlineClass[background:\LWR at origpound{}B3FFB3]{highlight}{#1}%
 }
 
 \fi% \if at todonotes@disabled
@@ -35634,7 +38188,7 @@
 %    \begin{macrocode}
 \newcommand*{\LWR at mdfprintcolor}[1]{%
 \convertcolorspec{named}{\csuse{mdf@#1}}{HTML}\LWR at tempcolor%
-\#\LWR at tempcolor
+\LWR at origpound\LWR at tempcolor
 }
 %    \end{macrocode}
 % \end{noindmacro}
@@ -36195,10 +38749,158 @@
 %
 %
 %
+% \iffalse
+%<*mhchem>
+% \fi
 %
+% \part{lwarp-mhchem.sty}
+
+% \section{mhchem}
+% \label{sec:mhchem}
 %
+% \credits{Martin Hensel}
 %
+% \DescribePackage{mhchem}
+% \pkg{mhchem} is patched for use by \pkg{lwarp}.
+%
+% \pkg{mhchem} expressions are converted to \SVG\ math.
+% Inline expressions use hashed filenames to allow reuse,
+% and assume that any \pkg{mhchem} options are global.
+%
+% The \brand{MathJax} \pkg{mhchem} extension is not yet used.
+% \watchout[\brand{MathJax} and \pkg{mhchem}]
+% If \brand{MathJax} is used for math in the rest of the document,
+% \pkg{lwarp} converts standalone \pkg{mhchem}
+% expressions into \SVG\ math images, but expressions inside math
+% must be placed between \cs{displaymathother} and \cs{displaymathnormal}:
+% \begin{sourcedisplay}
+% \cs{displaymathother} \\
+% \cs{[} \cs{ce}\{ \dots\ \} \cs{]}  \qquad \dots \qquad \$ \cs{ce} \{ \dots\ \} \$ \\
+% \cs{displaymathnormal}
+% \end{sourcedisplay}
+%
+% When producing \HTML\ output, \pkg{lwarp} does not support \watchout[nested math]
+% the use of nested dollar signs in \pkg{mhchem} expressions.
+% \index{mhchem>troubleshooting}
+% \index{array>and mhchem}
+% \index{math>and mhchem}
+%
+% For some examples from the \pkg{mhchem} manual, change as follows:
+% \begin{Verbatim}[gobble=2,frame=leftline, xleftmargin=.5in,obeytabs,tabsize=4]
+% $\ce{NaOH(aq,$\infty$)}$            % old
+% $\ce{NaOH(aq,\infty)}$              % new
+%
+% $\ce{Fe(CN)_{$\frac{6}{2}}$}$       % old
+% $\ce{Fe(CN)_{\frac{6}{2}}}$         % new
+%
+% $\ce{NO_$x$}$                       % old
+% $\ce{NO_x}$                         % new
+% 
+% $\ce{NO_${x}$}$                     % old
+% $\ce{NO_{x}}$                       % new
+% 
+% $\ce{$cis${-}[PtCl2(NH3)2]}$        % old
+% $\ce{\mathit{cis}{-}[PtCl2(NH3)2]}$ % new
+% \end{Verbatim}
+%
+% \changes{v0.51}{2018/03/04}{\pkg{mhchem}: Added.}
+%
+% \codehtml
+%
+%    \begin{macrocode}
+\LWR at ProvidesPackagePass{mhchem}
+%    \end{macrocode}
+
+% The original definition of \cs{ce}:
+%    \begin{macrocode}
+\LetLtxMacro\LWR at mhchem@origce\ce
+%    \end{macrocode}
+
+% The new definition, called from the new \cs{ce} after math shift is set.
+% The starred \env{lateximage} uses a hashed filename for the \SVG\ image.
+% The \attribute{alt} tag is set to the \pkg{mhchem} expression.
+%    \begin{macrocode}
+\newcommand{\LWR at mhchem@HTML at ce}[1]{%
+\begin{lateximage}*[\textbackslash{}ce\{\LWR at HTMLsanitize{#1}\}]%
+\LWR at mhchem@origce{#1}%
+\end{lateximage}%
+\endgroup%
+\addtocounter{LWR at mhchem@cedepth}{-1}%
+}
+%    \end{macrocode}
+
+% Only set math shift if outer depth:
+%    \begin{macrocode}
+\newcounter{LWR at mhchem@cedepth}
+\setcounter{LWR at mhchem@cedepth}{0}
+%    \end{macrocode}
+
+% The new \cs{ce}.  Sets math shift then continues.
+%    \begin{macrocode}
+\renewcommand{\ce}{%
+\begingroup%
+\ifnumequal{\value{LWR at mhchem@cedepth}}{0}{%
+    \catcode`\$=3% math shift
+}{}%
+\addtocounter{LWR at mhchem@cedepth}{1}%
+\LWR at mhchem@HTML at ce%
+}
+%    \end{macrocode}
+
+% The original definition of \cs{cesplit}:
+%    \begin{macrocode}
+\LetLtxMacro\LWR at mhchem@origcesplit\cesplit
+%    \end{macrocode}
+
+% The new definition, called from the new \cs{cesplit} after math shift is set.
+% The starred \env{lateximage} uses a hashed filename for the \SVG\ image.
+% The \attribute{alt} tag is set to the \pkg{mhchem} expression.
+%    \begin{macrocode}
+\newcommand*{\LWR at mhchem@HTML at cesplit}[2]
+{%
+\begin{lateximage}*[\textbackslash{}cesplit\{\LWR at HTMLsanitize{#2}\}]%
+\LWR at mhchem@origcesplit{#1}{#2}%
+\end{lateximage}%
+\endgroup%
+}
+%    \end{macrocode}
+
+% Only set math shift if outer depth:
+%    \begin{macrocode}
+\newcounter{LWR at mhchem@cesplitdepth}
+\setcounter{LWR at mhchem@cesplitdepth}{0}
+%    \end{macrocode}
+
+% The new \cs{cesplit}.  Sets math shift then continues.
+%    \begin{macrocode}
+\renewcommand{\cesplit}{%
+\begingroup%
+\ifnumequal{\value{LWR at mhchem@cesplitdepth}}{0}{%
+    \catcode`\$=3% math shift
+}{}%
+\addtocounter{LWR at mhchem@cesplitdepth}{1}%
+\LWR at mhchem@HTML at cesplit%
+}
+%    \end{macrocode}
+
+% Resore originals inside a \env{lateximage}:
+%    \begin{macrocode}
+\appto\LWR at restoreorigformatting{%
+\LetLtxMacro\ce\LWR at mhchem@origce%
+\LetLtxMacro\cesplit\LWR at mhchem@origcesplit%
+}
+%    \end{macrocode}
+
 % \iffalse
+%</mhchem>
+% \fi
+%
+%
+%
+%
+%
+%
+% \iffalse
 %<*microtype>
 % \fi
 
@@ -36383,7 +39085,7 @@
 %    \begin{macrocode}
 \BeforeBeginEnvironment{verbatimtab}{%
 \LWR at forcenewpage
-\LWR at atbeginverbatim{Verbatim}\unskip\LWR at origvspace*{-\baselineskip}%
+\LWR at atbeginverbatim{3.5}{Verbatim}%
 }
 \AfterEndEnvironment{verbatimtab}{%
 \LWR at afterendverbatim%
@@ -36394,7 +39096,7 @@
 
 \renewcommand{\@verbatimtabinput}[2][]{%
 \LWR at forcenewpage
-\LWR at atbeginverbatim{Verbatim}\unskip\LWR at origvspace*{-\baselineskip}%
+\LWR at atbeginverbatim{3.5}{Verbatim}%
 \LWRMV at orig@verbatimtabinput[#1]{#2}%
 \LWR at afterendverbatim%
 }
@@ -36401,7 +39103,7 @@
 
 \BeforeBeginEnvironment{listing}{%
 \LWR at forcenewpage
-\LWR at atbeginverbatim{programlisting}\unskip\LWR at origvspace*{-\baselineskip}%
+\LWR at atbeginverbatim{3.5}{programlisting}%
 }
 
 \AfterEndEnvironment{listing}{%
@@ -36411,7 +39113,7 @@
 
 \BeforeBeginEnvironment{listingcont}{%
 \LWR at forcenewpage
-\LWR at atbeginverbatim{programlisting}\unskip\LWR at origvspace*{-\baselineskip}%
+\LWR at atbeginverbatim{3.5}{programlisting}%
 }
 
 \AfterEndEnvironment{listingcont}{%
@@ -36445,7 +39147,7 @@
 
 \renewcommand{\@listinginput}[3][]{
 \LWR at forcenewpage
-\LWR at atbeginverbatim{programlisting}\unskip\LWR at origvspace*{-\baselineskip}%
+\LWR at atbeginverbatim{3.5}{programlisting}%
 \LWRMV@@listinginput[#1]{#2}{#3}
 \LWR at afterendverbatim%
 }
@@ -36454,7 +39156,7 @@
 \renewenvironment*{boxedverbatim}
 {
 \LWR at forcenewpage
-\LWR at atbeginverbatim{boxedverbatim}\unskip\LWR at origvspace*{-2\baselineskip}%
+\LWR at atbeginverbatim{3.5}{boxedverbatim}%
 \verbatim%
 }
 {
@@ -36785,7 +39487,7 @@
 %
 %
 %    \begin{macrocode}
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \LetLtxMacro\multirow\LWR at origmultirow%
 \renewcommand{\multicolumnrow}{\LWR at origmulticolumnrow}%
 }
@@ -38280,8 +40982,8 @@
 % \phfqit at bitstring{#1}%
 }
 
-\appto{\LWR at restoreorigformatting}{
-\LetLtxMacro\bitstring\LWR at origbitstring
+\appto\LWR at restoreorigformatting{%
+\LetLtxMacro\bitstring\LWR at origbitstring%
 }
 %    \end{macrocode}
 
@@ -38667,7 +41369,7 @@
 \LetLtxMacro\LWR at origtextsmaller\textsmaller
 \let\LWR at textscale\textscale
 
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \let\relsize\LWR at origrelsize%
 \LetLtxMacro\larger\LWR at origlarger%
 \LetLtxMacro\smaller\LWR at origsmaller%
@@ -40053,7 +42755,9 @@
 %       \__siunitx_print:nn { number } { \ensuremath {#1} }
         \LWR at subsingledollar{% lwarp
             \textbackslash( \LWR at HTMLsanitize{#1} \textbackslash)% lwarp
-        }{\__siunitx_print:nn { number } { #1 }}% lwarp
+        }{siunitx}{\__siunitx_print:nn { number } {
+            \LWR at origensuredmath{#1}
+        }}% lwarp
 %    \end{macrocode}
 %    \begin{macrocode}
       \__siunitx_unit_output_print:
@@ -40278,7 +42982,7 @@
 {\LWR at HTMLtextstyle{#5}{#3}{#1}}%
 {%
     \convertcolorspec{named}{\csuse{#2}}{HTML}\LWR at tempcolor%
-    \LWR at htmlspanclass[#5;#4:\#\LWR at tempcolor]{#3}{#1}%
+    \LWR at htmlspanclass[#5;#4:\LWR at origpound\LWR at tempcolor]{#3}{#1}%
 }%
 }
 %    \end{macrocode}
@@ -40297,7 +43001,7 @@
 
 \newcommand{\hl}[1]{
 \LWR at soulcolor{#1}{LWR at soulhlcolor}{highlight}{background-color}%
-    {background:\#F8E800}
+    {background:\LWR at origpound{}F8E800}
 }
 %    \end{macrocode}
 %
@@ -41313,7 +44017,7 @@
 %
 % When a \env{lateximage} is begun:
 %    \begin{macrocode}
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \let\textdegree\LWR at origtextdegree%
 \let\textcelsius\LWR at origtextcelsius%
 \let\textohm\LWR at origtextohm%
@@ -41789,6 +44493,8 @@
 % \DescribePackage{tikz}
 % \pkg{tikz} is supported.
 %
+% \limitstikz
+%
 % \changes{v0.24}{2017/03/11}{\pkg{tikz}: For tikz v3.0.0 or later,
 %	auto-loads tikz babel library if necessary.}
 %
@@ -41822,7 +44528,7 @@
 %    \end{macrocode}
 
 
-% \begin{environment}{tikzpicture}
+% \begin{noindenvironment}{tikzpicture}
 % |tikzpicture| environment is enclosed inside a \cs{lateximage}.
 % May be used as-is, and its contents will be converted to an image.
 %
@@ -41830,23 +44536,28 @@
 % \changes{v0.19}{2016/05/29}{Adapts to tikz version.}
 % \changes{v0.24}{2017/03/13}{Fix for inline images.}
 % \changes{v0.44}{2017/11/16}{\pkg{tikz}: Fix: Groups for lateximages.}
+% \changes{v0.51}{2018/03/06}{\pkg{tikz}: Fix for \cs{tikz} macro.}
+% \changes{v0.51}{2018/03/20}{\pkg{tikz}: Fix for \env{tikz} with optional argument.}
 %
 %    \begin{macrocode}
-\BeforeBeginEnvironment{tikzpicture}{%
-\begin{lateximage}%
-\ifbool{LWR at tikzbabel}% Test for Tikz version v3.0.0
-{}%
-{\catcode`\$=3}% dollar sign is math shift
+\LetLtxMacro\LWR at origtikzpicture\tikzpicture
+
+\renewcommand*{\tikzpicture}[1][]{%
+    \begin{lateximage}%
+    \ifbool{LWR at tikzbabel}% Test for Tikz version v3.0.0
+    {}%
+    {\catcode`\$=3}% dollar sign is math shift
+    \LWR at origtikzpicture[#1]%
 }
 
-\AfterEndEnvironment{tikzpicture}{%
-\end{lateximage}%
-\ifbool{LWR at tikzbabel}% Test for Tikz version v3.0.0
-{}%
-{\catcode`\$=\active}%
+\LetLtxMacro\LWR at origendtikzpicture\endtikzpicture
+
+\renewcommand*{\endtikzpicture}{%
+    \LWR at origendtikzpicture%
+    \end{lateximage}%
 }
 %    \end{macrocode}
-% \end{environment}
+% \end{noindenvironment}
 
 % \iffalse
 %</tikz>
@@ -42579,6 +45290,18 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{noindmacro}{\thanksfootmark}
+% \changes{v0.51}{2018/03/05}{\pkg{titling}: Fix for \cs{thanks} mark.}
+%    \begin{macrocode}
+\renewcommand{\thanksfootmark}{%
+%   \hb at xt@\thanksmarkwidth{\hfil\normalfont%
+        \thanksscript{%
+            \thanksfootpre \tamark \thanksfootpost%
+        }%
+%   }%
+}
+%    \end{macrocode}
+% \end{noindmacro}
 %
 %\begin{macro}{\maketitle}
 %   \HTML\ mode.
@@ -43952,8 +46675,7 @@
 \setlength{\leftmargini}{\HTMLleftmargini}
 }{}
 \LWR at forcenewpage
-\LWR at atbeginverbatim{verse}
-\unskip\LWR at origvspace{-\baselineskip}
+\LWR at atbeginverbatim{3.5}{verse}%
 }
 %    \end{macrocode}
 % After the end of the \env{verse} environment, which places the \element{pre} tag at the
@@ -44108,7 +46830,7 @@
 \newcommand*{\LWR at vwcol@addrule}[1]{%
     \appto{\LWR at vwcolstyle}{%
         #1: %
-        \LWR at printlength{\vwcol at rule} solid \#\LWR at vwcol@rulecolor ; %
+        \LWR at printlength{\vwcol at rule} solid \LWR at origpound\LWR at vwcol@rulecolor ; %
     }%
 }
 %    \end{macrocode}
@@ -44565,6 +47287,9 @@
 \LetLtxMacro\LWRprint at nopagecolor\nopagecolor
 \LetLtxMacro\LWRprint at colorbox\colorbox
 \LetLtxMacro\LWRprint at colorboxBlock\colorbox
+%    \end{macrocode}
+% New print-mode versions of the following are also defined:
+%    \begin{macrocode}
 \LetLtxMacro\LWRorigprint at fcolorbox\fcolorbox
 \LetLtxMacro\LWRorigprint at fcolorboxBlock\fcolorbox
 \LetLtxMacro\LWRorigprint at boxframe\boxframe
@@ -44574,7 +47299,7 @@
 % Inside a \env{lateximage} the following gets restored to their print-mode actions:
 % \margintag{\small\cs{LWR at restoreorigformatting}}
 %    \begin{macrocode}
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \LetLtxMacro\textcolor\LWRprint at textcolor%
 \LetLtxMacro\pagecolor\LWRprint at pagecolor%
 \LetLtxMacro\nopagecolor\LWRprint at nopagecolor%
@@ -44587,19 +47312,11 @@
 %
 % \subsection{HTML color style}
 %
-% \begin{noindmacro}{\LWR at tempcolor}
-% The color converted to \HTML\ colorspace.
-%    \begin{macrocode}
-\newcommand*{\LWR at tempcolor}{}
-\newcommand*{\LWR at tempcolortwo}{}
-%    \end{macrocode}
-% \end{noindmacro}
-%
 % \begin{noindmacro}{\LWR at findcurrenttextcolor}
-% \changes{v0.44}{2017/11/10}{\pkg{xcolor}: Added \cs{LWR at findcurrentcolor}.}
+% \changes{v0.44}{2017/11/10}{\pkg{xcolor}: Added \cs{LWR at findcurrenttextcolor}.}
 % Sets \cs{LWR at tempcolor} to the current color.
 %    \begin{macrocode}
-\newcommand*{\LWR at findcurrenttextcolor}{%
+\renewcommand*{\LWR at findcurrenttextcolor}{%
 \protect\colorlet{LWR at current@color}{.}%
 \protect\convertcolorspec{named}{LWR at current@color}{HTML}\LWR at tempcolor%
 }
@@ -44614,28 +47331,28 @@
 \LWR at findcurrenttextcolor%
 \ifdefstring{\LWR at tempcolor}{000000}%
 {}%
-{color: \#\LWR at tempcolor ; }%
+{color: \LWR at origpound\LWR at tempcolor ; }%
 }
 %    \end{macrocode}
 % \end{noindmacro}
 %
 %
-% \begin{noindmacro}{\LWR at textcurrentcolor} \marg{text}
+% \begin{macro}{\LWR at textcurrentcolor} \marg{text}
 % Like \cs{textcolor} but uses the current \cs{color} instead.
 % \changes{v0.44}{2017/11/10}{\pkg{xcolor}: Added \cs{LWR at textcurrentcolor}.}
 %    \begin{macrocode}
-\newcommand*{\LWR at textcurrentcolor}[1]{%
+\DeclareDocumentCommand{\LWR at textcurrentcolor}{m}{%
 \begingroup%
 \LWR at FBcancel%
 \LWR at findcurrenttextcolor%
-\InlineClass[color:\#\LWR at tempcolor]{textcolor}{%
-    \renewcommand*{\LWR at currenttextcolor}{\#\LWR at tempcolor}%
+\InlineClass[color:\LWR at origpound\LWR at tempcolor]{textcolor}{%
+    \renewcommand*{\LWR at currenttextcolor}{\LWR at origpound\LWR at tempcolor}%
     #1%
 }%
 \endgroup%
 }
 %    \end{macrocode}
-% \end{noindmacro}
+% \end{macro}
 %
 %
 % \begin{noindmacro}{\LWR at colorstyle} \marg{2: model} \marg{3: color}
@@ -44656,7 +47373,7 @@
 %    \end{macrocode}
 % Print the converted color:
 %    \begin{macrocode}
-\#\LWR at tempcolor%
+\LWR at origpound\LWR at tempcolor%
 \endgroup%
 }
 %    \end{macrocode}
@@ -44701,16 +47418,6 @@
 %
 % \subsection{High-level macros}
 %
-% \DescribeMacro{\color}
-% \cs{color} appears in the \LaTeX{} \PDF\ output,
-% but is ignored by \prog{pdftotext} and thus is ignored in the \HTML\ file.
-% Text styling by local group is not yet supported.
-%
-%
-%
-% Each of the following macros is given a temporary name, and is \cs{let} to the final
-% name once the \HTML\ conversion starts.
-%
 % \label{sec:textcolor}
 % \begin{macro}{\textcolor}
 % \oarg{model} \marg{color} \marg{text}
@@ -44717,13 +47424,35 @@
 %
 % Converted into an \HTML\ hex color span.
 %    \begin{macrocode}
-\RenewDocumentCommand{\textcolor}{O{named} m m}{%
+\RenewDocumentCommand{\textcolor}{o m m}{%
 \begingroup%
+%    \end{macrocode}
+% Set the \PDF\ color, to be picked up by \SVG\ math if possible.
+%
+% The print-mode \cs{color} command cannot accept the \optn{named}
+% option with color mixing, but it works with no option at all.
+%
+% \changes{v0.51}{2018/03/14}{Fix: SVG math color.}
+%    \begin{macrocode}
+\IfValueTF{#1}{%
+    \color[#1]{#2}%
+}{%
+    \color{#2}%
+}%
+%    \end{macrocode}
+%    \begin{macrocode}
 \LWR at FBcancel%
+\IfValueTF{#1}{%
 \InlineClass[color:\LWR at colorstyle{#1}{#2}]{textcolor}{%
-\renewcommand*{\LWR at currenttextcolor}{\#\LWR at tempcolor}%
+\renewcommand*{\LWR at currenttextcolor}{\LWR at origpound\LWR at tempcolor}%
 #3%
 }%
+}{%
+\InlineClass[color:\LWR at colorstyle{named}{#2}]{textcolor}{%
+\renewcommand*{\LWR at currenttextcolor}{\LWR at origpound\LWR at tempcolor}%
+#3%
+}%
+}%
 \endgroup%
 }
 %    \end{macrocode}
@@ -44843,7 +47572,7 @@
 {% yes background color
     \convertcolorspec{#3}{#4}{HTML}\LWR at tempcolortwo%
     \begin{BlockClass}[%
-    background:\#\LWR at tempcolortwo\ ; %
+    background:\LWR at origpound\LWR at tempcolortwo\ ; %
     \LWR at borderpadding{#1}{#2}%
     ]{fcolorboxBlock}
     #5
@@ -44894,7 +47623,7 @@
 {\LWR at subfcolorminipage{#1}{#2}{}{#6}}%
 {%
     \convertcolorspec{#3}{#4}{HTML}\LWR at tempcolortwo%
-    \LWR at subfcolorminipage{#1}{#2}{background:\#\LWR at tempcolortwo\ ; }{#6}%
+    \LWR at subfcolorminipage{#1}{#2}{background:\LWR at origpound\LWR at tempcolortwo\ ; }{#6}%
 }%
 }
 {\end{BlockClass}}
@@ -45118,7 +47847,7 @@
 % Produce \HTML\ tags for a small superscript numerator and
 % a small (non-subscript) denominator.
 %
-% Scaling is turned off so that \cmds{pdftotext} correctly reads the result.
+% Scaling is turned off so that \prog{pdftotext} correctly reads the result.
 %
 % \changes{v0.16}{2016/04/07}{\pkg{xfrac}: Adjusted for the use of any font:}
 % \changes{v0.48}{2018/02/13}{\pkg{xfrac}: Fix: Added groups around super/subscripts
@@ -45457,7 +48186,7 @@
 %    \begin{macrocode}
 \AtBeginDocument{
 
-\preto{\xy}{\begin{lateximage}[xy image]}
+\preto{\xy}{\begin{lateximage}[(xy)]}
 \appto{\endxy}{\end{lateximage}}
 
 \@ifundefined{xymatrix}{}{
@@ -45464,7 +48193,7 @@
 \LetLtxMacro\LWR at origxymatrix\xymatrix
 
 \renewcommand{\xymatrix}[1]{%
-\begin{lateximage}[xymatrix]
+\begin{lateximage}[(xymatrix)]
 \LWR at origxymatrix{#1}
 \end{lateximage}
 }
@@ -45474,7 +48203,7 @@
 \LetLtxMacro\LWR at origxygraph\xygraph
 
 \renewcommand{\xygraph}[1]{%
-\begin{lateximage}[xygraph]
+\begin{lateximage}[(xygraph)]
 \LWR at origxygraph{#1}
 \end{lateximage}
 }
@@ -45566,7 +48295,7 @@
 \def\UserRightMargin{1in}
 \def\UserTopMargin{1in}
 \def\UserBotMargin{1in}
-\def\thePageNumber{\#\,\arabic{page}}
+\def\thePageNumber{\LWR at origpound\,\arabic{page}}
 \ifXeTeX
 \def\ifcaseZWdriver{\ifcase2}
 \else
@@ -47055,6 +49784,9 @@
 % \part{Change History and Index}
 % \label{sec:changehistory}
 %
+%   For the most recent changes and the start of the Index,
+%   see page \pageref{sec:changesend}.
+%
 % \pagestyle{plain}
 %
 % \Finale

Modified: trunk/Master/texmf-dist/source/latex/lwarp/lwarp.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/lwarp/lwarp.ins	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/source/latex/lwarp/lwarp.ins	2018-03-25 21:28:55 UTC (rev 47115)
@@ -73,6 +73,11 @@
 \file{lwarp-chngpage.sty}{\from{lwarp.dtx}{chngpage}}
 \file{lwarp-chappg.sty}{\from{lwarp.dtx}{chappg}}
 \file{lwarp-chapterbib.sty}{\from{lwarp.dtx}{chapterbib}}
+\file{lwarp-chemfig.sty}{\from{lwarp.dtx}{chemfig}}
+\file{lwarp-chemformula.sty}{\from{lwarp.dtx}{chemformula}}
+\file{lwarp-chemgreek.sty}{\from{lwarp.dtx}{chemgreek}}
+\file{lwarp-chemmacros.sty}{\from{lwarp.dtx}{chemmacros}}
+\file{lwarp-chemnum.sty}{\from{lwarp.dtx}{chemnum}}
 \file{lwarp-cite.sty}{\from{lwarp.dtx}{cite}}
 \file{lwarp-color.sty}{\from{lwarp.dtx}{color}}
 \file{lwarp-colortbl.sty}{\from{lwarp.dtx}{colortbl}}
@@ -96,6 +101,7 @@
 \file{lwarp-enumitem.sty}{\from{lwarp.dtx}{enumitem}}
 \file{lwarp-epigraph.sty}{\from{lwarp.dtx}{epigraph}}
 \file{lwarp-epstopdf.sty}{\from{lwarp.dtx}{epstopdf}}
+\file{lwarp-epstopdf-base.sty}{\from{lwarp.dtx}{epstopdf-base}}
 \file{lwarp-eso-pic.sty}{\from{lwarp.dtx}{eso-pic}}
 \file{lwarp-everypage.sty}{\from{lwarp.dtx}{everypage}}
 \file{lwarp-everyshi.sty}{\from{lwarp.dtx}{everyshi}}
@@ -136,6 +142,7 @@
 \file{lwarp-graphicx.sty}{\from{lwarp.dtx}{graphicx}}
 \file{lwarp-graphics.sty}{\from{lwarp.dtx}{graphics}}
 \file{lwarp-grffile.sty}{\from{lwarp.dtx}{grffile}}
+\file{lwarp-grid.sty}{\from{lwarp.dtx}{grid}}
 \file{lwarp-hang.sty}{\from{lwarp.dtx}{hang}}
 \file{lwarp-hanging.sty}{\from{lwarp.dtx}{hanging}}
 \file{lwarp-hypcap.sty}{\from{lwarp.dtx}{hypcap}}
@@ -158,6 +165,7 @@
 \file{lwarp-longtable.sty}{\from{lwarp.dtx}{longtable}}
 \file{lwarp-lscape.sty}{\from{lwarp.dtx}{lscape}}
 \file{lwarp-ltcaption.sty}{\from{lwarp.dtx}{ltcaption}}
+\file{lwarp-ltxgrid.sty}{\from{lwarp.dtx}{ltxgrid}}
 \file{lwarp-ltxtable.sty}{\from{lwarp.dtx}{ltxtable}}
 \file{lwarp-luacolor.sty}{\from{lwarp.dtx}{luacolor}}
 \file{lwarp-luatodonotes.sty}{\from{lwarp.dtx}{luatodonotes}}
@@ -168,6 +176,7 @@
 \file{lwarp-mdframed.sty}{\from{lwarp.dtx}{mdframed}}
 \file{lwarp-memhfixc.sty}{\from{lwarp.dtx}{memhfixc}}
 \file{lwarp-metalogo.sty}{\from{lwarp.dtx}{metalogo}}
+\file{lwarp-mhchem.sty}{\from{lwarp.dtx}{mhchem}}
 \file{lwarp-microtype.sty}{\from{lwarp.dtx}{microtype}}
 \file{lwarp-midfloat.sty}{\from{lwarp.dtx}{midfloat}}
 \file{lwarp-midpage.sty}{\from{lwarp.dtx}{midpage}}

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-alltt.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-alltt.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-alltt.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -22,7 +22,7 @@
 \LWR at traceinfo{Patching alltt.}
 \AtBeginEnvironment{alltt}{%
 \LWR at forcenewpage
-\LWR at atbeginverbatim{alltt}\unskip\LWR at origvspace*{-\baselineskip}%
+\LWR at atbeginverbatim{3.5}{alltt}%
 }
 \AfterEndEnvironment{alltt}{\unskip\LWR at origvspace*{-\baselineskip}\LWR at afterendverbatim}
 }

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-array.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-array.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-array.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -19,7 +19,7 @@
 \let\LWR at origfirsthline\firsthline
 \let\LWR at origlasthline\lasthline
 
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \let\firsthline\LWR at origfirsthline%
 \let\lasthline\LWR at origlasthline%
 }

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-axodraw2.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-axodraw2.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-axodraw2.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -18,7 +18,7 @@
 
 \LWR at ProvidesPackagePass{axodraw2}
 
-\BeforeBeginEnvironment{axopicture}{\begin{lateximage}[axopicture]}
+\BeforeBeginEnvironment{axopicture}{\begin{lateximage}[(axopicture)]}
 
 \AfterEndEnvironment{axopicture}{\end{lateximage}}
 

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-bigdelim.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-bigdelim.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-bigdelim.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -29,7 +29,7 @@
 \renewcommand{\LWR at multirowborder}{left}%
 \multirow{#2}{#3}{\InlineClass{rdelim}{#1} #4}%
 }
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \LetLtxMacro{\ldelim}{\LWR at origldelim}%
 \LetLtxMacro{\rdelim}{\LWR at origrdelim}%
 }

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-bigstrut.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-bigstrut.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-bigstrut.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -20,7 +20,7 @@
 
 \renewcommand\bigstrut[1][x]{}
 
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \LetLtxMacro{\bigstrut}{\LWR at origbigstrut}%
 }
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-bytefield.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-bytefield.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-bytefield.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -18,7 +18,7 @@
 
 \LWR at ProvidesPackagePass{bytefield}
 
-\BeforeBeginEnvironment{bytefield}{\begin{lateximage}[bytefield]}
+\BeforeBeginEnvironment{bytefield}{\begin{lateximage}[(bytefield)]}
 
 \AfterEndEnvironment{bytefield}{\end{lateximage}}
 

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-cancel.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-cancel.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-cancel.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -21,7 +21,7 @@
 \LetLtxMacro\LWR at origbcancel\bcancel
 \LetLtxMacro\LWR at origxcancel\xcancel
 
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \LetLtxMacro\cancel\LWR at origcancel%
 \LetLtxMacro\bcancel\LWR at origbcancel%
 \LetLtxMacro\xcancel\LWR at origxcancel%
@@ -30,7 +30,7 @@
 \newcommand{\LWR at cancelcolor}[5]{%
 \ifcsempty{#2}%
 {\LWR at HTMLtextstyle{#5}{#3}{#1}}%
-{\LWR at htmlspanclass[#5;#4:\#\LWR at tempcolor]{#3}{#1}}%
+{\LWR at htmlspanclass[#5;#4:\LWR at origpound\LWR at tempcolor]{#3}{#1}}%
 }
 
 \DeclareRobustCommand{\cancel}[1]{%

Added: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemfig.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemfig.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemfig.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -0,0 +1,62 @@
+%%
+%% This is file `lwarp-chemfig.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% lwarp.dtx  (with options: `chemfig')
+%% This is a generated file.
+%% Copyright 2016-2018 Brian Dunn
+%% 
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+
+\LWR at ProvidesPackagePass{chemfig}
+
+\LetLtxMacro\LWR at chemfig@origchemfig\chemfig
+
+\DeclareDocumentCommand\chemfig{s O{} O{} m}{%
+    \begin{lateximage}[(chemfig)]%
+    \IfBooleanTF{#1}{%
+        \LWR at chemfig@origchemfig*[#2][#3]{#4}%
+    }{%
+        \LWR at chemfig@origchemfig[#2][#3]{#4}%
+    }
+    \end{lateximage}%
+}
+
+\LetLtxMacro\LWR at chemfig@origCF at lewis@b\CF at lewis@b
+
+\def\CF at lewis@b#1#2{%
+\begin{lateximage}[(chemfig)]%
+\LWR at chemfig@origCF at lewis@b{#1}{#2}%
+\end{lateximage}%
+}
+
+\preto{\schemestart}{\begin{lateximage}[(chemfig)]}
+\appto{\CF at schemestop}{\end{lateximage}}
+
+\LetLtxMacro\LWR at chemfig@origchemleft\chemleft
+
+\def\chemleft#1#2\chemright#3{%
+\begin{lateximage}[(chemfig)]%
+\LWR at chemfig@origchemleft#1#2\chemright#3%
+\end{lateximage}%
+}
+
+\LetLtxMacro\LWR at chemfig@origchemup\chemup
+
+\def\chemup#1#2\chemdown#3{%
+\begin{lateximage}[(chemfig)]%
+\LWR at chemfig@origchemup#1#2\chemdown#3%
+\end{lateximage}%
+}
+
+\endinput
+%%
+%% End of file `lwarp-chemfig.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemfig.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemformula.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemformula.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemformula.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -0,0 +1,177 @@
+%%
+%% This is file `lwarp-chemformula.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% lwarp.dtx  (with options: `chemformula')
+%% This is a generated file.
+%% Copyright 2016-2018 Brian Dunn
+%% 
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+
+\LWR at ProvidesPackagePass{chemformula}[2017/03/23]
+
+\ExplSyntaxOn
+\RenewDocumentCommand \ch { O{}m }
+  {%
+    \ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}%  lwarp
+    {
+        \chemformula_ch:nn {#1} {#2}%   original
+    }
+    {
+        \begingroup%
+        \boolfalse{mathjax}%
+        \LWR at subsingledollar*{% lwarp
+            \textbackslash{}ch\{\LWR at HTMLsanitize{#2}\}% alt text
+        }{%
+            \LWR at HTMLsanitize{#1}% add'l hashing
+        }%
+        {%
+            \chemformula_ch:nn {#1} {#2}%   original
+        }%
+        \endgroup%
+    }
+  }
+\cs_gset_protected:Npn \chemformula_chcpd:nn #1#2
+  {
+    \begingroup%
+    \boolfalse{mathjax}%
+    \LWR at subsingledollar*{% lwarp
+        \textbackslash{}chcpd\{\LWR at HTMLsanitize{#2}\}%
+    }{%
+        \LWR at HTMLsanitize{#1}%
+    }{% original
+    \group_begin:
+      \tl_if_blank:nF {#2}
+        {
+          \keys_set:nn {chemformula} {#1}
+          \__chemformula_save_catcodes:
+          \__chemformula_sanitize:Nn
+            \l__chemformula_chemformula_tmpa_tl
+            {#2}
+          \__chemformula_input_compound_no_check:NV
+            \l__chemformula_compound_tl
+            \l__chemformula_chemformula_tmpa_tl
+          \__chemformula_prepare_output:N \l__chemformula_compound_tl
+          \chemformula_write:V \l__chemformula_compound_tl
+        }
+    \group_end:
+    }
+    \endgroup
+  }
+\RenewDocumentCommand \charrow { mO{}O{} }
+{
+    \begin{lateximage}[(charrow)]
+    \group_begin:
+      \__chemformula_draw_arrow:nnn {#1} {#2} {#3}
+    \group_end:
+    \end{lateximage}
+}
+\RenewDocumentCommand \chname { R(){}R(){} }
+  {
+    \begin{lateximage}*[%
+        \textbackslash{}chname(\LWR at HTMLsanitize{#1})(\LWR at HTMLsanitize{#2})
+    ]%
+        \chemformula_chwritebelow:nn {#1} {#2}
+    \end{lateximage}
+  }
+\RenewDocumentCommand \chlewis { O{}mm }
+  {
+    \begingroup%
+    \boolfalse{mathjax}%
+    \LWR at subsingledollar*{\textbackslash{}chlewis\{#2\}\{#3\}}{#1}{
+        \chemformula_lewis:nnn {#1} {#2} {#3}
+    }
+    \endgroup%
+  }
+\bool_new:N      \l__chemformula_first_last_LWRdollar_bool
+\cs_gset_protected:Npn \__chemformula_input_escape_math:n #1
+  {
+    \__chemformula_first_last_math:n {#1}
+    \bool_if:NT \l__chemformula_first_last_dollar_bool
+      {
+        \bool_set_true:N \l__chemformula_first_last_math_bool
+        \__chemformula_read_escape_dollar:w #1 \q_nil
+      }
+    \bool_if:NT \l__chemformula_first_last_mathbraces_bool
+      {
+        \bool_set_true:N \l__chemformula_first_last_math_bool
+        \__chemformula_read_escape_mathbraces:w #1 \q_nil
+      }
+    \bool_if:NT \l__chemformula_first_last_LWRdollar_bool%      lwarp
+      {
+        \bool_set_true:N \l__chemformula_first_last_math_bool%  lwarp
+        \__chemformula_read_escape_LWRdollar:w #1 \q_nil%       lwarp
+      }
+  }
+\begingroup
+\catcode`\$=\active
+
+\cs_new_protected:Npn \__chemformula_read_escape_LWRdollar:w $#1$ \q_nil
+{
+    \__chemformula_read_escape_math:n {#1}
+}
+
+\endgroup
+\cs_new_protected:Npn \__chemformula_bool_cs_set_if_first_last:NnNN #1#2#3#4
+  {
+    \int_zero:N \l__chemformula_tmpa_int
+    \int_zero:N \l__chemformula_tmpb_int
+    \int_set:Nn \l__chemformula_tmpa_int { \tl_count:n {#2} }
+    \tl_map_inline:nn {#2}
+      {
+        \int_incr:N \l__chemformula_tmpb_int
+        \int_compare:nT { \l__chemformula_tmpb_int = 1 }
+          {
+            \ifdefstrequal{##1}{#3}% lwarp
+                {
+                    \bool_set_true:N #1
+                }% lwarp
+                {}
+          }
+        \int_compare:nT { \l__chemformula_tmpb_int = \l__chemformula_tmpa_int }
+          {
+            \ifdefstrequal{##1}{#4}
+                {}
+                {
+                    \bool_set_false:N #1
+                }
+          }
+      }
+  }
+\cs_gset_protected:Npn \__chemformula_first_last_math:n #1
+  {
+    \bool_set_false:N \l__chemformula_first_last_math_bool
+    \bool_set_false:N \l__chemformula_first_last_dollar_bool
+    \bool_set_false:N \l__chemformula_first_last_LWRdollar_bool%    lwarp
+    \bool_set_false:N \l__chemformula_first_last_mathbraces_bool
+    \__chemformula_bool_set_if_first_last:Nnnn
+      \l__chemformula_first_last_dollar_bool
+      {#1}
+      { $ } { $ }
+    \bool_if:NF \l__chemformula_first_last_dollar_bool
+      {
+        \__chemformula_bool_set_if_first_last:Nnnn
+          \l__chemformula_first_last_mathbraces_bool
+          {#1}
+          { \( } { \) }
+          \bool_if:NF \l__chemformula_first_last_mathbraces_bool%   lwarp
+            {
+                \__chemformula_bool_cs_set_if_first_last:NnNN
+                \l__chemformula_first_last_LWRdollar_bool
+                {#1}
+                { \LWR at newsingledollar } { \LWR at newsingledollar }
+            }%  lwarp
+      }
+  }
+\ExplSyntaxOff
+\endinput
+%%
+%% End of file `lwarp-chemformula.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemformula.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemgreek.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemgreek.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemgreek.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -0,0 +1,37 @@
+%%
+%% This is file `lwarp-chemgreek.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% lwarp.dtx  (with options: `chemgreek')
+%% This is a generated file.
+%% Copyright 2016-2018 Brian Dunn
+%% 
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+
+\LWR at ProvidesPackagePass{chemgreek}[2016/02/10]
+
+\ExplSyntaxOn
+
+\cs_undefine:N \chemgreek_text:n
+
+\cs_new_protected:Npn \chemgreek_text:n #1
+  { { \text {#1} } }
+
+\appto\LWR at restoreorigformatting{%
+\cs_set_protected:Npn \chemgreek_text:n #1%
+  { \ensuremath { \text {#1} } }%
+}
+
+\ExplSyntaxOff
+
+\endinput
+%%
+%% End of file `lwarp-chemgreek.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemgreek.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemmacros.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemmacros.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemmacros.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -0,0 +1,867 @@
+%%
+%% This is file `lwarp-chemmacros.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% lwarp.dtx  (with options: `chemmacros')
+%% This is a generated file.
+%% Copyright 2016-2018 Brian Dunn
+%% 
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+
+\LWR at ProvidesPackagePass{chemmacros}
+\ExplSyntaxOn
+
+\newcommand{\@ifchemmacrosmoduleloaded}[1]{%
+\@ifl at aded{\c__chemmacros_module_extension_tl}{\c__chemmacros_module_prefix_tl.#1}%
+}
+
+\ExplSyntaxOff
+\DeclareDocumentEnvironment{polymerdelims}{}
+{\begin{lateximage}[(polymer)]}
+{\end{lateximage}}
+
+\DeclareDocumentEnvironment{redoxreaction}{m m}
+{\begin{lateximage}[(redox~reaction)]}
+{\end{lateximage}}
+\ExplSyntaxOn
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{acid-base}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~acid-base}
+
+\cs_gset_protected:Npn \chemmacros_p:n #1
+  {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{
+        \textbackslash{}p\{\LWR at HTMLsanitize{#1}\}
+    }{
+        chemmacrosp\LWR at HTMLsanitize{#1}
+    }{
+    \group_begin:
+      \mbox
+        {
+          \chemmacros_p_style:n {p}
+          \ensuremath {#1}
+        }
+    \group_end:
+    }
+    \endgroup
+  }
+
+\RenewDocumentCommand \pH  {} {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}pH}{chemmacros}{
+        \chemmacros_p:n { \chemmacros_chemformula:n {H} }
+    }
+    \endgroup
+}
+
+\RenewDocumentCommand \pOH {} {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}pOH}{chemmacros}{
+        \chemmacros_p:n { \chemmacros_chemformula:n {OH} }
+    }
+    \endgroup
+}
+
+\RenewDocumentCommand \pKa {O{}}
+  {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}pKa{[}#1{]}}{chemmacros #1}{
+        \chemmacros_p:n
+        {
+            \Ka \ifblank {#1} {}
+            { {} \c_math_subscript_token { \chemmacros_bold:n {#1} } }
+        }
+    }
+    \endgroup
+  }
+
+\RenewDocumentCommand \pKb {O{}}
+  {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}pKb{[}#1{]}}{chemmacros #1}{
+        \chemmacros_p:n
+        {
+            \Kb \ifblank {#1} {}
+            { {} \c_math_subscript_token { \chemmacros_bold:n {#1} } }
+        }
+    }
+    \endgroup
+  }
+
+\LetLtxMacro\LWR at chemmacros@origKa\Ka
+\renewcommand*{\Ka}{%
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}Ka}{chemmacros}{%
+        \LWR at chemmacros@origKa%
+    }%
+    \endgroup
+}
+
+\LetLtxMacro\LWR at chemmacros@origKb\Kb
+\renewcommand*{\Kb}{%
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}Kb}{chemmacros}{%
+        \LWR at chemmacros@origKb%
+    }%
+    \endgroup
+}
+
+\LetLtxMacro\LWR at chemmacros@origKw\Kw
+\renewcommand*{\Kw}{%
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}Kw}{chemmacros}{
+        \LWR at chemmacros@origKw
+    }
+    \endgroup
+}
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{charges}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~charges}
+
+\cs_gset_protected:Npn \fplus  {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}fplus}{chemmacros}
+    { \LWR at origensuredmath{\chemformula_fplus:}  }
+    \endgroup
+}
+\cs_gset_protected:Npn \fminus {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}fminus}{chemmacros}
+    { \LWR at origensuredmath{\chemformula_fminus:} }
+    \endgroup
+}
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{nomenclature}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~nomenclature}
+
+\cs_gset_protected:Npn \chemmacros_charge:n #1
+  {
+    \ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}
+    {\chemmacros_chemformula:n { {}^{#1} }}
+    {
+        \ifmmode
+            {\chemmacros_chemformula:n { {}^{#1} }}
+        \else
+            { \textsuperscript{\ensuremath{#1}} }
+        \fi
+    }
+  }
+
+\LetLtxMacro\LWR at chemmacros@origchemprime\chemprime
+
+\protected\def\chemprime { \HTMLunicode{2032} }
+
+\appto\LWR at restoreorigformatting{%
+\LetLtxMacro\chemprime\LWR at chemmacros@origchemprime%
+}
+\ChemCompatibilityFrom{5.8}
+\cs_gset_protected:Npn \__chemmacros_cip:n #1
+  {
+    \tl_set:Nn \l__chemmacros_tmpa_tl {#1}
+    \int_step_inline:nnnn {0} {1} {9}
+      {
+        \tl_replace_all:Nnn \l__chemmacros_tmpa_tl
+          {##1}
+          { { \l__chemmacros_cip_number_tl ##1} }
+      }
+    {
+        \l__chemmacros_cip_inner_tl
+        \LWR at textcurrentcolor{\LWR at textcurrentfont{% lwarp
+            \l__chemmacros_tmpa_tl
+        }}% lwarp
+    }
+  }
+\EndChemCompatibility
+\RenewDocumentCommand \Sconf { O{S} } {
+\begin{lateximage}[\textbackslash{}Sconf{[}#1{]}]
+    \chemmacros_sconf:n {#1}
+\end{lateximage}
+}
+
+\RenewDocumentCommand \Rconf { O{R} } {
+\begin{lateximage}[\textbackslash{}Rconf{[}#1{]}]
+    \chemmacros_rconf:n {#1}
+\end{lateximage}
+}
+\cs_gset_protected:Npn \chemmacros_hapto:n #1
+  {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}hapto\{#1\}}{chemmacros}{
+        \chemmacros_coordination_symbol:nnnn
+        { \l__chemmacros_coord_use_hyphen_bool }
+        {
+            \chemmacros_if_compatibility:nnTF {>} {5.7}
+            { \c_true_bool }
+            { \c_false_bool }
+        }
+        { \chemeta }
+        {#1}
+    }
+    \endgroup
+  }
+
+\cs_gset_protected:Npn \chemmacros_dento:n #1
+  {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}dento\{#1\}}{chemmacros}{
+        \chemmacros_coordination_symbol:nnnn
+        { \l__chemmacros_coord_use_hyphen_bool }
+        {
+            \chemmacros_if_compatibility:nnTF {>} {5.7}
+            { \c_true_bool }
+            { \c_false_bool }
+        }
+        { \chemkappa }
+        {#1}
+    }
+    \endgroup
+  }
+
+\cs_gset_protected:Npn \chemmacros_bridge:n #1
+  {
+    \begingroup
+    \boolfalse{mathjax}
+    \LWR at subsingledollar*{\textbackslash{}bridge\{#1\}}{chemmacros}{
+        \chemmacros_coordination_symbol:nnnn
+        { \l__chemmacros_coord_use_hyphen_bool }
+        { \l__chemmacros_bridge_super_bool }
+        { \chemmu }
+        {#1}
+    }
+    \endgroup
+  }
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{particles}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~particles}
+
+\cs_gset_protected:Npn \chemmacros_declare_nucleophile:Nn #1#2
+  {
+    \cs_set_protected:cpn {__chemmacros_ \chemmacros_remove_backslash:N #1:}
+      {
+        \bool_if:NTF \l__chemmacros_nucleophile_elpair_bool
+          {
+            \chemmacros_elpair:n { #2 }
+            \chemmacros_if_compatibility:nnT {>=} {5.3}
+              { \skip_horizontal:N \l__chemmacros_nucleophile_dim }
+            \chemmacros_chemformula:n { {}^{-} }
+          }
+          { \chemmacros_chemformula:n { #2^{-} } }
+      }
+    \DeclareDocumentCommand #1 {o}
+      {%
+        \begin{lateximage}%
+        \group_begin:%
+          \IfNoValueF {##1}%
+            { \chemmacros_set_keys:nn {particles} {##1} }%
+          \use:c {__chemmacros_ \chemmacros_remove_backslash:N #1:}%
+        \group_end:%
+        \end{lateximage}%
+      }
+  }
+
+\RenewChemNucleophile \Nuc {Nu}
+\RenewChemNucleophile \ba  {ba}
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{phases}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~phases}
+
+\cs_undefine:N \chemmacros_phase:n
+\cs_new_protected:Npn \chemmacros_phase:n #1
+  {
+    \chemmacros_leave_vmode:
+    \bool_if:NTF \l__chemmacros_phases_sub_bool
+      {
+        \ifnumequal{\value{LWR at lateximagedepth}}{0}
+        {
+            \textsubscript{ (#1) }
+        }
+        {
+            \chemformula_subscript:n { (#1) }
+        }
+      }
+      {
+        \skip_horizontal:N \l__chemmacros_phases_space_dim
+        \chemmacros_text:n { (#1) }
+      }
+  }
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{mechanisms}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~mechanisms}
+
+\chemmacros_define_keys:nn {textmechanisms}
+  {
+    type      .choice: ,
+    type /    .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { S }
+          {
+              \textsubscript{N}
+          }
+          { }
+      } ,
+    type / 1  .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { S }
+          {
+              \textsubscript{N}
+            1
+          }
+          { }
+      } ,
+    type / 2  .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { S }
+          {
+              \textsubscript{N}
+            2
+          }
+          { }
+      } ,
+    type / se .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { S }
+          {
+              \textsubscript{E}
+          }
+          { }
+      } ,
+    type / 1e .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { S }
+          {
+              \textsubscript{E}
+            1
+          }
+          { }
+      } ,
+    type / 2e .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { S }
+          {
+              \textsubscript{E}
+            2
+          }
+          { }
+      } ,
+    type / ar .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { S }
+          {
+              \textsubscript{E}
+          }
+          { Ar - }
+      } ,
+    type / e  .code:n    =
+      { \__chemmacros_set_mechanisms:nnn { E } { } { } } ,
+    type / e1 .code:n    =
+      { \__chemmacros_set_mechanisms:nnn { E } { 1 } { } } ,
+    type / e2 .code:n    =
+      { \__chemmacros_set_mechanisms:nnn { E } { 2 } { } } ,
+    type / cb .code:n    =
+      {
+        \__chemmacros_set_mechanisms:nnn { E }
+          {
+            1
+              \textsubscript{cb}
+          }
+          { }
+      } ,
+    type      .default:n =
+  }
+
+\cs_gset_protected:Npn \chemmacros_mechanisms:n #1
+  {
+    \tl_if_blank:nTF {#1}
+      { \chemmacros_set_keys:nn {textmechanisms} { type } }
+      { \chemmacros_set_keys:nn {textmechanisms} { type = #1 } }
+    \mbox
+      {
+        \tl_use:N \l__chemmacros_mechanisms_ar_tl
+        \tl_use:N \l__chemmacros_mechanisms_type_tl
+        \tl_use:N \l__chemmacros_mechanisms_mol_tl
+      }
+  }
+
+\appto\LWR at restoreorigformatting{%
+\cs_set_protected:Npn \chemmacros_mechanisms:n #1%
+  {%
+    \tl_if_blank:nTF {#1}%
+      { \chemmacros_set_keys:nn {mechanisms} { type } }%
+      { \chemmacros_set_keys:nn {mechanisms} { type = #1 } }%
+    \mbox%
+      {%
+        \tl_use:N \l__chemmacros_mechanisms_ar_tl%
+        \tl_use:N \l__chemmacros_mechanisms_type_tl%
+        \tl_use:N \l__chemmacros_mechanisms_mol_tl%
+      }%
+  }%
+}
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{newman}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~newman}
+
+\RenewDocumentCommand \newman {od()m}%
+  {
+    \IfValueTF{#2}
+    {\begin{lateximage}[\textbackslash{}newman(#2)\{#3\}]}
+    {\begin{lateximage}[\textbackslash{}newman\{#3\}]}
+    \group_begin:
+      \IfNoValueF  {#1} { \chemmacros_set_keys:nn {newman} {#1} }
+      \IfNoValueTF {#2}
+        { \chemmacros_newman:nn {  } {#3} }
+        { \chemmacros_newman:nn {#2} {#3} }
+    \group_end:
+    \end{lateximage}
+  }%
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{orbital}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~orbital}
+
+\RenewDocumentCommand \orbital {om}
+  {
+    \IfValueTF{#1}
+    {
+        \begin{lateximage}[%
+            \textbackslash{}orbital{[}\LWR at HTMLsanitize{#1}{]}\{#2\}%
+        ][][margin-left: 1em ; margin-right: 1em]
+    }
+    {
+        \begin{lateximage}[%
+            \textbackslash{}orbital\{#2\}%
+        ][][margin-left: 1em ; margin-right: 1em]
+    }
+    \group_begin:
+      \chemmacros_set_keys:nn {orbital/type} {#2}
+      \IfNoValueTF {#1}
+        { \chemmacros_orbital:n {  } }
+        { \chemmacros_orbital:n {#1} }
+    \group_end:
+    \end{lateximage}
+  }
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{reactions}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~orbital}
+
+\cs_gset_protected:Npn \chemmacros_declare_reaction_env:nnnn #1#2#3#4
+  {
+    \exp_args:Nnx \DeclareDocumentEnvironment {#1} { O{} \prg_replicate:nn {#3+0} {m} }
+      {
+        \boolfalse{mathjax}%    lwarp
+        \chemmacros_add_reaction_description:n {##1}
+        \__chemmacros_begin_reaction:
+        \chemmacros_reaction_read:nnw {#2} {#4}
+      }
+      {
+        \__chemmacros_end_reaction:
+      }
+  }
+\cs_generate_variant:Nn \chemmacros_declare_reaction_env:nnnn {nnnV}
+
+\RenewChemReaction {reaction}   {equation}
+\RenewChemReaction {reaction*}  {equation*}
+\RenewChemReaction {reactions}  {align}
+\RenewChemReaction {reactions*} {align*}
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{redox}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~redox}
+
+\NewDocumentCommand \LWR at chemmacros@ox { s m >{\SplitArgument{1}{,}}m }
+  {
+    \IfBooleanTF {#1}
+      { \chemmacros_ox:nnnn {#1} {#2} #3 }
+      { \chemmacros_ox:nnnn {  } {#2} #3 }
+  }
+
+\RenewDocumentCommand \ox { s O{} m }
+  {
+    \begingroup
+    \boolfalse{mathjax}
+    \IfBooleanTF {#1}
+      {
+        \LWR at subsingledollar*{% yes hash
+            \textbackslash{}ox*\{\LWR at HTMLsanitize{#3}\}% alt
+        }{%
+            star \LWR at HTMLsanitize{#2}% addl' hashing with star
+        }{%
+            \LWR at chemmacros@ox* {#2} {#3}% contents
+        }%
+      }
+      {
+        \LWR at subsingledollar*{% yes hash
+            \textbackslash{}ox*\{\LWR at HTMLsanitize{#3}\}% alt
+        }{%
+            \LWR at HTMLsanitize{#2}% addl' hashing without star
+        }{%
+            \LWR at chemmacros@ox {#2} {#3}% contents
+        }%
+      }
+    \endgroup
+  }
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{scheme}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~scheme}
+
+\ifdefstring{\schemename}{los}{
+\SetupFloatingEnvironment{scheme}{
+name = \chemmacros_translate:n {scheme-name}
+}
+}{}
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{spectroscopy}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~spectroscopy}
+
+\ChemCompatibilityTo{5.8}
+\cs_gset_protected:Npn \__chemmacros_nmr_base:nn #1#2
+  {
+    \tl_if_blank:VF \g__chemmacros_nmr_element_coupled_tl
+      {
+        \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl { \{ }
+        \tl_put_right:Nn \g__chemmacros_nmr_element_coupled_tl { \} }
+      }
+    \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl {#2}
+    \textsuperscript{#1}
+    \bool_if:NTF \l__chemmacros_nmr_parse_bool
+      { \chemformula_ch:nV {} \g__chemmacros_nmr_element_coupled_tl }
+      { \chemmacros_chemformula:V \g__chemmacros_nmr_element_coupled_tl }
+    \tl_use:N \l__chemmacros_nmr_element_method_connector_tl
+    \tl_use:N \l__chemmacros_nmr_method_tl
+  }
+\EndChemCompatibility
+\ChemCompatibilityFrom{5.8}
+\cs_gset_protected:Npn \__chemmacros_nmr_base:nn #1#2
+  {
+    \group_begin:
+      \tl_use:N \l__chemmacros_nmr_base_format_tl
+      \tl_if_blank:VF \g__chemmacros_nmr_element_coupled_tl
+        {
+          \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl { \{ }
+          \tl_put_right:Nn \g__chemmacros_nmr_element_coupled_tl { \} }
+        }
+      \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl {#2}
+      \textsuperscript{#1}
+      \tl_if_blank:VF \g__chemmacros_nmr_element_coupled_tl
+        {
+          \bool_if:NTF \l__chemmacros_nmr_parse_bool
+            { \chemformula_ch:nV {} \g__chemmacros_nmr_element_coupled_tl }
+            { \chemmacros_chemformula:V \g__chemmacros_nmr_element_coupled_tl }
+        }
+      \tl_use:N \l__chemmacros_nmr_element_method_connector_tl
+      \tl_use:N \l__chemmacros_nmr_method_tl
+    \group_end:
+  }
+\EndChemCompatibility
+
+\cs_gset_protected:Npn \chemmacros_nmr_position:n #1
+  {
+    \chemmacros_chemformula:x
+      {
+        \exp_not:V \g__chemmacros_nmr_element_tl
+        \bool_if:NF \l__chemmacros_nmr_position_side_bool
+          {
+            \tl_if_eq:NnTF \l__chemmacros_nmr_position_tl {^}% lwarp
+            { \textsuperscript{\exp_not:n { {#1} }} }% lwarp
+            { \textsubscript{\exp_not:n { {#1} }} }% lwarp
+          }
+      }
+    \bool_if:NT \l__chemmacros_nmr_position_side_bool
+      {
+        \tl_use:N \l__chemmacros_nmr_position_tl
+        \__chemmacros_nmr_position:n {#1}
+      }
+  }
+
+\cs_gset_protected:Npn \__chemmacros_nmr_coupling:w (#1;#2)
+  {
+    \tl_set:Nn \l__chemmacros_nmr_coupling_bonds_tl
+      {
+        \l__chemmacros_nmr_coupling_bonds_pre_tl
+        #1
+        \l__chemmacros_nmr_coupling_bonds_post_tl
+      }
+    \bool_if:NTF \l__chemmacros_nmr_coupling_nuclei_sub_bool
+      {
+        \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl
+          {
+            \textsubscript% lwarp
+              {
+                \l__chemmacros_nmr_coupling_nuclei_pre_tl
+                \chemmacros_chemformula:n {#2}
+                \l__chemmacros_nmr_coupling_nuclei_post_tl
+              }
+          }
+      }
+      {
+        \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl
+          {
+            \l__chemmacros_nmr_coupling_nuclei_pre_tl
+            \chemmacros_chemformula:n {#2}
+            \l__chemmacros_nmr_coupling_nuclei_post_tl
+          }
+      }
+    \__chemmacros_nmr_coupling_aux_i:w
+  }
+
+\AfterEndPreamble{% After \AtBeginDocument
+\cs_gset_protected:Npn \chemmacros_nmr:nnnn #1#2#3#4
+    {
+    \bool_if:NT \l__chemmacros_nmr_list_bool { \item \scan_stop: }
+    \group_begin:
+        \chemmacros_leave_vmode:
+        \bool_set_false:N \l__chemmacros_nmr_frequency_bool
+        \bool_set_false:N \l__chemmacros_nmr_solvent_bool
+        \tl_if_empty:nF {#3}
+        { \bool_set_true:N \l__chemmacros_nmr_frequency_bool }
+        \tl_if_empty:nF {#4}
+        { \bool_set_true:N \l__chemmacros_nmr_solvent_bool }
+        \bool_if:nT
+        {
+            \l__chemmacros_nmr_frequency_bool
+            ||
+            \l__chemmacros_nmr_solvent_bool
+        }
+        { \bool_set_true:N \l__chemmacros_nmr_delimiters_bool }
+        \bool_if:nT
+        {
+            \l__chemmacros_nmr_frequency_bool
+            &&
+            \l__chemmacros_nmr_solvent_bool
+        }
+        { \bool_set_true:N \l__chemmacros_nmr_comma_bool }
+        \tl_if_empty:nTF {#2}
+        {
+            \__chemmacros_nmr_nucleus:VV
+            \l__chemmacros_nmr_isotope_default_tl
+            \l__chemmacros_nmr_element_default_tl
+        }
+        { \__chemmacros_nmr_nucleus:w #2 \q_stop }
+        \mode_if_math:TF
+        {
+            \text
+            {
+                \group_begin:
+                \tl_use:N \l__chemmacros_nmr_format_tl
+\LWR at textcurrentcolor{\LWR at textcurrentfont{% lwarp
+                \__chemmacros_nmr_base:VV
+                    \g__chemmacros_nmr_isotope_tl
+                    \g__chemmacros_nmr_element_tl
+                \bool_if:NT \l__chemmacros_nmr_delimiters_bool
+                    { ~ ( }
+                \bool_if:NT \l__chemmacros_nmr_frequency_bool
+                    { \__chemmacros_nmr_frequency:n {#3} }
+                \bool_if:NT \l__chemmacros_nmr_comma_bool
+                    { , ~ }
+                \bool_if:NT \l__chemmacros_nmr_solvent_bool
+                    { \chemmacros_chemformula:n {#4} }
+                \bool_if:NT \l__chemmacros_nmr_delimiters_bool
+                    { ) }
+                \tl_if_blank:nT {#1} {:~}
+}}% lwarp
+                \group_end:
+            }
+            \tl_if_blank:nT {#1}
+            {
+                \delta
+                \text { \l__chemmacros_nmr_delta_tl }
+                \bool_if:NT \l__chemmacros_nmr_use_equal_bool {=}
+            }
+        }
+        {
+            \group_begin:
+            \tl_use:N \l__chemmacros_nmr_format_tl
+\LWR at textcurrentcolor{\LWR at textcurrentfont{% lwarp
+            \__chemmacros_nmr_base:VV
+                \g__chemmacros_nmr_isotope_tl
+                \g__chemmacros_nmr_element_tl
+            \bool_if:NT \l__chemmacros_nmr_delimiters_bool
+                {~(}
+            \bool_if:NT \l__chemmacros_nmr_frequency_bool
+                { \__chemmacros_nmr_frequency:n {#3} }
+            \bool_if:NT \l__chemmacros_nmr_comma_bool
+                {,~}
+            \bool_if:NT \l__chemmacros_nmr_solvent_bool
+                {
+                \bool_if:NTF \l__chemmacros_nmr_parse_bool
+                    { \chemformula_ch:nn { } {#4} }
+                    {#4}
+                }
+            \bool_if:NT \l__chemmacros_nmr_delimiters_bool
+                {)}
+}}% lwarp
+            \tl_if_blank:nT {#1} {:}
+            \group_end:
+            \tl_if_blank:nT {#1}
+            {
+                \tl_use:N \c_space_tl
+                \c_math_toggle_token
+                \delta
+                \c_math_toggle_token
+                \l__chemmacros_nmr_delta_tl
+                \bool_if:NT \l__chemmacros_nmr_use_equal_bool {~=}
+            }
+        }
+    \group_end:
+    }
+}% AfterEndPremble
+
+\RenewDocumentCommand \chemmacros_data:w { smo }
+  {
+    \bool_if:NT \l__chemmacros_nmr_list_bool { \item }
+      {
+        \tl_use:N \l__chemmacros_nmr_format_tl
+        \LWR at textcurrentcolor{\LWR at textcurrentfont{% lwarp
+            #2
+            \IfNoValueF {#3} { ~ ( #3 ) }
+            \IfBooleanT {#1} { \bool_if:NT \l__chemmacros_nmr_use_equal_bool { : } }
+        }}% lwarp
+      }
+    \IfBooleanF {#1} { \bool_if:NT \l__chemmacros_nmr_use_equal_bool { ~ = } }
+  }
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+\AtBeginDocument{
+\@ifchemmacrosmoduleloaded{thermodynamics}{
+\PackageInfo{lwarp}{Patching~chemmacros~module~thermodynamics}
+
+\cs_gset_protected:Npn \chemmacros_state:nn #1#2
+  {
+    \group_begin:
+      \boolfalse{mathjax}
+      \chemmacros_set_keys:nn {thermodynamics} {#1}
+        \LWR at subsingledollar*{% yes hashing
+            \textbackslash{}state\{\LWR at HTMLsanitize{#2}\}% alt
+        }{%
+            chemmacros_state% add'l hashing
+            #1% options
+            LSP \tl_use:N \l__chemmacros_state_sp_left_tl% super/subscripts
+            LSB \tl_use:N \l__chemmacros_state_sb_left_tl
+            RSP \tl_use:N \l__chemmacros_state_sp_right_tl
+            RSB \tl_use:N \l__chemmacros_state_sb_right_tl
+        }
+        {
+         \LWR at origensuredmath{
+          \chemmacros_text:V \l__chemmacros_state_pre_tl
+          \c_math_superscript_token
+            { \chemmacros_text:V \l__chemmacros_state_sp_left_tl }
+          \tl_if_empty:NTF \l__chemmacros_state_sb_left_tl
+          {}
+          {
+            \c_math_subscript_token
+            { \chemmacros_text:V \l__chemmacros_state_sb_left_tl }
+          }
+          #2
+          \c_math_superscript_token
+            { \chemmacros_text:V \l__chemmacros_state_sp_right_tl }
+          \tl_if_empty:NTF \l__chemmacros_state_sb_right_tl
+          {}
+          {
+            \c_math_subscript_token
+            { \chemmacros_text:V \l__chemmacros_state_sb_right_tl }
+          }
+          \chemmacros_text:V \l__chemmacros_state_post_tl
+         }
+        }
+    \group_end:
+  }
+\cs_generate_variant:Nn \chemmacros_state:nn { nV }
+
+\cs_gset_protected:Npn \chemmacros_declare_state:Nn #1#2
+  {
+    \chemmacros_define_keys:xn
+      {thermodynamics/\chemmacros_remove_backslash:N #1}
+      {
+        pre               .meta:nn = {chemmacros/thermodynamics} { pre = ##1 } ,
+        post              .meta:nn = {chemmacros/thermodynamics} { post = ##1 } ,
+        superscript-left  .meta:nn = {chemmacros/thermodynamics} { superscript-left = ##1 } ,
+        superscript-right .meta:nn = {chemmacros/thermodynamics} { superscript-right = ##1 } ,
+        superscript       .meta:n  = { superscript-right = ##1 } ,
+        subscript-left    .meta:nn = {chemmacros/thermodynamics} { subscript-left = ##1 } ,
+        subscript-right   .meta:nn = {chemmacros/thermodynamics} { subscript-right = ##1 } ,
+        subscript         .meta:n     = { subscript-left = ##1 } ,
+        subscript-pos     .choices:nn =
+          { left , right }
+          { \tl_set_eq:NN \l__chemmacros_state_sb_pos_tl \l_keys_choice_tl } ,
+        symbol            .tl_set:N = \l__chemmacros_state_symbol_tl ,
+        unit              .tl_set:N = \l__chemmacros_state_unit_tl
+      }
+    \DeclareDocumentCommand #1 { sO{}D(){}m }
+      {
+        \group_begin:
+          \chemmacros_set_keys:xn
+            {thermodynamics/\chemmacros_remove_backslash:N #1}
+            {#2}
+          \tl_if_blank:nF {##3}
+            {
+              \chemmacros_set_keys:nx {thermodynamics}
+                { subscript-\l__chemmacros_state_sb_pos_tl = \exp_not:n {##3} }
+            }
+              \chemmacros_state:nV {##2} \l__chemmacros_state_symbol_tl
+              \chemmacros_set_keys_groups:nnn {thermodynamics} {variables} {##2}
+              \IfBooleanF {##1} {  = ~ \SI {##4} { \l__chemmacros_state_unit_tl } }
+        \group_end:
+      }
+  }
+\RenewChemState \enthalpy { symbol = H , unit = \kilo\joule\per\mole }
+\RenewChemState \entropy  { symbol = S , unit = \joule\per\kelvin\per\mole , pre = }
+\RenewChemState \gibbs    { symbol = G , unit = \kilo\joule\per\mole }
+
+}{}% \@ifchemmacrosmoduleloaded
+}% AtBeginDocument
+\ExplSyntaxOff
+
+\endinput
+%%
+%% End of file `lwarp-chemmacros.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemmacros.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemnum.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemnum.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemnum.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -0,0 +1,60 @@
+%%
+%% This is file `lwarp-chemnum.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% lwarp.dtx  (with options: `chemnum')
+%% This is a generated file.
+%% Copyright 2016-2018 Brian Dunn
+%% 
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+
+\LWR at ProvidesPackagePass{chemnum}
+
+\ExplSyntaxOn
+
+\cs_undefine:N \chemnum_compound_write:n
+\cs_new_protected:Npn \chemnum_compound_write:n #1
+  {
+    \chemnum_get_compound_property:nn {#1} {pre-main-label-code}
+    \group_begin:
+      \bool_if:NTF \l__chemnum_compound_local_bool
+        { \l__chemnum_local_label_format_tl }
+        { \chemnum_get_compound_property:nn {#1} {label-format} }
+      {
+        \LWR at textcurrentfont{
+            \chemnum_get_compound_property:nn {#1} {counter-representation}
+        }
+      }
+    \group_end:
+    \chemnum_get_compound_property:nn {#1} {post-main-label-code}
+  }
+
+\cs_undefine:N \chemnum_subcompound_write:nn
+\cs_new_protected:Npn \chemnum_subcompound_write:nn #1#2
+  {
+    \group_begin:
+      \bool_if:NTF \l__chemnum_compound_local_bool
+        { \l__chemnum_local_label_format_tl }
+        { \chemnum_get_compound_property:nn {#1} {label-format} }
+      {
+        \LWR at textcurrentfont{
+            \chemnum_get_subcompound_property:nnn {#1} {#2}
+            {counter-representation}
+        }
+      }
+    \group_end:
+  }
+
+\ExplSyntaxOff
+
+\endinput
+%%
+%% End of file `lwarp-chemnum.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-chemnum.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-colortbl.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-colortbl.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-colortbl.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -23,12 +23,12 @@
 \LetLtxMacro\LWR at origarrayrulecolor\arrayrulecolor
 \LetLtxMacro\LWR at origdoublerulesepcolor\doublerulesepcolor
 
-\appto{\LWR at restoreorigformatting}{%
-\LetLtxMacro\columncolor\LWR at origcolumncolor
-\LetLtxMacro\rowcolor\LWR at origrowcolor
-\LetLtxMacro\cellcolor\LWR at origcellcolor
-\LetLtxMacro\arrayrulecolor\LWR at origarrayrulecolor
-\LetLtxMacro\doublerulesepcolor\LWR at origdoublerulesepcolor
+\appto\LWR at restoreorigformatting{%
+\LetLtxMacro\columncolor\LWR at origcolumncolor%
+\LetLtxMacro\rowcolor\LWR at origrowcolor%
+\LetLtxMacro\cellcolor\LWR at origcellcolor%
+\LetLtxMacro\arrayrulecolor\LWR at origarrayrulecolor%
+\LetLtxMacro\doublerulesepcolor\LWR at origdoublerulesepcolor%
 }
 
 \RenewDocumentCommand{\LWR at HTMLcolumncolor}{O{named} m o o}{%

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-diagbox.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-diagbox.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-diagbox.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -20,9 +20,9 @@
 \LetLtxMacro\LWR at origdiagbox@double\diagbox at double
 \LetLtxMacro\LWR at origdiagbox@triple\diagbox at triple
 
-\appto\LWR at restoreorigformatting{
-\LetLtxMacro\diagbox at double\LWR at origdiagbox@double
-\LetLtxMacro\diagbox at triple\LWR at origdiagbox@triple
+\appto\LWR at restoreorigformatting{%
+\LetLtxMacro\diagbox at double\LWR at origdiagbox@double%
+\LetLtxMacro\diagbox at triple\LWR at origdiagbox@triple%
 }
 
 \newcommand{\LWR at diagbox@AB}[4]{

Added: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-epstopdf-base.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-epstopdf-base.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-epstopdf-base.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -0,0 +1,24 @@
+%%
+%% This is file `lwarp-epstopdf-base.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% lwarp.dtx  (with options: `epstopdf-base')
+%% This is a generated file.
+%% Copyright 2016-2018 Brian Dunn
+%% 
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+\LWR at ProvidesPackageDrop{epstopdf-base}[2016/05/15]
+\providecommand*{\epstopdfsetup}[1]{}
+\providecommand*{\epstopdfcall}[1]{}
+\providecommand*{\epstopdfDeclareGraphicsRule}[4]{}
+\endinput
+%%
+%% End of file `lwarp-epstopdf-base.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-epstopdf-base.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-epstopdf.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-epstopdf.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-epstopdf.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -16,9 +16,9 @@
 %% and version 1.3 or later is part of all distributions of LaTeX
 %% version 2005/12/01 or later.
 \LWR at ProvidesPackageDrop{epstopdf}
-\newcommand*{\epstopdfsetup}[1]{}
-\newcommand*{\epstopdfcall}[1]{}
-\newcommand*{\epstopdfDeclareGraphicsRule}[4]{}
+\providecommand*{\epstopdfsetup}[1]{}
+\providecommand*{\epstopdfcall}[1]{}
+\providecommand*{\epstopdfDeclareGraphicsRule}[4]{}
 \endinput
 %%
 %% End of file `lwarp-epstopdf.sty'.

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-fancybox.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-fancybox.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-fancybox.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -55,18 +55,39 @@
 \endLWR at figcaption%
 }
 \RenewDocumentEnvironment{Btrivlist}{m o}
-{\begin{BlockClass}{Btrivlist}\tabular{#1}}
-{\endtabular\end{BlockClass}}
+{%
+    \begin{BlockClass}{Btrivlist}%
+    \tabular{#1}%
+}
+{%
+    \endtabular%
+    \end{BlockClass}%
+}
 \AtBeginEnvironment{LWR at nestspan}{%
 \RenewDocumentEnvironment{Btrivlist}{m o}{}{}%
-\RenewDocumentCommand{\LWR at origitem}{d()}{\LWRFB at origitem}%
 }
 \let\LWRFB at origitemizeitem\LWR at itemizeitem
 \let\LWRFB at origdescitem\LWR at descitem
-\LetLtxMacro{\LWRFB at origitem}{\LWR at origitem}
 
-\RenewDocumentCommand{\LWR at itemizeitem}{d()}{\LWRFB at origitemizeitem}
-\RenewDocumentCommand{\LWR at descitem}{d()}{\LWRFB at origdescitem}
+\RenewDocumentCommand{\LWR at itemizeitem}{d()o}{%
+    \IfValueTF{#2}{%
+        \LWRFB at origitemizeitem[#2]%
+    }{%
+        \LWRFB at origitemizeitem%
+    }%
+}
+
+\RenewDocumentCommand{\LWR at descitem}{d()o}{%
+    \IfValueTF{#2}{%
+        \LWRFB at origdescitem[#2]~%
+    }{%
+        \LWRFB at origdescitem%
+    }%
+}
+\RenewDocumentCommand{\LWR at nestspanitem}{d()}{%
+\if at newlist\else{\LWR at htmltagc{br /}}\fi%
+\LWR at origitem%
+}
 \renewenvironment{Bitemize}[1][]{\begin{itemize}}{\end{itemize}}
 \renewenvironment{Benumerate}[1][]{\begin{enumerate}}{\end{enumerate}}
 \renewenvironment{Bdescription}[1][]{\begin{description}}{\end{description}}
@@ -85,7 +106,7 @@
 \def\endLandscape{}
 \let\LWRFB at UseVerbatim\UseVerbatim
 \renewcommand*{\UseVerbatim}[1]{%
-\LWR at atbeginverbatim{Verbatim}\unskip\LWR at origvspace*{-.5\baselineskip}%%
+\LWR at atbeginverbatim{3.5}{Verbatim}%
 \LWRFB at UseVerbatim{#1}%
 \LWR at afterendverbatim%
 }
@@ -93,7 +114,7 @@
 \let\LWRFB at LUseVerbatim\LUseVerbatim
 
 \renewcommand*{\LUseVerbatim}[1]{%
-\LWR at atbeginverbatim{LVerbatim}%\unskip\LWR at origvspace*{-\baselineskip}%%
+\LWR at atbeginverbatim{3.5}{LVerbatim}%
 \noindent%
 \LWRFB at LUseVerbatim{#1}%
 \LWR at afterendverbatim%
@@ -100,7 +121,7 @@
 }
 
 \def\@BUseVerbatim[#1]#2{%
-\LWR at atbeginverbatim{BVerbatim}\unskip\LWR at origvspace*{-.5\baselineskip}%%
+\LWR at atbeginverbatim{3.5}{BVerbatim}%
 \LWRFB at UseVerbatim{#2}%
 \LWR at afterendverbatim%
 }

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-fancyvrb.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-fancyvrb.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-fancyvrb.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -50,7 +50,7 @@
 
 \renewcommand*{\FV at SingleFrameSep}{}
 \def\FV at BUseVerbatim#1{%
-    \LWR at atbeginverbatim[\LWR at FVstyle]{verbatim}%
+    \LWR at atbeginverbatim[\LWR at FVstyle]{.5}{verbatim}%
     \FV at BVerbatimBegin#1\FV at BVerbatimEnd%
     \LWR at afterendverbatim%
 }
@@ -58,7 +58,7 @@
 \newcommand*{\LWR at FVstyle}{}
 \newcommand*{\LWR at fvstartnone}{%
 \LWR at traceinfo{fvstartnone}%
-\LWR at atbeginverbatim[\LWR at FVstyle]{verbatim}%
+\LWR at atbeginverbatim[\LWR at FVstyle]{.5}{verbatim}%
 }
 
 \newcommand*{\LWR at fvendnone}{%
@@ -98,7 +98,8 @@
 \newcommand*{\LWR at FVborderstyle}[1]{%
 padding#1: \strip at pt\dimexpr \FV at FrameSep\relax\relax pt ; %
 \LWR at FVfindbordercolor %
-border#1: \strip at pt\dimexpr \FV at FrameRule\relax\relax pt solid \#\LWR at tempcolor ; %
+border#1: \strip at pt\dimexpr \FV at FrameRule\relax\relax pt %
+solid \LWR at origpound\LWR at tempcolor ; %
 }
 
 \def\FV at Frame@none{%
@@ -167,7 +168,10 @@
         \ifx\FV at LabelPositionTopLine\relax
         \else
         \LWR at FVfindbordercolor
-        \LWR at htmltagc{div class="fancyvrblabel" style="color: \#\LWR at tempcolor"}
+        \LWR at htmltagc{%
+            div class="fancyvrblabel" % extra space
+                style="color: \LWR at origpound\LWR at tempcolor"%
+        }
         \LWR at origtextrm{\FV at LabelBegin}% \textrm preserves emdash
         \LWR at htmltagc{/div}
         \fi
@@ -176,7 +180,10 @@
         \else
         \LWR at FVfindbordercolor
 
-        \LWR at htmltagc{div class="fancyvrblabel" style="color: \#\LWR at tempcolor"}
+        \LWR at htmltagc{%
+            div class="fancyvrblabel" % extra space
+                style="color: \LWR at origpound\LWR at tempcolor"%
+        }
         \LWR at origtextrm{\FV at LabelEnd}
         \LWR at htmltagc{/div}
         \fi
@@ -199,7 +206,7 @@
 \AtBeginEnvironment{BVerbatim}
 {%
 \LWR at forcenewpage% instead of \preto
-\LWR at atbeginverbatim{bverbatim}%
+\LWR at atbeginverbatim{0}{bverbatim}%
 }
 
 \AfterEndEnvironment{BVerbatim}

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-framed.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-framed.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-framed.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -35,7 +35,7 @@
 \renewenvironment{shaded}{%
 \convertcolorspec{named}{shadecolor}{HTML}\LWR at tempcolor%
 \LWR at forcenewpage
-\BlockClass[background: \#\LWR at tempcolor]{shaded}%
+\BlockClass[background: \LWR at origpound\LWR at tempcolor]{shaded}%
 }
 {\endBlockClass}
 
@@ -42,7 +42,7 @@
 \renewenvironment{shaded*}{%
 \convertcolorspec{named}{shadecolor}{HTML}\LWR at tempcolor%
 \LWR at forcenewpage
-\BlockClass[background: \#\LWR at tempcolor]{shaded}%
+\BlockClass[background: \LWR at origpound\LWR at tempcolor]{shaded}%
 }
 {\endBlockClass}
 
@@ -57,7 +57,7 @@
 \renewenvironment{snugshade}{%
 \convertcolorspec{named}{shadecolor}{HTML}\LWR at tempcolor%
 \LWR at forcenewpage
-\BlockClass[background: \#\LWR at tempcolor]{snugframed}%
+\BlockClass[background: \LWR at origpound\LWR at tempcolor]{snugframed}%
 }
 {\endBlockClass}
 
@@ -64,7 +64,7 @@
 \renewenvironment{snugshade*}{%
 \convertcolorspec{named}{shadecolor}{HTML}\LWR at tempcolor%
 \LWR at forcenewpage
-\BlockClass[background: \#\LWR at tempcolor]{snugframed}%
+\BlockClass[background: \LWR at origpound\LWR at tempcolor]{snugframed}%
 }
 {\endBlockClass}
 
@@ -78,9 +78,9 @@
 \renewcommand{\CustomFBox}[7]{%
 \convertcolorspec{named}{TFFrameColor}{HTML}\LWR at tempcolor%
 \LWR at forcenewpage
-\begin{BlockClass}[border: 3px solid \#\LWR at tempcolor]{framed}%
+\begin{BlockClass}[border: 3px solid \LWR at origpound\LWR at tempcolor]{framed}%
 \ifthenelse{\isempty{#1}}{}{% not empty
-    \begin{BlockClass}[background: \#\LWR at tempcolor]{framedtitle}%
+    \begin{BlockClass}[background: \LWR at origpound\LWR at tempcolor]{framedtitle}%
     \textcolor{TFTitleColor}{\textbf{#1}}%
     \end{BlockClass}
 }% not empty
@@ -89,7 +89,7 @@
 
 \ifthenelse{\isempty{#2}}{}{% not empty
     \convertcolorspec{named}{TFFrameColor}{HTML}\LWR at tempcolor%
-    \begin{BlockClass}[background: \#\LWR at tempcolor]{framedtitle}%
+    \begin{BlockClass}[background: \LWR at origpound\LWR at tempcolor]{framedtitle}%
     \textcolor{TFTitleColor}{\textbf{#2}}%
     \end{BlockClass}
 }% not empty

Added: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-grid.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-grid.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-grid.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -0,0 +1,22 @@
+%%
+%% This is file `lwarp-grid.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% lwarp.dtx  (with options: `grid')
+%% This is a generated file.
+%% Copyright 2016-2018 Brian Dunn
+%% 
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+\LWR at ProvidesPackageDrop{grid}
+\newenvironment*{gridenv}{}{}
+\endinput
+%%
+%% End of file `lwarp-grid.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-grid.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-hyphenat.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-hyphenat.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-hyphenat.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -37,15 +37,15 @@
 \renewrobustcmd{\colonhyp}{:}
 \renewrobustcmd{\hyp}{-}
 
-\appto\LWR at restoreorigformatting{
-\LetLtxMacro\textnhtt\LWRHYNAT at origtextnhtt
-\LetLtxMacro\nhttfamily\LWRHYNAT at orignhttfamily
-\LetLtxMacro\nohyphens\LWRHYNAT at orignohyphens
-\LetLtxMacro\bshyp\LWRHYNAT at origbshyp
-\LetLtxMacro\fshyp\LWRHYNAT at origfshyp
-\LetLtxMacro\dothyp\LWRHYNAT at origdothyp
-\LetLtxMacro\colonhyp\LWRHYNAT at origcolonhyp
-\LetLtxMacro\hyp\LWRHYNAT at orighyp
+\appto\LWR at restoreorigformatting{%
+\LetLtxMacro\textnhtt\LWRHYNAT at origtextnhtt%
+\LetLtxMacro\nhttfamily\LWRHYNAT at orignhttfamily%
+\LetLtxMacro\nohyphens\LWRHYNAT at orignohyphens%
+\LetLtxMacro\bshyp\LWRHYNAT at origbshyp%
+\LetLtxMacro\fshyp\LWRHYNAT at origfshyp%
+\LetLtxMacro\dothyp\LWRHYNAT at origdothyp%
+\LetLtxMacro\colonhyp\LWRHYNAT at origcolonhyp%
+\LetLtxMacro\hyp\LWRHYNAT at orighyp%
 }
 \endinput
 %%

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-listings.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-listings.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-listings.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -30,13 +30,22 @@
 \renewcommand{\lst at Init}[1]{%
 \LWR at traceinfo{lst at Init}%
 \renewcommand*{\@captype}{lstlisting}%
-\LWR at origlst@Init{#1}%
+\let\lst at aboveskip\z@\let\lst at belowskip\z@%
+\gdef\lst at boxpos{t}%
+\let\lst at frame\@empty
+    \let\lst at frametshape\@empty
+    \let\lst at framershape\@empty
+    \let\lst at framebshape\@empty
+    \let\lst at framelshape\@empty
+\lstframe@\lst at frameround ffff\relax%
+\lst at multicols\@empty%
+\LWR at origlst@Init{#1}\relax%
 \LWR at traceinfo{finished origlst at Init}%
 \lst at ifdisplaystyle%
 \LWR at traceinfo{About to create verbatim.}%
 \let\lsthk at EveryPar\relax%
 \LWR at forcenewpage
-\LWR at atbeginverbatim{programlisting}%
+\LWR at atbeginverbatim{2.5}{programlisting}%
 
 \let\lsthk at EveryPar\LWR at origlsthkEveryPar%
 \else%

Added: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-ltxgrid.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-ltxgrid.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-ltxgrid.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -0,0 +1,26 @@
+%%
+%% This is file `lwarp-ltxgrid.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% lwarp.dtx  (with options: `ltxgrid')
+%% This is a generated file.
+%% Copyright 2016-2018 Brian Dunn
+%% 
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+\LWR at ProvidesPackageDrop{ltxgrid}
+\newcommand*{\onecolumngrid}{}
+\newcommand*{\twocolumngrid}{}
+\newcommand*{\removestuff}{}
+\newcommand*{\addstuff}[2]{}
+\newcommand*{\replacestuff}[2]{}
+\endinput
+%%
+%% End of file `lwarp-ltxgrid.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-ltxgrid.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-luatodonotes.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-luatodonotes.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-luatodonotes.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -93,7 +93,7 @@
 }%
 
 \DeclareDocumentCommand{\todonotes at textmark@highlight}{m}{%
-\InlineClass[background:\#B3FFB3]{highlight}{#1}%
+\InlineClass[background:\LWR at origpound{}B3FFB3]{highlight}{#1}%
 }
 
 \fi% \if at todonotes@disabled

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-mdframed.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-mdframed.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-mdframed.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -43,7 +43,7 @@
 }
 \newcommand*{\LWR at mdfprintcolor}[1]{%
 \convertcolorspec{named}{\csuse{mdf@#1}}{HTML}\LWR at tempcolor%
-\#\LWR at tempcolor
+\LWR at origpound\LWR at tempcolor
 }
 
 \newcommand*{\LWR at mdfprintlength}[1]{%

Added: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-mhchem.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-mhchem.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-mhchem.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -0,0 +1,72 @@
+%%
+%% This is file `lwarp-mhchem.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% lwarp.dtx  (with options: `mhchem')
+%% This is a generated file.
+%% Copyright 2016-2018 Brian Dunn
+%% 
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% 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.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+
+\LWR at ProvidesPackagePass{mhchem}
+
+\LetLtxMacro\LWR at mhchem@origce\ce
+
+\newcommand{\LWR at mhchem@HTML at ce}[1]{%
+\begin{lateximage}*[\textbackslash{}ce\{\LWR at HTMLsanitize{#1}\}]%
+\LWR at mhchem@origce{#1}%
+\end{lateximage}%
+\endgroup%
+\addtocounter{LWR at mhchem@cedepth}{-1}%
+}
+
+\newcounter{LWR at mhchem@cedepth}
+\setcounter{LWR at mhchem@cedepth}{0}
+
+\renewcommand{\ce}{%
+\begingroup%
+\ifnumequal{\value{LWR at mhchem@cedepth}}{0}{%
+    \catcode`\$=3% math shift
+}{}%
+\addtocounter{LWR at mhchem@cedepth}{1}%
+\LWR at mhchem@HTML at ce%
+}
+
+\LetLtxMacro\LWR at mhchem@origcesplit\cesplit
+
+\newcommand*{\LWR at mhchem@HTML at cesplit}[2]
+{%
+\begin{lateximage}*[\textbackslash{}cesplit\{\LWR at HTMLsanitize{#2}\}]%
+\LWR at mhchem@origcesplit{#1}{#2}%
+\end{lateximage}%
+\endgroup%
+}
+
+\newcounter{LWR at mhchem@cesplitdepth}
+\setcounter{LWR at mhchem@cesplitdepth}{0}
+
+\renewcommand{\cesplit}{%
+\begingroup%
+\ifnumequal{\value{LWR at mhchem@cesplitdepth}}{0}{%
+    \catcode`\$=3% math shift
+}{}%
+\addtocounter{LWR at mhchem@cesplitdepth}{1}%
+\LWR at mhchem@HTML at cesplit%
+}
+
+\appto\LWR at restoreorigformatting{%
+\LetLtxMacro\ce\LWR at mhchem@origce%
+\LetLtxMacro\cesplit\LWR at mhchem@origcesplit%
+}
+
+\endinput
+%%
+%% End of file `lwarp-mhchem.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-mhchem.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-moreverb.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-moreverb.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-moreverb.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -19,7 +19,7 @@
 \LWR at ProvidesPackagePass{moreverb}
 \BeforeBeginEnvironment{verbatimtab}{%
 \LWR at forcenewpage
-\LWR at atbeginverbatim{Verbatim}\unskip\LWR at origvspace*{-\baselineskip}%
+\LWR at atbeginverbatim{3.5}{Verbatim}%
 }
 \AfterEndEnvironment{verbatimtab}{%
 \LWR at afterendverbatim%
@@ -29,7 +29,7 @@
 
 \renewcommand{\@verbatimtabinput}[2][]{%
 \LWR at forcenewpage
-\LWR at atbeginverbatim{Verbatim}\unskip\LWR at origvspace*{-\baselineskip}%
+\LWR at atbeginverbatim{3.5}{Verbatim}%
 \LWRMV at orig@verbatimtabinput[#1]{#2}%
 \LWR at afterendverbatim%
 }
@@ -36,7 +36,7 @@
 
 \BeforeBeginEnvironment{listing}{%
 \LWR at forcenewpage
-\LWR at atbeginverbatim{programlisting}\unskip\LWR at origvspace*{-\baselineskip}%
+\LWR at atbeginverbatim{3.5}{programlisting}%
 }
 
 \AfterEndEnvironment{listing}{%
@@ -45,7 +45,7 @@
 
 \BeforeBeginEnvironment{listingcont}{%
 \LWR at forcenewpage
-\LWR at atbeginverbatim{programlisting}\unskip\LWR at origvspace*{-\baselineskip}%
+\LWR at atbeginverbatim{3.5}{programlisting}%
 }
 
 \AfterEndEnvironment{listingcont}{%
@@ -57,7 +57,7 @@
 
 \renewcommand{\@listinginput}[3][]{
 \LWR at forcenewpage
-\LWR at atbeginverbatim{programlisting}\unskip\LWR at origvspace*{-\baselineskip}%
+\LWR at atbeginverbatim{3.5}{programlisting}%
 \LWRMV@@listinginput[#1]{#2}{#3}
 \LWR at afterendverbatim%
 }
@@ -65,7 +65,7 @@
 \renewenvironment*{boxedverbatim}
 {
 \LWR at forcenewpage
-\LWR at atbeginverbatim{boxedverbatim}\unskip\LWR at origvspace*{-2\baselineskip}%
+\LWR at atbeginverbatim{3.5}{boxedverbatim}%
 \verbatim%
 }
 {

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-multirow.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-multirow.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-multirow.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -62,7 +62,7 @@
 \addtocounter{LWR at tablecolindex}{-1}%
 \booltrue{LWR at skipatbang}%
 }
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \LetLtxMacro\multirow\LWR at origmultirow%
 \renewcommand{\multicolumnrow}{\LWR at origmulticolumnrow}%
 }

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-phfqit.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-phfqit.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-phfqit.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -26,8 +26,8 @@
 ]{bitstring}{#1}%
 }
 
-\appto{\LWR at restoreorigformatting}{
-\LetLtxMacro\bitstring\LWR at origbitstring
+\appto\LWR at restoreorigformatting{%
+\LetLtxMacro\bitstring\LWR at origbitstring%
 }
 
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-relsize.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-relsize.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-relsize.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -25,7 +25,7 @@
 \LetLtxMacro\LWR at origtextsmaller\textsmaller
 \let\LWR at textscale\textscale
 
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \let\relsize\LWR at origrelsize%
 \LetLtxMacro\larger\LWR at origlarger%
 \LetLtxMacro\smaller\LWR at origsmaller%

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-siunitx.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-siunitx.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-siunitx.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -97,7 +97,9 @@
       \__siunitx_unit_output_pre_print:
         \LWR at subsingledollar{% lwarp
             \textbackslash( \LWR at HTMLsanitize{#1} \textbackslash)% lwarp
-        }{\__siunitx_print:nn { number } { #1 }}% lwarp
+        }{siunitx}{\__siunitx_print:nn { number } {
+            \LWR at origensuredmath{#1}
+        }}% lwarp
       \__siunitx_unit_output_print:
     }
     \group_end:% lwarp

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-soul.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-soul.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-soul.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -36,7 +36,7 @@
 {\LWR at HTMLtextstyle{#5}{#3}{#1}}%
 {%
     \convertcolorspec{named}{\csuse{#2}}{HTML}\LWR at tempcolor%
-    \LWR at htmlspanclass[#5;#4:\#\LWR at tempcolor]{#3}{#1}%
+    \LWR at htmlspanclass[#5;#4:\LWR at origpound\LWR at tempcolor]{#3}{#1}%
 }%
 }
 
@@ -52,7 +52,7 @@
 
 \newcommand{\hl}[1]{
 \LWR at soulcolor{#1}{LWR at soulhlcolor}{highlight}{background-color}%
-    {background:\#F8E800}
+    {background:\LWR at origpound{}F8E800}
 }
 \newcommand*{\soulaccent}[1]{}
 \newcommand*{\soulregister}[2]{}

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-textcomp.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-textcomp.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-textcomp.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -107,7 +107,7 @@
 \InlineClass[border: 1px solid \LWR at currenttextcolor]{textcircled}{#1}%
 }
 }% AtBeginDocument
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \let\textdegree\LWR at origtextdegree%
 \let\textcelsius\LWR at origtextcelsius%
 \let\textohm\LWR at origtextohm%

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-tikz.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-tikz.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-tikz.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -25,18 +25,21 @@
 {\usetikzlibrary{babel}\booltrue{LWR at tikzbabel}}
 {\boolfalse{LWR at tikzbabel}}
 
-\BeforeBeginEnvironment{tikzpicture}{%
-\begin{lateximage}%
-\ifbool{LWR at tikzbabel}% Test for Tikz version v3.0.0
-{}%
-{\catcode`\$=3}% dollar sign is math shift
+\LetLtxMacro\LWR at origtikzpicture\tikzpicture
+
+\renewcommand*{\tikzpicture}[1][]{%
+    \begin{lateximage}%
+    \ifbool{LWR at tikzbabel}% Test for Tikz version v3.0.0
+    {}%
+    {\catcode`\$=3}% dollar sign is math shift
+    \LWR at origtikzpicture[#1]%
 }
 
-\AfterEndEnvironment{tikzpicture}{%
-\end{lateximage}%
-\ifbool{LWR at tikzbabel}% Test for Tikz version v3.0.0
-{}%
-{\catcode`\$=\active}%
+\LetLtxMacro\LWR at origendtikzpicture\endtikzpicture
+
+\renewcommand*{\endtikzpicture}{%
+    \LWR at origendtikzpicture%
+    \end{lateximage}%
 }
 
 \endinput

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-titling.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-titling.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-titling.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -57,6 +57,11 @@
 ##1%
 }% \@makefntext
 }
+\renewcommand{\thanksfootmark}{%
+        \thanksscript{%
+            \thanksfootpre \tamark \thanksfootpost%
+        }%
+}
 \renewcommand*{\maketitle}{%
 \begin{titlepage}
 \@bsmarkseries

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-verse.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-verse.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-verse.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -27,8 +27,7 @@
 \setlength{\leftmargini}{\HTMLleftmargini}
 }{}
 \LWR at forcenewpage
-\LWR at atbeginverbatim{verse}
-\unskip\LWR at origvspace{-\baselineskip}
+\LWR at atbeginverbatim{3.5}{verse}%
 }
 \AtEndEnvironment{verse}{
 \LWR at afterendverbatim

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-vwcol.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-vwcol.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-vwcol.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -19,7 +19,7 @@
 \newcommand*{\LWR at vwcol@addrule}[1]{%
     \appto{\LWR at vwcolstyle}{%
         #1: %
-        \LWR at printlength{\vwcol at rule} solid \#\LWR at vwcol@rulecolor ; %
+        \LWR at printlength{\vwcol at rule} solid \LWR at origpound\LWR at vwcol@rulecolor ; %
     }%
 }
 

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-xcolor.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-xcolor.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-xcolor.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -28,7 +28,7 @@
 \LetLtxMacro\LWRorigprint at fcolorbox\fcolorbox
 \LetLtxMacro\LWRorigprint at fcolorboxBlock\fcolorbox
 \LetLtxMacro\LWRorigprint at boxframe\boxframe
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \LetLtxMacro\textcolor\LWRprint at textcolor%
 \LetLtxMacro\pagecolor\LWRprint at pagecolor%
 \LetLtxMacro\nopagecolor\LWRprint at nopagecolor%
@@ -36,9 +36,7 @@
 \LetLtxMacro\fcolorbox\LWRprint at fcolorbox%
 \LetLtxMacro\boxframe\LWRorigprint at boxframe%
 }
-\newcommand*{\LWR at tempcolor}{}
-\newcommand*{\LWR at tempcolortwo}{}
-\newcommand*{\LWR at findcurrenttextcolor}{%
+\renewcommand*{\LWR at findcurrenttextcolor}{%
 \protect\colorlet{LWR at current@color}{.}%
 \protect\convertcolorspec{named}{LWR at current@color}{HTML}\LWR at tempcolor%
 }
@@ -47,14 +45,14 @@
 \LWR at findcurrenttextcolor%
 \ifdefstring{\LWR at tempcolor}{000000}%
 {}%
-{color: \#\LWR at tempcolor ; }%
+{color: \LWR at origpound\LWR at tempcolor ; }%
 }
-\newcommand*{\LWR at textcurrentcolor}[1]{%
+\DeclareDocumentCommand{\LWR at textcurrentcolor}{m}{%
 \begingroup%
 \LWR at FBcancel%
 \LWR at findcurrenttextcolor%
-\InlineClass[color:\#\LWR at tempcolor]{textcolor}{%
-    \renewcommand*{\LWR at currenttextcolor}{\#\LWR at tempcolor}%
+\InlineClass[color:\LWR at origpound\LWR at tempcolor]{textcolor}{%
+    \renewcommand*{\LWR at currenttextcolor}{\LWR at origpound\LWR at tempcolor}%
     #1%
 }%
 \endgroup%
@@ -63,7 +61,7 @@
 \begingroup%
 \LWR at FBcancel%
 \convertcolorspec{#1}{#2}{HTML}\LWR at tempcolor%
-\#\LWR at tempcolor%
+\LWR at origpound\LWR at tempcolor%
 \endgroup%
 }
 \NewDocumentCommand{\LWR at backgroundcolor}{O{named} m m}{%
@@ -78,13 +76,25 @@
 border:\LWR at printlength{\LWR at atleastonept} solid \LWR at colorstyle{#1}{#2} ; %
 padding:\LWR at printlength{\fboxsep}%
 }
-\RenewDocumentCommand{\textcolor}{O{named} m m}{%
+\RenewDocumentCommand{\textcolor}{o m m}{%
 \begingroup%
+\IfValueTF{#1}{%
+    \color[#1]{#2}%
+}{%
+    \color{#2}%
+}%
 \LWR at FBcancel%
+\IfValueTF{#1}{%
 \InlineClass[color:\LWR at colorstyle{#1}{#2}]{textcolor}{%
-\renewcommand*{\LWR at currenttextcolor}{\#\LWR at tempcolor}%
+\renewcommand*{\LWR at currenttextcolor}{\LWR at origpound\LWR at tempcolor}%
 #3%
 }%
+}{%
+\InlineClass[color:\LWR at colorstyle{named}{#2}]{textcolor}{%
+\renewcommand*{\LWR at currenttextcolor}{\LWR at origpound\LWR at tempcolor}%
+#3%
+}%
+}%
 \endgroup%
 }
 
@@ -150,7 +160,7 @@
 {% yes background color
     \convertcolorspec{#3}{#4}{HTML}\LWR at tempcolortwo%
     \begin{BlockClass}[%
-    background:\#\LWR at tempcolortwo\ ; %
+    background:\LWR at origpound\LWR at tempcolortwo\ ; %
     \LWR at borderpadding{#1}{#2}%
     ]{fcolorboxBlock}
     #5
@@ -179,7 +189,7 @@
 {\LWR at subfcolorminipage{#1}{#2}{}{#6}}%
 {%
     \convertcolorspec{#3}{#4}{HTML}\LWR at tempcolortwo%
-    \LWR at subfcolorminipage{#1}{#2}{background:\#\LWR at tempcolortwo\ ; }{#6}%
+    \LWR at subfcolorminipage{#1}{#2}{background:\LWR at origpound\LWR at tempcolortwo\ ; }{#6}%
 }%
 }
 {\end{BlockClass}}

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-xy.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-xy.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-xy.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -20,7 +20,7 @@
 
 \AtBeginDocument{
 
-\preto{\xy}{\begin{lateximage}[xy image]}
+\preto{\xy}{\begin{lateximage}[(xy)]}
 \appto{\endxy}{\end{lateximage}}
 
 \@ifundefined{xymatrix}{}{
@@ -27,7 +27,7 @@
 \LetLtxMacro\LWR at origxymatrix\xymatrix
 
 \renewcommand{\xymatrix}[1]{%
-\begin{lateximage}[xymatrix]
+\begin{lateximage}[(xymatrix)]
 \LWR at origxymatrix{#1}
 \end{lateximage}
 }
@@ -37,7 +37,7 @@
 \LetLtxMacro\LWR at origxygraph\xygraph
 
 \renewcommand{\xygraph}[1]{%
-\begin{lateximage}[xygraph]
+\begin{lateximage}[(xygraph)]
 \LWR at origxygraph{#1}
 \end{lateximage}
 }

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-zwpagelayout.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-zwpagelayout.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp-zwpagelayout.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -61,7 +61,7 @@
 \def\UserRightMargin{1in}
 \def\UserTopMargin{1in}
 \def\UserBotMargin{1in}
-\def\thePageNumber{\#\,\arabic{page}}
+\def\thePageNumber{\LWR at origpound\,\arabic{page}}
 \ifXeTeX
 \def\ifcaseZWdriver{\ifcase2}
 \else

Modified: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp.sty	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp.sty	2018-03-25 21:28:55 UTC (rev 47115)
@@ -17,7 +17,7 @@
 %% version 2005/12/01 or later.
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{lwarp}
-    [2018/03/03 v0.50  Allows LaTeX to directly produce HTML5 output.]
+    [2018/03/24 v0.51  Allows LaTeX to directly produce HTML5 output.]
 
 
 
@@ -113,6 +113,7 @@
 \newbool{warpingprint}
 \newbool{warpingHTML}
 \newbool{mathjax}
+\newbool{LWR at origmathjax}
 \booltrue{warpingprint}%
 \boolfalse{warpingHTML}%
 \boolfalse{mathjax}%
@@ -131,10 +132,12 @@
 \DeclareVoidOption{mathsvg}{%
 \PackageInfo{lwarp}{Using option 'mathsvg'}
 \boolfalse{mathjax}%
+\boolfalse{LWR at origmathjax}%
 }
 \DeclareVoidOption{mathjax}{%
 \PackageInfo{lwarp}{Using option 'mathjax'}
 \booltrue{mathjax}%
+\booltrue{LWR at origmathjax}%
 }
 
 \DeclareStringOption[\jobname]{BaseJobname}
@@ -276,6 +279,11 @@
 \LWR at notmemoirloadafter{chngpage}
 \LWR at loadafter{chappg}
 \LWR at loadafter{chapterbib}
+\LWR at loadafter{chemfig}
+\LWR at loadafter{chemformula}
+\LWR at loadafter{chemgreek}
+\LWR at loadafter{chemmacros}
+\LWR at loadafter{chemnum}
 \LWR at loadafter{cite}
 \LWR at loadafter{color}
 \LWR at loadafter{colortbl}
@@ -299,6 +307,7 @@
 \LWR at loadafter{enumitem}
 \LWR at notmemoirloadafter{epigraph}
 \LWR at loadafter{epstopdf}
+\LWR at loadafter{epstopdf-base}
 \LWR at loadafter{eso-pic}
 \LWR at loadafter{everypage}
 \LWR at loadafter{everyshi}
@@ -334,6 +343,7 @@
 \LWR at loadafter{geometry}
 \LWR at loadafter{glossaries}
 \LWR at loadafter{grffile}
+\LWR at loadafter{grid}
 \LWR at loadafter{hang}
 \LWR at loadafter{hanging}
 \LWR at loadafter{hypcap}
@@ -355,6 +365,7 @@
 \LWR at loadafter{longtable}
 \LWR at loadafter{lscape}
 \LWR at loadafter{ltcaption}
+\LWR at loadafter{ltxgrid}
 \LWR at loadafter{ltxtable}
 \LWR at loadafter{luacolor}
 \LWR at loadafter{luatodonotes}
@@ -365,6 +376,7 @@
 \LWR at loadafter{mdframed}
 \LWR at loadafter{memhfixc}
 \LWR at loadafter{metalogo}
+\LWR at loadafter{mhchem}
 \LWR at loadafter{microtype}
 \LWR at loadafter{midfloat}
 \LWR at loadafter{midpage}
@@ -511,10 +523,6 @@
 
 \RequirePackage{xparse}
 
-\@ifundefined{AfterPackage}%
-{
-\RequirePackage{afterpackage}
-}{}
 
 \end{warpall}
 
@@ -898,7 +906,7 @@
 
 \LetLtxMacro\LWR at origmbox\mbox
 \LetLtxMacro\LWR at origmakebox\makebox
-
+\chardef\LWR at origpound=`\#
 \let\LWR at origcomma\,
 \let\LWR at origtilde~
 \let\LWR at origenskip\enskip
@@ -1050,12 +1058,12 @@
 \LetLtxMacro{\c}{\LWR at origc}%
 \LetLtxMacro{\d}{\LWR at origd}%
 \LetLtxMacro{\b}{\LWR at origb}%
-}
+}%
 \else% XeLaTeX, LuaLaTeX:
 \newcommand*{\LWR at restoreorigaccents}{%
 \LetLtxMacro{\t}{\LWR at origt}%
-}
-\fi
+}%
+\fi%
 }% AtBeginDocument
 \end{warpHTML}
 
@@ -2085,7 +2093,9 @@
 div.flushright table {margin-left:auto ; margin-right: 0em ;}
 
 /* Fancybox */
-div.Btrivlist table tr td { padding: .2ex 0em ; }
+div.Btrivlist table tr td {
+    padding: .2ex 0em ;
+}
 
 /* program listing callouts: */
 span.callout {
@@ -2201,12 +2211,11 @@
 div.lateximagesource { padding: 0px ; margin: 0px ; display: none; }
 
 img.lateximage{
-    padding: 0px 0px 0px 0px ;
+    padding: 0pt ;
+    margin: 0pt ;
     box-shadow: none ;
     border: none ;
     background: none ;
-    margin: 0px 0px -.15ex 0px ;
-        /* pdfcrop leaves a slight margin, adjust to baseline */
     max-width: 100% ;
     border-radius: 0ex ;
     border: none ;
@@ -2934,11 +2943,11 @@
 \begin{warpprint}
 \begin{filecontents*}{lwarp_one_limage.txt}
 @echo off
-pdfseparate -f %1 -l %1 %4_html.pdf lateximages\lateximagetemp-%%d.pdf"
-pdfcrop  lateximages\lateximagetemp-%1.pdf lateximages\%3.pdf
-pdftocairo -svg lateximages\%3.pdf lateximages\%3.svg
+pdfseparate -f %1 -l %1 %4_html.pdf lateximages\lateximagetemp-%%d.pdf
+pdfcrop  --hires  lateximages\lateximagetemp-%1.pdf lateximages\%3.pdf
+pdftocairo  -svg -noshrink  lateximages\%3.pdf lateximages\%3.svg
 del lateximages\%3.pdf
-del lateximages\lateximagetemp-%1.pdf"
+del lateximages\lateximagetemp-%1.pdf
 exit
 \end{filecontents*}
 \end{warpprint}
@@ -3057,7 +3066,7 @@
 
 -- Print the usage of the lwarpmk command:
 
-printversion = "v0.50"
+printversion = "v0.51"
 
 function printhelp ()
 print ("lwarpmk: Use lwarpmk -h or lwarpmk --help for help.") ;
@@ -3421,11 +3430,11 @@
     "lateximages" .. dirslash .."lateximagetemp-%d" .. ".pdf" ..
     seqname ..
 -- Crop the image:
-"pdfcrop  lateximages" .. dirslash .. "lateximagetemp-" .. lwimgpage .. ".pdf " ..
+"pdfcrop  --hires  lateximages" .. dirslash .. "lateximagetemp-" .. lwimgpage .. ".pdf " ..
     "lateximages" .. dirslash .. lwimgname .. ".pdf" ..
     seqname ..
 -- Convert the image to svg:
-"pdftocairo -svg lateximages" .. dirslash .. lwimgname .. ".pdf " ..
+"pdftocairo -svg  -noshrink  lateximages" .. dirslash .. lwimgname .. ".pdf " ..
     "lateximages" .. dirslash .. lwimgname ..".svg" ..
     seqname ..
 -- Remove the temporary files:
@@ -3831,7 +3840,7 @@
 \LWR at origampersand#1;%
 \endgroup
 }
-\newcommand*{\HTMLunicode}[1]{\HTMLentity{\#x#1}}
+\newcommand*{\HTMLunicode}[1]{\HTMLentity{\LWR at origpound{}x#1}}
 
 \renewrobustcmd*{\&}{\HTMLentity{amp}}
 
@@ -4042,7 +4051,7 @@
     \renewrobustcmd*{\FBthinspace}{%
         \begingroup%
         \LWR at FBcancel%
-        \LWR at origampersand\#x202f;% \,
+        \LWR at origampersand\LWR at origpound{}x202f;% \,
         \endgroup%
     }%
     \renewrobustcmd*{\FBguillspace}{%
@@ -4054,7 +4063,7 @@
     \DeclareDocumentCommand{\FBmedkern}{}{%
         \begingroup%
         \LWR at FBcancel%
-        \LWR at origampersand\#x202f;% \,
+        \LWR at origampersand\LWR at origpound{}x202f;% \,
         \endgroup%
     }%
     \DeclareDocumentCommand{\FBthickkern}{}{%
@@ -4133,7 +4142,7 @@
 }
 
 \NewDocumentCommand{\LWR at htmlspanclass}{o m +m}{%
-\LWR at traceinfo{LWR at htmlspanclass #2}%
+\LWR at traceinfo{LWR at htmlspanclass |#1|#2|}%
 \LWR at ensuredoingapar%
 \LWR at subhtmlelementclass{span}[#1]{#2}%
 \begin{LWR at nestspan}%
@@ -4187,7 +4196,7 @@
 
 
 \NewDocumentCommand{\LWR at subhtmlelementclass}{m O{} m}{%
-\LWR at traceinfo{LWR at subhtmlelementclass #1 #3}%
+\LWR at traceinfo{LWR at subhtmlelementclass !#1!#2!#3!}%
 \ifblank{#2}%
 {\LWR at htmltag{#1 class="#3"}}% empty option
 {\LWR at htmltag{#1 class="#3" style="#2"}}% non-empty option
@@ -4711,7 +4720,7 @@
     {\textless}{-}[\LWR at thisnewfilename]
 \StrSubstitute{\LWR at thisnewfilename}%
     {\textgreater}{-}[\LWR at thisnewfilename]
-\StrSubstitute{\LWR at thisnewfilename}{\#}{-}[\LWR at thisnewfilename]
+\StrSubstitute{\LWR at thisnewfilename}{\LWR at origpound}{-}[\LWR at thisnewfilename]
 \StrSubstitute{\LWR at thisnewfilename}{\_}{-}[\LWR at thisnewfilename]
 \StrSubstitute{\LWR at thisnewfilename}{\ }{-}[\LWR at thisnewfilename]
 \StrSubstitute{\LWR at thisnewfilename}{\%}{-}[\LWR at thisnewfilename]
@@ -4766,6 +4775,18 @@
 }%
 }
 
+\newcommand{\LWR at nullifymathjaxensuremath}{%
+\ifbool{mathjax}{
+\LWR at stoppars
+\LWR at htmlcomment{Nullify \textbackslash{}ensuremath for MathJax:}
+
+\(
+\newcommand\ensuremath[1]{##1}
+\)
+\LWR at startpars
+}{}
+}
+
 \newcommand*{\LWR at newhtmlfile}[1]{
 \LWR at traceinfo{LWR at newhtmlfile}
 
@@ -4839,6 +4860,7 @@
 
 \LWR at stoppars
 
+\LWR at nullifymathjaxensuremath
 \LWR at traceinfo{LWR at newhtmlfile: done}
 }
 
@@ -5264,6 +5286,7 @@
 \immediate\write\@mainaux{\catcode`\string$\active}%
 \LetLtxMacro\LWR at syntaxhighlightone$% balance for editor syntax highlighting
 \LWR at startpars
+\LWR at nullifymathjaxensuremath
 \LWR at traceinfo{LWR at lwarpStart: done}
 }
 \catcode`\$=3% math shift until lwarp starts
@@ -5475,41 +5498,38 @@
 \end{warpHTML}
 \begin{warpall}
 
-\AfterPackage{titling}{
 \newcommand*{\AddSubtitlePublished}{%
-
-\newcommand{\@published}{}
-
-\newcommand{\published}[1]{\gdef\@published{##1}}
-
-\renewcommand*{\maketitlehooka}{\printpublished}
-
-\newcommand*{\printpublished}{%
-\warpprintonly{\begin{center}\unskip}%
-\begin{BlockClass}{published}%
-\warpprintonly{\large\itshape}%
-\@published%
-\end{BlockClass}%
-\warpprintonly{\end{center}}%
-}
-
-\newcommand{\@subtitle}{}
-
-\newcommand{\subtitle}[1]{\gdef\@subtitle{##1}}
-
-\renewcommand*{\maketitlehookb}{\printsubtitle}
-
-\newcommand*{\printsubtitle}{%
-\warpprintonly{\begin{center}\unskip}%
-\begin{BlockClass}{subtitle}%
-\warpprintonly{\Large\itshape}%
-\@subtitle%
-\end{BlockClass}%
-\warpprintonly{\end{center}}%
-}
-
+\@ifpackageloaded{titling}{% yes titling package
+    \newcommand{\@published}{}%
+    \newcommand{\published}[1]{\gdef\@published{##1}}%
+    \renewcommand*{\maketitlehooka}{\printpublished}%
+    \newcommand*{\printpublished}{%
+        \warpprintonly{\begin{center}\unskip}%
+        \begin{BlockClass}{published}%
+        \warpprintonly{\large\itshape}%
+        \@published%
+        \end{BlockClass}%
+        \warpprintonly{\end{center}}%
+    }%
+    \newcommand{\@subtitle}{}%
+    \newcommand{\subtitle}[1]{\gdef\@subtitle{##1}}%
+    \renewcommand*{\maketitlehookb}{\printsubtitle}%
+    \newcommand*{\printsubtitle}{%
+        \warpprintonly{\begin{center}\unskip}%
+        \begin{BlockClass}{subtitle}%
+        \warpprintonly{\Large\itshape}%
+        \@subtitle%
+        \end{BlockClass}%
+        \warpprintonly{\end{center}}%
+    }%
+}% yes titling package
+{% no titling package
+    \newcommand{\published}[1]{}%
+    \newcommand*{\printpublished}{}%
+    \newcommand{\subtitle}{}%
+    \newcommand*{\printsubtitle}%
+}% no titling package
 }% \AddSubtitlePublished
-}% AfterPackage
 
 \end{warpall}
 
@@ -5588,14 +5608,16 @@
 \newbool{LWR at verbtags}
 \booltrue{LWR at verbtags}
 
-\newcommand*{\LWR at atbeginverbatim}[2][]
+\newcommand*{\LWR at atbeginverbatim}[3][]
 {%
 \setlength{\parskip}{0ex}%
 \LWR at stoppars%
 \ifbool{LWR at verbtags}{%
-    \LWR at htmltag{pre class="#2"
-    \ifthenelse{\equal{#1}{}}{}{style="#1"}%
-}\LWR at orignewline% pre
+    \LWR at htmltag{pre class="#3"
+        \ifthenelse{\equal{#1}{}}{}{style="#1"}%
+    }%
+    \unskip\LWR at origvspace*{-#2\baselineskip}%
+    \LWR at orignewline% pre
 }{}%
 \begingroup%
 \LWR at orignormalsize%
@@ -5618,7 +5640,7 @@
 
 \renewcommand{\verbatim at input}[2]{%
 \ifbool{LWR at verbtags}{\LWR at forcenewpage}{}%
-\LWR at atbeginverbatim{Verbatim}\unskip\LWR at origvspace*{-\baselineskip}%%
+\LWR at atbeginverbatim{3.5}{Verbatim}%
 \LWRV at origverbatim@input{#1}{#2}%
 \unskip\LWR at origvspace*{-\baselineskip}\LWR at afterendverbatim%
 }
@@ -5627,7 +5649,8 @@
 \LWR at traceinfo{Patching verbatim.}
 \AtBeginEnvironment{verbatim}{%
 \LWR at forcenewpage%
-\LWR at atbeginverbatim{verbatim}\unskip\LWR at origvspace*{-2\baselineskip}%
+\LWR at atbeginverbatim{.5}{verbatim}%
+\unskip\LWR at origvspace*{-1.5\baselineskip}%
 }
 \AfterEndEnvironment{verbatim}{%
     \unskip\LWR at origvspace*{-\baselineskip}\LWR at afterendverbatim%
@@ -5638,7 +5661,7 @@
 \LWR at traceinfo{Patching tabbing.}
 \AtBeginEnvironment{tabbing}{%
 \LWR at forcenewpage
-\LWR at atbeginverbatim{tabbing}\unskip\LWR at origvspace*{-\baselineskip}%
+\LWR at atbeginverbatim{3.5}{tabbing}%
 }
 \AfterEndEnvironment{tabbing}{%
     \unskip\LWR at origvspace*{-\baselineskip}\LWR at afterendverbatim%
@@ -5710,7 +5733,7 @@
       \refstepcounter\@listctr
     \fi
   \fi
-    \makelabel{#1}%
+    \makelabel{#1} % extra space
   \ignorespaces%
 }
 
@@ -6288,7 +6311,7 @@
         }{%
             \LWR at htmltag{%
                 tr class="hline" %
-                style="border-top: 1px solid \#\LWR at ruleHTMLcolor "%
+                style="border-top: 1px solid \LWR at origpound\LWR at ruleHTMLcolor "%
             }%
         }%
         \LWR at orignewline%
@@ -6301,7 +6324,7 @@
             }{%
                 \LWR at htmltag{%
                     tr class="tbrule" %
-                    style="border-top: 1px solid \#\LWR at ruleHTMLcolor "%
+                    style="border-top: 1px solid \LWR at origpound\LWR at ruleHTMLcolor "%
                 }%
             }%
             \LWR at orignewline%
@@ -6529,14 +6552,14 @@
     border-top:\LWR at printlength{\LWR at atleastonept} solid %
     \ifdefvoid{\LWR at ruleHTMLcolor}{%
         \ifdimcomp{#1}{<}{\LWR at lightrulewidth}%
-        {\#A0A0A0}%
+        {\LWR at origpound{}A0A0A0}%
         {% lightrule or heaver
             \ifdimcomp{#1}{<}{\LWR at heavyrulewidth}%
-            {\#808080}%
+            {\LWR at origpound{}808080}%
             {black}%
         }% lightrule or heavier
     }{%
-        \#\LWR at ruleHTMLcolor%
+        \LWR at origpound\LWR at ruleHTMLcolor%
     }
 }% custom width and/or color
 }
@@ -6571,12 +6594,12 @@
         \ifdefvoid{\LWR at xcolorrowHTMLcolor}{}%
         {% xcolor row color
             \LWR at tdaddstyle%
-            background:\#\LWR at xcolorrowHTMLcolor%
+            background:\LWR at origpound\LWR at xcolorrowHTMLcolor%
         }%
     }%
     {% explicit row color
         \LWR at tdaddstyle%
-        background:\#\LWR at rowHTMLcolor%
+        background:\LWR at origpound\LWR at rowHTMLcolor%
     }%
 }%
 }
@@ -6589,7 +6612,7 @@
     \ifdefvoid{\LWR at ruleHTMLcolor}{}%
     {%
         \LWR at tdaddstyle%
-        border-top: 1px solid \#\LWR at ruleHTMLcolor%
+        border-top: 1px solid \LWR at origpound\LWR at ruleHTMLcolor%
     }{}%
 }{}%
 }
@@ -6601,13 +6624,13 @@
         \edef\LWR at tempone{\LWR at getexparray{LWR at colbarspec}{leftedge}}%
         \ifdefstring{\LWR at tempone}{tvertbarl}{%
                 \LWR at tdaddstyle%
-                border-left: 1px solid \#\LWR at vertruleHTMLcolor%
+                border-left: 1px solid \LWR at origpound\LWR at vertruleHTMLcolor%
         }{}%
     }{}%
     \edef\LWR at tempone{\LWR at getexparray{LWR at colbarspec}{\arabic{LWR at tablecolindex}}}%
     \ifdefstring{\LWR at tempone}{tvertbarr}{%
             \LWR at tdaddstyle%
-            border-right: 1px solid \#\LWR at vertruleHTMLcolor%
+            border-right: 1px solid \LWR at origpound\LWR at vertruleHTMLcolor%
     }{}%
 }%
 }
@@ -6616,7 +6639,7 @@
 
 \newcommand*{\LWR at subaddtabularcellcolor}[1]{%
 \LWR at htmltag{div class="cellcolor" style="%
-    background:\#{}#1 %
+    background:\LWR at origpound{}{}#1 %
 " }%
 \addtocounter{LWR at cellcolordepth}{1}%
 }
@@ -6734,11 +6757,11 @@
 \ifbool{LWR at tabularmutemods}{}{%
     \ifbool{LWR at mcolvertbarl}{%
         \LWR at tdaddstyle%
-        border-left: 1px solid \#\LWR at vertruleHTMLcolor%
+        border-left: 1px solid \LWR at origpound\LWR at vertruleHTMLcolor%
     }{}%
     \ifbool{LWR at mcolvertbarr}{%
         \LWR at tdaddstyle%
-        border-right: 1px solid \#\LWR at vertruleHTMLcolor%
+        border-right: 1px solid \LWR at origpound\LWR at vertruleHTMLcolor%
     }{}%
 }%
 }
@@ -7319,7 +7342,7 @@
 \LWR at traceinfo{LWR at startref B}%
 \LWR at origmbox{\LWR at htmlrefsectionfilename{#1}}%
 \LWR at traceinfo{LWR at startref C}%
-\#%
+\LWR at origpound%
 \LWR at traceinfo{LWR at startref D: !#1!}%
 \ifthenelse{\equal{\LWR at lidref}{??}}%
 {%
@@ -7492,11 +7515,16 @@
 \boolfalse{LWR at freezethisautoid}
 
 \newcommand*{\LWR at newautoidanchor}{%
-\ifbool{LWR at freezethisautoid}{}{%
-    \addtocounter{LWR at thisautoid}{1}%
-    \LWR at htmltag{a id="\LWR at origmbox{autoid-\arabic{LWR at thisautoid}}"}\LWR at htmltag{/a}%
-}%
+\ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}%
+{}%
+{
+    \ifbool{LWR at freezethisautoid}{}{%
+        \addtocounter{LWR at thisautoid}{1}%
+        \LWR at htmltag{a id="\LWR at origmbox{autoid-\arabic{LWR at thisautoid}}"}%
+            \LWR at htmltag{/a}%
+    }%
 }
+}
 
 \newcommand*{\@captype}{}
 
@@ -7590,8 +7618,10 @@
 
 \renewcommand*{\addcontentsline}[3]{%
 \ifstrequal{#1}{toc}{}{% not TOC
-    \LWR at newautoidanchor%
-    \ifthenelse{\equal{#1}{thm}}{\csdef{ext@#2}{thm}}{}%
+\ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}%
+    {}
+    {\LWR at newautoidanchor}%
+    \ifcsvoid{ext@#2}{\csdef{ext@#2}{#1}}{}%
     \addtocontents{\@nameuse{ext@#2}}{%
         \protect\LWRsetnextfloat%
         {\arabic{LWR at latestautopage}}%
@@ -7751,7 +7781,7 @@
 \ifthenelse{\cnttest{#1}{<=}{\value{tocdepth}}}{%
     \LWR at startpars%
     \LWR at subhyperrefclass{%
-        \LWR at htmlrefsectionfilename{autopage-#4}\#\LWR at origmbox{autosec-#4}%
+        \LWR at htmlrefsectionfilename{autopage-#4}\LWR at origpound\LWR at origmbox{autosec-#4}%
     }{#3}{toc#2}%
     \LWR at stoppars%
 }
@@ -7780,7 +7810,7 @@
     \LWR at startpars%
     \LWR at subhyperrefclass{%
     \LWR at htmlrefsectionfilename{autopage-\arabic{LWR at nextautopage}}%
-    \#\LWR at origmbox{autoid-\arabic{LWR at nextautoid}}}%
+    \LWR at origpound\LWR at origmbox{autoid-\arabic{LWR at nextautoid}}}%
     {#4}{toc#2}%
     \LWR at stoppars%
 }{}%
@@ -7942,9 +7972,9 @@
 \let\llap\LWR at origllap%
 \let\rlap\LWR at origrlap%
 \let\hfilneg\LWR at orighfilneg%
-\let\raggedright\LWR at origraggedright
-\let\raggedleft\LWR at origraggedleft
-\let\centering\LWR at origcentering
+\let\raggedright\LWR at origraggedright%
+\let\raggedleft\LWR at origraggedleft%
+\let\centering\LWR at origcentering%
 \let\,\LWR at origcomma% disable HTML short unbreakable space
 \let\textellipsis\LWR at origtextellipsis%
 \let\textless\LWR at origtextless%
@@ -8015,8 +8045,6 @@
 \let\LaTeXe\LWR at origLaTeXe%
 \renewcommand*{\Xe}{X\textsubscript{E}}%
 \LetLtxMacro\@ensuredmath\LWR at origensuredmath%
-\csletcs{equation*}{LWR at origequationstar}%
-\csletcs{endequation*}{LWR at origendequationstar}%
 \LWR at restoreorigaccents%
 \LWR at restoreoriglists%
 \LWR at FBcancel%
@@ -8024,57 +8052,52 @@
 \end{warpHTML}
 \begin{warpHTML}
 
+\newcounter{LWR at externalfilecnt}
+
+\newbool{LWR at indisplaymathimage}
+
 \let\LWR at origtextdollar\$
 
 \renewcommand*{\$}{%
 \ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}%
 {\LWR at origtextdollar}%
-{\LWR at htmltagc{span}\LWR at origtextdollar\LWR at htmltagc{/span}}%
+{\HTMLentity{dollar}}%
 }
 
-\newcounter{LWR at externalfilecnt}
+\AtBeginDocument{
 
-\LetLtxMacro\LWR at origdollar$
-\LetLtxMacro\LWR at secondorigdollar$% balance for editor syntax highlighting
+\@ifpackageloaded{graphicx}{
+    \newcommand*{\LWR at addbaselinemarker}{%
+        \LWR at origincludegraphics[%
+            width=10sp,height=10sp%
+        ]{lwarp_baseline_marker.png}%
+    }
+}{
+    \@ifpackageloaded{graphics}{
+        \newcommand*{\LWR at addbaselinemarker}{%
+            \LWR at origincludegraphics{lwarp_baseline_marker.png}%
+        }
+    }{
+        \newcommand*{\LWR at addbaselinemarker}{%
+            \hspace*{10sp}%
+        }
+    }
+}
 
-\LetLtxMacro\LWR at origopenparen\(
-\LetLtxMacro\LWR at origcloseparen\)
-\LetLtxMacro\LWR at origopenbracket\[
-\LetLtxMacro\LWR at origclosebracket\]
+}% AtBeginDocument
 
-\begingroup
-\catcode`\$=\active%
-\protected\gdef${\@ifnextchar$\LWR at doubledollar\LWR at singledollar}%
-
-\protected\gdef\LWR at doubledollar$#1$${
-\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
-{
-
-        \textbackslash[%
-        \LWR at HTMLsanitize{#1}%
-        \textbackslash]
-
-}% mathjax
-{% not mathjax
-
-        \begin{BlockClass}{displaymath}
-        \begin{lateximage}%
-        [%
-            \textbackslash{[} % extra space
-            \LWR at HTMLsanitize{#1} % extra space
-            \textbackslash{]}%
-        ]%
-        \LWR at origdollar\LWR at origdollar#1\LWR at origdollar\LWR at origdollar%
-        \end{lateximage}%
-        \end{BlockClass}
-
-}% not mathjax
-}%
 \newlength{\LWR at singledollarwidth}
 \newlength{\LWR at singledollarheight}
 \newlength{\LWR at singledollardepth}
 
-\protected\gdef\LWR at subsingledollar#1#2{%
+\newsavebox{\LWR at singledollarbox}
+
+\NewDocumentCommand{\LWR at subsingledollar}{s m m m}{%
+\ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}%
+{%
+    #4% contents
+}%
+{% not in a lateximage
 \begingroup%
 \ifboolexpr{%
     (
@@ -8081,41 +8104,54 @@
         bool{mathjax} or
         ( bool{FormatWP} and bool{WPMarkMath} )
     ) and
-    ( not test { \ifstrequal {#1} {math image} } )
+    ( not test { \ifstrequal {#2} {(math image)} } )% from \ensuredmath
 }%
 {%
-    {\textbackslash(\LWR at HTMLsanitize{#2}\textbackslash)}%
+    {\textbackslash(\LWR at HTMLsanitize{#4}\textbackslash)}%
 }% mathjax
 {% not mathjax
+    \begingroup%
     \LWR at restoreorigformatting%
+    \RenewDocumentEnvironment{lateximage}{s o o o}{}{}% inside group
     \LWR at orignormalsize%
-    \global\setlength{\LWR at singledollardepth}{\depthof{%
-        \LWR at origdollar#2\LWR at origdollar%
-    }*\real{.8}}%
-    \global\setlength{\LWR at singledollarwidth}{\widthof{%
-        \LWR at origdollar#2\LWR at origdollar%
-    }*\real{.8}}%
-    \global\setlength{\LWR at singledollarheight}{\totalheightof{%
-        \LWR at origdollar#2\LWR at origdollar%
-    }*\real{.8}}%
-    \LWR at origscriptsize%
-    \ifdimgreater{\LWR at singledollarwidth}{\LWR at singledollarheight}{%
+    \csuse{LWR at orig\LWR at f@family family}%
+    \csuse{LWR at orig\LWR at f@series series}%
+    \csuse{LWR at orig\LWR at f@shape shape}%
+    \global\advance\c at LWR@lateximagedepth 1\relax%
+    \global\sbox{\LWR at singledollarbox}{#4}%
+    \global\sbox{\LWR at singledollarbox}{%
+        \usebox{\LWR at singledollarbox}%
+        \hspace*{-10sp}%
+        \raisebox{-\dp\LWR at singledollarbox}{%
+            \LWR at addbaselinemarker%
+        }%
+    }%
+    \global\advance\c at LWR@lateximagedepth -1\relax% Due to AmS \text macro.
+    \setlength{\LWR at singledollardepth}{.70\dp\LWR at singledollarbox}%
+    \global\LWR at singledollardepth=\LWR at singledollardepth%
+    \setlength{\LWR at singledollarwidth}{.70\wd\LWR at singledollarbox}%
+    \global\LWR at singledollarwidth=\LWR at singledollarwidth%
+    \setlength{\LWR at singledollarheight}{.70\ht\LWR at singledollarbox}%
+    \addtolength{\LWR at singledollarheight}{.70\dp\LWR at singledollarbox}%
+    \global\LWR at singledollarheight=\LWR at singledollarheight%
+    \endgroup%
+    \ifdimgreater{\LWR at singledollarwidth}{.7\LWR at singledollarheight}{%
         \def\LWR at singledollarstyle{%
             width:\LWR at convertto{em}{\the\LWR at singledollarwidth} em%
         }%
     }{%
         \def\LWR at singledollarstyle{%
-            height:\LWR at convertto{em}{\the\LWR at singledollarheight }em%
+            height:\LWR at convertto{em}{\the\LWR at singledollarheight} em%
         }%
     }%
-    \ifdimless{\LWR at singledollarwidth}{.8em}%
+    \ifdimless{\LWR at singledollarwidth}{.2em}%
     {%
         \def\LWR at singledollarstyle{%
-            height:\LWR at convertto{em}{\the\LWR at singledollarheight }em%
+            height:\LWR at convertto{em}{\the\LWR at singledollarheight} em%
         }%
     }%
     {}%
-    \ifdimless{\LWR at singledollarheight}{.3em}%
+    \ifdimless{\LWR at singledollarheight}{.2em}%
     {%
         \def\LWR at singledollarstyle{%
             width:\LWR at convertto{em}{\the\LWR at singledollarwidth} em%
@@ -8122,7 +8158,7 @@
         }%
     }%
     {}%
-    \ifdimgreater{\LWR at singledollardepth}{0.01em}{%
+    \ifdimgreater{\LWR at singledollardepth}{0.05ex}{%
         \def\LWR at singledollardepthstyle{%
             \ ; % extra space
             \LWR at origmbox{%
@@ -8132,27 +8168,93 @@
     }{%
         \def\LWR at singledollardepthstyle{}%
     }%
-    \ifblank{#1}{%
-        \begin{lateximage}*%
-            [%
-                \textbackslash( %
-                \LWR at HTMLsanitize{#2} % extra space
-                \textbackslash)%
+    \IfValueTF{#1}{%
+        \LWR at findcurrenttextcolor% sets \LWR at tempcolor
+        \begin{lateximage}*% use hashing
+            [#2]% alt
+            [% addl' hashing
+                #3%
+                FM\LWR at f@family%
+                SR\LWR at f@series%
+                SH\LWR at f@shape%
+                CL\LWR at tempcolor%
             ]%
-            [\LWR at singledollarstyle \LWR at singledollardepthstyle]%
+            [\LWR at singledollarstyle \LWR at singledollardepthstyle]% CSS
     }{%
-        \begin{lateximage}%
-            [#1]%
-            [\LWR at singledollarstyle \LWR at singledollardepthstyle]%
+        \begin{lateximage}% no hashing
+            [#2]% alt
+            []% no add'l hashing
+            [\LWR at singledollarstyle \LWR at singledollardepthstyle]% CSS
     }%
-    \LWR at origdollar#2\LWR at origdollar%
+    \LWR at addbaselinemarker%
+    \hspace*{-10sp}%
+    \usebox{\LWR at singledollarbox}%
+    \hspace*{-10sp}%
+    \LWR at addbaselinemarker%
     \end{lateximage}%
-}%
+}% not mathjax
 \endgroup%
+}% not in a lateximage
 }
 
+\LetLtxMacro\LWR at origdollar$
+\LetLtxMacro\LWR at secondorigdollar$% balance for editor syntax highlighting
+
+\LetLtxMacro\LWR at origopenparen\(
+\LetLtxMacro\LWR at origcloseparen\)
+\LetLtxMacro\LWR at origopenbracket\[
+\LetLtxMacro\LWR at origclosebracket\]
+
+\begingroup
+\catcode`\$=\active%
+\protected\gdef${\@ifnextchar$\LWR at doubledollar\LWR at singledollar}%
+
+\protected\gdef\LWR at newsingledollar{\@ifnextchar$\LWR at doubledollar\LWR at singledollar}%
+
+\protected\gdef\LWR at doubledollar$#1$${%
+\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
+{
+
+    \textbackslash[%
+    \LWR at HTMLsanitize{#1}%
+    \textbackslash]
+
+}% mathjax
+{% not mathjax
+    \begin{BlockClass}{displaymath}%
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
+    \begin{lateximage}%
+    [%
+        \textbackslash{[} % extra space
+        \LWR at HTMLsanitize{#1} % extra space
+        \textbackslash{]}%
+    ]%
+    \LWR at origdollar\LWR at origdollar#1\LWR at origdollar\LWR at origdollar%
+    \end{lateximage}%
+    \end{BlockClass}%
+}% not mathjax
+}%
 \protected\gdef\LWR at singledollar#1${%
-\LWR at subsingledollar{}{#1}%
+\ifbool{mathjax}{%
+\LWR at subsingledollar*%
+    {% alt tag
+        \textbackslash( %
+        \LWR at HTMLsanitize{#1} % extra space
+        \textbackslash)%
+    }%
+    {singledollar}% add'l hashing
+    {#1}% contents
+}{% not mathjax
+\LWR at subsingledollar*%
+    {% alt tag
+        \textbackslash( %
+        \LWR at HTMLsanitize{#1} % extra space
+        \textbackslash)%
+    }%
+    {singledollar}% add'l hashing
+    {\LWR at origensuredmath{#1}}% contents
+}% not mathjax
 }
 
 \protected\gdef\(#1\){$#1$}
@@ -8160,16 +8262,27 @@
 
 \endgroup
 
+\LetLtxMacro\LWR at openbracketnormal\[
+\LetLtxMacro\LWR at closebracketnormal\]
+
 \LetLtxMacro\LWR at origensuredmath\@ensuredmath
 
 \renewcommand{\@ensuredmath}[1]{%
 \ifbool{mathjax}{%
-    \LWR at subsingledollar{math image}{\relax#1}%
+    \LWR at subsingledollar*{(math image)}{\LWR at HTMLsanitize{#1}}{\relax%
+        \LWR at origensuredmath{#1}%
+    }%
 }{% SVG math
 \ifmmode%
     \LWR at origensuredmath{#1}%
 \else%
-    \LWR at subsingledollar{math image}{\relax#1}%
+    \ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}%
+    {\LWR at origensuredmath{#1}}%
+    {%
+        \LWR at subsingledollar*{(math image)}{\LWR at HTMLsanitize{#1}}{%
+            \LWR at origensuredmath{#1}%
+        }%
+    }%
 \fi%
 }%
 }
@@ -8180,8 +8293,41 @@
 \let\enddisplaymath\relax
 
 \NewEnviron{math}{\expandafter\(\BODY\)}
-\NewEnviron{displaymath}{\expandafter\[\BODY\]\@ignoretrue}
+\NewEnviron{LWR at displaymathnormal}{\expandafter\[\BODY\]\@ignoretrue}
 
+\LetLtxMacro\[\LWR at openbracketnormal%
+\LetLtxMacro\]\LWR at closebracketnormal%
+\LetLtxMacro\displaymath\LWR at displaymathnormal%
+\LetLtxMacro\enddisplaymath\endLWR at displaymathnormal%
+\newenvironment{LWR at displaymathother}
+{%
+    \begin{BlockClass}{displaymath}%
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
+    \begin{lateximage}%
+    [(display math)]%
+    \LWR at origdollar\LWR at origdollar%
+}
+{%
+    \LWR at origdollar\LWR at origdollar%
+    \end{lateximage}%
+    \end{BlockClass}%
+}
+\newenvironment{LWR at equationother}
+{%
+    \begin{BlockClass}{displaymathnumbered}%
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
+    \begin{lateximage}%
+    [(display math)]%
+    \LWR at origequation%
+}
+{%
+    \LWR at origendequation%
+    \end{lateximage}%
+    \end{BlockClass}%
+}
+
 \newcounter{LWR at nextequation}
 \newcommand*{\LWR at syncmathjax}{%
 \ifcsdef{thechapter}{
@@ -8240,6 +8386,8 @@
 }
 {% not mathjax
     \begin{BlockClass}{displaymathnumbered}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[%
         (\LWR at equationtag) \textbackslash{begin\{equation\}} % extra space
         \LWR at HTMLsanitizeexpand{\detokenize\expandafter{\BODY}} % extra space
@@ -8260,12 +8408,59 @@
 
 ]
 
+\LetLtxMacro\LWR at equationnormal\equation
+\LetLtxMacro\LWR at endequationnormal\endequation
+
 \csletcs{LWR at origequationstar}{equation*}
 \csletcs{LWR at origendequationstar}{endequation*}
+
 \renewenvironment*{equation*}
 {\displaymath}
 {\enddisplaymath}
 
+\csletcs{LWR at equationnormalstar}{equation*}
+\csletcs{LWR at endequationnormalstar}{endequation*}
+
+\LetLtxMacro\LWR at equationless\equation
+\LetLtxMacro\LWR at endequationless\endequation
+\csletcs{LWR at equationlessstar}{equation*}
+\csletcs{LWR at endequationlessstar}{endequation*}
+
+\newcommand*{\displaymathnormal}{%
+\ifbool{LWR at origmathjax}{\booltrue{mathjax}}{\boolfalse{mathjax}}%
+\LetLtxMacro\[\LWR at openbracketnormal%
+\LetLtxMacro\]\LWR at closebracketnormal%
+\LetLtxMacro\displaymath\LWR at displaymathnormal%
+\LetLtxMacro\enddisplaymath\endLWR at displaymathnormal%
+\LetLtxMacro\equation\LWR at equationnormal%
+\LetLtxMacro\endequation\LWR at endequationnormal%
+\csletcs{equation*}{LWR at equationnormalstar}%
+\csletcs{endequation*}{LWR at endequationnormalstar}%
+}
+
+\newcommand*{\displaymathother}{%
+\boolfalse{mathjax}%
+\LetLtxMacro\displaymath\LWR at displaymathother%
+\LetLtxMacro\enddisplaymath\endLWR at displaymathother%
+\LetLtxMacro\[\LWR at displaymathother%
+\LetLtxMacro\]\endLWR at displaymathother%
+\LetLtxMacro\equation\LWR at equationother%
+\LetLtxMacro\endequation\endLWR at equationother%
+\csletcs{equation*}{displaymath}%
+\csletcs{endequation*}{enddisplaymath}%
+}
+
+\end{warpHTML}
+
+\begin{warpprint}
+
+\newcommand*{\displaymathnormal}{}
+\newcommand*{\displaymathother}{}
+
+\end{warpprint}
+
+\begin{warpHTML}
+
 \newbool{LWR at amsmultline}
 \boolfalse{LWR at amsmultline}
 
@@ -8328,7 +8523,9 @@
 {% not mathjax
     \ifbool{LWR at numbereqnarray}
     {
-        \begin{BlockClass}{displaymathnumbered}
+        \begin{BlockClass}{displaymathnumbered}%
+        \LWR at newautoidanchor%
+        \booltrue{LWR at indisplaymathimage}%
         \begin{lateximage}[(\LWR at startingequationtag--\LWR at equationtag)
             \LWR at addmathjax{eqnarray}{\BODY}]
         \LWR at origeqnarray
@@ -8339,6 +8536,8 @@
     }%
     {% not LWR at numbereqnarray
         \begin{BlockClass}{displaymath}
+        \LWR at newautoidanchor%
+        \booltrue{LWR at indisplaymathimage}%
         \begin{lateximage}[\LWR at addmathjax{eqnarray*}{\BODY}]
         \LWR at origeqnarray
         \BODY
@@ -8367,6 +8566,8 @@
 }
 {
     \begin{BlockClass}{displaymathnumbered}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbodynumbered{multline}]
 }
 }
@@ -8393,6 +8594,8 @@
 }
 {
     \begin{BlockClass}{displaymath}
+    \LWR at newautoidanchor
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbody{multline*}]
 }
 }
@@ -8419,7 +8622,9 @@
     \LWR at beginhideamsmath
 }
 {
-     \begin{BlockClass}{displaymathnumbered}
+    \begin{BlockClass}{displaymathnumbered}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbodynumbered{gather}]
 }
 }
@@ -8445,6 +8650,8 @@
 }
 {
     \begin{BlockClass}{displaymath}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbody{gather*}]
 }
 }
@@ -8469,7 +8676,9 @@
     \LWR at beginhideamsmath
 }
 {
-     \begin{BlockClass}{displaymathnumbered}
+    \begin{BlockClass}{displaymathnumbered}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbodynumbered{align}]
 }
 }
@@ -8495,6 +8704,8 @@
 }
 {
     \begin{BlockClass}{displaymath}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbody{align*}]
 }
 }
@@ -8520,6 +8731,8 @@
 }
 {
     \begin{BlockClass}{displaymathnumbered}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbodynumbered{flalign}]
 }
 }
@@ -8545,6 +8758,8 @@
 }
 {
     \begin{BlockClass}{displaymath}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
     \begin{lateximage}[\LWR at amsmathbody{flalign*}]
 }
 }
@@ -8560,6 +8775,60 @@
 
 }
 
+\BeforeBeginEnvironment{alignat}{
+
+\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
+{
+    \LWR at syncmathjax
+    \boolfalse{LWR at amsmultline}
+    \LWR at beginhideamsmath
+}
+{
+    \begin{BlockClass}{displaymathnumbered}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
+    \begin{lateximage}[\LWR at amsmathbodynumbered{alignat}]
+}
+}
+
+\AfterEndEnvironment{alignat}{
+
+\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
+{
+    \LWR at endhideamsmath
+    \LWR at addmathjax{alignat}{\the\@envbody}
+}
+{\end{lateximage}\end{BlockClass}}
+
+}
+
+\BeforeBeginEnvironment{alignat*}{
+
+\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
+{
+    \LWR at syncmathjax
+    \boolfalse{LWR at amsmultline}
+    \LWR at beginhideamsmath
+}
+{
+    \begin{BlockClass}{displaymath}
+    \LWR at newautoidanchor%
+    \booltrue{LWR at indisplaymathimage}%
+    \begin{lateximage}[\LWR at amsmathbody{alignat*}]
+}
+}
+
+\AfterEndEnvironment{alignat*}{
+
+\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
+{
+    \LWR at endhideamsmath
+    \LWR at addmathjax{alignat*}{\the\@envbody}
+}
+{\end{lateximage}\end{BlockClass}}
+
+}
+
 \end{warpHTML}
 
 \begin{warpHTML}
@@ -8583,43 +8852,36 @@
 
 \begin{warpHTML}
 
-\newcommand{\LWR at HTMLsanitize}[1]{%
+\newrobustcmd{\LWR at HTMLsanitize}[1]{%
 \begingroup%
 \LWR at FBcancel%
+\fullexpandarg%
 \protect\StrSubstitute{\detokenize{#1}}%
-{\detokenize{&}}%
-{\detokenize{&}}[\LWR at strresult]%
+{\detokenize{&}}{\detokenize{&}}[\LWR at strresult]%
 \protect\StrSubstitute{\detokenize\expandafter{\LWR at strresult}}%
-{\detokenize{<}}%
-{\detokenize{<}}%
-[\LWR at strresult]%
+{\detokenize{<}}{\detokenize{<}}[\LWR at strresult]%
 \protect\StrSubstitute{\detokenize\expandafter{\LWR at strresult}}%
-{\detokenize{>}}%
-{\detokenize{>}}%
-[\LWR at strresult]%
+{\detokenize{>}}{\detokenize{>}}[\LWR at strresult]%
 \protect\StrSubstitute{\detokenize\expandafter{\LWR at strresult}}%
-{\detokenize{##}}%
-{\#}%
-[\LWR at strresult]%
+{\detokenize{"}}{\detokenize{"}}[\LWR at strresult]%
+\protect\StrSubstitute{\detokenize\expandafter{\LWR at strresult}}%
+{\detokenize{##}}{\LWR at origpound}[\LWR at strresult]%
 \LWR at strresult%
 \endgroup%
 }
 
-\newcommand{\LWR at HTMLsanitizeexpand}[1]{%
+\newrobustcmd{\LWR at HTMLsanitizeexpand}[1]{%
 \begingroup%
 \LWR at FBcancel%
+\fullexpandarg%
 \protect\StrSubstitute{\detokenize\expandafter{#1}}%
-{\detokenize{&}}%
-{\detokenize{&}}%
-[\LWR at strresult]%
+{\detokenize{&}}{\detokenize{&}}[\LWR at strresult]%
 \protect\StrSubstitute{\detokenize\expandafter{\LWR at strresult}}%
-{\detokenize{<}}%
-{\detokenize{<}}%
-[\LWR at strresult]%
+{\detokenize{<}}{\detokenize{<}}[\LWR at strresult]%
 \protect\StrSubstitute{\detokenize\expandafter{\LWR at strresult}}%
-{\detokenize{>}}%
-{\detokenize{>}}%
-[\LWR at strresult]%
+{\detokenize{>}}{\detokenize{>}}[\LWR at strresult]%
+\protect\StrSubstitute{\detokenize\expandafter{\LWR at strresult}}%
+{\detokenize{"}}{\detokenize{"}}[\LWR at strresult]%
 \LWR at strresult%
 \endgroup%
 }
@@ -8695,14 +8957,16 @@
 
 \catcode`\$=\active%
 
-\NewDocumentEnvironment{lateximage}{s O{image} O{}}
+\NewDocumentEnvironment{lateximage}{s O{(image)} O{} O{}}
 {%
 \LWR at traceinfo{lateximage: starting on \jobname.pdf page \arabic{page}}%
-\ifthenelse{\cnttest{\value{LWR at lateximagedepth}}{>}{0}}%
+\LWR at traceinfo{lateximage: entering depth is \arabic{LWR at lateximagedepth}}%
+\ifnumcomp{\value{LWR at lateximagedepth}}{>}{0}%
 {%
-    \addtocounter{LWR at lateximagedepth}{1}%
+    \global\advance\c at LWR@lateximagedepth 1\relax% Due to AmS \text macro.
 }%
 {% start of outer-most lateximage
+\LWR at traceinfo{lateximage: starting outer-most lateximage}%
     \setcounter{LWR at startingequation}{\value{equation}}%
     \addtocounter{LWR at startingequation}{1}%
     \booltrue{LWR at isstartingequation}%
@@ -8716,13 +8980,15 @@
     \LWR at traceinfo{lateximage: LWR at externalfilecnt is \arabic{LWR at externalfilecnt}}%
     \setcounterpageref{LWR at LIpage}{LWRlateximage\arabic{LWR at lateximagenumber}}%
     \LWR at traceinfo{lateximage: LWR at LIpage is \arabic{LWR at LIpage}}%
-    \LWR at htmltag{span id="lateximage\arabic{LWR at lateximagenumber}" %
+    \LWR at htmltag{span id="lateximage\arabic{LWR at lateximagenumber}" % extra space
     class="lateximagesource"}%
     \LWR at traceinfo{lateximage: about to write to lateximages.txt}%
     \IfBooleanTF{#1}% starred
     {% hash
-        \LWR at traceinfo{lateximage: hash true}%
-        \edef\LWR at hashedname{\LWR at mdfive{\detokenize\expandafter{#2}}}%
+        \LWR at traceinfo{lateximage: hash true, adding !#2!#3!}%
+        \edef\LWR at hashedname{%
+            \LWR at mdfive{\detokenize\expandafter{#2}-!-#3}%
+        }%
         \LWR at traceinfo{lateximage: hash is \LWR at hashedname}%
         \immediate\write\LWR at lateximagesfile{%
             |\arabic{LWR at LIpage}|true|\LWR at hashedname|%
@@ -8736,7 +9002,7 @@
     }% no hash
     \LWR at traceinfo{lateximage: about to create open comment}%
     \LWR at htmlopencomment%
-    \addtocounter{LWR at lateximagedepth}{1}%
+     \addtocounter{LWR at lateximagedepth}{1}%
     \LWR at traceinfo{lateximage: about to create a new page}%
     \LWR at orignewpage%
     \LWR at traceinfo{lateximage: about to create minipage}%
@@ -8754,16 +9020,29 @@
     \catcode`\$=3% math shift
     \LetLtxMacro\(\LWR at origopenparen%
     \LetLtxMacro\)\LWR at origcloseparen%
-    \LetLtxMacro\[\LWR at origopenbracket%
-    \LetLtxMacro\]\LWR at origclosebracket%
+    \ifbool{LWR at indisplaymathimage}{}{% not in display math
+        \LetLtxMacro\[\LWR at origopenbracket%
+        \LetLtxMacro\]\LWR at origclosebracket%
+        \let\equation\LWR at origequation%
+        \let\endequation\LWR at origendequation%
+        \csletcs{equation*}{LWR at origequationstar}%
+        \csletcs{endequation*}{LWR at origendequationstar}%
+    }% not in display math
+    \LetLtxMacro\LWR at newsingledollar$%
+    \LetLtxMacro\LWR at newsingledollar$% syntax highlighting
 }% end of outer-most lateximage
 \LWR at traceinfo{lateximage: finished start of environment}%
 }% end of \begin{lateximage}
 {% start of \end{lateximage}
-\LWR at traceinfo{lateximage: starting end of environment}%
-\ifthenelse{\cnttest{\value{LWR at lateximagedepth}}{>}{1}}%
-{\addtocounter{LWR at lateximagedepth}{-1}}%
+\LWR at traceinfo{lateximage: starting end of lateximage}%
+\LWR at traceinfo{lateximage: internal depth was \arabic{LWR at lateximagedepth}}%
+\ifnumcomp{\value{LWR at lateximagedepth}}{>}{1}%
+{%
+    \LWR at traceinfo{lateximage: unnesting}%
+    \global\advance\c at LWR@lateximagedepth -1\relax%
+}%
 {% end of outer-most lateximage
+\LWR at traceinfo{lateximage: ending outer-most lateximage}%
     \LWR at origendminipage%
     \LWR at orignewpage%
     \LWR at origscriptsize%
@@ -8776,7 +9055,7 @@
         {%
             lateximages\OSPathSymbol%
             \LWR at origmbox{\LWR at hashedname}%
-        }{svg}{#3}%
+        }{svg}{#4}%
     }% hash
     {% no hash
         \LWR at subinlineimage[#2]{lateximage}%
@@ -8783,7 +9062,7 @@
         {%
             lateximages\OSPathSymbol%
             \LWR at origmbox{lateximage-\theLWR at externalfilecnt}%
-        }{svg}{#3}%
+        }{svg}{#4}%
     }% no hash
     \LWR at ensuredoingapar%
     \LWR at htmltag{/span}%
@@ -8792,6 +9071,7 @@
     }{}%
     \addtocounter{LWR at lateximagedepth}{-1}%
 }% end of outer-most lateximage
+\LWR at traceinfo{lateximage: exiting depth is \arabic{LWR at lateximagedepth}}%
 \LWR at traceinfo{lateximage: done}%
 }%
 \catcode`\$=3% math shift
@@ -8799,7 +9079,7 @@
 
 \begin{warpprint}
 
-\NewDocumentEnvironment{lateximage}{s o o}
+\NewDocumentEnvironment{lateximage}{s o o o}
     {\begin{varwidth}[b]{\linewidth}}
     {\end{varwidth}}
 
@@ -8867,14 +9147,14 @@
 \newrobustcmd{\LWR at siunitx@textdegree}{\HTMLentity{deg}}
 \newrobustcmd{\LWR at siunitx@textprime}{\HTMLunicode{2032}}
 \newrobustcmd{\LWR at siunitx@textdblprime}{\HTMLunicode{2033}}
-\newrobustcmd{\LWR at siunitx@textplanckbar}{\text{\HTMLunicode{0127}}}
+\newrobustcmd{\LWR at siunitx@textplanckbar}{\text{\textit{\HTMLunicode{0127}}}}
 
-\appto\LWR at restoreorigformatting{
-\renewrobustcmd{\LWR at siunitx@textcelsius}{\text{\ensuremath{^\circ}C}}
-\renewrobustcmd{\LWR at siunitx@textdegree}{\text{\ensuremath{^\circ}}}
-\renewrobustcmd{\LWR at siunitx@textprime}{\text{\ensuremath{^\prime}}}
-\renewrobustcmd{\LWR at siunitx@textdblprime}{\text{\ensuremath{^{\prime\prime}}}}
-\renewrobustcmd{\LWR at siunitx@textplanckbar}{\text{\ensuremath{\hbar}}}
+\appto\LWR at restoreorigformatting{%
+\renewrobustcmd{\LWR at siunitx@textcelsius}{\text{\ensuremath{^\circ}C}}%
+\renewrobustcmd{\LWR at siunitx@textdegree}{\text{\ensuremath{^\circ}}}%
+\renewrobustcmd{\LWR at siunitx@textprime}{\text{\ensuremath{^\prime}}}%
+\renewrobustcmd{\LWR at siunitx@textdblprime}{\text{\ensuremath{^{\prime\prime}}}}%
+\renewrobustcmd{\LWR at siunitx@textplanckbar}{\text{\ensuremath{\hbar}}}%
 }
 
 \PassOptionsToPackage{
@@ -8994,7 +9274,7 @@
 \LetLtxMacro\endfcolorminipage\endLWRprint at fcolorminipage%
 }
 
-\appto{\LWR at restoreorigformatting}{%
+\appto\LWR at restoreorigformatting{%
 \LWR at restoreorigprintxcolor%
 }
 \warpprintonly{\LWR at restoreorigprintxcolor}
@@ -9004,9 +9284,23 @@
 }% AtBeginDocument
 \end{warpall}
 
+\begin{warpprint}
 
+\AtBeginDocument{
+\@ifpackageloaded{chemmacros}{
+\DeclareDocumentEnvironment{polymerdelims}{}
+    {}{}
 
+\DeclareDocumentEnvironment{redoxreaction}{m m}
+    {\rule{0pt}{#1}}{\rule[-#2]{0pt}{#2}}
+}{}% chemmacros
+}% AtBeginDocument
 
+\end{warpprint}
+
+
+
+
 \begin{warpHTML}
 \AtEndPreamble{
 \RequirePackage{cleveref}
@@ -9480,7 +9774,7 @@
 \DeclareRobustCommand{\LWR at HTMLtextstyle}[3]{##3}%
 \def\(##1\){}%
 \def\[##1\]{}%
-\renewcommand{\LWR at subsingledollar}[2]{}
+\RenewDocumentCommand{\LWR at subsingledollar}{s m m m}{}
 }
 
 
@@ -9550,6 +9844,17 @@
     {overline}{#1}%
 }
 
+\newcommand*{\LWR at currenttextcolor}{black}
+\newcommand*{\LWR at tempcolor}{}
+\newcommand*{\LWR at tempcolortwo}{}
+\newcommand*{\LWR at findcurrenttextcolor}{%
+\renewcommand{\LWR at tempcolor}{black}%
+}
+\NewDocumentCommand{\LWR at textcurrentcolor}{m}{%
+    \renewcommand*{\LWR at currenttextcolor}{black}%
+    #1%
+}
+
 \end{warpHTML}
 
 
@@ -9672,7 +9977,6 @@
 \RenewDocumentCommand{\enlargethispage}{s m}{}
 \renewcommand*{\clearpage}{}
 \renewcommand*{\cleardoublepage}{}
-\newcommand*{\LWR at currenttextcolor}{black}
 \NewDocumentCommand{\LWR at rule}{o m m}{%
 \setlength{\LWR at tempwidth}{#2}%
 \ifthenelse{\lengthtest{\LWR at tempwidth=0pt}}

Added: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp_baseline_marker.png
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp_baseline_marker.png
===================================================================
--- trunk/Master/texmf-dist/tex/latex/lwarp/lwarp_baseline_marker.png	2018-03-25 21:28:04 UTC (rev 47114)
+++ trunk/Master/texmf-dist/tex/latex/lwarp/lwarp_baseline_marker.png	2018-03-25 21:28:55 UTC (rev 47115)

Property changes on: trunk/Master/texmf-dist/tex/latex/lwarp/lwarp_baseline_marker.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property


More information about the tex-live-commits mailing list