%
% \iffalse meta-comment
%
% Copyright 2016-2017 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.
%
% \fi
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{lwarp}
%<package>    [2017/11/22 v0.44  Allows LaTeX to directly produce HTML5 output.]
%
%<*driver>
\documentclass{ltxdoc}

\usepackage{lmodern}
% \usepackage{libertine}
\usepackage[space]{erewhon}
% \usepackage[varqu,varl]{inconsolata} % typewriter
% \usepackage{roboto}
% \usepackage{cabin}
\usepackage[tabular]{sourcesanspro}


\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{textcomp}   % provides \degree, \textquotesingle, \textmu

\usepackage{newunicodechar}
\newunicodechar{ﬀ}{ff}
\newunicodechar{ﬁ}{fi}
\newunicodechar{ﬂ}{fl}
\newunicodechar{ﬃ}{ffi}
\newunicodechar{ﬄ}{ffl}
% \newunicodechar{°}{\degree}
\newunicodechar{ρ}{\ensuremath{\rho}}
\newunicodechar{⨯}{\texttimes}
\newunicodechar{⁄}{\textfractionsolidus}
% \newunicodechar{®}{\textregistered}
% \newunicodechar{©}{\textcopyright}
\newunicodechar{—}{---}
\newunicodechar{–}{--}
% \newunicodechar{”}{''}
% \newunicodechar{“}{``}
% \newunicodechar{§}{\S}
% \newunicodechar{¶}{\P}
% \newunicodechar{†}{\dag}
\newunicodechar{‡}{\ddag}
\newunicodechar{Á}{\'{A}}
\newunicodechar{è}{\`{e}}
\newunicodechar{ø}{\o{}}
\newunicodechar{Æ}{\AE{}}
\newunicodechar{â}{\^{a}}
\newunicodechar{ô}{\^{o}}
\newunicodechar{Ô}{\^{O}}
\newunicodechar{ê}{\^{e}}
\newunicodechar{Ω}{\textohm}
\newunicodechar{μ}{\textmu}
\newunicodechar{⁅}{\textlquill}
\newunicodechar{⁆}{\textrquill}
\newunicodechar{℗}{\textcircledP}
\newunicodechar{—}{\texttwelveudash}% emdash
\newunicodechar{—}{\textthreequartersemdash}% emdash
\newunicodechar{℧}{\textmho}
\newunicodechar{₦}{\textnaira}
\newunicodechar{₱}{\textpeso}
\newunicodechar{℞}{\textrecipe}
\newunicodechar{⸘}{\textinterrobangdown}
\newunicodechar{‱}{\textpertenthousand}
\newunicodechar{฿}{\textbaht}
\newunicodechar{℠}{\textservicemark}

\usepackage[log-declarations=false]{xparse}



\usepackage[lwarpmk]{lwarp}

\usepackage[erewhon]{newtxmath}



\usepackage{titlesec}
% \usepackage[nobottomtitles*]{titlesec}
% \renewcommand{\bottomtitlespace}{.\textheight}

\titleformat{\part}[hang]
    {\LARGE\ttfamily\bfseries}{}{0pt}{}[\marginpar{\hfill{}File\,\thepart}]

\titlespacing*{\part}{0pt}{*5}{0ex}




\usepackage{needspace}


\usepackage[svgnames]{xcolor}
\definecolor{myurlcolor}{rgb}{0,0,.7}
\definecolor{mylinkcolor}{rgb}{.7,0,0}
\definecolor{codecolor}{rgb}{0,.4,.2}
\definecolor{overviewcolor}{rgb}{0,.2,.4}


\usepackage{graphicx}
\graphicspath{{images/}}

\usepackage{enumitem}

\usepackage{array}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{multirow}
\usepackage{bigdelim}

\usepackage[normalem]{ulem}

\usepackage{fancyvrb}

\usepackage{capt-of}

\usepackage{comment}
\excludecomment{testing}


% \usepackage{morefloats}
% \usepackage{marginfix}



\usepackage{tocloft}
\renewcommand{\cftpartfont}{\Large\bfseries}
\setlength{\cftsecnumwidth}{2.5em}
\setlength{\cftsubsecnumwidth}{3em}
\setlength{\cftsubsubsecindent}{2.8em}
\setlength{\cftsubsubsecnumwidth}{4em}

\usepackage[notbib,notindex,nottoc]{tocbibind}

\usepackage{titleps}

\newpagestyle{pageheadfoot}{
    \headrule
    \sethead{\pkg{lwarp}}{}{\thepage}
% 	\renewcommand{\makefootrule}{\rule[2.5ex]{\linewidth}{.4pt}}
    \setfoot{}{}{}
}

\pagestyle{pageheadfoot}




\usepackage{dtxdescribe}

\newcommand{\ItemDescribeMacro}[1]{%
\item[\cmd{#1}:]%
\setlength{\parskip}{1.5ex}%
\DescribeMacro{#1}%
}

\newcommand{\ItemDescribeEnv}[1]{%
\item[\env{#1}:]%
\setlength{\parskip}{1.5ex}%
\DescribeEnv{#1}%
}

\newcommand{\ItemDescribeOption}[1]{%
\item[\texttt{#1}:]%
\setlength{\parskip}{1.5ex}%
\DescribeOption{#1}%
}

\newcommand{\ItemDescribeCounter}[1]{%
\item[\texttt{#1}:]%
\setlength{\parskip}{1.5ex}%
\DescribeCounter{#1}%
}

\newcommand{\ItemDescribeBoolean}[1]{%
\item[\texttt{#1}:]%
\setlength{\parskip}{1.5ex}%
\DescribeBoolean{#1}%
}

% A macro which is not indexed:
\makeatletter
\newenvironment{noindmacro}[1]
{
\setlength{\parskip}{\marginparpush}
\leavevmode\par\DTXD@margintag{}{\cmd{#1}}{}}
{\unskip}
\makeatother

% An environment which is not indexed:
\makeatletter
\newenvironment{noindenvironment}[1]
{
\setlength{\parskip}{\marginparpush}
\leavevmode\par\DTXD@margintag{}{#1}{Env}}
{\unskip}
\makeatother


\usepackage{microtype}

\usepackage[all,defaultlines=2]{nowidow}



\usepackage[pdftex,bookmarks=true,hidelinks,%
colorlinks,linkcolor=mylinkcolor,urlcolor=myurlcolor,%
pageanchor=true,hyperindex=true,hyperfootnotes=false%
]{hyperref}

\hypersetup{%
pdfinfo={%
Title={LaTeX lwarp package},%
Author={Brian Dunn},%
Subject={LaTeX to HTML conversion},%
Keywords={LaTeX, HTML, conversion}%
}}


\usepackage{cleveref}


\renewcommand{\partname}{Package}
\renewcommand*{\thepart}{\arabic{part}}


\newrobustcmd{\lmacro}[1]{\textbackslash#1}
\newrobustcmd{\cmds}[1]{\texttt{#1}}
\newrobustcmd{\env}[1]{\texttt{#1}}
\newrobustcmd{\pkg}[1]{\textsf{#1}}
\newrobustcmd{\acro}[1]{\textsc{\lowercase{#1}}}
\newrobustcmd{\element}[1]{\texttt{<#1>}}
\newrobustcmd{\attribute}[1]{\texttt{#1}}
\newrobustcmd{\UI}[1]{\textbf{\textsf{#1}}}

\newrobustcmd{\TOC}{\acro{TOC}}
\newrobustcmd{\LOF}{\acro{LOF}}
\newrobustcmd{\LOT}{\acro{LOT}}

\newrobustcmd{\HTML}{\acro{HTML}}
\newrobustcmd{\HTMLfive}{\HTML\textsc{5}}
\newrobustcmd{\CSS}{\acro{CSS}}
\newrobustcmd{\CSSthree}{\CSS\textsc{3}}
\newrobustcmd{\EPUB}{\acro{EPUB}}
\newrobustcmd{\SVG}{\acro{SVG}}
\newrobustcmd{\PNG}{\acro{PNG}}
\newrobustcmd{\JPG}{\acro{JPG}}
\newrobustcmd{\PDF}{\acro{PDF}}
\newrobustcmd{\tikz}{Ti\textit{k}z}
\newrobustcmd{\MathML}{Math\acro{ML}}
\newrobustcmd{\CTAN}{\acro{CTAN}}
\newrobustcmd{\TDS}{\acro{TDS}}

\newcommand{\DescribeDefault}[1]{\margintag{\footnotesize \textcolor{green!50!black}{Default: \texttt{#1}}}}

\newcommand{\goesto}{$\Rightarrow$}

\newcommand{\credits}[1]{{\footnotesize(\textit{Emulates or patches code by} \textsc{#1}.)}}

\newcommand{\codehtml}{\leavevmode\marginpar{\footnotesize\raggedleft\textcolor{codecolor}{\textbf{for HTML output:~}}}\vspace{-5.25ex}}
\newcommand{\codeprint}{\leavevmode\marginpar{\footnotesize\raggedleft\textcolor{codecolor}{\textbf{for PRINT output:~}}}\vspace{-5.25ex}}
\newcommand{\codeall}{\leavevmode\marginpar{\footnotesize\raggedleft\textcolor{codecolor}{\textbf{for HTML \& PRINT:~}}}\vspace{-5.25ex}}

\newcommand*{\testthis}{\textcolor{blue}{Please send bug reports!}\watchout[Not yet tested!]}

\newcommand{\userentry}[1]{%
\par
\hspace*{2em}\begin{minipage}{\linewidth-2em}
{\footnotesize Enter~$\Rightarrow$}\quad\texttt{#1}
\end{minipage}
\par
}

\newenvironment{sourcedisplay}
{
\leavevmode
\par
\hspace*{2em}\minipage{\linewidth-2em}
\ttfamily
}
{
\endminipage
\par
}

\newenvironment{UIdisplay}
{
\leavevmode
\par
\hspace*{2em}\minipage{\linewidth-2em}
\sffamily
}
{
\endminipage
\par
}

\newenvironment{docsidebar}[1][]
{%
\ifblank{#1}{}{\medskip}%
\hfill\minipage{.9\linewidth}%
\setlength{\parskip}{1.5ex}%
\ifblank{#1}{}{\textit{#1}}%
\leavevmode\smallskip\hrule%
}
{\smallskip\hrule\endminipage\hspace*{\fill}\bigskip}

% \makeatletter
% \newcommand{\watchout}[1][]{%
% \@bsphack%
% \marginpar{\raggedleft\textcolor{blue!70!black}{#1} \quad \includegraphics[height=3ex]{symbol_warning.pdf}}
% \@esphack%
% }
% \makeatother

\newcommand{\pdflatexonly}{
\textcolor{red}{Only pre-loaded if \texttt{pdflatex} is being used.}
\marginpar{\raggedleft\textcolor{blue!70!black}{\texttt{pdflatex} only:}}
}

% \newcommand{\margintag}[1]{%
% \marginpar{\raggedleft\textcolor{blue!70!black}{#1}}%
% }


% The following text is used in multiple places in the documentation:

\newcommand{\usedbykomascript}{
This package may be loaded standalone, but
is also loaded automatically if \pkg{koma-script} classes are in use.
\cs{DeclareDocumentCommand} is used to overwrite the \pkg{koma-script} definitions.
}

\newcommand{\documentationnotes}{
The following sections document the actual implementation of the \pkg{lwarp} package.

The small numbers at the left end of a line refer to line numbers
\margintag{line numbers}
in the \texttt{lwarp.sty} file.

Blue-colored tags in the left margin
\margintag{subjects}
aid in quickly identifying the subject of each paragraph.

Black-colored tags in the left marign are used to
\margintag{objects}
identify programming objects such as files, packages,
environments, booleans, and counters.
Items without a tag are command macros.
Each of these also appears in the index as
\margintag{index entries}
individual entries, and are also listed together under ``files'', ``packages'', ``environments'',
``booleans'', and ``counters''.

Special warnings are marked with a warning icon.
\watchout[warnings]

\codehtml\vspace*{5.25ex}\ignorespaces
\codeprint\vspace*{5.25ex}\ignorespaces
\codeall\vspace*{5.25ex}\ignorespaces
Green-colored tags in the left margin show which sections of source
code apply to the generation of \HTML, print, or both forms of output.
}

\newcommand{\limitscpageref}{\pkg{cleveref} and \pkg{varioref} are supported,
\watchout[\pkg{cleveref} page numbers]
but printed page numbers do not map to \HTML,
so a section name or a text phrase
are used for \cs{cpageref} and \cs{cpagerefrange}.
This phrase includes \cs{cpagerefFor}, which defaults to ``for''.

\needspace{3\baselineskip}
Ex:
\begin{sourcedisplay}
    \cs{cpageref}\{tab:first,tab:second\} \\
    \hspace*{-2em} in \HTML\ becomes:\\
    \rmfamily
    ``pages \textbf{for} table \textcolor{red}{4.1} and
    \textbf{for} table \textcolor{red}{4.2}''
\end{sourcedisplay}
See \cs{cpagerefFor} at \cpageref{sec:cpagereffor}
to redefine the message which is printed for page number references.
}

\newcommand{\limitshyperlinks}{%
\pkg{lwarp} emulates \pkg{hyperref}, including the creation of active hyperlinks,
but does not require that \pkg{hyperref} be loaded by the document.

\pkg{lwarp} can also load \pkg{url}, but \pkg{url} should not be used at the
same time as \pkg{hyperref}, since they both define the \cs{url} command.
\pkg{lwarp} does not (yet) attempt to convert \pkg{url} links into hyperlinks
during \HTML\ output, nor does \pkg{url} create hyperlinks during print output.
}

\newcommand{\limitsabstract}{%
If using the \texttt{number} option with file splits,
\watchout[missing \acro{TOC}]
be sure to place the table of contents before the abstract.
The number option causes a section break which
may cause a file split, which would put a table of contents out
of the home page if it is after the abstract.
}

\newcommand{\limitstitlepage}{%
\pkg{lwarp} supports the native \LaTeX\ titling commands, and also
\margintag{package support}
supports the packages \pkg{authblk} and \pkg{titling}.  If both are
\watchout[load order]
used, \pkg{authblk} should be loaded before \pkg{titling}.

If using the \pkg{titling} package, additional titlepage fields
\margintag{\cs{published} and \cs{subtitle}}
for \cs{published} and \cs{subtitle} may be added by using
\cs{AddSubtitlePublished} in the preamble.
See \cref{sec:publishedsubtitle}.
}

\newcommand{\limitsappendix}{%
During \HTML\ conversion, the option \texttt{toc} without
\watchout[incorrect \acro{TOC} link]
the option \texttt{page} results in a \acro{TOC} link to
whichever section was before the \texttt{appendices} environment.
It is recommended to use both \texttt{toc} and also \texttt{page} at the same time.
}

\newcommand{\limitsindexlanguage}{%
The \pkg{lwarp} package takes an option
\DescribeOption{IndexLanguage}
\texttt{IndexLanguage=english} to set the language used by \texttt{xindy}.
This is passed to \texttt{xindy} using its \texttt{-L} option, and is
used for both index and glossary generation.
}

\newcommand{\limitsglossaries}{%
\texttt{xindy} is required for \pkg{glossaries}.

The default \texttt{style=item} option for \pkg{glossaries} conflicts
with \pkg{lwarp}, so the style is forced to \texttt{index} instead.

The page number list in the printed form would become \cs{nameref}s in \HTML,
which could become a very long string if many items are referenced.
For now, the number list is simply turned off.

The glossaries may be placed in a numbered or unnumbered section, given
\margintag{placement and \acro{TOC} options}
a \acro{TOC} entry, and placed inline or on their own \HTML\ page:
\begin{description}

\item [Numbered section, on its own \HTML\ page:]
    \begin{sourcedisplay}
    \cs{usepackage}[xindy,toc,numberedsection=nolabel]\{glossaries\} \\
    \dots \\
    \cs{printglossaries}
    \end{sourcedisplay}

\item [Unnumbered section, inline with the current \HTML\ page:]
    \begin{sourcedisplay}
    \cs{usepackage}[xindy,toc]\{glossaries\} \\
    \dots \\
    \cs{printglossaries}
    \end{sourcedisplay}

\item [Unnumbered section, on its own \HTML\ page:]
    \begin{sourcedisplay}
    \cs{usepackage}[xindy,toc]\{glossaries\} \\
    \dots \\
    \cs{ForceHTMLPage} \\
    \cs{printglossaries}
    \end{sourcedisplay}
\end{description}

\limitsindexlanguage

\DescribeOption[lwarpmk]{printglossary}
\DescribeOption[lwarpmk]{htmlglossary}
\texttt{lwarpmk} has the commands \texttt{lwarpmk printglossary} and
\texttt{lwarpmk htmlglossary} to process the glossaries created by
\pkg{glossaries} using \texttt{xindy}.
}


\newcommand*{\limitsindex}{%

\limitsindexlanguage

\limitstocloft

An index may be placed inline with other \HTML\ text, or on its own \HTML\ page:
\margintag{placement and \acro{TOC} options}

\begin{description}

\item [Inline, with a manual TOC entry:] \

    A commonly-used method to introduce an index in a \LaTeX\ document:
    \begin{sourcedisplay}
    \cs{cleardoublepage} \\
    \cs{phantomsection} \\
    \cs{addcontentsline}\{toc\}\{section\}\{\cs{indexname}\}\% or chapter \\
    \cs{printindex}
    \end{sourcedisplay}

\item [On its own \HTML\ page, with a manual TOC entry:] \
    \begin{sourcedisplay}
    \cs{begin}\{warpprint\} \\
    \cs{cleardoublepage} \\
    \cs{phantomsection} \\
    \cs{addcontentsline}\{toc\}\{section\}\{\cs{indexname}\}\% or chapter \\
    \cs{end}\{warpprint\} \\
    \cs{ForceHTMLPage} \\
    \cs{ForceHTMLTOC} \\
    \cs{printindex}
    \end{sourcedisplay}

\item [Inline, with an automatic TOC entry:] \

    The \pkg{tocbibind}
    \DescribePackage{tocbibind}
    package may be used to automatically place an entry in the \acro{TOC}.
    \begin{sourcedisplay}
    \cs{usepackage}[nottoc]\{tocbibind\} \\
    \dots \\
    \cs{cleardoublepage} \\
    \cs{phantomsection} \% to fix print-version index link \\
    \cs{printindex}
    \end{sourcedisplay}

\item [On its own \HTML\ page, with an automatic TOC entry:]
    \begin{sourcedisplay}
    \cs{usepackage}[nottoc]\{tocbibind\} \\
    \dots \\
    \cs{cleardoublepage} \\
    \cs{phantomsection} \% to fix print-version index link \\
    \cs{ForceHTMLPage} \\
    \cs{printindex}
    \end{sourcedisplay}
\end{description}

Use the \pkg{tocbibind} \texttt{numindex} option to generate a numbered index.
\DescribeOption[tocbibind]{numindex}
Without this option, the index heading has no number.
\margintag{numbered index section}
}

\newcommand{\limitstocloft}{%
If using \pkg{tocloft} with \pkg{tocbibind}, \pkg{anonchap},
\watchout[\pkg{tocloft} \& other packages]
\pkg{fncychap}, or other packages which change chapter title formatting,
load \pkg{tocloft} with its \texttt{titles} option, which
tells \pkg{tocloft} to use standard \LaTeX\ commands to create the titles,
allowing other packages to work with it.
}

\newcommand*{\limitspagenote}{%
\pkg{pagenote} works as-is, but the \texttt{page} option is disabled.
}

\newcommand*{\limitsendnotes}{%
To place the endnotes in the \acro{TOC}, use:
\margintag{table of contents}
\begin{sourcedisplay}
\cs{usepackage}\{endnotes\} \\
\cs{appto}\cs{enoteheading}\{\cs{addcontentsline}\{toc\}\{section\}\{\cs{notesname}\}\}
\cs{renewcommand*}\{\cs{notesname}\}\{Endnotes\} \% optional \\
\end{sourcedisplay}

To additionally have the endnotes on their own \HTML\ page,
\margintag{\HTML\ page}
if \texttt{FileDepth} allows:
\begin{sourcedisplay}
\cs{ForceHTMLPage} \\
\cs{theendnotes}
\end{sourcedisplay}
}


\newcommand{\limitstext}{%
\cs{textbf}, etc.\ are supported,
\watchout[\cs{bfseries}, etc.]
but \cs{bfseries}, etc.\ are not yet supported.

\texttt{\&}, \texttt{\textless}, and \texttt{\textgreater}
\watchout[HTML special chars]
have special meanings in \HTML.
If \cs{\&}, \cs{textless}, and \cs{textgreater} are used, the proper result
should occur in \HTML, but there may be \HTML\ parsing problems
if these special characters occur unescaped in program listings
or other verbatim text.
}

\newcommand{\limitshspace}{%
\DescribeMacro{\hspace}%
\index{space>horizontal}%
\index{horizontal space}%
\cs{hspace} is converted to an inline \HTML\ span of the given width,
except that \texttt{0} width is ignored,
a width of \texttt{.16667em} is converted to
an \HTML\ thin breakable space (\texttt{U+2009}),
and a \cs{fill} is converted to a \cs{qquad}.

\index{\texttt{\textasciitilde}}%
\DescribeMacro{\,}%
\texttt{\~} and \cs{,} are converted to \HTML\ entities.

\DescribeMacro{\kern}%
\DescribeMacro{\hskip}%
\cs{kern} and \cs{hskip} are treated as a single normal space.
}

\newcommand{\limitstextcomp}{%
Some \pkg{textcomp} symbols do not have Unicode equivalents, and thus
are not supported.

Many \pkg{textcomp} symbols are not supported by many fonts.
\watchout[Missing symbols]
Try using more complete fonts in the \CSS, but expect to see gaps in coverage.
}

\newcommand{\limitsaccents}{%
Native \LaTeX\ accents such as \cs{"} will work, but many more kinds of
accents are available when using Unicode-aware \XeLaTeX\ and \LuaLaTeX.
}

\newcommand{\limitsrelsize}{%
For \HTML\, only the inline macros are supported: \cs{textlarger}, \cs{textsmaller}, and
\cs{textscale}.  Each becomes an inline span of a modified \attribute{font-size}.

\cs{relsize}, \cs{larger}, \cs{smaller}, and \cs{relscale} are ignored.

While creating \SVG\ math for \HTML, the original definitions are temporarilty restored,
and so should work as expected.

The \HTML\ browser's setting for minumum font size
\watchout[not small]
may limit how small the output will be displayed.
}

\newcommand{\limitsreferences}{%
Labels with special characters may be a problem.
\margintag{labels}
It is best to stick with alpha-numeric, hyphen, and perhaps the colon (if not French).
The underscore currently does not yet work when generating math for MathJax.
\watchout[underscores]

\cs{nameref} refers to the most recently-used section where the \cs{label}
\margintag{\cs{nameref}}
was defined.
If no section has been defined before the \cs{label},
\watchout[empty link]
the link will be empty.
Index entries also use \cs{nameref} and have the same limitation.
}

\newcommand{\limitspfnote}{
While emulating \pkg{pfnote}, \pkg{lwarp} is not able to reset \HTML\ footnote
\watchout[\pkg{pfnote} numbers]
numbers per page number to match the printed version,
as \HTML\ has no concept of page numbers.
\pkg{lwarp} therefore uses continuous footnote numbering even for \pkg{pfnote}.
}

\newcommand{\limitsfootnotes}{
\pkg{lwarp} uses native \LaTeX\ footnote code, although with its own
\cs{box} to avoid the \LaTeX\ output routine.  The usual functions work as-is.

\limitspfnote
}

\newcommand{\limitskomascript}{
Many features are ignored during the \HTML\ conversion.
The goal is source-level compatibility.

\cs{titlehead}, \cs{subject},
\cs{captionformat}, \cs{figureformat}, and \cs{tableformat} are not yet emulated.

\testthis

Some features have not yet been tested.
Please contact the author with any bug reports.
}

\newcommand{\limitsverse}{%
\DescribeMacro{\attrib}
The documentation for the \pkg{verse} and \pkg{memoir} packages suggest
defining an \cs{attrib} command, which may already exist in current documents,
but it will only work for print output.
\pkg{lwarp} provides \cs{attribution}, which
works for both print and \HTML\ output.  To combine the two so that
\cs{attrib} is used for print and \cs{attribution} is used for \HTML:

\begin{docsidebar}
\raggedright
\ttfamily
\cs{begin}\{warpHTML\}

\cs{let}\cs{attrib}\cs{attribution}

\cs{end}\{warpHTML\}
\end{docsidebar}

\DescribeLength{vleftskip}
\DescribeLength{vleftmargini}
These lengths are used by \pkg{verse} and \pkg{memoir} to control the left margin,
and they may already be set by the user for print output.  New lengths
 \DescribeLength{HTMLvleftskip}\DescribeLength{HTMLleftmargini}
\cs{HTMLvleftskip} and \cs{HTMLleftmargini} are provided to control the
margins in \HTML\ output.  These new lengths may be set by the user
before any \env{verse} environment, and persist until they are manually changed again.
One reason to change \cs{HTMLleftmargini} is if there is a wide
\cs{flagverse} in use, such as the word ``Chorus'', in which case the value of
\cs{HTMLleftmargini} should be set to a wide enough length to contain ``Chorus''.
The default is wide enough for a stanza number.

Horizontal spacing relies on \texttt{pdftotext}'s ability to discern the layout
(\texttt{-layout} option) of the
text in the \HTML-tagged \PDF\ output.  For some settings of
\cs{HTMLleftmargini} or \cs{HTMLleftskip} the horizontal alignment may not work out
exactly, in which case a label may be shifted by one space.
}


\newcommand{\limitslateximagefontsize}{%
The size of the math and text used
\margintag{SVG image font size}
in the \SVG\ image may be adjusted
\index{font>size --- lateximage}%
\index{font>size --- math, SVG}%
\index{math>font size --- SVG}%
\index{lateximages>font size}%
by setting \cs{LateximageFontSizeName} to a font size name --- \emph{without the backslash}, for ex: \\
\hspace*{.5in}\texttt{\cs{renewcommand}\{\cs{LateximageFontSizeName}\}\{\textcolor{red}{large}\}}
}


\newcommand{\limitsmath}{%

\subsubsection{Rendering tradeoffs}

Math may be rendered
\margintag{Math rendering}
as \SVG\ graphics or using the \textsc{MathJax} JavaScript display engine.
\index{JavaScript>MathJax}

In its current implementation,
\margintag{SVG files}
rendering math as images creates a new \SVG\ file for each expression.
In text with many references to math variables,
this can result in a large number of files with
duplicate content.
In the future, some method of content-based naming and check-summing
may be used to remove the need for duplicate files.

Another approach could be
\margintag{SVG inline}
to in-line the \SVG\ files directly into the \HTML.
This may reduce the number of files and potentially speed loading the images,
but slows the display of the rest of the document before the images are loaded.

Others converters have used \PNG\ files,
\margintag{PNG files}
sometimes pre-scaled for print resolution but displayed
on-screen at a scaled down size.  This allows high-quality print output at the expense
of larger files, but \SVG\ files are the preferred approach for scalable graphics.

Conversion to \MathML\ might be a better approach,
\margintag{MathML}
among other things allowing a more compact representation of math than \SVG\ drawings.
Problems with \MathML\ include limited browser support and some
issues with the fine control of the appearance of the result.
Also see \cref{sec:epub} regarding \EPUB\ output with MathJax.

\subsubsection{SVG option}

For \SVG\ math,
\margintag{SVG math option}
math is rendered as usual by \LaTeX{} into the initial \PDF\ file using the
\index{math>SVG summary}%
\index{SVG>math summary}%
current font\footnote{See \cref{sec:xfrac} regarding fonts and fractions.},
then is captured from the \PDF\ and converted to \SVG\ graphics
via a number of utility programs.
The \SVG\ format is a scalable-vector web format, so math may be typeset by \LaTeX{}
with its fine control and precision, then displayed or printed at any size,
depending on (sometimes broken) browser support.
An \HTML\ \attribute{alt} attribute carries the \LaTeX{} code which generated the
math, allowing copy/paste of the \LaTeX{} math expression into other documents.

\limitslateximagefontsize

For \SVG\ math, text copy/paste from the \HTML\ \element{alt} tags lists the
\margintag{SVG math copy/paste}
equation number or tag for single equations, along with the \LaTeX\ code
for the math expression.
For \AmS\ environments with multiple numbers in the same environment,
only the first and last is copy/pasted, as a range.
No tags are listed inside a starred \AmS\ environment, although the \cs{tag}
macro will still appear inside the \LaTeX\ math expression.

\subsubsection{MathJax option}

The popular MathJax alternative (\url{mathjax.org}) may be used to display math.
\margintag{MathJax math option}
\DescribeProgram{MathJax}
\index{math>MathJax summary}
\index{MathJax>summary}

When MathJax is enabled, math is rendered twice:
\begin{enumerate}
\item As regular \LaTeX\ \PDF\ output placed inside an \HTML\ comment, allowing
equation numbering and cross referencing to be almost entirely under the control of \LaTeX, and
\item As detokenized printed \LaTeX{} commands placed directly into the \HTML\ output
for interpretation by the MathJax display scripts.  An additional script is used to
pre-set the equation number format and value according to the current \LaTeX\ values,
and the MathJax cross-referencing system is ignored in favor of the \LaTeX\ internal system,
seamlessly integrating with the rest of the \LaTeX\ code.
\end{enumerate}

Limitations when using MathJax include:
\margintag{MathJax limitations}
\DescribeProgram{MathJax}
\begin{itemize}
\item In document classes which have chapters,
    \margintag{chapter numbers}%
    \index{MathJax>tagged equations}%
    \index{tagged equations>Mathjax}%
    \cs{tag}ged equations have the chapter number prepended in \HTML\ output, unlike \LaTeX.
    \cs{tag*} equations (correctly) do not.
    This may be improved with future versions of the MathJax support script.

    \href{https://groups.google.com/forum/\#!topic/mathjax-users/jUtewUcE2bY}
        {\texttt{https://groups.google.com/forum/\#!topic/\\
            \hspace*{2em}mathjax-users/jUtewUcE2bY}}

\item MathJax itself does not support subequations.
    \margintag{subequations}
\index{MathJax>subequations}%
\index{subequations>MathJax}%
    This may be improved by parsing the \LaTeX{}
    math expression to manually insert tags, but this has not yet been done.
\item Footnotes inside equations are not yet supported while using MathJax.
    \margintag{footnotes in math}
\item Math appearing inside a lateximage,
    \margintag{lateximage}
    and therefore also inside a \tikz{} or \env{picture}
    environment, is rendered as SVG math even if MathJax is used in the rest of the document.
\item Usage of \pkg{siunitx} inside a math equation
    \margintag{siunitx}
    is supported via a third-party MathJax extension.
    While inside a math expression, do not use \cs{SI} or \cs{si} inside \cs{text},
    where it will be rendered as normal text.
    \watchout[siunitx inside an equation]

    \href{https://github.com/burnpanck/MathJax-siunitx}
        {\texttt{https://github.com/burnpanck/MathJax-siunitx}}

    Also see \cref{sec:limitssiunitx}.

\item Other math-related macros and packages are not supported by MathJax,
    \watchout[other macros and packages]
    including \cs{ensuremath}, \pkg{bigdelim}, \pkg{units}, and \pkg{nicefrac},
    along with occasionally-used macros such as \cs{footnote} and \cs{relax}.

\item MathJax does not automatically support custom \LaTeX{} macros,
    \margintag{custom MathJax macros}
    \index{MathJax>custom macros}
    but they may be created by the user inside a math expression:
    \begin{sourcedisplay}
    \cs{begin}\{document\}\\
    \textrm{(\dots)} \\
    \cs{begin}\{warpHTML\}  \% Only for HTML output, \\
    \cs{ifbool}\{mathjax\}  \% and only for MathJax output: \\
    \{ \\
    \hspace*{2em}\% New macros for MathJax are \\
    \hspace*{2em}\% placed inside a math expression: \\
    \hspace*{2em}\cs{(} \\
        \hspace*{4em}\cs{newcommand}\{\cs{expval}\}[1]\{\cs{langle}\#1\cs{rangle}\} \\
        \hspace*{4em}\cs{newcommand}\{\cs{abs}\}[1]\{\cs{lvert}\#1\cs{rvert}\} \\
    \hspace*{2em}\cs{)} \\
    \}\{\} \\
    \cs{end}\{warpHTML\} \\
    \end{sourcedisplay}
\end{itemize}
}

\newcommand{\limitsntheorem}{%
This conversion is not total.
\watchout[Font control]
Font control is via \CSS, and the custom \LaTeX\ font settings
are ignored.

\limitsntheoremnumbering
}

\newcommand{\limitsntheoremnumbering}{%
\pkg{ntheorem} has a bug with equation numbering in \AmS\ environments%
\watchout[Equation numbering]%
\index{equation>miss-numbered}%
\index{split>miss-numbered}%
\index{AMSmath>split miss-numbered}
when the option \texttt{thref} is used.  \pkg{lwarp} does not share
this bug, so equations with \cs{split}, etc, are numbered correctly
with \pkg{lwarp}'s \HTML\ output, but not with the print output.
It is recommended to use \pkg{cleveref} instead of \pkg{ntheorem}'s
\texttt{thref} option.
}


\newcommand{\limitsgraphics}{%
For \cs{includegraphics} with \texttt{.pdf} files,
\watchout[\texttt{.pdf} image files]
the user should provide a \texttt{.pdf} image file, and also
a \texttt{.svg}, \texttt{.png}, or \texttt{.jpg} version of the same image.
\textcolor{red}{These should be referred to without a file extension:}
\watchout[no file extension]
\begin{sourcedisplay}
\cs{includegraphics}\{filename\}    \% print:.pdf,  HTML:.svg or other
\end{sourcedisplay}
For print output, \pkg{lwarp} will automatically choose the \texttt{.pdf} if available,
other some other format otherwise.
For \HTML, one of the other formats is used instead.

If a \texttt{.pdf} file is explicitly referred to with its file extension,
a link to the \texttt{.pdf} file will appear in the \HTML\ output.
\begin{sourcedisplay}
\cs{includegraphics}\{filename.pdf\} \% creates a link in HTML
\end{sourcedisplay}

For \texttt{.png}, \texttt{.jpg}, or \texttt{.gif} image files,
\margintag{other image files}
the same file may be used in
both print or \HTML\ versions, and may be used with a file extension,
but will also be used without the file extension if it is the only file of
its base name.

If using the older \pkg{graphics} syntax, use both optional arguments
\watchout[\pkg{graphics} vs. \pkg{graphicx}]
for \cs{includegraphics}.
A single optional parameter is interpreted as the newer \pkg{graphicx} syntax.
Note that viewports are not supported by \pkg{warp};
\watchout[viewports]
the entire image will be shown.

For \cs{includegraphics}, avoid \texttt{px} and \% units for width and height, or
\margintag{units}
enclose them inside \env{warpHTML} environments.
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}},
or similar for \cmds{\lmacro{textwidth}} or \cmds{\lmacro{textheight}}
to give fixed-sized images proportional to a 6 by 9 inch text area.

\cs{includegraphics} accepts \texttt{width} and \texttt{height},
\margintag{options}
\texttt{origin}, \texttt{rotate} and \texttt{scale},
plus a new \texttt{class} key.

With \HTML\ output, \cs{includegraphics} accepts an optional
\margintag{\HTML\ class}
\texttt{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.
\margintag{\cs{rotatebox}}

\cs{rotatebox}, \cs{scalebox}, and \cs{reflectbox} depend
\watchout[browser support]
on modern browser support.
The \CSSthree\ standard declares that when an object is transformed
the whitespace which they occupied is preserved,
unlike \LaTeX{}, so expect some
ugly results for scaling and rotating.
}

\newcommand{\limitssvgimages}{%
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}
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}
recompile the document one more
time to get the page numbers back in sync, then remake the images one more time.

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.
\watchout[Lots of files!]
There is no attempt at
reusing the same file each time the same expression occurs, so each
time \texttt{\$x\$} is used, for example, yet another file is created.
For a document with a large amount of math,
see \cref{sec:tutorialmathjax} to use MathJax instead.
}

\newcommand{\limitsgrffile}{%
\pkg{grffile} is supported as-is.
File types known to the browser are displayed, and unknown file types are given a link.
Each \PDF\ image for print mode should be accompanied
\watchout[matching \PDF\ and \SVG]
by an \SVG, \PNG, or \JPG\ version for \HTML.
}

\newcommand{\limitscolor}{%
\pkg{color} is superceded by \pkg{xcolor}, and
\pkg{lwarp} requires several of the features of \pkg{xcolor}.

It should be sufficient for the user's document to load \pkg{color} then
\watchout[missing colors]
load \pkg{xcolor} as well.
}

\newcommand{\limitsxcolor}{%
\cs{colorboxBlock} and \cs{fcolorboxBlock} are provided for
\margintag{\cs{colorboxBlock} and \cs{fcolorboxBlock}}
increased \HTML\ compatibility, and they are identical to
\cs{colorbox} and \cs{fcolorbox} in print mode.  In \HTML\ mode
they place their contents into a \element{div} instead of a \element{span}.
These \element{div}s are set to \attribute{display:~inline-block} so
adjacent \cs{colorboxBlock}s appear side-by-side in \HTML, although
text is placed before or after each.

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}}
in which case only the frame is drawn, which can be useful for \HTML.

Color definitions, models, and mixing are fully supported
\margintag{color support}
without any changes required.

Colored tables are ignored so far.  Use \CSS\ to style tables.
\margintag{tables}

\cs{textcolor}, \cs{colorbox}, and \cs{fcolorbox} are supported.
\margintag{colored text and boxes}

\cs{color} and \cs{pagecolor} are ignored.
Use \CSS\ or \cs{textcolor} where possible.
\margintag{\cs{color} and \cs{pagecolor}}
}

\newcommand{\limitsoverpic}{%
The macros \cs{overpicfontsize} and \cs{overpicfontskip} are used during
\watchout[scaling]
\HTML\ generation.  These are sent to \cs{fontsize} to adjust the font
size for scaling differences between the print and \HTML\ versions of the
document.  Renew these macros before using the \env{overpic} and \env{Overpic}
environments.
}

\newcommand{\limitstabular}{%
Tabular mostly works as expected, but pay special attention to the
following, especially if working with environments, macros inside tabulars,
multirows, \texttt{*} column specifiers, \pkg{siunitx} \texttt{S} columns,
or the packages \pkg{multirow}, \pkg{longtable}, \pkg{supertabular}, or \pkg{xtab}.
\begin{description}
\item [Defining environments:] \
    \begin{itemize}
    \item When defining environments or macros which include \env{tabular}
        and\watchout[misplaced alignment alignment tab character \&]
        \index{alignment tab character \&, misplaced}
        \index{misplaced alignment tab character \&}
        \index{tabular>misplaced alignment tab character \&}
        instances of the \texttt{\&} character, it may be
        necessary to make \texttt{\&} active before the environment or macro is defined,
        then restore \texttt{\&} to its default catcode after, using the following commands.
        These are are ignored in print mode.
        \begin{sourcedisplay}
        \textcolor{red}{\cs{StartDefiningTabulars}} \\
        <define macros or environments using \env{tabular} and \texttt{\&} here> \\
        \textcolor{red}{\cs{EndDefiningTabulars}}
        \end{sourcedisplay}
    \item \limitsresumetabular
    \end{itemize}

\item [Cell contents:] \
    \begin{itemize}
    \item Multiple paragraphs in one cell of a \texttt{p}, \texttt{b}, \texttt{m} column
        \watchout[paragraphs]
        must have \cs{newline} between paragraphs.
    \item For \pkg{multirow}, insert \cs{mrowcell} into any empty multi-row cells.
        \watchout[\cs{multirow}]
        This will be a null function for the print output, and is a placeholder for
        parsing the table for \HTML\ output.
        \begin{sourcedisplay}
        \small
        \begin{tabular}{lll}
        \dots\ \& & \cs{multirow}\{2\}\{.5in\}\{text\} & \&\ \dots \\
        \dots\ \& & \textcolor{red}{\cs{mrowcell}} & \&\ \dots \\
        \end{tabular}
        \end{sourcedisplay}
        Note that recent versions of \pkg{multirow} include a new optional
        \margintag{\texttt{vposn}}
        \texttt{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
        print and \HTML.
    \item
        See \cref{sec:multicolumnmultirow} for \cs{multicolumrow}.

        \limitsmulticolumnrow

    \item Using a custom macro inside a tabular data cell
        \watchout[macro in a table]\margintag{custom macros}
        \index{tabular>row corruption}%
        \index{tabular>macros inside}%
        may result in an extra \HTML\ data cell tag, corrupting the \HTML\ table.
        To avoid this, use \cs{TabularMacro} just before the macro.
        This is ignored in print mode.
        \begin{sourcedisplay}
        \textcolor{red}{\cs{TabularMacro}}\cs{somemacro} \&
            more row contents \textbackslash\textbackslash
        \end{sourcedisplay}
    \end {itemize}

\item [Column specifiers:] \
    \begin{itemize}
    \item \texttt{*} in a column specification is not used (so far).
        \watchout[* column specification]
        Repeat the column type the correct number of times.

    \item Only one each of \texttt{@} and \texttt{!}
        \margintag{\texttt{@} and \texttt{!}}
        is used at each column, and they are used in that order.

    \item In \cs{multirow} cells, the print version may have extra
        \margintag{\cs{multirow}}
        instances of \texttt{\textless}, \texttt{\textgreater}, \texttt{@},
        and \texttt{!} cells on the second and later rows in the \cs{multirow}
        which do not appear in the \HTML\ version.

    \item \cs{newcolumntype} is ignored; unknown column types are set to \texttt{l}.
        \watchout[\cs{newcolumntype}]
    \end{itemize}

\item [Rules:] \
    \begin{itemize}
    \item Vertical rules next to either side of an \texttt{@} or \texttt{!} column
        \margintag{vertical rules}
        are displayed on both sides of the column.

    \item Width options are honored.  Trim options are converted to
        \margintag{width and trim}
        rounded top corners.
        Trim corners are not rounded with \texttt{@} or \texttt{!} columns,
        and full-width rules ignore trim.

    \item \cs{toprule}, \cs{midrule}, \cs{bottomrule}, and \cs{hline}
        \margintag{full-width rules}
        ignore trim.  When given an optional width, each cell is styled
        to create the custom border.  Without an optional width, the entire
        row is given a class to assign the standard border.

    \item If you wish to use \cs{cmidrule} followed by \cs{bottomrule},
        \margintag{combined rules}
        it may be necessary to use:
        \begin{sourcedisplay}
        \cs{cmidrule}\{2-3\} \textbackslash\textbackslash[-2ex] \\
        \cs{bottomrule}
        \end{sourcedisplay}
        The optional \texttt{-2ex} is ignored in \HTML\, but improves the
        visual formatting in the print output.

    \item For \cs{toprule} and \cs{bottomrule},
        \watchout[\cs{warpprintonly}]
        when combined with a \env{warpprint} or \env{warpHTML} environment,
        \margintag{misplaced \cs{noalign}}%
        \index{tabular>misplaced \protect\cs{noalign}}%
        \index{misplaced \protect\cs{noalign}}
        if a ``misplaced \cs{noalign}'' error occurs,
        change
        \begin{sourcedisplay}
        This \& That \cs{endhead}
        \end{sourcedisplay}
        to
        \begin{sourcedisplay}
        \textcolor{red}{\cs{warpprintonly}\{}This \& That \cs{endhead}\textcolor{red}{\}}
        \end{sourcedisplay}
        and likewise with the other \cs{end} headings.
        Keep the \cs{endfirsthead} row unchanged, as it is still relevent to \HTML\ output.
    \end{itemize}

\item[Other:] \
    \begin{itemize}
    \item \pkg{tabularx} ignores the width, but \texttt{X} columns do produce paragraph
        columns or multicolumns.
    \item For \pkg{longtable}, place headings and footings which
        \margintag{\env{longtable} headings}
        do not apply to \HTML\ inside \cs{warpprintonly\{\}}.
    \item For S columns (from the \pkg{siunitx} package),
        \watchout[S columns]
        while producing print output,
        anything non-numeric must be placed
        inside \{ \} braces, including commands such as \cs{multirow}.
        While producing \HTML\ output, though, anything placed inside
        braces is not seen by \pkg{lwarp}'s tabular handling algorithm.
        To resolve this problem, make a copy of the row, with one version
        for print output, containing the extra braces, and another version
        for \HTML\ output, without the extra braces, such as: \\
        \hspace*{.375in} \cs{warpprintonly}\{\texttt{1 \& 2 \& \textcolor{red}{\{}\cs{multirow}\{2\}\{2cm\}\{Text\}\textcolor{red}{\}} \& 3 \textbackslash\textbackslash\}} \\
        \hspace*{.375in} \cs{warpHTMLonly}\{\texttt{1 \& 2 \& \cs{multirow}\{2\}\{2cm\}\{Text\} \& 3 \textbackslash\textbackslash\}}
    \end{itemize}
\end{description}
}

\newcommand{\limitsmulticolumnrow}{%
\pkg{lwarp} does not support
\watchout[\cs{multicolumn} \& \cs{multirow}]
directly combining \cs{multicolumn} and \cs{multirow}.
Use \cs{multicolumnrow} instead.
To create a 2 column, 3 row cell:
\begin{sourcedisplay}
\cs{multicolumnrow}%
  \textcolor{blue}{\{2\}\{c\}}%
  \textcolor{green!50!black}{[c]\{3\}[0]\{1in\}[0pt]}\{Text\}
\end{sourcedisplay}
The two arguments for \cs{multicolumn} come first, followed by
the five arguments for \cs{multirow}, many of which are optional,
followed by the contents.

As per \cs{multirow},
\watchout[skipped cells]
skipped cells to the right of the \cs{multicolumnrow}
statement are not included in the source code on the same line.
On the following lines, \cs{mcolrowcell} must be used for each cell
\watchout[empty cells]
of each column and each row to be skipped:
\begin{sourcedisplay}
\small
\begin{tabular}{lll}
\dots\ \& & \cs{multicolumnrow}\{2\}\{c\}[c]\{3\}[0]\{1in\}[0pt]\{Text\} & \&\ \dots \\
\dots\ \& & \textcolor{red}{\cs{mcolrowcell}} \hfill \& \hfill \textcolor{red}{\cs{mcolrowcell}} & \&\ \dots \\
\dots\ \& & \textcolor{red}{\cs{mcolrowcell}} \hfill \& \hfill \textcolor{red}{\cs{mcolrowcell}} & \&\ \dots \\
\end{tabular}
\end{sourcedisplay}

Note that recent versions of \pkg{multirow} include a new optional
\margintag{\texttt{vposn}}
\texttt{vposn} argument.
}

\newcommand{\limitsresumetabular}{%
When creating a new environment
\watchout[\env{tabular} inside another environment]
which contains a \env{tabular} environment,
\pkg{lwarp}'s emulation of the tabular does not automatically resume
when the containing enviroment ends, resulting in corrupted \HTML\ rows.
To fix this, use \cs{ResumeTabular} as follows.
This is ignored in print mode.
\begin{sourcedisplay}
\textcolor{red}{\cs{StartDefiningTabulars}} \% because \& is used in a definition \\
\cs{newenvironment}\{outerenvironment\} \\
\{ \\
\cs{tabular}\{cc\} \\
left \& right \textbackslash\textbackslash \\
\} \\
\{ \\
\textcolor{red}{\cs{TabularMacro}\cs{ResumeTabular}} \\
left \& right \textbackslash\textbackslash \\
\cs{endtabular} \\
\} \\
\textcolor{red}{\cs{EndDefiningTabulars}} \\
\end{sourcedisplay}
}

\newcommand{\limitslongtable}{%
Longtable \cs{endhead}, \cs{endfoot}, and \cs{endlastfoot} rows are
not used for \HTML, and these rows should be disabled.
\watchout
Use
    \begin{sourcedisplay}
    \cs{warpprintonly}\{row contents\}
    \end{sourcedisplay}
instead of
    \begin{sourcedisplay}
    \cs{begin}\{warpprint\} \ldots\ \cs{end}\{warpprint\}
    \end{sourcedisplay}
Doing so helps avoid ``Misplaced \cs{noalign}.'' when using \cs{begin}\{warpprint\}.

Keep the \cs{endfirsthead} row, which is still relevent to \HTML\ output.

\cs{kill} is ignored, place a \cs{kill} line inside
\watchout
    \begin{sourcedisplay}
    \cs{begin}\{warpprint\} \ldots\  \cs{end}\{warpprint\}
    \end{sourcedisplay}
or place it inside \cs{warpingprintonly}.
}

\newcommand{\limitssupertabular}{%
For \cs{tablefirsthead}, etc., enclose them as follows:
\watchout[misplaced alignment alignment tab character \&]
\begin{sourcedisplay}
\textcolor{red}{\cs{StartDefiningTabulars}} \\
\cs{tablefirsthead} \\
\dots \\
\textcolor{red}{\cs{EndDefiningTabulars}}
\end{sourcedisplay}
See \cref{sec:limitstabular}.
}

\newcommand{\limitsbigdelim}{%
\cs{ldelim} and \cs{rdelim} use \cs{multirow}, so
\watchout[use \cs{mrowcell}]
\cs{mrowcell} must be used in the proper number of empty cells in the
same column below \cs{ldelim} or \cs{rdelim}, but not in cells which
are above or below the delimiter:
\begin{sourcedisplay}
\hrule\smallskip
\cs{begin}\{tabular\}\{lll\} \\
\textcolor{green!50!black}{<empty>} \& a \& b \textbackslash\textbackslash \\
\cs{ldelim}\{\textbackslash\{\}\{2\}\{.25in\}[left ] \& c \& d \textbackslash\textbackslash \\
\textcolor{red}{\cs{mrowcell}} \& e \& f \textbackslash\textbackslash \\
\textcolor{green!50!black}{<empty>} \& g \& h \textbackslash\textbackslash \\
\cs{end}\{tabular\}
\smallskip\hrule
\begin{tabular}{lll}
 & a & b \\
\ldelim{\{}{2}{.25in}[left ] & c & d \\
\mrowcell & e & f \\
 & g & h \\
\end{tabular}
\hrule
\end{sourcedisplay}
}

\newcommand{\limitsmarginpars}{%
\DescribeMacro{\marginpar} \oarg{left} \marg{right}
\qquad
\cs{marginpar} may contains paragraphs, but in order to remain inline with
the surrounding text \pkg{lwarp} nullifies block-related macros inside the
\cs{marginpar}.  Paragraph breaks are converted to \element{br /} tags.

\DescribeMacro{\marginparBlock} \oarg{left} \marg{right}
\qquad
To include block-related macros, use \cs{marginparBlock}, which takes the
same arguments but creates a \element{div} instead of a \element{span}.
A line break will occur in the text where the \cs{marginBlock} occurs.
}

\newcommand{\limitssaveboxes}{%
\LaTeX\ boxes are placed inline and do not allow line breaks, so boxes
with long contents may overflow the line during \HTML\ conversion.
This is mostly a problem when the boxes contain objects which themselves
hold large \HTML\ tags, such as rotation commands with long contents.
When this object overflows the line, some \HTML\ code will be lost and 
the page will be corrupted.
}

\newcommand{\limitsminipage}{%
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}.

Minipages and parboxes will be placed side-by-side in \HTML\
\margintag{placement}
unless you place a \cs{newline} between them.

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
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.

There is limited support for minipages inside an \HTML\ \element{span}.
\margintag{in a span}
An \HTML\ \element{div} cannot appear inside a \element{span}.
While in a \element{span}, minipages, and parboxes, and any enclosed lists
have limited \HTML\ tags, resulting in an ``inline'' format, without markup
except for \HTML\ breaks.
Use \cs{newline} or \cs{par} for an \HTML\ break.

When using \cs{linewidth}, \cs{textwidth}, and \cs{textheight},
\margintag{size}
widths and heights are scaled proportionally to a 6\texttimes{}9 inch text area.

A minipage of width exactly \cs{linewidth} is automatically
given no \HTML\ width.
\margintag{no-width minipages}

A new macro \cs{minipagefullwidth} requests
\margintag{full-width minipages}
that the next minipage be generated
without an \HTML\ \attribute{width} attribute, allowing it to be the full width of
the display rather than the fixed width given.

Nested minipages adopt their parent's text alignment in \HTML,
whereas in regular \LaTeX{} \PDF\ output they do not.
\watchout[text alignment]
Use a \env{flushleft} or similar environment in the child minipage
to force a text alignment.
}

\newcommand{\limitsfancybox}{%
\pkg{fancybox}'s documentation has an example \env{FramedEqn} environment
\margintag{framed equation example}
which combines math, \cs{Sbox}, a minipage, and an \cs{fbox}.
This combination requires that the entire
environment be enclosed inside a \env{lateximage}, which is done by
adding \cs{lateximage} at the very start of \env{FramedEqn}'s beginning code, and
\cs{endlateximage} at the very end of the ending code.
Unfortunately, the \HTML\ \attribute{alt} attribute is not used here.
\begin{sourcedisplay}
\cs{newenvironment}{FramedEqn} \\
\{ \\
\cs{lateximage}\% NEW \\
\cs{setlength}\{\cs{fboxsep}\}\{15pt\} \\
\dots\}\{\dots\\
\cs{[}\cs{fbox}\{\cs{TheSbox}\}\cs{]} \\
\cs{endlateximage}\% NEW \\
\}
\end{sourcedisplay}

\cs{fbox} works with \pkg{fancybox}.
\margintag{framing alternatives}
Also see \pkg{lwarp}'s \cs{fboxBlock} macro and \env{fminipage} environment for
alternatives to \cs{fbox} for framing environments.

The \pkg{fancybox} documentation's example framed table
\margintag{framed table example}
using an \cs{fbox} containing a \env{tabular}
does not work with \pkg{lwarp}, but the \env{FramedTable} environment does work if
\cs{fbox} is replaced by \cs{fboxBlock}.  This method loses \HTML\ formatting.
A better method is to enclose the table's contents inside a \env{fminipage} environment.
The caption may be placed either inside or outside the \env{fminipage}:
\begin{sourcedisplay}
\cs{begin}\{table\}\\
\cs{begin}\{fminipage\}\{\cs{linewidth}\}\\
\cs{begin}\{tabular\}\{lr\}\\
\dots \\
\cs{end}\{tabular\}\\
\cs{end}\{fminipage\}\\
\cs{end}\{table\}\\
\end{sourcedisplay}

\pkg{lwarp} does not support the \env{verbatim} environment inside a span, box,
\margintag{framed verbatim}
or \pkg{fancybox}'s \cs{Sbox}, but a \env{verbatim} may be placed inside
a \env{fminipage}.  The \pkg{fancybox} documentation's example \env{FramedVerb}
may be defined as:
\begin{sourcedisplay}
\cs{newenvironment}\{FramedVerb\}[1] \% width\\
\{\\
\cs{VerbatimEnvironment}\\
\cs{fminipage}\{\#1\}\\
\cs{begin}{Verbatim}\\
\}\{\\
\cs{end}{Verbatim}\\
\cs{endfminipage}\\
\}
\end{sourcedisplay}


\pkg{fancybox}'s \cs{VerbBox} may be used inside \cs{fbox}.
\margintag{framed \cs{VerbBox}}

\env{LVerbatim}, \cs{LVerbatimInput}, and \cs{LUseVerbatim} indent with horizontal
\margintag{indented alignment}
space which may not line up exactly with what \texttt{pdftotext} detects.
Some lines may be off slightly in their left edge.
}

\newcommand{\limitsmdframed}{%
Most basic functionality is supported, including
\margintag{support}
frame background colors and single-border colors and thickness,
title and subtitle background colors and borders and thickness,
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}.
\watchout[loading]

For title font, use
\margintag{font}%
\begin{sourcedisplay}
frametitlefont=\cs{textbf},
\end{sourcedisplay}
instead of
\begin{sourcedisplay}
frametitlefont=\cs{bfseries},
\end{sourcedisplay}
where \cs{textbf} must appear just before the comma and will receive the
following text as its argument (since the text happens to be between braces
in the \pkg{mdframed} source).
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
\margintag{theoremtitlefont}
in braces in the \pkg{mdframed} source.

Footnotes are currently placed at the bottom of the \HTML\ page.
\margintag{footnotes}

\texttt{userdefinedwidth} and \texttt{align} are currently ignored.
\margintag{ignored options}
}

\newcommand{\limitscaption}{%
To ensure proper float numbering, set caption positions
such as:
\begin{sourcedisplay}
\cs{captionsetup}[table]\{position=top\} \\
\cs{captionsetup}[figure]\{position=bottom\}
\end{sourcedisplay}
Similarly for \texttt{subtable}, \texttt{subfigure},
and \texttt{longtable}.
}

\newcommand{\limitscombiningfloats}{%
If using \cs{newfloat}, \pkg{trivfloat}, and/or
\pkg{algorithmicx} together, see \cref{sec:combiningfloats}.
\watchout[package conflicts]
}

\newcommand{\limitssubfig}{%
% At present, subfigures before the enclosing figure/table's \cs{caption}
% \margintag{LOF/LOT}
% 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}]
are not working.  These counters must be set separately after the
package has been loaded.

In the document source, use \cs{hfill} and \cs{hspace*}
\margintag{horizontal spacing}
between subfigures to spread them
apart horizontally.  The use of other forms of whitespace may
cause paragraph tags to be generated, resulting in subfigures
appearing on the following lines instead of all on a single line.
}

\newcommand{\limitsfloatrow}{%
When combined with the \pkg{subfig} package,
\watchout[\pkg{subfig} package]
while inside a \env{subfloatrow} \cs{ffigbox} and \cs{ttabbox}
must have the caption in the first of the two of the mandatory arguments.

The emulation of \pkg{floatrow} does not support \cs{FBwidth} or \cs{FBheight}.
These values are pre-set to \texttt{.3\cs{linewidth}} and \texttt{2in}.
\watchout[\cs{FBwidth}, \cs{FBheight}]
Possible solutions include:
\begin{itemize}
\item Use fixed lengths.  \pkg{lwarp} will scale the \HTML\ lengths appropriately.
\item Use \env{warpprint} and \env{warpHTML} environments to select appropriate
    values for each case.
\item Inside a \env{warpHTML} environment, manually change
    \cs{FBwidth} or \cs{FBheight} before the \cs{ffigbox} or \cs{ttabbox}.
    Use \cs{FBwidth} or \cs{FBheight} normally afterwards; it will be used as
    expected in print output, and will use your custom-selected value in \HTML\
    output.  This custom value will be used repeatedly,
    until it is manually changed to a new value.
\end{itemize}
}

\newcommand{\limitskeyfloat}{%
If placing a \cs{keyfig}[H] inside a \env{keywrap},
\watchout[\env{keywrap}]
use an absolute width for
\cs{keyfig}, instead of \texttt{lw}-proportional widths.
(The [H] option forces the use of a minipage, which internally adjusts for
a virtual 6-inch wide minipage, which then corrupts the \texttt{lw} option.)
}

\newcommand{\limitssiunitx}{%
Do not use \cmds{per-mode=fraction},
\watchout[per-mode]
which cannot be seen by the final \cmds{pdftotext} conversion.

Some units will require that the expression be placed inside math mode.
\watchout[math mode required]

\textcolor{red}{NOTE: As of this writing, the \pkg{siunitx} extension
for MathJax is not currently hosted at any public CDN,
thus \pkg{siunitx} is not usable with MathJax unless a local copy
of this extension is created first.}
}

\newcommand{\limitsnicefrac}{%
\pkg{units} and \pkg{nicefrac} work as-is with \pkg{lwarp}, but
MathJax does not have an extension for \pkg{units} or \pkg{nicefrac}.
These packages do work with \pkg{lwarp}'s option \texttt{svgmath}.
}


% \newcommand{\limitsbabelone}{%
% If using \pkg{babel} with French, use
% \watchout[French]%
% \begin{sourcedisplay}
% \cs{frenchbsetup\{StandardLists=true\}}
% \end{sourcedisplay}
% to preserve the special \HTML\ and list handling.
% }

\newcommand{\limitsbabeltwo}{%
When French is used, the caption separator is
\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\}}
\end{sourcedisplay}

Also when French is used,
\margintag{punctuation spaces}
\pkg{lwarp} creates fixed-width space around punctuation by patching
\cs{FBcolonspace}, \cs{FBthinspace},
\cs{FBguillspace}, \cs{FBmedkern}, \cs{FBthickkern}, \cs{FBtextellipsis},
and the tilde.
If the user's document also changes these parameters,
\watchout[customized spacing]
the user's changes
should be placed inside a \env{warpprint} environment so that the user's
changes do not affect the \HTML\ output.
}

\newcommand{\limitsnewclude}{%
\pkg{newclude} modifies \cs{label} in a non-adaptive way, so
\pkg{newclude} must be loaded before \pkg{lwarp} is loaded:
\watchout[loading]

\begin{docsidebar}
\raggedright
\cs{documentclass\{article\}} \\
\ldots <font setup> \\
\cs{usepackage\{newclude\}} \\
\cs{usepackage[warpHTML]\{lwarp\}} \\
\ldots
\end{docsidebar}
}

\newcommand{\limitstodonotes}{%
The documentation for \pkg{todonotes} and \pkg{luatodonotes} have an
example with a todo inside a caption.  If this example does not work
it will be necessary to move the todo outside of the caption.
}

\newcommand{\limitsfixme}{%
External layouts (\cs{fxloadlayouts}) are not supported.\watchout[external layouts]

User control is provided for setting the \HTML\ styling of the ``faces''.
The defaults are as follows, and may be changed in the preamble after
\pkg{fixme} is loaded:
\begin{sourcedisplay}
\cs{def}\cs{FXFaceInlineHTMLStyle}\{font-weight:bold\} \\
\cs{def}\cs{FXFaceEnvHTMLStyle}\{font-weight:bold\} \\
\cs{def}\cs{FXFaceSignatureHTMLStyle}\{font-style:italic\} \\
\cs{def}\cs{FXFaceTargetHTMLStyle}\{font-style:italic\}
\end{sourcedisplay}
\bigskip
}

\newcommand{\limitsnewtxmath}{%
The proper load order is:
\watchout[loading sequence]
\begin{sourcedisplay}
\textrm{\dots} \\
\cs{usepackage}\{lwarp\} \\
\textrm{\dots} \\
\cs{usepackage}\{amsthm\} \\
\cs{usepackage}\{newtxmath\} \\
\textrm{\dots} \\
\end{sourcedisplay}
}



\newcommand{\osportabilityusage}{%
\pkg{lwarp} tries to detect which operating system is being used.
\DescribeProgram{Unix}\DescribeProgram{Mac OS}\DescribeProgram{Linux}
\textsc{Unix}~/ \textsc{Mac~OS}~/ \textsc{Linux} is the default
(collectively referred to as ``\textsc{Unix}'' in the configuration files),
and \textsc{MS-Windows} is supported as well.

If \textsc{Windows} is not correctly detected,
\DescribeProgram{MS-Windows} \DescribeProgram{Windows}
use the \pkg{lwarp} option \texttt{OSWindows}.
\DescribeOption{OSWindows}

When detected or specified, the operating-system path separator used by \pkg{lwarp}
is modified, the boolean \texttt{usingOSWindows} is set true.
This boolean may be tested by the user for later use.
}


\setlength{\marginparsep}{1em}
\setlength{\marginparpush}{.7ex}
\setlength{\parindent}{0em}
\setlength{\parskip}{2ex}
\setlength{\IndexMin}{40ex}


\setcounter{IndexColumns}{2}

\DisableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{lwarp.dtx}
\end{document}
%</driver>
%
% \fi
%
%
% \iffalse
%<*package>
% \fi
%
% \CheckSum{16359}
%
% \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
%   Lower-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
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote \"      Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent \'      Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than \>      Question mark \?
%   Commercial at \@     Left bracket \[      Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent \`      Left brace    \{     Vertical bar \|
%   Right brace   \}     Tilde         \~}

%
% \changes{v0.10}{2016/03/08}{\ 2016/03/08 Initial version}
% \changes{v0.11}{2016/03/11}{\ 2016/03/11}
% \changes{v0.11}{2016/03/10}{Test Suite: limages and index in README.txt}
% \changes{v0.11}{2016/03/11}{Test Suite: MS-Windows in README.txt}
% \changes{v0.12}{2016/03/14}{\ 2016/03/14}
% \changes{v0.12}{2016/03/14}{Global: Uses \textbackslash{}p@(type) in float captions.}
% \changes{v0.12}{2016/03/14}{Test Suite: Sub-figures}
% \changes{v0.13}{2016/03/24}{\ 2016/03/24}
% \changes{v0.13}{2016/03/23}{Test Suite: Ordinals, Subcaption}
% \changes{v0.13}{2016/03/24}{Removed package: subfig}
% \changes{v0.14}{2016/03/31}{\ 2016/03/31}
% \changes{v0.14}{2016/03/29}{Test Suite: Assigned cleveref name for Test Float.}
% \changes{v0.14}{2016/03/31}{Test Suite: Floatrow}
% \changes{v0.15}{2016/04/06}{\ 2016/04/06}
% \changes{v0.15}{2016/03/31}{Files: lwarp\_formal.css added.}
% \changes{v0.15}{2016/03/31}{Test Suite: test\_suite\_formal.css file added.}
% \changes{v0.16}{2016/04/11}{\ 2016/04/11}
% \changes{v0.16}{2016/04/07}{Test Suite: Supports XeLaTeX, LuaLaTeX.}
% \changes{v0.16}{2016/04/08}{Test Suite: Lwarp no longer selects fonts.}
% \changes{v0.16}{2016/04/08}{Removed package: suffix}
% \changes{v0.17}{2016/04/14}{\ 2016/04/14}
% \changes{v0.17}{2016/04/14}{Test Suite: Mdframed}
% \changes{v0.17}{2016/04/14}{Test Suite: Fix: Print-version front-matter page numbers.}
% \changes{v0.18}{2016/05/19}{\ 2016/05/19}
% \changes{v0.18}{2016/04/23}{Files: lwarp.css and lwarp\_formal.css: Improved responsive design.}
% \changes{v0.18}{2016/04/23}{File: lwarp.css: Improved TOC outline display.}
% \changes{v0.18}{2016/05/13}{Test Suite: Verse package}
% \changes{v0.19}{2016/06/08}{\ 2016/06/08}
% \changes{v0.19}{2016/05/25}{File: \texttt{lwarp\_mathjax.txt} added.}
% \changes{v0.19}{2016/06/01}{File: lwarp.css: \texttt{tnoteitemheader} added}
% \changes{v0.20}{2017/02/09}{\ 2017/02/09}
% \changes{v0.20}{2016/06/27}{Test Suite: \HTML\ meta descriptions.}
% \changes{v0.20}{2016/09/19}{File: lwarp.css: Minor fixes for validation.}
% \changes{v0.20}{2016/12/08}{Docs: Improved index.}
% \changes{v0.20}{2016/12/17}{File: lwarpmk used to compile print, \HTML, indexes, and lateximages.}
% \changes{v0.20}{2016/12/17}{Removed reliance on make, grep, gawk.}
% \changes{v0.20}{2016/12/17}{Parallel versions of aux files for print/HTML.}
% \changes{v0.20}{2017/01/03}{Moved sidebar and example code to test suite.}
% \changes{v0.20}{2017/01/25}{\pkg{caption} and \pkg{subcaption} supported.}
% \changes{v0.21}{2017/02/23}{\ 2017/02/23}
% \changes{v0.22}{2017/03/02}{\ 2017/03/02}
% \changes{v0.23}{2017/03/02}{\ 2017/03/02}
% \changes{v0.24}{2017/03/15}{\ 2017/03/15}
% \changes{v0.25}{2017/03/22}{\ 2016/03/22}
% \changes{v0.25}{2017/03/16}{Docs: Adds credits for patched code.}
% \changes{v0.26}{2017/03/31}{\ 2017/03/31}
% \changes{v0.27}{2017/04/04}{\ 2017/04/04}
% \changes{v0.28}{2017/04/14}{\ 2017/04/14}
% \changes{v0.29}{2017/04/15}{\ 2017/04/15}
% \changes{v0.30}{2017/04/29}{\ 2017/04/29}
% \changes{v0.31}{2017/05/15}{\ 2017/05/15}
% \changes{v0.32}{2017/06/09}{\ 2016/06/09}
% \changes{v0.33}{2017/07/10}{\ 2017/07/10}
% \changes{v0.34}{2017/08/08}{\ 2017/08/08}
% \changes{v0.34}{2017/07/25}{File: \texttt{README.txt}: updated.}
% \changes{v0.34}{2017/07/25}{Docs: Horizontal space limitations.}
% \changes{v0.35}{2017/08/08}{\ 2017/08/08}
% \changes{v0.36}{2017/08/15}{Source: Improved formatting.}
% \changes{v0.36}{2017/08/17}{\ 2017/08/17}
% \changes{v0.37}{2017/08/19}{\ 2017/08/19}
% \changes{v0.38}{2017/08/27}{\ 2017/08/27}
% \changes{v0.39}{2017/09/05}{\ 2017/09/05}
% \changes{v0.40}{2017/09/25}{\ 2017/09/25}
% \changes{v0.41}{2017/10/07}{\ 2017/10/07}
% \changes{v0.42}{2017/10/30}{\ 2017/10/30}
% \changes{v0.43}{2017/11/08}{\ 2017/11/08}
% \changes{v0.44}{2017/11/22}{\ 2017/11/22}





% \GetFileInfo{lwarp.sty}
%
% \DoNotIndex{\newcommand,\renewcommand,\addtocounter,\begin,\end,\begingroup,\endgroup}
% \DoNotIndex{\global,\ifbool,\ifthenelse,\isequivalentto,\let}
% \DoNotIndex{\booltrue,\boolfalse}
% \expandafter\DoNotIndex\expandafter{\detokenize{\(,\),\,,\\,\#,\$,\%,\^,\_,\~,\ ,\&,\{,\}}}
%
%
% \thispagestyle{empty}
%
% \begin{center}
% \includegraphics[width=.3\linewidth]{lwarp_logo.pdf}
%
% \bigskip
%
% {\Huge The \textbf{lwarp} package}
%
% {\Large \textup{\LaTeX{} to HTML}}
%
% \bigskip
%
% \fileversion{} --- \filedate
%
% \bigskip
%
% {\small\textcopyright{} 2016--2017} Brian Dunn\\ \small \texttt{bd@BDTechConcepts.com}
%
% 
% ^^A % \title{The \pkg{lwarp} package\thanks{This document
% ^^A %   corresponds to \pkg{lwarp}~\fileversion,
% ^^A %   dated \filedate.}}
% ^^A % \author{{\small\textcopyright{} 2016--2017} Brian Dunn\\ \small \texttt{bd@BDTechConcepts.com}}
% ^^A % \published{}
% ^^A % \subtitle{\textup{\LaTeX{} to HTML5}}
% ^^A %
% ^^A % \maketitle
%
% \vfill
%
% \begin{abstract}
% \noindent
% The \pkg{lwarp} package allows \LaTeX\ to directly produce \HTMLfive\ output,
% using external utility programs only for the final conversion of text and images.
% Math may be represented by \SVG\ files or MathJax.
%
% Documents may be produced by pdf\LaTeX, \LuaLaTeX, or \XeLaTeX.
% A |texlua| script removes the need for system utilities such as |make| and |gawk|,
% and also supports |xindy| and |latexmk|.  Configuration is automatic at the
% first manual compile.
%
% Print and \HTML\ versions of each document may coexist, each with its own
% set of auxiliary files.  Support files are self-generated on request.
% Assistance is provided for import into \EPUB\ conversion software and word processors.
%
% A modular package-loading system uses the \pkg{lwarp} version of a package for
% \HTML\ when available.
% Almost two hundred \LaTeX\ packages are supported with these high-level source
% compatibility replacements, and many others work as-is.
%
% A tutorial is provided to quickly introduce the user to the major components
% of the package.
%
%
% \bigskip
%
% \begin{center}
% \textcolor{blue}{To update existing projects, see \cref{sec:updates},
% \nameref{sec:updates}.}
% \end{center}
%
% \bigskip
%
% \noindent
% \textcolor{red!30!black}{\bfseries
% Note that this is still a ``beta'' version of \pkg{lwarp},
% and some things may change in response to user feedback and
% further project development.
% }
%
% \bigskip
%
% \footnotesize
% \begin{description}
% \item[License:] \
%
% 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.
% \end{description}
%
%
% \end{abstract}
%
% \vspace*{\fill}
% \vspace*{\fill}
% \vspace*{\fill}
%
% \end{center}
%
% \clearpage
% 
% \section{Supporting \protect\TeX\ development}
% \changes{v0.42}{2017/10/30}{Docs: Added support page.}
% 
% \TeX\ development:
% \begin{itemize}[nosep]
% \item is mostly open-sourced and a volunteer effort;
% \item benefits students, academics, scientists, engineers, and businesses;
% \item helps drive education, public and private research, and commercial activity;
% \item is used in the fields of mathematics, science, engineering, and the humanities;
% \item spans decades of development;
% \item is enduring --- many older packages are still actively used and maintained;
% \item is largely backwards compatible;
% \item is portable across all the major computing platforms;
% \item is usable even on older computers and away from internet access;
% \item requires no yearly subscription fees;
% \item is supported by an active community of knowledgeable volunteers;
% \item and is continuing to maintain relevance with modern improvements.
% \end{itemize}
% 
% Please consider helping by joining and/or contributing to the \TeX\ Users Group,
% a United States 501(c)(3) tax-exempt charitable organization.
% Contributions are accepted by credit card, check, or Pay Pal, via the United Way,
% or by USA or European bank transfer.
% Membership in TUG supports the development of \TeX{}Live, the major \TeX\ distribution.
% 
% Donations may be directed towards individual projects:
% \begin{description}[nosep]
% \item[TUG Bursary Fund:] Assistance for attending annual TUG meetings.
% \item[CTAN:] The Comprehensive \TeX\ Archive Network --- Central storage for \TeX.
% \item[TeX Development Fund:] Support for specific projects.
% \item[EduTeX:] Teaching and using \TeX\ in schools and universities.
% \item[GUST e-foundry fonts:] Enhanced for math and additional language groups.
% \item[LaTeX Project:] Modernizing the \LaTeX\ core.
% \item[Libre Font Fund:] Fonts, tools (FontForge), and distribution (the Open Font Library).
% \item[LuaTeX:] Combining the pdf\TeX\ engine and the Lua language.
% \item[MetaPost:] Postscript graphics.
% \item[MacTeX:] \TeX\ for Mac.
% \item[PDF Accessibility:] Modern PDF standards.
% \item[Other:] Additional projects may be specified.
% \end{description}
%
% To make a contribution: \hfill
% \href{https://www.tug.org/donate.html}{\texttt{https://www.tug.org/donate.html}}
%
% For users of MiK\TeX: \hfill
% \href{https://miktex.org/donations.html}{\texttt{https://miktex.org/donations.html}}
%
% For country-specific \TeX\ users groups: \hfill
% \href{http://tug.org/usergroups.html}{\texttt{http://tug.org/usergroups.html}}
%
% \clearpage
%
%
% \tableofcontents
%
% \clearpage
% \listoffigures
% \listoftables
%
%
% \thispagestyle{pageheadfoot}
%
% \clearpage
%
% \section{Updates}
% \label{sec:updates}
%
% The following is intended for those updating existing projects which use
% \pkg{lwarp}, highlighting 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}.
%
% \begin{description}
% \item[v0.44:] \
%   \begin{itemize}
%       \item Added \pkg{koma-script} classes (except \pkg{scrlttr2}, \pkg{scrjura}).
%       \margintag{\pkg{koma-script}}
%       \item Added \pkg{scrextend},
%           \pkg{scrlayer}, \pkg{scrlayer-notecolumn}, \pkg{scrlayer-scrpage},
%           \pkg{scrhack}, \pkg{tocstyle}, \pkg{tocbasic}.
%       \item Added \cs{HTMLTitle}.
%           \margintag{HTML title and author}
%           Fixed web page title if \cs{HTMLTitle} empty and no \cs{title} given and
%           not using \pkg{titling} package.
%       \item Fixed web page author if \cs{HTMLauthor} is empty and \cs{author} is not given.
%       \item If using |pdflatex|, automatically loads T1 and UTF8 encodings.
%           \margintag{encodings}
%           (Additional \pkg{fontenc} encodings may be loaded after \pkg{lwarp}.)
%       \item Added \env{list} and \env{trivlist} environments, \pkg{hang}.\margintag{lists}
%       \item Fix: \cs{multicolumn} alignment if formatting for a word processor.
%           \margintag{tabular}
%       \item Added \pkg{ltxtable}.
%       \item Fix: MathJax combined with \env{lateximage}s.\margintag{math}
%       \item \pkg{algorithmicx}: Improved comment symbol and floating.
%       \item Completed \pkg{todonotes} and \pkg{luatodonotes}.
%           \margintag{\pkg{packages}}
%       \item Added \pkg{todo}, \pkg{easy-todo}, \pkg{fixmetodonotes}, \pkg{fixme}.
%       \item Added \pkg{soulutf8}, \pkg{soulpos}, \pkg{cancel}.
%       \item Added \pkg{section}, \pkg{fancyref}, \pkg{ifoddpage}.
%       \item Added \pkg{preview}, \pkg{atbegshi}, \pkg{watermark}.
%       \item Improved \pkg{tocloft} \cs{newlistof} and \cs{newlistentry}.
%   \end{itemize}
% \item[v0.43:] \
%   \begin{itemize}
%       \item Docs: Reorganized \HTML\ customization, added an \HTML\ settings table.
%           See \cref{sec:htmlsettings}.
%       \item Added |FootnoteDepth| to control the placement
%           \margintag{footnotes}
%           of pending footnotes before section breaks.
%           By default, pending footnotes are printed before
%           each \cs{subparagraph} or higher.
%       \item Fix: Expansion in section name. \margintag{sectioning}
%       \item Fix: Ignore spaces in tabular column specification.
%           \margintag{\env{tabular}}
%       \item Fix: Tabular rules at bottom or when finishing incomplete rows.
%       \item Fix: \cs{multicolumn} at/bang/before/after specifications, trim,
%           and vertical rules.
%       \item Fix: \pkg{supertabular} and \pkg{xtab} column misalignment.
%       \item Fix: \env{equation*}.
%           \margintag{math}
%       \item Fix: \SVG\ math in a section name.
%       \item Fix: \cs{ref} and \cs{eqref} in \SVG\ math.
%       \item Added \pkg{todonotes} and \pkg{luatodonotes} (but only |disabled|).
%           \margintag{packages}
%       \item Added \pkg{breakurl}.
%       \item \pkg{hyperref}: Fix: Several macros were made robust, \cs{Gauge} added.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.42:] \
%   \begin{itemize}
%       \item Added \TeX\ development support page.\margintag{Support \TeX!}
%       \item Improved assitance for word-processor conversions when
%           \margintag{word-processor conversion}
%           boolean |FormatWP| is set |true|.
%           See \cref{sec:wordprocessorconversion}.
%           \begin{itemize}
%           \item \textcolor{red}{The} \watchout[name change]
%               \textcolor{red}{boolean |FormatWordProcessor| has
%               been renamed |FormatWP|.}
%           \item \textcolor{red}{The} \watchout[name change]
%               \textcolor{red}{boolean |HTMLMarkFloats| has
%               been renamed |WPMarkFloats|.}
%           \item New booleans control whether to place additional
%               marks around minipages, at the table of contents,
%               at the \acro{LOF} and \acro{LOT}, and whether to
%               print math as \LaTeX\ source for copy/paste into the
%               LibreOffice Writer TeXMaths extension.
%           \item Improved formatting for numerous objects.
%               See \cref{sec:wordprocessorconversion}.
%           \end{itemize}
%       \item Add: \env{tabbing} environment.
%           \margintag{\env{tabbing}}
%       \item Add: \pkg{overpic} package.  See \cref{sec:overpic}.
%           \margintag{\pkg{overpic}}
%       \item Fix: Text copy/paste of \AmS\ math environment numbers and names.
%           \margintag{math}
%       \item Improved \cs{ensuremath}.
%       \item MathJax with \pkg{siunitx}: Updated script and documentation.
%       \item \pkg{textcomp}: Improved \cs{interrobangdown}.
%           \margintag{symbols}
%       \item \pkg{realscripts}: Fix for subscripts in a \env{lateximage}.
%       \item \pkg{morewrites}: Enforces loading before \pkg{lwarp}.
%           \margintag{load order}
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.41:] \
%   \begin{itemize}
%       \item Added tabular vertical rules, subject to some limitations.
%           \margintag{\env{tabular}}
%           See the rules section of \cref{sec:limitstabular}.
%       \item Improved \pkg{booktabs}: Width and trim are honored.
%       \item Added \cs{mcolrowcell} for empty cells inside a \cs{multicolumnrow}.
%           \watchout[new syntax]
%           \textcolor{red}{Use \cs{mcolrowcell} instead of \cs{mrowcell} for two-dimensional
%           cells created by \cs{multicolumnrow}.}
%           Continue to use \cs{mrowcell} for empty cells in a \cs{multirow}.
%           See \cref{sec:multicolumnmultirow} on \cpageref{sec:multicolumnmultirow}.
%       \item Fix: Unfinished tabular rows are automatically filled.
%       \item Fix for tabular column specifiers while using \pkg{babel-french}.
%           (\cs{NoAutoSpacing} is activated then nullified inside the tabular,
%           due to a conflict with the tabular column parsing code.)
%   \end{itemize}
% \item[v0.40:] \
%   \begin{itemize}
%       \item \pkg{graphics} and \pkg{graphicx} have been moved from the
%           \margintag{\pkg{graphics}, \pkg{graphicx}}
%           \pkg{lwarp} core, and are only loaded if requested with \cs{usepackage}.
%       \item Improved \pkg{graphics} \cs{graphicspath} support.
%           \margintag{\cs{includegraphics} path}
%           Multiple image directories may now be used.
%           \textcolor{red}{Refer to |.pdf| files without a file extension}
%           \watchout[image file extensions]
%           to allow the \HTML\ version
%           to use a |.svg|, |.png|, |.jpg|, or |.gif| version instead.
%           See \cref{sec:limitsgraphics}.
%       \item \pkg{grffile} is now directly supported instead of emulated.
%       \item Fix for \pkg{bigdelim}, and improved documentation.
%           \margintag{\pkg{bigdelim}}
%           See \cref{sec:bigdelim}.
%       \item Improved \LaTeX\ and \pkg{textcomp} symbols.\margintag{\pkg{symbols}}
%       \item Fix for \LaTeX\ logos and \cs{InlineClass}, etc. inside a \env{lateximage}.
%           \margintag{\pkg{fixes}}
%       \item Fix for \pkg{xltxtra} with \XeLaTeX.
%       \item Fixes for \pkg{tocbibind} with \cs{simplechapter}, etc.
%		\item Fixes for \cs{multicolumnrow} and \cs{nullfonts} with older versions
%			of \pkg{multirow} and \pkg{xparse}.
%       \item Added \cs{underline}.
%       \item Added \pkg{adjmulticol}.\margintag{margins}
%       \item Added \pkg{cuted}, \pkg{midfloat}.\margintag{columns}
%       \item Added \pkg{pfnote}, \pkg{fnpos}, \pkg{dblfnote}.\margintag{footnotes}
%       \item Added \pkg{stabular}, \pkg{tabls}.\margintag{tabular}
%       \item Added \pkg{sectsty}, \pkg{anonchap}, \pkg{quotchap}.\margintag{sectioning}
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.39:] \
%   \begin{itemize}
%       \item Improved the titlepage \HTML\ code, \cs{thanks} notes,
%           \margintag{title pages}
%           and \cs{maketitle}.
%           \pkg{titling} is no longer required, but is still supported.
%           The \cs{published} and \cs{subtitle} fields are no longer provided,
%           \watchout[\cs{published} and \cs{subtitle}]
%           but \cs{AddSubtitlePublished} replicates them using \pkg{titling}.
%           See \cref{sec:publishedsubtitle}.
%           \pkg{authblk} is added, and should be loaded before \pkg{titling}.
%           \watchout[load order]
%           See \cref{sec:titles}.
%       \item \cs{multirow} now supports the new optional |vpos| argument.
%           \margintag{tabular}
%       \item Added \cs{multicolumnrow} for combined
%           \margintag{multi column/row cell}
%           \cs{multicolumn} and \cs{multirow}.
%           See \cref{sec:multicolumnmultirow}.
%       \item Tabular special cases:
%       \begin{itemize}
%            \item Added \cs{TabularMacro} to mark custom macros
%                \watchout[macros inside tabular]
%                inside tabular data cells, avoiding row corruption.
%                See \cref{sec:limitstabular}.
%            \item Added \cs{ResumeTabular} for use when a \env{tabular} environment
%                \watchout[tabular defined inside another environment]
%                is defined inside another environment.
%                See \cref{sec:limitstabular}.
%       \end{itemize}
%       \item Added \pkg{supertabular}, \pkg{xtab}, \pkg{bigstrut}, \pkg{bigdelim}.
%           \margintag{tabular}
%       \item Added \pkg{fullwidth}.\margintag{margins}
%       \item Added \pkg{addlines}, \pkg{anysize}, \pkg{a4}, \pkg{a4wide}, \pkg{a5comb},
%           \margintag{page layout}
%           \pkg{textarea}, \pkg{zwpagelayout}, \pkg{typearea}, \pkg{ebook}.
%   \end{itemize}
% \item[v0.38:] \
%   \begin{itemize}
%   \item Added |lwarpmk print1| and |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,
%       or changes were not detected.
%   \item Added \cs{ForceHTMLPage} and \cs{ForceHTMLTOC} to force
%       \margintag{starred sections}
%       a starred sectional unit onto its own \HTML\ page
%       and with its own \acro{TOC} entry.
%       See \cref{sec:forcesectionstar}.
%   \item Modified the tutorial to use the new \cs{ForceHTMLPage}
%       \margintag{updated tutorial}
%       and \cs{ForceHTMLTOC} macros.
%   \item Added \pkg{appendix}, \pkg{tocbibind}, \pkg{fncychap}, \pkg{fix2col}.
%       \margintag{packages}
%   \item Added \pkg{relsize}, \pkg{scalefnt}.\margintag{font size}
%   \item Added \pkg{realscripts}, \pkg{metalogo}, \pkg{xltxtra}.
%   \item Added \pkg{grffile}, \pkg{romanbar}.
%   \item Added \pkg{arabicfront}, \pkg{chappg}, \pkg{nonumonpart}, \pkg{nopageno},
%       \margintag{page numbering}
%       \pkg{romanbarpagenumber}.
%   \item Docs: Improved description of the use of front/back matter.
%       \margintag{front \& back matter}
%       See \cref{sec:frontbackmatter}.
%   \item Fix: \pkg{color} requests \pkg{xcolor}.
%   \item Fix: \cs{part} for |article| class.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.37:] \
%   \begin{itemize}
%   \item \cs{include} now maintains independent |.aux| files
%       \margintag{\cs{include} for \HTML}
%       for \HTML\ versions.
%   \item \pkg{comment}, used by \pkg{lwarp}, now maintains
%       \margintag{\texttt{latexmk}}
%       independent cut files for print and \HTML\ versions, helping |latexmk| to
%       better know whether to recompile.
%   \item Improved support for \LaTeX\ accents,
%       \margintag{accents and symbols}
%       \pkg{textcomp}, \pkg{siunitx} symbols.
%   \item Improved \pkg{babel-french} handling for
%       \margintag{\pkg{babel-french}}
%       load order and \textasciitilde\ tilde.
%   \end{itemize}
% \item[v0.36:] \
%	\begin{itemize}
%	\item Recorganized the documentation section regarding special cases and limitations.
%		(\Cref{sec:limitations})
%   \item Improved source formatting.
%	\item \cs{fbox} and related now use \cs{fboxsep} and \cs{fboxrule}.
%       \margintag{boxes and frames}
%	\item \cs{makebox} and \cs{framebox} now use width and position.
%	\item \cs{fcolorbox} and related now work inside a \env{lateximage}.
%   \item \pkg{babel-french}: Improvements for French variants, load order,
%       \margintag{\pkg{babel-french}}
%       footnotes, ellipses.
%   \item Improved footnote numbering.
%       \margintag{footnotes}
%       \env{lateximage} footnotes now appear as regular footnotes to match
%       the numbering of the print version.
%       Also fixed a regression with MathJax.
%   \item Improved \pkg{siunitx} units.
%       \margintag{\pkg{siunitx}}
%   \item Fix for filenames while using MathJax.
%   \item Fix for \cs{rule} when \pkg{xcolor} is not loaded.
%	\item Added \pkg{transparent}, \pkg{upref}.
%	\end{itemize}
% \item[v0.35:] Fix: \cs{textbf} and related.
% \item[v0.34:] \
%	\begin{itemize}
%	\item \env{BlockClass}'s optional argument has been moved
%		\watchout[Optional arguments]
%		in front of the mandatory argument:
%		\begin{sourcedisplay}
%		|BlockClass[style]{class}| \quad \textrm{(NEW)}
%		\end{sourcedisplay}
%		instead of:
%		\begin{sourcedisplay}
%		|BlockClass{class}[style]| \quad \textrm{(OLD)}
%		\end{sourcedisplay}
%		This change makes it more consistent with \LaTeX\ standards,
%		and avoids problems with space between arguments.
%	\item Likewise, \cs{InlineClass}'s optional argument now
%		\watchout[Optional arguments]
%		comes before the mandatory arguments:
%		\begin{sourcedisplay}
%		|\InlineClass[style]{class}{text}|
%		\end{sourcedisplay}
%	\item Improved compatibility between spans, minipages, lists,
%		\margintag{spans with minipages}
%		frames, and math.
%		Handles minipages and lists inside an \HTML\ span,
%		such as an \cs{fbox} containing a minipage,
%		although with minimal \HTML\ fomatting.
%		See \cref{sec:minipages}.
%		\cs{fboxBlock} is added to frame minipages, tables,
%		\margintag{framing minipages}
%		and lists with full \HTML\ formatting
%		but no longer inline, and behaves as \cs{fbox} for print output.
%		The \env{fminipage} environment is added for framed minipages,
%		as an environment with full \HTML\ formatting,
%		and draws a framed minipage in print output.
%		See \cref{sec:framedminipages}.
%		\cs{fbox} and minipages now often work in \SVG\ math and \env{lateximage}s.
%		MathJax supports \cs{fbox}, but not \cs{fboxBlock} nor \env{fminipage}.
%	\item Improved compatibility between \env{lateximage} and
%		\margintag{\env{lateximage}, \SVG\ math, \env{tabular}}
%		\env{minipage}, \cs{parbox}, \cs{makebox}, \cs{fbox}, \cs{framebox},
%		\cs{raisebox}, \cs{scalebox}, \cs{reflectbox}, \env{tabular}, \pkg{booktabs}.
%	\item Improved font control for \env{lateximage}es and \SVG\ math.
%	\item Added the \env{eqnarray} environments.\margintag{\env{eqnarray}}
%	\item \pkg{fancyvrb} is no longer required (preloaded),
%		\margintag{verbatim packages}
%		but is still supported.
%	\item Added \pkg{verbatim} and \pkg{moreverb}.
%	\item Added \pkg{fancybox}, \pkg{boxedminipage2e} and \pkg{shadow}.
%		\margintag{framing packages}
%	\item \pkg{enumitem} is no longer required, but is still supported.
%		\margintag{list packages}
%	\item Added \pkg{enumerate} and \pkg{paralist}.
%	\item \pkg{titleps} is no longer required, but is still supported.
%	\item Added \pkg{crop}.
%	\item Added \pkg{rotfloat}, \pkg{marginfit},
%		and several minor packages; see the change log.
%	\item Adds fixed-width \HTML\ spaces around punctuation
%		\margintag{\pkg{babel-french}}
%		when using \pkg{babel-french}.
%       \LuaTeX\ does not yet use the extra punctuation spacing.
%	\end{itemize}
% \needspace{2\baselineskip}
% \item[v0.33:] \
%	\begin{itemize}
%	\item Tabular |@| and |!| columns now have their own \HTML\ columns.
%	\item |&| catcode changes are localized, perhaps causing errors
%		about the tab alignment character |&|,
%		so any definitions of macros or environments
%		which themselves contain \env{tabular} and |&| must be enclosed within \cs{StartDefiningTabulars}
%		and \cs{EndDefiningTabulars}.  See \cref{sec:localizingampersand}.
%		This change is not required for the routine use of tables,
%		but only when a table is defined inside another macro or environment,
%		and while also using the |&| character inside the definition.
%		This may include the use inside conditional expressions.
%	\item   Several math environments were incorrectly placed inline.
%		Also, for \pkg{amsmath} with \SVG\ math, the |fleqn| option has been removed,
%		resulting in improved spacing for aligned equations.
%	\item Bug fixes; see the changelog.
%	\end{itemize}
% \item[v0.32:] Bug fixes; no source changes needed:
%	\begin{itemize}
%	\item |lwarpmk| has been adjusted to work with the latest |luatex|.
%	\item Spaces in the \cs{usepackage} and \cs{RequirePackage} package lists are now accepted and ignored.
%	\item Fix for the \pkg{glossaries} package and \cs{glo@name}.
%	\end{itemize}
% \item[v0.31:] Bug fix; no source changes needed:
%	\begin{itemize}
%	\item Improved compatibility with \pkg{keyfloat},
%		including the new \env{keywrap} environment.
%	\end{itemize}
%	\needspace{2\baselineskip}
% \item[v0.30:] \
%	\begin{itemize}
%	\item \pkg{lwarp-newproject} has been removed, and its functions
%		\watchout[\pkg{lwarp-newproject}]
%		have been combined with \pkg{lwarp}.
%
%		To modify existing documents, remove from the document source:
%		\begin{sourcedisplay}
%		\cs{usepackage}\{lwarp-newproject\}
%		\end{sourcedisplay}
%
%		The \pkg{lwarp} package now produces the configuration files during
%		print output, and also accepts the option |lwarpmk| if desired.
%
%	\item A number of macros
%		\watchout[HTML setup changes.]
%		related to \HTML\ settings have been converted to options, and
%		other macros and options have been renamed to create a consistent syntax:
%		\begin{center}
%		\begin{tabular}{ll}
%		\toprule
%		Old Macro & New Package Option \\ \midrule
%		\cs{HomeHTMLFileName} & |HomeHTMLFilename| \\
%		\cs{HTMLFileName} & |HTMLFilename| \\
%		\cs{useLatexmk} & |latexmk| \\
%		\cs{warpOSwindows} & |OSWindows| \\[2.5ex] \toprule
%		Old Package Option & New Package Option \\ \midrule
%		|lwarpmklang| & |IndexLanguage| \\
%		(new) & |xdyFilename| \\[2.5ex] \toprule
%		Old Macro & New Macro \\ \midrule
%		\cs{MetaLanguage} & \cs{HTMLLanguage} \\
%		\cs{HTMLauthor} & \cs{HTMLAuthor} \\
%		\cs{NewHTMLdescription} & \cs{HTMLDescription} \\
%		\cs{SetFirstPageTop} & \cs{HTMLFirstPageTop} \\
%		\cs{SetPageTop} & \cs{HTMLPageTop} \\
%		\cs{SetPageBottom} & \cs{HTMLPageBottom} \\
%		\cs{NewCSS} & \cs{CSSFilename} \\
%		\bottomrule
%		\end{tabular}
%		\end{center}
%
%	\needspace{2\baselineskip}
%	\item Per the above changes, in existing documents,
%		modify the package load of \pkg{lwarp}, such as:
%		\begin{Verbatim}[tabsize=4,gobble=2]
%		\usepackage[
%			HomeHTMLFilename=index,
%			HTMLFilename={},
%			IndexLanguage=english
%		]{lwarp}
%		\end{Verbatim}
%
%	\item The file |lwarp_html.xdy| has been renamed |lwarp.xdy|.
%		To update each document's project:
%		\begin{enumerate}
%		\item Make the changes shown above.
%		\item Recompile the document in print mode.
%			This updates the project's configuration files, and also generates the
%			new file |lwarp.xdy|.
%		\item The old file |lwarp_html.xdy| may be deleted.
%		\end{enumerate}
%
%	\item The new \pkg{lwarp} package option |xdyFilename| may be used to tell
%	|lwarpmk| to use a custom |.xdy| file instead of |lwarp.xdy|.
%	See \cref{sec:modifyxindy}.
%
%	\item Improvements in index processing:
%		\begin{itemize}
%		\item |xindy|'s language is now used for index processing
%			as well as glossary.
%		\item Print mode without |latexmk| now uses |xindy| instead of |makeindex|.
%		\item |texindy|/|xindy| usage depends on |pdflatex| vs |xelatex|, |lualatex|.
%		\item For |pdflatex| and |texindy|, the |-C utf8| option is used.  This is
%			supported in modern distributions, but a customized |lwarpmk.lua| may
%			need to be created for use with older distributions.
%		\end{itemize}
%
%	\end{itemize}
%
% \needspace{2\baselineskip}
%
% \item[v0.29:] \
%	\begin{itemize}
%	\item Add: |lwarpmklang| option for \pkg{lwarp-newproject} and \pkg{lwarp}.
%		Sets the language to use while processing the glossary.
%		(As of v0.30, this has been changed to the |IndexLanguage| option.)
%	\item Fix: \cs{includegraphics} when no optional arguments.
%	\end{itemize}
% \item[v0.28:] \
%	\begin{itemize}
%	\item \cs{HTMLAuthor} \marg{name} assigns \HTML\ meta author if non-empty.
%		Defaults to \cs{theauthor}.
%	\item Booean |HTMLDebugComments| controls whether \HTML\ comments are
%		added for closing \element{div}s, opening and closing sections, etc.
%	\item Boolean |FormatEPUB| changes \HTML\ output for easy \EPUB\ conversion
%		via an external program.
%		Removes per-file headers, footers, and nav.  Adds footnotes per chapter/section.
%	\item Boolean |FormatWordProcessor| changes \HTML\ output for easier conversion
%		by a word processor.  Removes headers and nav, prints footnotes per section,
%		and also forces single-file output and turns off \HTML\ debug comments.
%       Name changed to |FormatWP| as of v0.42.
%	\item Boolean |HTMLMarkFloats| adds text marks around floats only if
%		|FormatWordProcessor|.  These make it easier to identify float boundaries,
%		which are to be manually converted to word-processor frames.
%       Name changed to |WPMarkFloats| as of v0.42.
%	\item Updated for the new MathJax \acro{CDN} repository.
%	\item Adds \pkg{tabulary}.
%	\item Supports the options syntax for \pkg{graphics}.
%	\item Improved index references, now pointing exactly to their target.
%	\item Adds \pkg{glossaries}.
%		|lwarpmk| is modified to add |printglosssary| and |htmlglossary| actions.
%	\end{itemize}
%
% ^^A	\needspace{2\baselineskip}
% ^^A  \item[v0.27:] \
% ^^A 	\begin{itemize}
% ^^A 	\item Improved documentation for MacOS install.
% ^^A 	\item Fix for \pkg{microtype} with \XeLaTeX\ and \LuaLaTeX.
% ^^A 	\item Fix for table footnote paragraph tags.
% ^^A 	\item Adds \pkg{lettrine}, \pkg{ulem}, and \pkg{soul}.
% ^^A 	\end{itemize}
% ^^A  \needspace{2\baselineskip}
% ^^A  \item[v0.26:] \
% ^^A 	\begin{itemize}
% ^^A 	\item Improved installation instructions for MiK\TeX\ regarding generating
% ^^A 		the |lwarpmk| executable.
% ^^A 	\item Footnotes are now supported by \LaTeX\ boxes instead of pagenotes.
% ^^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 		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}
% ^^A  \needspace{2\baselineskip}
% ^^A  \item[v0.25:] \
% ^^A 	\begin{itemize}
% ^^A 	\item Fix: Allows \pkg{graphicx} and \pkg{graphicx} before \pkg{lwarp} because
% ^^A 		\XeLaTeX\ and \LuaLaTeX\ use \pkg{xunicode} which uses \pkg{graphics}.
% ^^A 	\item Package support for \pkg{framed}, several theorem packages, and ellipses.
% ^^A 	\end{itemize}
% ^^A  \needspace{2\baselineskip}
% ^^A  \item[v0.24:] \
% ^^A 	\begin{itemize}
% ^^A 	\item \pkg{tikz}'s |babel| library is load automatically as needed.
% ^^A 	\item \pkg{subfig} has been added, along with |lofdepth| and |lotdepth|.
% ^^A 	\item \env{picture} and \env{tikzpicture} now may be inline.
% ^^A 	\end{itemize}
% ^^A  \needspace{2\baselineskip}
% ^^A  \item[v0.22:] \
% ^^A 	\begin{itemize}
% ^^A 	\item Support has been added for tabular column types |D|, |!|, and |X|.
% ^^A 		Unknown column types are converted to |l|.
% ^^A 	\item Additional packages are supported, including \pkg{abstract},
% ^^A 		\pkg{dcolumn}, \pkg{tabularx}, and \pkg{varioref}.
% ^^A 	\end{itemize}
% ^^A  \item[v0.21:] \
% ^^A 	\begin{itemize}
% ^^A 	\item Documentation for installing on Windows has been updated and improved.
% ^^A 	\item For Windows compatibility, the |lateximages| shell script
% ^^A 		has been replaced with a |lateximages.txt| file, which is parsed
% ^^A 		by |lwarpmk| to generate lateximages.
% ^^A 		This does not require any changes in the user's code.
% ^^A 	\item Windows |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}
% ^^A 		must be loaded before \pkg{lwarp}, and the other packages which
% ^^A 		\pkg{lwarp} knows about must be loaded after.
% ^^A 	\item \pkg{lwarp} no longer requires a \cs{title} be assigned.
% ^^A 	\end{itemize}
% ^^A  \item[v0.20:] \
% ^^A 	\begin{itemize}
% ^^A 	\item The |makefile| and related infrastructure
% ^^A 		has been replaced by the |lwarpmk| utility.
% ^^A 		This provides increased portability, reduced dependencies,
% ^^A 		and much simpler installation and setup.
% ^^A 	\item The |lwarp-newproject| package is now used to locally create
% ^^A 		support files.
% ^^A 	\item The print and \HTML\ versions of a document may co-exist with their
% ^^A 		own sets of auxiliary files.
% ^^A 	\item Package handling is now controlled by a modular system which
% ^^A 		looks for and loads an |lwarp-<package>| version if available.
% ^^A 	\item High-level source compatibility is provided for all supported
% ^^A 		packages, almost totally eliminating the need
% ^^A 		for |warpprint| and |warpHTML| environments.
% ^^A 	\item A large number of additional packages are supported.
% ^^A 	\item A new tutorial is included in the documentation, and
% ^^A 		many obsolete sections have been removed.
% ^^A 	\item \cs{NewHTMLdescription} sets the \HTML\ meta description tag for each file.
% ^^A 		See \cref{sec:htmldescription}.  (v0.30 changes this to \cs{HTMLDescription}.)
% ^^A 	\item \cs{HTMLFilename} may now be empty, allowing filenames without a prefix.
% ^^A 		Lwarp no longer automatically appends a |-| character.
% ^^A 		\watchout
% ^^A 		For existing projects, add a |-| to the end of \cs{HTMLFilename}.
% ^^A 	\item \cs{HomeHTMLFilename} and \cs{HTMLFilename} no longer use
% ^^A 		escaped underscore\watchout\
% ^^A 		characters.  Underscores may be used in filenames as-is.
% ^^A 		(Version 0.30 changes these to package options |HomeHTMLFilename| and
% ^^A 		|HTMLFilename|.)
% ^^A 	\item \pkg{lwarp} now tries to auto-detect the operating system,
% ^^A 		and \cs{warpOSwindows} is only needed if the auto-detection
% ^^A 		fails to detect Windows. (As of v0.30, \cs{warpOSwindows} has been converted to
% ^^A 		the |OSWindows| option.)
% ^^A 	\item Tabular column types |@|, |>|, and |<| are now supported.
% ^^A 	\item |BlockClass| and \cs{InlineClass} add an optional style.
% ^^A 	\item The |sidebar| and |example| environments have been moved to the
% ^^A 		test suite, and are no longer included in \pkg{lwarp}.
% ^^A 	\end{itemize}
% ^^A 	\needspace{2\baselineskip}
% ^^A  \item[v0.19:] \
% ^^A 	\begin{itemize}
% ^^A 	\item \textsc{MathJax} now may be used to display math via the |mathjax| option.
% ^^A 		See \cref{sec:loading,sec:limitsmath}.
% ^^A 	To use MathJax with a pre-existing project,
% ^^A 	\watchout
% ^^A 	copy or link the file |lwarp_mathjax.txt| to the project's directory.
% ^^A 	\item \cs{rule} added, supporting width, height, raise, \cs{textcolor}.
% ^^A 	\item \cs{LateximageFontSizeName} provides user-adjustable font size for math
% ^^A 		and \env{lateximage}s.
% ^^A 	\item \cs{minipagefullwidth} requests that the next minipage be
% ^^A 		full-width in \HTML, but still the assigned width in print.
% ^^A 	\item \env{minipage} improved side-by-side rendering.
% ^^A 	\item CSS class |tablenotes| is provided for table note items.
% ^^A 	\item \cs{warpprintonly} replaces \cs{rowprintedonly},
% ^^A 		and \cs{warpHTMLonly} is added.  These behave like the \env{warpprint}
% ^^A 		\watchout
% ^^A 		and \env{warpHTML} environments, and are generally useful, so they replace
% ^^A 		the previously table-specific syntax.
% ^^A 	\item \pkg{cleveref} is loaded \cs{AtEndPreamble} for improved reliability.
% ^^A 		See \cref{sec:cleveref}.
% ^^A 	\item \cs{xfracHTMLfontsize} controls \pkg{xfrac} font size in \HTML.
% ^^A 	\item \tikz\ improved catcode handling.
% ^^A 	\end{itemize}
% ^^A  \item[v0.18:] \
% ^^A 	\begin{itemize}
% ^^A 	\item The \pkg{verse} package and the verse-related commands from
% ^^A 		the \pkg{memoir} package are now supported.
% ^^A 	\item Responsive web design has been improved for the side\TOC.
% ^^A 	\item \cs{includegraphics} now maintains relative sized for em, ex, and \%.
% ^^A 	\end{itemize}
% ^^A  \item[v0.17:] \
% ^^A 	\begin{itemize}
% ^^A 	\item \pkg{mdframed} package is supported.
% ^^A 	\end{itemize}
% ^^A  \item[v0.16:] \
% ^^A 	\begin{itemize}
% ^^A 	\item Font and input encoding are now controlled by the user, and
% ^^A 		\pkg{lwarp} is loaded after fonts have been selected.
% ^^A 	\item Support for \XeLaTeX{} and \LuaLaTeX.  See \cref{sec:fonts}.
% ^^A 	\end{itemize}
% \end{description}
%
% \clearpage
%
% \section{Introduction}
% \changes{v0.19}{2016/05/25}{Introduction: MathJax support mentioned.}
%
% The \pkg{lwarp} project aims to allow a rich \LaTeX{} document
% to be converted to a reasonable \HTML\
% interpretation.  No attempt has been made to force \LaTeX{} to provide for every
% \HTML-related possibility, and \HTML\ cannot exactly render every possible \LaTeX{} concept.
% Where compromise is necessary, it is desirable to allow the print output to remain
% typographically rich, and compromise only in the \HTML\ conversion.
%
% Several ``modern'' features of \HTMLfive, \CSSthree, and \SVG\
% are employed to allow a fairly feature-rich document
% without relying on the use of Javascript.
% Limited testing on older browsers show that these new features
% degrade gracefully, although the \SVG\ format
% for math may not be available on small cell phones.
%
% |pdflatex|, |xelatex|, or |lualatex| is used, allowing \pkg{lwarp} to process the usual image formats.
% While generating \HTML\ output, \SVG\ files are used in placed of \PDF.
% Other formats such as \JPG\ are used as-is.
%
% \SVG\ images may be used for math,
% and are also used for \env{picture}, and \tikz{} environments,
% as this format has
% better browser and e-book support than \MathML\ (as of this writing),
% while still allowing for the high-quality display and printing of images (again, subject to potentially
% bug-ridden\footnote{Firefox has had an on-again/off-again bug for quite some time regareding
% printing \SVG{}s at high resolution.} browser
% support).
%
% Furthermore, \SVG\ images allow math to be presented with
% the same precise formatting as in the print version.
% Math is accompanied by \element{alt} tags holding the \LaTeX{} source for the expression, allowing it to be
% copy/pasted into other documents.\footnote{There seems to be some debate as to whether
% \MathML\ is actually an improvement over \LaTeX{} for sharing math.  The author has no
% particular opinion on the matter, except to say that in this case \LaTeX{} is much easier to implement!}
% Custom \LaTeX{} macros may be used as-is in math expressions, since the math is evaluated
% entirely inside \LaTeX.
%
% The \textsc{MathJax} JavaScript display engine may be selected
% for math display instead of using \SVG\ images.
% Subject to browser support and Internet access,
% MathJax allows an \HTML\ page to display
% math without relying on a large number of external image files,
% one per math expression.  \pkg{lwarp} maintains \LaTeX\ control for cross-referencing
% and equation numbering\,/\,formatting.
%
% \hfill\rule[.7ex]{.3\linewidth}{.4pt}\hspace*{\fill}
%
% The \pkg{lwarp} package allows \LaTeX{} to directly generate \HTMLfive\ tags from a \LaTeX{}
% source document, with only minor intervention on the user's part.
% A |texlua| program called |lwarpmk| is used to process either the print or \HTML\
% version of the document.  A few external utility programs are used to finish
% the conversion from a \LaTeX{}-generated \PDF\ file which happens to have \HTMLfive\ tags,
% to a number of \HTMLfive\ plain-text files and accompanying images.
%
% \pkg{lwarp} automatically generates the extra files necessary for
% the \HTML\ conversion, such as \CSS\ and |.xdy| files, and configuration files
% for the utility |lwarpmk|.
% Also included is a parallel version of the user's source document,
% |<sourcename>-html.tex|, which selects \HTML\ output and then inputs the user's own source.
% This process allows both the printed and \HTML\ versions to co-exist side-by-side,
% each with their own auxiliary files.
%
% When requesting packages during \HTML\ conversion,
% |lwarp| first looks to see if it has its own modified version
% to use instead of the usual \LaTeX\ version.  These |lwarp-packagename.sty| files contain
% code used to emulate or replace functions for \HTML\ output.
%
% Enough functionality is provided to convert a typical article containing technical content.
% Not every package has been tested, but many of the most useful ones are known to work,
% either as-is or through emulation with replacement code.  (See \cref{tab:supported}.)
%
% Assistance is provide for modifying the \HTML\ output to suite the creation
% of \EPUB\ documents, and for modifying the \HTML\ output to ease import into
% a word processor.
%
%
% \subsection{Supported packages and features}
%
% \changes{v0.15}{2016/04/05}{Docs: Moved the supported functions table to the introduction.}
% \changes{v0.38}{2017/08/22}{Docs: Enhanced \protect\textit{Supported Functions} table.}
%
% Supported classes include \pkg{book}, \pkg{report}, and \pkg{article},
% and the Koma-script classes \pkg{scrbook}, \pkg{scrreprt}, and \pkg{scrartcl}.
% \pkg{memoir} is planned, but in the meantime many of the packages
% used by \pkg{memoir} are already supported.
%
%
% \Cref{tab:supported} lists some of the various \LaTeX{} features which may be used.
% \emph{Supported} means that the package or macro may be used as-is,
% perhaps with minor limitations.
% \emph{Emulated} means that the original package or macro is not used, but similar
% functionality is provided in a way which is intended to be compatible with the
% user's \LaTeX{} code.
%
% \renewcommand{\arraystretch}{1.5}
%
% \begin{longtable}{>{\raggedright}m{.3\linewidth}m{.6\linewidth}}
% \caption{\protect\LaTeX--HTML generation ---
% \protect\pkg{lwarp} package ---
% Supported functions\label{tab:supported}} \endfirsthead
% \warpprintonly{\multicolumn{2}{c}{\pkg{lwarp} Supported Functions --- continued} \\
%	Category & Status \\ \toprule \endhead}
%
% \toprule
%
% Category & Status \\
%
% \midrule
%
% Engines: & pdf\LaTeX, \XeLaTeX, \LuaLaTeX \\
%
% \midrule
%
% Classes: & \pkg{book}, \pkg{report}, \pkg{article},
%   \pkg{scrbook}, \pkg{scrreprt}, \pkg{scrartcl}. \pkg{memoir} is planned. \\
%
% Koma-script: & \pkg{scrextend}, \pkg{scrlayer}, \pkg{scrhack}.
%   Others as listed below. \\
%
% \midrule
%
% Page layout: & Emulates \pkg{geometry}, \pkg{fancyhdr}, \pkg{titleps},
%       \pkg{scrlayer-scrpage}, \pkg{typearea},
%       \pkg{addlines}, \pkg{anysize}, \pkg{a4}, \pkg{a4wide}, \pkg{a5comb},
%       \pkg{textarea}, \pkg{zwpagelayout}, \pkg{ebook},
%       \pkg{preview},
%       \pkg{draftwatermark}, \pkg{watermark},
%       \pkg{everyshi}, \pkg{atbegshi}. \\
%
% Sectioning: & Supported, with hyperlinks.
% 	Adds \cmds{FileDepth} for splitting the \HTML\ output.
% 	Files may be numbered sequentially or named according to section name.
% 	Common short words and punctuation is removed from the filenames. 
%	Emulates \pkg{titlesec}, \pkg{fncychap}, \pkg{sectsty}, \pkg{section},
%	\pkg{anonchap}, \pkg{quotchap}. \\
%
% Table of contents, figures, tables: & Supported, with hyperlinks.
%	Supports \pkg{tocbibind}.  Emulates \pkg{titletoc}, \pkg{tocloft},
%   \pkg{tocbasic}, and \pkg{tocstyle}. \\
%
% Title page: & \cs{maketitle}, \env{titlepage}, \pkg{titling}, \pkg{authblk}. \\
%
% Front \&\ back matter: & \pkg{abstract}, \pkg{appendix} \\
%
% Indexing: & \cmds{texindy} is used, with hyperlinks. \pkg{idxlayout} is emulated. \\
%
% Glossary: & \pkg{glossaries} and \cmds{xindy} are used. \\
%
% Bibliography: & Supported text-only. \\
%
% \midrule
%
% Cross-references: & Emulated, with hyperlinks.
%   \pkg{hyperref}, \pkg{cleveref}, \pkg{varioref}, \pkg{fancyref},
%   \pkg{url}, \pkg{breakurl}. \\
%
% Languages: & \pkg{babel}.  (\pkg{polyglossia} is untested.) \\
%
% \midrule
%
% Margin notes: & \pkg{marginfit}, \pkg{marginfix}, \pkg{scrlayer-notecolumn}. \\
%
% Footnotes: & Adds \cmds{FootnoteDepth} to print footnotes at section breaks.
%   \pkg{footnote}, \pkg{footmisc},
%	\pkg{marginnote}, \pkg{sidenote}, \pkg{pagenote}, \pkg{endnotes}. \\
%
% \midrule
%
% Math: & Supported.  Converted to \SVG\ images with \HTML\ \element{alt} tags containing the
% 	\LaTeX{} source for the math expression.
%	MathJax supported as an alternative.
% 	\AmS{} environments are supported.
% 	User-defined macros are available during converson,
% 	due to native \LaTeX{} processing.\\
%
% Theorems: & Support for native \LaTeX\ theorems, plus
%	\pkg{theorem}, \pkg{amsthm}, \pkg{ntheorem}. \\
%
% Add'l math: & \pkg{delarray}, \pkg{bm}, math fonts via \SVG\ images. \\
%
% Units and fractions: & \pkg{siunitx}, \pkg{xfrac}, \pkg{nicefrac}, \pkg{units} \\
%
% \midrule
%
% Floats: & Appear where declared.
%	\pkg{float}, \pkg{rotfloat}, \pkg{newfloat}, \pkg{caption} and \pkg{subcaption},
%	\pkg{subfig}, \pkg{capt-of}, \pkg{placeins}, \pkg{trivfloat}, \pkg{floatrow},
%	\pkg{subfloat}, \pkg{keyfloat}, \pkg{wrapfig}, \pkg{cutwin}, \pkg{floatflt}. \\
%
% \midrule
%
% Tabular &
%   \env{tabular} environment, \pkg{array}, \pkg{tabularx}, \pkg{tabulary},
%   \pkg{threeparttable}, \pkg{multirow},
%   \pkg{longtable}, \pkg{supertabular}, \pkg{xtab}, \pkg{ltxtable},
%   \pkg{booktabs}. \\
%
% \midrule
%
% Graphics & \pkg{graphics} and \pkg{graphicx} are emulated.
%   \cs{includegraphics} supports \cmds{width}, \cmds{height},
%   \cmds{origin}, \cmds{angle}, and \cmds{scale} tags, and adds \cmds{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.
%   \pkg{rotating} is emulated but all objects are unrotated.
%   \pkg{picture} and \pkg{tikz} are converted to an \SVG\ image.
%   \pkg{grffile} and \pkg{overpic} are supported. \\
%
%
% \midrule
%
% \pkg{xcolor}: & \textcolor{DarkGreen}{Supported}.
%   Full package color names, any color models,
%   and \textcolor{Goldenrod}{mixing}.
%   \textcolor{Maroon}{\cs{textcolor}},
%   \colorbox{LightSteelBlue}{\cs{colorbox}},
%   \fcolorbox{red}{NavajoWhite}{\cs{fcolorbox}}.
%   Enhanced for \HTML\ compatibility. \\
%
% \midrule
%
% Lists: & Standard \LaTeX\ environments are supported, along with
%	\pkg{enumitem}, \pkg{enumerate}, \pkg{paralist}, \pkg{hang}.\\
%
% \midrule
%
% Environments: & Standard \LaTeX{} environments are supported. \\
%
% \env{minipage}: & Supported with some \HTMLfive-imposed limitations.
%	Nested minipages are supported. \\
%
% Quotations: & \pkg{verse}, \pkg{csquotes}, \pkg{epigraph} \\
%
% Verbatim: & \pkg{verbatim}, \pkg{moreverb}, \pkg{fancyvrb} (except for verbatim footnotes). \\
%
% Frames: & \pkg{framed}, \pkg{fancybox}, \pkg{mdframed}, \pkg{boxedminipage2e}, \pkg{shadow}. \\
%
% \pkg{multicol}: & Emulated, with \CSSthree.
%   Converted to up to three columns with an optional heading,
%   per browser support. Single-column if unsupported.\\
%
% \env{fullwidth}: & Emulated. \\
%
% \midrule
%
% Todo: & \pkg{todo}, \pkg{todonotes}, \pkg{easy-todo}, \pkg{fixmetodonotes}, \pkg{fixme}. \\
%
% \midrule
%
% Direct formatting: & \cs{emph}, \cs{textsuperscript},
% 	\cs{textbf}, etc are supported.
% 	\cs{bfseries}, etc.\ are not yet supported.
%	\pkg{lettrine}, \pkg{ulem}, \pkg{soul}, \pkg{soulutf8}, \pkg{soulpos}, \pkg{cancel},
%       \pkg{relsize}, \pkg{scalefnt},
%       and \pkg{realscripts} are supported. \\
%
% Ordinals: & \pkg{nth}, \pkg{fmtcount}, and \pkg{engord} are supported. \\
%
% Text ligatures: & Ligatures for symbols are supported.
% 	Ligatures for f, q, t are intentionally turned off
% 	because many simpler browsers do not display them correctly.
% 	Modern full-featured browsers re-create these ligatures on-the-fly.\\
%
% Horizontal space: &
%	\HTML\ output for thin-unbreakable, unbreakable,
%	\cs{enskip}, \cs{quad}, \cs{qquad}, \cs{hspace}. \\
%
% Rules: & \cs{rule} with width, height, raise, text color. \\
%
% \HTML\ reserved characters: & \cs{\&}, \cs{textless}, and
% 	\cs{textgreater} are converted to \HTML\ entities. \\
%
% \midrule
%
% Fonts: & Used as-is.  Appear in math expressions or embedded image environments. \\
%
% Symbols: & Native \LaTeX\ diacriticals, \pkg{textcomp}. \\
%
% \midrule
%
% Working as-is: & 
%   Various utility, calculation, file, and text-only packags, such as
%   \pkg{calc},
%   \pkg{fileerr},
%   \pkg{somedefs},
%   \pkg{trace},
%   \pkg{xspace}. \\
%
% \midrule
%
% Where: & \\
%
% \textbf{Supported:} & The existing \LaTeX{} package is used. \\
% \textbf{Emulated:} & The \LaTeX{} package is not used, but some/all of its
% 	functions are emulated.  Null functions, lengths, and counters are provided
% 	for source compatibility. \\
%
% \bottomrule
%
% \end{longtable}
%
%
%
%
%
% \clearpage
%
% \section{Alternatives}
% 
% Summarized below are several other ways to convert a \LaTeX{} or other document to \HTML.
% Where an existing \LaTeX{} document is to be converted to \HTML, \pkg{lwarp} may be
% a good choice.  For new projects with a large number of documents, it may be worth
% investigating the alternatives before decided which path to take.
%
% \subsection{Internet class}
%
% \changes{v0.21}{2017/02/15}{Docs: Added \protect\texttt{internet} class.}
%
% The closest to \pkg{lwarp} in design principle is the
% \DescribeClass{internet}
% \verb+internet+ class by Andrew Stacey
% (\url{https://github.com/loopspace/latex-to-internet}),
% an interesting project which directly produces several versions
% of markdown, and also \HTML\ and \EPUB.
% 
% 
%
% \subsection{TeX4ht}
%
% \url{http://tug.org/tex4ht/}\DescribeProgram{TeX4ht}\DescribeProgram{htlatex}
%
% This system uses native \LaTeX{} processing to produce a DVI file containing special commands,
% and then uses additional post-processing for the \HTML\ conversion by way of numerous configuration
% files.
% In most cases, \pkg{lwarp} provides a better \HTML\ conversion,
% while supporting more packages.
% TeX4ht produces several other forms of output beyond \HTML.
%
% \subsection{Translators}
%
% \changes{v0.21}{2017/02/14}{Docs: Added TeX2page, GladTeX.}
%
% These systems use external programs to translate a subset of \LaTeX{} syntax into \HTML.
% Search for each on \CTAN\ (\url{http:\\ctan.org}).
% \begin{description}
% \item [H\textsuperscript{E}v\textsuperscript{E}a:] \url{http://hevea.inria.fr/}
%	\DescribeProgram{Hevea} {\footnotesize(not on \CTAN)}
% \item [T\textsubscript{T}H:] \url{http://hutchinson.belmont.ma.us/tth/}
%	\DescribeProgram{TtH}
% \item [GELLMU:] \url{http://www.albany.edu/~hammond/gellmu/}
%	\DescribeProgram{GELLMU}
% \item [\LaTeX{}ML:] \url{http://dlmf.nist.gov/LaTeXML/}
%	\DescribeProgram{LaTeXML}
% \item [PlasTeX:] \url{https://github.com/tiarno/plastex}
%	\DescribeProgram{Plastex}
% \item [\LaTeX2HTML:] \url{http://www.latex2html.org/}
%	\DescribeProgram{LaTeX2HTML} \\
%                     and \url{http://ctan.org/pkg/latex2html}.
% \item [\TeX2page:] \url{http://ds26gte.github.io/tex2page/index.html} \DescribeProgram{TeX2page}
% \end{description}
% Finally, Glad\TeX\ may used to directly insert \LaTeX\ math into \HTML:
% \begin{description}
% \item [Glad\TeX:] \url{http://humenda.github.io/GladTeX/} \DescribeProgram{GladTeX}
% \end{description}
% 
% \subsection{AsciiDoc}
%
% AsciiDoc is one of the most capable markup languages, providing enough features to produce
% the typical technical-writing document with cross-references,
% and it writes \LaTeX{} and \HTML.
% \begin{description}
% \item [Asciidoctor:] \url{http://asciidoctor.org/} (More active.)\DescribeProgram{AsciiDoc}
% \item [AsciiDoc:] \url{http://asciidoc.org/} (The original version.)\DescribeProgram{AsciiDoctor}
% \end{description}
%
% The Asciidoctor-LaTeX project is adding additional \LaTeX{}-related features.
% \begin{description}
% \item [Asciidoctor-LateX:] ~ \\
%	\url{http://www.noteshare.io/book/asciidoctor-latex-manual} \\
%	\url{https://github.com/asciidoctor/asciidoctor-latex}
% 	\DescribeProgram{Asciidoctor-LaTeX}
% \end{description}
%
% \subsection{Pandoc}
% \DescribeProgram{Pandoc}
%
% A markup system which also reads and writes \LaTeX{} and \HTML.
% \begin{description}
% \item [Pandoc:] \url{http://pandoc.org/}
% \end{description}
%
% (Watch for improvements in cross-references to figures and tables.)
%
% \subsection{Word processors}
%
% It should be noted that the popular word processors
% \DescribeProgram{Word}\DescribeProgram{LibreOffice}\DescribeProgram{OpenOffice}
% have advanced through the years in their abilities
% to represent math with a \LaTeX-ish input syntax, unicode math fonts,
% and high-quality output, and also generate \HTML\ with varying success.
% See recent developments in Microsoft\,\textregistered{} Word\,\textregistered{}
% and LibreOffice\,\texttrademark{} Writer.
%
% \subsection{Commercial systems}
%
% Likewise, several professional systems exist whose
% \DescribeProgram{Adobe} \DescribeProgram{FrameMaker}
% \DescribeProgram{InDesign} \DescribeProgram{Flare} \DescribeProgram{Madcap}
% abilities have been advancing in the areas of typesetting, cross-referencing, and \HTML\ generation.
% See Adobe\,\textregistered{} FrameMaker\,\textregistered{},
% Adobe\,\textregistered{} InDesign\,\textregistered{},
% and Madcap Flare\,\texttrademark{}.
%
% \subsection{Comparisons}
% \index{markup languages}
%
% AsciiDoc, Pandoc, and various other markup languages typically have a syntax which tries to be
% natural and human-readable, but the use of advanced features tends to require
% many combinations of special characters, resulting in a complicated mess of syntax.
% By contrast, \LaTeX{} spells things out in readable words but takes longer to type, although
% integrated editors exist which can provide faster entry and a graphic user interface.
% For those functions which are covered by the typical markup language
% it is arguable that \LaTeX{} is comparably easy to learn, while \LaTeX{} provides many more advanced
% features where needed, along with a large number of pre-existing packages which provide solutions
% to numerous common tasks.
%
% Text-based document-markup systems share some of the advantages of \LaTeX{} vs.\ a typical word
% processor.  Documents formats are stable.  The documents themselves are portable,
% work well with revision control,
% do not crash or become corrupted, and are easily generated under program control.
% Formatting commands are visible,
% cross-referencing is automatic, and editing is responsive.
% Search/replace with regular expressions provides a powerful tool for
% the manipulation of both document contents and structure.
% Markup systems and some commercial systems allow printed output
% through a \LaTeX{} back end, yielding high-quality results especially when the \LaTeX{}
% template is adjusted, but they lose the ability to use \LaTeX{} macros and
% other \LaTeX{} source-document features.
% 
% The effort required to customize the output of each markup system varies.
% For print output, \LaTeX{} configuration
% files are usually used.  For \HTML\ output, a \CSS\ file will be available, but additional
% configuration may require editing some form of control file with a different syntax, such as XML.
% In the case of \pkg{lwarp}, CSS is used, and much \HTML\ output is adjusted
% through the usual \LaTeX{} optional macro parameters,
% but further customization may require patching \LaTeX{} code.
% 
% The popular word processors and professional document systems each has a large
% base of after-market support including pre-designed styles and templates, and often include
% content-management systems for topic reuse.
%
%
%
%
% \clearpage
%
% \section{Installation}
%
% \Cref{tab:utility} shows the tools which are used for
% the \LaTeX\ to \HTML\ conversion.
% In most cases, these will be available via the
% standard package-installation tools.
%
% \index{utility>programs}
% \index{programs>utility}
%
% \begin{table}
% \caption{Required software programs\label{tab:utility}}
% \hrule
% \begin{description}
%
% \item[Provided by your \LaTeX\ distribution:] \
%
%	From \TeX{}Live: \url{http://tug.org/texlive/}.
%
% \begin{description}
%
% \item[\LaTeX:] |pdflatex|, |xelatex|, or |lualatex|.
%	\DescribeProgram[requirement]{pdfLaTeX}
%	\DescribeProgram[requirement]{XeLaTeX}
%	\DescribeProgram[requirement]{LuaLaTeX}
%
% \item[The \pkg{lwarp} package:] This package.
%
% \item[The |lwarpmk| utility:] Provided along with this package.  This
%	should be an operating-system executable in the same way that
%	|pdflatex| or |latexmk| is.  It is possible to have the
%	\pkg{lwarp} package generate a local copy of |lwarpmk|
%	called |lwarpmk.lua|.
%	See \cref{sec:genlatexmk}.
%
% \item[luatex:] Used by the |lwarpmk| program to simplify and automate document generation.
%
% \item [xindy:] The \pkg{xindy} package is used by \pkg{lwarp} to create
%	indexes.  On a MiK\TeX\ system this may have to be acquired separately,
%	but it is part of the regular installer as of mid 2015.
%
% \item[latexmk:] Optionally used by |lwarpmk| to compile \LaTeX\ code.
%	On a MiK\TeX\ system, Perl may need to be installed first.
%
% \item[pdfcrop:] Used to pull images out of the \LaTeX{} \PDF.
%	\DescribeProgram[requirement]{pdfcrop}
%
% \end{description}
%
% \item[Poppler PDF utilities:] \
%
% \begin{description}
%
% \item[pdftotext:] Used to convert \PDF\ to text.
%	\DescribeProgram[requirement]{pdftotext}\index{Poppler}
%
% \item[pdfseparate:] Used to pull images out of the \LaTeX{} \PDF.
%	\DescribeProgram[requirement]{pdfseparate}
%
% \item[pdftocairo:] Used to convert images to \SVG.
%	\DescribeProgram[requirement]{pdftocairo}
%
% \end{description}
%
%	These might be provided by your operating-system package manager.
%
%	From Poppler: \url{poppler.freedesktop.org}.
%
%	For MacOS\textregistered, see
%		\url{https://brew.sh/}, install Homebrew, then
%		\userentry{brew install poppler}
%
%	For Windows, see: \\
%		\url{https://sourceforge.net/projects/poppler-win32/} \quad and: \\
%		\url{http://blog.alivate.com.au/poppler-windows/}
%
% \item[Perl:] \
%
% This may be provided by your operating-system package manager, and is
% required for some of the Poppler \PDF\ utilities.
%
% \url{perl.org}, \url{strawberryperl.com}
%
% \item[Automatically downloaded from the internet as required:] \
% \begin{description}
%
% \item[MathJax:] Optionally used to display math.
%	Automatically loaded from the MathJax website when needed. \\
%	From: \url{mathjax.org}
%	\DescribeProgram[requirement]{MathJax}
%
% \end{description}
% \end{description}
%
% \hrule
% \end{table}
%
% \subsection{Installing the \protect\pkg{lwarp} package}
%
% There are several ways to install \pkg{lwarp}.  These are listed here
% with the preferred methods listed first:
%
% \begin{description}
% \raggedright
%
% \item [Pre-installed:] Try entering into a command line:
%	\userentry{kpsewhich lwarp.sty}
%
% If a path to |lwarp.sty| is shown, then \pkg{lwarp} is already installed.
%
% \item [\TeX\ Live:]If using a \TeX\ Live distribution,
%	try installing via |tlmgr|:
%	\userentry{tlmgr install lwarp}
%
% \item [MiK\TeX:] If using MiK\TeX, try using the package installer to
%	install the package |lwarp|.
%	Also update the package |miktex-misc|, which will install the
%	|lwarpmk| executable.
% \changes{v0.26}{2017/03/23}{Docs: Improved MiK\TeX\ install instructions.}
%
% \item [Operating-system package:] The operating-system package manager may
%	already have |lwarp|, perhaps as part of a set of \TeX-related packages.
%
% \item [CTAN TDS archive:] \pkg{lwarp} may be downloaded from the Comprehensive \TeX\ Archive:
%	\begin{enumerate}
%	\item See \url{http://ctan.org/pkg/lwarp} for the \pkg{lwarp} package.
%	\item Download the \TDS\ archive: |lwarp.tds.zip|
%	\item Find the \TeX\ |local| directory:
%		\begin{description}
%		\item[\TeX\ Live:] \
%
%			\userentry{kpsewhich -var-value TEXMFLOCAL}
%		\item[MiK\TeX:] \
%
%			In the ``Settings'' window, ``Roots'' tab, look for a local \TDS\ root.
%		\end{description}
%		This should be something like:
%		\begin{sourcedisplay}
%		|/usr/local/texlive/texmf-local/|
%		\end{sourcedisplay}
%	\item Unpack the archive in the \TDS\ local directory.
%	\item Renew the cache:
%		\userentry{mktexlsr} \quad —\,or\,—
%		\userentry{texhash}
%
%		Or, for Windows MiK\TeX, start the program called |MiKTeX Settings (Admin)|
%		and click on the button called \textsf{Refresh FNDB}.
%	\end{enumerate}
%
% \item[CTAN \texttt{.dtx} and \texttt{.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.
%
%	\begin{enumerate}
%	\item See \url{http://ctan.org/pkg/lwarp} for the \pkg{lwarp} package.
%	\item Download the zip archive |lwarp.zip| into your own |lwarp| directory.
%	\item Unpack |lwarp.zip|.
%	\item Locate the contents |lwarp.dtx| and |lwarp.ins|
%	\item Create the documentation: \userentry{pdflatex lwarp.dtx} (several times)
%	\item Create the |.sty| files: \userentry{pdflatex lwarp.ins}
%	\item Copy the |.sty| files somewhere such as the \TeX\ Live local tree
%		found in the previous \CTAN\ \TDS\ section, under the subdirectory:
%		\begin{sourcedisplay}
%		|<texlocal>/tex/latex/local/lwarp|
%		\end{sourcedisplay}
%	\item Copy the documentation |lwarp.pdf| to a |source| directory in the local tree,
%		such as:
%		\begin{sourcedisplay}
%		|<texlocal>/doc/local/lwarp|
%		\end{sourcedisplay}
%	\item Renew the cache:
%		\userentry{mktexlsr} \quad —\,or\,—
%		\userentry{texhash}
%
%		Or, for Windows MiK\TeX, start the program called |MiKTeX Settings (Admin)|
%		and click on the button called \textsf{Refresh FNDB}.
%
%	\item See \cref{sec:locallwarpmk} to generate your local copy of |lwarpmk|.
%	\item Once the local version of |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
%		|.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
%		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!}\
%		\pkg{lwarp} before deciding whether to permanently install it.
% \end{description}
%
% \subsection{Installing the \protect\texttt{lwarpmk} utility}
% \label{sec:installlwarpmk}
%
% \changes{v0.21}{2017/02/22}{Docs: Installing on Windows.}
%
% {\small
% (Note: If |lwarpmk| is not already installed,
% it is easiest to use a local copy instead of installing it system-wide.
% See \cref{sec:locallwarpmk}.)
% }
%
% After the \pkg{lwarp} package is installed,
% you may need to setup the |lwarpmk| utility:
% \begin{enumerate}
% \item At a command line, try executing |lwarpmk|.  If the |lwarpmk| help message
%	appears, then |lwarpmk| is already set up.
%	If not, it is easiest to generate and use a local copy.
%	See \cref{sec:locallwarpmk}.
%
% \item For MiK\TeX, try updating the |miktex-misc| package.  This may install
% the |lwarpmk| executable for you.
% \changes{v0.26}{2017/03/23}{Docs: Improved MiK\TeX\ install instructions.}
%
%	Otherwise, continue with the following:
%
% \item Locate the file |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}
%
%	(If the file is not found, you may also generate a local copy and use it instead.
%	See \cref{sec:locallwarpmk}.)
%
% \item Create |lwarpmk|:
%	\begin{description}
%	\item [Unix:] Create a symbolic link and make it executable:
%		\begin{enumerate}
%		\item Locate the \TeX\ Live binaries:
%			\userentry{kpsewhich -var-value TEXMFROOT}
%			This will be something like:
%		\begin{sourcedisplay}
%			|/usr/local/texlive/<year>|
%		\end{sourcedisplay}
%			The binaries are then located in the |bin/<arch>| directory
%			under the root:
%		\begin{sourcedisplay}
%			|/usr/local/texlive/<year>/bin/<architecture>/|
%		\end{sourcedisplay}
%			In this directory you will find programs
%			such as |pdflatex| and |makeindex|.
%		\item In the binaries directory,
%			create a new symbolic link from the binaries directory to |lwarpmk.lua|:
%			\userentry{ln -s <pathtolwarpmk.lua> lwarpmk}
%		\item Make the link executable:
%			\userentry{chmod 0755 lwarpmk}
%		\end{enumerate}
%	\item [Windows \TeX\ Live:] Create a new |lwarpmk.exe| file:
%		\begin{enumerate}
%		\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|
%			which is in the |scripts| directory of the distribution.
%		\end{enumerate}
%	\item [Windows MiK\TeX:] Create a new |lwarpmk.bat| file:
%		\begin{enumerate}
%		\item Locate the binaries.  These will be in a directory such as:
%		\begin{sourcedisplay}
%			|C:\Program Files\MiKTeX 2.9\miktex\bin\x64|
%		\end{sourcedisplay}
%			In this directory you will find programs
%			such as |pdflatex.exe| and |makeindex.exe|.
%		\item Create a new file named |lwarpmk.bat| containing:
%		\begin{sourcedisplay}
%			{\footnotesize
%			|texlua "C:\Program Files\MiKTeX 2.9\scripts\lwarp\lwarp.texlua" %*|}
%		\end{sourcedisplay}
%			This will call the copy of |lwarpmk.lua|
%			which is in the |scripts| directory of the distribution.
%		\end{enumerate}
%	\end{description}
% \end{enumerate}
%
% \subsubsection{Using a local copy of \protect\pkg{lwarpmk}}
% \label{sec:locallwarpmk}
% It is also possible to use a local version of |lwarpmk|:
% \begin{enumerate}
% \item When compiling the tutorial in \cref{sec:tutorial},
%	use the |lwarpmk| option for the \pkg{lwarp} package:
%	\begin{sourcedisplay}
%	|\usepackage[lwarpmk]{lwarp}|
%	\end{sourcedisplay}
% \item When the tutorial is compiled with |pdflatex|, the file |lwarpmk.lua|
%	will be generated along with the other configuration files.
% \item |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 Compile documents with
%				\userentry{./lwarpmk.lua html}
%				\userentry{./lwarpmk.lua print} \quad etc.
%			\item It may be useful to rename or link to a version without the |.lua| suffix.
%			\end{enumerate}
%		\item[Windows:] \
%
%			Compile documents with either of the following, depending
%			on which command shell is being used:
%			\userentry{texlua lwarpmk.lua html}
%			\userentry{texlua lwarpmk.lua print} \quad etc.
%
%			Or:
%
%			\userentry{lwarpmk html}
%			\userentry{lwarpmk print} \quad etc.
% 	\end{description}
% \end{enumerate}
%
%
% \subsection{Installing additional utilities}
%
% \changes{v0.27}{2017/04/02}{Docs: Installing utilities for MacOS.}
%
% \begin{description}
% \item [To test for the existence of the additional utilities:] \
%
%	Enter the following in a command line.  If each programs' version is
%	displayed, then that utility is already installed.
%	See \cref{tab:utility} on page \pageref{tab:utility}.
%
%	\userentry{luatex --version}
%	\userentry{xindy --version}
%	\userentry{latexmk --version}
%	\userentry{perl --version}
%	\userentry{pdfcrop --version}
%	\userentry{pdftotext -v}
%	\userentry{pdfseparate --version}
%	\userentry{pdftocairo -v}
%
% \item [To install |xindy|, |latexmk|, and |pdfcrop|:] \
%
% The \TeX\ utilities |xindy|, |latexmk|, and |pdfcrop| may be provided by
% your operating system's package manager, and are also provided by
% the \CTAN\ archive:
%	\begin{sourcedisplay}
% \url{http://ctan.org/pkg/xindy} \\
% \url{http://ctan.org/pkg/latexmk} \\
% \url{http://ctan.org/pkg/pdfcrop}
%	\end{sourcedisplay}
%
%
% \item [To install the Poppler utilities to a Unix/Linux system:] \
%	\DescribeProgram[requirement]{pdftotext}\index{Poppler}
%	\DescribeProgram[requirement]{pdfseparate}
%	\DescribeProgram[requirement]{pdftocairo}
%
% The tools from the \textsc{Poppler} project should be provided by your
% operating system's package manager.
%
%
% \item [To install the Poppler utilities to a MacOS machine:] \
%	\begin{enumerate}
%	\item Install Homebrew from \url{https://brew.sh/}:
%		\userentry{\small~ \\ \hspace*{-2in}/usr/bin/ruby -e "\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"}
%	\item Install the Poppler utilities:
%		\userentry{brew install poppler}
%	\end{enumerate}
%
%
% \item [To install the Poppler utilities to a Windows machine:] \
%
% \begin{enumerate}
% \item See \cref{tab:utility} on \cpageref{tab:utility}.
% \item Download and extract the Poppler utilities |pdftotext|, |pdfseparate|,
% and |pdftocairo| to a directory, such as |Poppler|.
% \item In the Start window, type "Path" to search for results
% related to Path.  Or, open the control panel and search for "Path".
% \item Choose "Edit the system environment variables" in the control panel.
% \item Choose the "Environment Variables" button.
% \item Choose the "Path" variable, then the "Edit" button.
% \item Choose the "New" button to make an additional entry.
% \item Enter the |bin| directory of the Poppler utilities, such as:
%	\begin{sourcedisplay}
%	|C:\Users\<myname>\Desktop\Poppler\poppler-0.5_x86\poppler-0.5\bin|
%	\end{sourcedisplay}
%
%	Be sure to include |\bin|.
% \item Click "Ok" when done.
% \end{enumerate}
%
% \item [To install Perl to a Windows machine:] \
% \DescribeProgram[requirement]{perl}\index{Perl}
% \begin{enumerate}
% \item Download and install a version of Perl, such as Straweberry Perl,
%	to a directory without a space in its name, such as |C:\Strawberry|.
% \item Edit the Path as seen above for the Poppler utilities.
% \item Enter the |bin| directory of the Perl utility, such as:
%	\begin{sourcedisplay}
%	|C:\Strawberry\perl\bin|
%	\end{sourcedisplay}
%
%	Be sure to include |\bin|.
% \item Click "Ok" when done.
% \end{enumerate}
%
% \end{description}
%
% \vfill
% \textcolor{red}{\textbf{Any utilities installed by hand must be added to the |PATH|.}}
% \vfill
%
%
%
% \clearpage
%
% \section{Tutorial}
% \label{sec:tutorial}
%
% This section shows an example of how to create an \pkg{lwarp} document.
%
%
% \subsection{Starting a new project}
%
% \changes{v0.21}{2017/02/23}{File \texttt{lwarp\_tutorial.txt} added.}
%
% \begin{enumerate}
%
% \item Create a new project directory called |tutorial|.
%
% \item Inside the |tutorial| directory,
% \DescribeFile{tutorial.tex}
%	create a new file called |tutorial.tex|.
%	This may be done several ways:
%	\begin{description}
%	\item [Copy from the documentation PDF:] \
%
%	A listing is in \cref{fig:tutorial},
%	which may be copied/pasted from the figure directly into your own editor,
%	depending on the quality of the \PDF\ viewer and editor, or:
%
%	\item [Copy from the \pkg{lwarp} documentation directory:] \
%
%	Another copy may be found by entering into a command line:
% \DescribeFile{lwarp_tutorial.txt}
%	\watchout[Note: |.txt| suffix!]
%	\userentry{texdoc -l lwarp\_tutorial.txt}
%
%	This should be in the |doc/latex/lwarp/| directory along
%	with this \PDF\ documentation.
%	Copy |lwarp_tutorial.txt| directly into your |tutorial| directory,
%	renamed as |tutorial.tex|.
%	\end{description}
%
%	\emph{When using Windows, use an editor other than Notepad,
%	\watchout[Bad formatting!]
%	since Notepad does not accept the end-of-line from a Unix text file.}
%
% \item Compile the project: \userentry{pdflatex tutorial.tex}
%				\quad (several times)
%
% (|xelatex| or |lualatex| may be used as well.)
%
% \item View the resulting |tutorial.pdf| with a \PDF\ viewer.
%
% \end{enumerate}
%
%
% A number of new files are created when |tutorial.tex| is compiled, as
% shown in \cref{fig:newprojectfiles}.  These files are created by
% the |lwarp| package.
%
% (Two of the new files are configuration files for the helper program |lwarpmk|.
% Whenever a print version of the document is created,
% the configuration files for |lwarpmk| are updated to
% record the operating system, \LaTeX\ program (|pdflatex|, |xelatex|, or |lualatex|),
% the filenames of the source code and \HTML\ output, and whether
% the additional helper program |latexmk| will be used to compile the document.)
%
%
%
% \clearpage
%
% \begingroup
% \captionof{figure}{tutorial.tex listing}
% \label{fig:tutorial}
%
% \begin{center}
% \footnotesize
% \textcolor{red}{Note: There are two pages!}
% \end{center}
%
% \small
%
% \VerbatimInput{lwarp_tutorial.txt}
%
% ^^A so they don't copy/paste the header:
% \thispagestyle{empty}
%
% ^^A **************************************************************************
% ^^A NOTE: lwarp_tutorial.txt is located in the TDS doc directory!
% ^^A       Copy it to the source directory if you wish to recompile lwarp.dtx!
% ^^A       (It is stored in the doc directory so that texdoc can find it and
% ^^A       the user can copy it.)
% ^^A **************************************************************************
%
% \endgroup
%
%
% \begin{table}
% \caption{Files created along with the print version\label{fig:newprojectfiles}}
% \begin{description}
%
% \item [|tutorial.pdf|:] The \PDF\ output from \LaTeX.
%	The print version of the document.
%
% \item [|tutorial\_html.tex|:] A small |.tex| file used to create
%	a parallel \HTML\ version of the document, which co-exists with usual
%	the \PDF\ version, and which will have its
%	own auxiliary files.  In this way, both \PDF\ and \HTML\
%	documents may co-exist side-by-side.
%
% \item [Auxiliary files:] The usual \LaTeX\ files |.aux|, |.log|, |.out|, |.toc|, |.lof|, |.idx|.
%	When an \HTML\ version of the document is created, |_html| versions
%	of the auxiliary files will also be generated.
%
% \item [|lwarpmk.conf|:] A configuration file for |lwarpmk|,
%	which is used to automate the compilation of \PDF\ or \HTML\
%	versions of the document.
%
% \item [|tutorial.lwarpmkconf|:] Another configuration file used by |lwarpmk|,
%	which is only useful if you wish to have several projects
%	residing in the same directory.
%
% \item [|.css files|:] |lwarp.css|, |lwarp_formal.css|, |lwarp_sagebrush.css|
%	These files are standard for \pkg{lwarp}, and are not meant to be modified
%	by the user.
%
% \item [|sample\_project.css|:] An example of a user-customized \CSS\ file,
%	which may be used for project-specific changes to the \pkg{lwarp} defaults.
%
% \item [|lwarp.xdy|:] Used by \pkg{lwarp} while creating an index.
%	This file should not be modified by the user.
%	A custom file may be used instead, if necessary.
%
% \item [|lwarp\_mathjax.txt|:] Inserted into the \HTML\ files when
%	|MathJax| is used to display math.
%	This file should not be modified by the user.
%
% \item [|comment.cut|:] A temporary file used by \pkg{lwarp} to
%	conditionally process blocks of text.  This file may be ignored.
% \end{description}
%
% \hrule \medskip
% \label{sec:genlatexmk}
% When the |lwarpmk| option is given to the \pkg{lwarp} package:
% \begin{description}
% \item [|lwarpmk.lua|:] A local copy of the |lwarpmk| utility.
%
%	On Unix-related operating systems this file must be made executable:
%	\begin{sourcedisplay}
%	|chmod u+x lwarpmk.lua|
%	\end{sourcedisplay}
%
%	This may be useful to have to archive with a project for future use.
% \end{description}
% \end{table}
%
%
%
% \clearpage
%
% \subsection{Compiling the print version with \texttt{lwarpmk}}
%
% The |lwarpmk| utility program is used to compile either the printed or
% the \HTML\ version of the document.
%
% |lwarpmk print| is used to recompile a printed version of the document.
%
% \begin{enumerate}
%
% \item Re-compile the print version: \userentry{lwarpmk print}
%
%	|lwarpmk| prints an introduction then checks to see if the document
%	must be recompiled.  If it seems that the files are up-to-date, then
%	|lwarpmk| informs you of that fact and then exits.
%
% \item Make a small change in the original document,
%	such as adding a space character.
%
% \item Recompile again.  \userentry{lwarpmk print}
%
%	The document is recompiled when a change is seen in the source.
%	Several compilations may be necessary to resolve cross-references.
%
% \item Force a recompile to occur.
%	\userentry{lwarpmk again}
%	\userentry{lwarpmk print}
%
% |lwarpmk again| updates the date code for the file,
%	triggering a recompile the next time the document is made.\footnote{
%	Although, when using the utility |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
%	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}
%
% \item Recompile again to include the index.
%	\userentry{lwarpmk print}
%
% \item To force a single recompile when needed, even if no changes were detected:
%   \userentry{lwarpmk print1}
%
% \end{enumerate}
%
% Note that the \HTML\ customization commands are ignored while making the
% print version.
%
%
% \clearpage
%
% \subsection{Compiling the HTML version with \texttt{lwarpmk}}
%
% |lwarpmk html| is used to recompile an \HTML\ version of the document.
%
% \begin{enumerate}
% \item Compile the \HTML\ version:
%	\userentry{lwarpmk html}
%
%	\begin{enumerate}
%	\item |lwarpmk| uses \LaTeX\ to process |tutorial_html.tex|
%		to create \\
%		|tutorial_html.pdf|.
%	\item |pdftotext| is then used to convert to the file |tutorial_html.html|.
%		This file is a plain-text file containing \HTML\ tags and
%		content for the entire document.
%	\item |lwarpmk| manually splits |tutorial_html.html| into
%		individual \HTML\ files according to the \HTML\ settings.
%		For this tutorial, the result is |tutorial.html| (the home page),
%		along with |First-chapter.html|\footnote{
%			\texttt{First-chapter.html}
%			also contains the first section, even though the second
%			section is its own \HTML\ page.  This behavior is
%			controlled by the boolean \texttt{CombineHigherDepths}.},
%		|Some-math.html|, and the document's
%		index in |_Index.html|.\footnote{\texttt{index.html} is commonly
%		used as a homepage, so the document index is in \texttt{\_Index.html}.}
%	\end{enumerate}
%
% \item View the homepage in a web browser.
%
%	\qquad Open the file |tutorial.html| in a web browser.
%
%	Note that math is still displayed as its plain-text \LaTeX\ source
%	\margintag{math}
%	until the
%	images of the math expressions have been generated.  Math may be
%	displayed as \SVG\ images or by a MathJax script, as seen in
%	\cref{sec:tutorialsvgmath,sec:tutorialmathjax}.
%
% \item Force a recompile:
%	\userentry{lwarpmk again}
%	\userentry{lwarpmk html}
%	\userentry{lwarpmk print}
%
% \item Process the \HTML\ index and recompile:\index{index>processing}\footnote{A \texttt{lwarpmk htmlglossary} 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 htmlindex}
%	\userentry{lwarpmk html}
%
%	|_Index.html| is updated for the new \LaTeX\ index.
%
% \item Reload the web page to see the added index.
%
% \item To force a single recompile when needed, even if no changes were detected:
%   \userentry{lwarpmk html1}
%
% \end{enumerate}
%
%
%
% \clearpage
%
% \subsection{Generating the SVG images}
% \label{sec:tutorialsvgmath}
%
% By default \pkg{lwarp} represents math as \SVG\ images with
% \margintag{math as \SVG\ images}
% the \LaTeX\ source included in \attribute{alt} attributes.  In this way,
% the math displays as it was drawn by \LaTeX, and the \LaTeX\ source
% may be copied and pasted into some other document.
%
% \pkg{lwarp} uses the same mechanism for |picture| and \tikz\ environments.
% \margintag{\env{picture} and \tikz}
%
% \begin{enumerate}
% \item Create the \SVG\ images:
%	\userentry{lwarpmk limages}
%	\userentry{lwarpmk html}
%
% \item Move to the tutorial's math page and reload.
%
% \item The math images are displayed using the same font and formatting
%	as the printed version.
%
% \item Copy/paste a math expression into a text editor to see the \LaTeX\ source.
% \end{enumerate}
%
% \limitssvgimages
%
% \clearpage
%
% \subsection{Using MathJax for math}
% \label{sec:tutorialmathjax}
%
% Math may also be represented using the MathJax Javascript project.
% \margintag{math with MathJax}
%
% \begin{enumerate}
% \item In the tutorial's source code, uncomment the |mathjax| package option for \pkg{lwarp}:
%	\begin{sourcedisplay}
%	mathjax, \% Use MathJax to display math.
%	\end{sourcedisplay}
%
% \item Recompile \userentry{lwarpmk html}
%
% \item Reload the math page.
% \end{enumerate}
%
% MathJax requires web access unless a local copy of MathJax is available,
% \watchout[MathJax requirements]
% and it also requires that Javascript is enabled for the web page.
% The math is rendered by MathJax.  Right-click on math to see several
% options for rendering, and for copying the \LaTeX\ source.
%
% While using MathJax has many advantages, it may not be able to represent
% complex expressions or spacing adjustments as well as \LaTeX, and it
% may not support some math-related packages.
%
%
%
% \clearpage
% \subsection{Changing the CSS style}
%
% For a formal \CSS\ style, add to the preamble:
% \begin{sourcedisplay}
% \cs{usepackage}\{lwarp\} \\
% \dots \\
% \textcolor{red}{\cs{CSSFilename}\{lwarp\_formal.css\}} \\
% \dots \\
% \cs{begin}\{document\} \\
% \end{sourcedisplay}
%
% For a modern \CSS\ style, |lwarp_sagebrush.css| is also provided:
% \begin{sourcedisplay}
% \cs{CSSFilename}\{lwarp\_sagebrush.css\}
% \end{sourcedisplay}
%
% See \cref{sec:csscustomization} for more information about modifying the CSS styling
% of the document.
%
%
%
% \subsection{Customizing the HTML output}
%
% A number of settings may be made to control the \HTML\ output, including
% filename generation, automatic compilation, math output, document splitting,
% meta data, and page headers and footers.
%
% See \cref{sec:htmlsettings} for more information.
%
%
% \clearpage
%
% \subsection{Using \texttt{latexmk}}
%
% |latexmk| is a \LaTeX\ utility used to monitor changes in source files
% and recompile as needed.
%
% \begin{enumerate}
% \item In the tutorial's source code uncomment the |latexmk| option for the
%	\pkg{lwarp} package:
%	\begin{sourcedisplay}
%	latexmk,   \% Use latexmk to compile.
%	\end{sourcedisplay}
%
% \item Recompile the printed version of the document.
%	\userentry{lwarpmk print}
%
%	\begin{sloppy}
%	\pkg{lwarp} updates its own configuration files (|lwarpmk.conf| and \newline
%	|tutorial.lwarpmkconf|) whenever the printed version of the document
%	is compiled.  These configuration files remember that |lwarpmk| should
%	use |latexmk| to compile the document.
%	\end{sloppy}
%
% \item Recompile the document.
%	\userentry{lwarpmk print} \quad and/or
%	\userentry{lwarpmk html}
% \end{enumerate}
%
% Changes are detected by comparing checksums
% rather than modification times, so |lwarpmk again| will not trigger a
% recompile, but |latexmk| has a much better awareness of changes than
% the |lwarpmk| utility does and it is likely to correctly know when to
% recompile.  A recompile may be forced by making a small change to the source.
%
% A single recompile may be forced with:
%   \margintag{forced single-pass recompile}
%   \userentry{lwarpmk print1} \quad and/or
%   \userentry{lwarpmk html1}
%
%
% \clearpage
%
% \subsection{Using XeLaTeX or LuaLaTeX}
%
% \XeLaTeX\ or \LuaLaTeX\ may be used instead of \LaTeX.
%
% \begin{enumerate}
%
% \item Remove the auxiliary files for the project:
%	\userentry{lwarpmk cleanall}
%
% \item Use |xelatex| or |lualatex| to recompile the printed version.
%	\userentry{xelatex tutorial.tex} \quad -or-
%	\userentry{lualatex tutorial.tex}
%
%	When the recompile occurs,
%	the configuration files for |lwarpmk| are modified to remember
%	which \TeX\ engine was used.  \XeLaTeX\ or \LuaLaTeX\ will be used for
%	future runs of |lwarpmk|.
%
% \item To recompile the document:
%	\userentry{lwarpmk print} \quad -and-
%	\userentry{lwarpmk html}
%
% \item Also rememeber to update the indexes and recompile again.
% \end{enumerate}
%
%
%
% \clearpage
%
% \subsection{Using a glossary}
%
% \changes{v0.29}{2017/04/15}{Docs: Using a glossary}
%
% \pkg{lwarp} supports the \pkg{glossaries} package, although this tutorial
% does not supply an example.
%
% \DescribeOption{IndexLanguage}
% To assign a language to be used while processing the index and glossary,
% use the |IndexLanguage| option:
% \index{language>glossary}
% \index{language>index}
% \index{glossary>language}
% \index{index>language}
%
% \begin{Verbatim}[gobble=2,frame=lines]
% \usepackage[IndexLanguage=english]{lwarp}
% \end{Verbatim}
%
% \index{glossary>processing}
% To process the glossary for the print version:
% \index{glossary>processing}
%	\userentry{lwarpmk printglossary}
%
% To process the glossary for the \HTML\ version:
%	\userentry{lwarpmk htmlglossary}
%
% In each case, the document will have to be recompiled afterwards.
%
%
%
%
% \clearpage
%
% \subsection{Cleaning auxiliary files}
%
% To remove the auxiliary files |.aux|, |.toc|, |.lof|, |.lot|, |.idx|, |.ind|, |.log|,
%	and |.gl*|:
%	\userentry{lwarpmk clean}
%
%
% \subsection{Cleaning auxiliary and output files}
%
% To remove the auxiliary files, and also remove the |.pdf| and |.html| files:
%	\userentry{lwarpmk cleanall}
%
%
% \subsection{Processing multiple projects in the same directory}
%
% It is possible to have several projects in the same directory.
% |lwarpmk| has an optional parameter which is the document to compile.
%
% To create each project:
% \userentry{pdflatex project\_a}
% \userentry{pdflatex project\_b}
%
% Each project is given its own configuration file:
%	\begin{sourcedisplay}
%	|project_a.lwarpmkconf|, |project_b.lwarpmkconf|
%	\end{sourcedisplay}
%
% To compile each project with |lwarkmk|:
% \userentry{lwarpmk print project\_a}
% \userentry{lwarpmk html project\_b}
%
%
% \subsection{Using the \texttt{make} utility}
%
% |lwarpmk| has an action which may be useful for integration with the
% common |make| utility:
%	\begin{sourcedisplay}
%	|lwarpmk pdftohtml [project]|
%	\end{sourcedisplay}
%
% |make| may be used to compile the code to \PDF\ with \HTML\
% tags (|project_html.pdf|), then |lwarpmk| may be used to
% convert each target to \HTML\ files.
%
%
% \clearpage
%
% \section{Additional details}
%
% \label{sec:usage}
%
%
%
% \subsection{Font and UTF-8 support}
% \label{sec:fonts}
% \index{font>selection}
% \index{Unicode>selection}
% \index{UTF-8>selection}
% \changes{v0.16}{2016/04/08}{Docs: Font and UTF-8 support.}
% \changes{v0.16}{2016/04/08}{Lwarp no longer selects fonts.}
%
% \pkg{lwarp} uses |pdftotext| to convert \PDF\ output into UTF-8-encoded
% text.  This process requires that UTF-8 information be embedded in the \PDF\
% file, which usually prevents the use of older bit-mapped fonts.
% \index{font>bitmapped}
%
% While using |pdflatex|,
% \margintag{pdflatex, T1, UTF8}
% \pkg{fontspec} is automatically loaded with T1 encoding,
% and \pkg{inputenc} is automatically loaded with UTF8 encoding, each of which
% is required for the conversion process.
% \pkg{fontspec} may be loaded with an additional encoding after \pkg{lwarp}.
%
% While using |pdflatex|, if no font-related package is specified, the default
% \margintag{vector fonts}
% bit-mapped Computer Modern font is used,
% \margintag{Computer Modern}%
% \index{font>Computer Modern}\index{Computer Modern}%
% \watchout%
% so simply add
%	\begin{sourcedisplay}
%	|usepackage{lmodern}|
%	\end{sourcedisplay}
% to the preamble to enable the related vector font instead, or use
%	\begin{sourcedisplay}
% |\usepackage{dejavu}|
%	\end{sourcedisplay}
%
% \index{Deja Vu}%
% \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.
% Avoid bit-mapped fonts.
%
% \XeLaTeX{} and \LuaLaTeX{} users must use the \pkg{fontspec} package.
% \watchout
% Do NOT use \pkg{fontenc}!
%
% Place \pkg{fontspec} or \pkg{fontenc} and other font and UTF-8 related commands
% after the |\documentclass| command and before |\usepackage{lwarp}|:
%
% \begin{enumerate}
% \item |documentclass{article/book/report}| goes here, followed by any of:
% \item Font and UTF-8 related commands:
% \begin{itemize}
% \item For \XeLaTeX{} or \LuaLaTeX:
% \begin{itemize}
% \item \pkg{fontspec} and font choices
% \DescribePackage{fontspec}
%
% \medskip
% \pkg{lwarp} sets the following to turn off \TeX{} ligatures during
% \margintag{ligatures}
% the generation of \HTML\ tags, and turn off common ligatures
% in regular text, since older browsers may not display them correctly
% and newer browsers can automatically re-create them.
%	\index{ligatures}\index{font>ligatures}
% \vspace{-1ex}
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% \defaultfontfeatures[\rmfamily]{Ligatures={NoCommon,TeX}}
% \defaultfontfeatures[\sffamily]{Ligatures={NoCommon,TeX}}
% \defaultfontfeatures[\ttfamily]{Ligatures=NoCommon}
% \end{Verbatim}
% \end{itemize}
% \item For |pdflatex|:
% \begin{itemize}
% \item \pkg{lmodern} or other font-related packages
%	\DescribePackage{lmodern}
%	\index{font>packages}
% \item \pkg{fontenc}
% \DescribePackage{fontenc}
% \item \pkg{inputenc}
% \DescribePackage{inputenc}
% \item \pkg{newunicodechar}
% \DescribePackage{newunicodechar}
% \item |\input glyphtounicode.tex|
% \DescribeFile{glyphtounicode}
% \item |\input glyphtounicode-cmr.tex% from the pdfx package|
% \item |\pdfgentounicode=1|
% \item \pkg{cmap}
% \DescribePackage{cmap}
% \item \pkg{textcomp}
% \DescribePackage{textcomp}
% \item \pkg{microtype} is automatically used by \pkg{lwarp}
%	\DescribePackage{microtype}
%	to turn off f,q,t,T,Q ligatures for the same
%	\margintag{ligatures}
%	browser-related reasons shown above.  Also, the monospaced font is used
%	during \HTML\ tag generation to turn off \TeX{} ligatures.
%	\index{ligatures}\index{font>ligatures}
% \end{itemize}
% \end{itemize}
% \item |\usepackage{lwarp}| (\cref{sec:loading}) goes after any of the above, followed by:
% \item \ldots{} the rest of the preamble and the main document.
% \end{enumerate}
%
%
% \subsubsection{Indexes and UTF-8}
% \index{UTF-8>index}
% \index{index>UTF-8}
%
% \pkg{lwarp} uses the |xindy| program to processes indexes.
%
% While using |xelatex| or |lualatex|, |xindy| is used for the index.
% Everything is handled in UTF-8 encoding, and should work as expected.
%
% While using |pdflatex|, the |texindy| program is used with the |-C utf8| option,
% which is newly supported in recent distributions of \LaTeX.  This option correctly
% sorts index entries into headings while using Latin languages, but will not work
% 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 |-C utf8| option from the texindy call.
% See \cref{sec:modifylwarpmk}.
%
%
% \clearpage
%
% \subsection{\protect\pkg{lwarp} package loading and options}
% \label{sec:loading}
% \index{settings>lwarp package options}
% 
% \begin{table}
% \caption{Package options\label{tab:options}}
% \centering
% \begin{tabular}{>{\ttfamily}lp{3.25in}}
% Option & Description \\ \midrule
% warpprint & Generate print output, and also generate configuration files. \\
% warpHTML & Generate \HTML\ output. \\
% mathsvg & Show math using \SVG\ images. \\
% mathjax & Show math using MathJax. \\
% OSWindows & Force compatibility with MS-Windows. \\
% BaseJobname & The \cs{jobname} to use.
%   Set to the \cs{jobname} of the printed version even while generating \HTML. \\
% HomeHTMLFilename & The filename of the home page. \\
% HTMLFilename & A prefix for the filenames of the remaining web pages. \\
% IndexLanguage & The |xindy| language option used for index and glossary generation. \\
% latexmk & Boolean for |lwarpmk| to use |latexmk| for compiling documents. \\
% lwarpmk & Generate a local copy of |lwarpmk.lua|. \\
% xdyFilename & Set a custom filename for |xindy|. \\
% \bottomrule
% \end{tabular}
% \end{table}
%
%
% \pkg{lwarp} supports \pkg{book}, \pkg{report}, and \pkg{article} classes,
% as well as the equivalent Koma-script classes.
%
% Load the \pkg{lwarp} package immediately after the font and UTF-8 setup commands.
% \changes{v0.16}{2016/04/08}{Docs: Moved location of \cs{usepackage\{lwarp\}}.}
% \changes{v0.19}{2016/05/25}{Docs: Math options.}
% \DescribePackage{lwarp}
% \index{lwarp>loading}\index{lwarp>options}
%
% \DescribeOption{warpprint}
% \DescribeOption{warpHTML}
% Usually controlled by |lwarpmk|, and not set in the document.
% Select the |warpprint| option to generate print output (default),
% or the |warpHTML| option to generate \HTMLfive{} output.
% The default is print output, so the print version may be
% compiled with the usual |pdflatex|, etc.
% When \pkg{lwarp} is loaded in print mode, it creates
% |<project>_html.tex|, which sets the |warpHTML| option before calling
% the user's source code |<project>.tex|.  In this way, |<project>.tex|
% can |\usepackage{lwarp}| without any options to create a printed version,
% while |<project>_html.tex| will create an \HTML\ version.
%
% \DescribeOption{mathsvg}
% \DescribeOption{mathjax}
% For math display, select |mathsvg| (default), or |mathjax|.
% For more information about the math options, see \cref{sec:limitsmath}.
% 
% \DescribeOption{OSWindows} See \cref{sec:OSportabilityusage} if using Windows.
%
% \DescribeOption{BaseJobname}  Not intended for the user.
%   Used internally by \pkg{lwarp} when
%   creating the |*_html.tex| file used to compile the \HTML\ version.
%   See \cref{sec:handlingpackageoptions}.
%
% \DescribeOption{HomeHTMLFilename}  See \cref{sec:htmlsettings}.
%
% \DescribeOption{HTMLFilename}  See \cref{sec:htmlsettings}.
%
% \DescribeOption{IndexLanguage} If using an index or glossary,
%   see \cref{sec:handlingpackageoptions}.
%
% \DescribeOption{latexmk} Has |lwarpmk| use |latexmk| to recompile the
%   document several times if necessary.
%   Otherwise, |lwarpmk| attempts to determing for itself whether to recompile.
%   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,
%   compile the print version with the |lwarpmk| option set.
%   See \cref{sec:handlingpackageoptions}.
%
% \DescribeOption{xdyFilename} The default |xindy| filename is |lwarp.xdy|.
%   If you wish to use a custom |.xdy| file for
%   index generation, see \cref{sec:handlingpackageoptions}.
%
%
%
% \clearpage
%
% \subsection{Customizing the HTML output}
% \label{sec:htmlsettings}
% \index{settings>HTML conversion}
% \index{HTML>conversion settings}
%
% \changes{v0.43}{2017/11/04}{Docs: HTML settings table.}
% \changes{v0.43}{2017/11/06}{Docs: Reorganized HTML customization.}
% \begin{table}
% \caption{HTML settings}
% \begin{tabular}{>{\ttfamily}lp{3in}}
% \toprule
% Option & Description \\ \midrule
% SideTOCDepth & Sectioning depth of the side\TOC. \\
% FileDepth & Sectioning depth of the file splits. \\
% CombineHigherDepths & Combine higher section levels. \\
% FileSectionNames & Use section names for file names, else use numbers. \\
% FootnoteDepth & Sectioning depth of footnotes. \\
% \cs{abstractname} & The name of the abstract. \\
% \cs{CSSFilename} & The \CSS\ for the following files. \\
% \cs{HTMLLanguage} & The |html lang| tag. \\
% \cs{HTMLTitle} & The \HTML\ |title| meta tag, overriding \cs{title}. \\
% \cs{HTMLAuthor} & The \HTML\ |author| meta tag, overriding \cs{author}. \\
% \cs{HTMLDescription} & The \HTML\ |description| meta tag. \\
% \cs{HTMLFirstPageTop} & Heading for the home page. \\
% \cs{HTMLPageTop} & Heading for the other pages. \\
% \cs{HTMLPageBottom} & Footing for all pages. \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% Several settings may be used to customize the \HTML\ output.
% Watch for the correct placement of each!\watchout[Placement!]
%
% Note that if changes are made,
% \watchout[Changes!]
% it is best to first:
% \begin{enumerate}
% \item Clear all the \HTML, \PDF, and auxiliary files: \userentry{lwarpmk clearall}
% \item Recompile the print version in order to recreate
%   the configuration files for |lwarpmk|: \userentry{lwarpmk print}
% \item Finally, recompile the \HTML\ version with the new settings: \userentry{lwarpmk html}
% \end{enumerate}
%
% \begin{description}[style=unboxed]
%
% \item[Options for the \pkg{lwarp} package:] \ \newline
%   Use the following as options for |\usepackage[<options>]{lwarp}|:
%
%   \begin{description}
%
% \ItemDescribeOption{HomeHTMLFilename} \DescribeDefault{\cs{BaseJobname}}
%   Filename of the homepage, without
%   the ``|.html|'' suffix.
%   Defaults to the \cs{BaseJobname}.  A common setting is:
%   \begin{sourcedisplay}
%   |HomeHTMLFilename=index|
%   \end{sourcedisplay}
%   causing the
%   homepage to be the file |index.html|.  Underscores are allowed in
%   \margintag{filename underscores}
%   |HomeHTMLFilename| and |HTMLFilename| options, but may need to be escaped
%   elsewhere, such as when appearing in a list:
%   \index{underscore>filename}\index{file>underscore}
%   \changes{v0.24}{2017/03/13}{Docs: Filename underscore.}
%   \begin{sourcedisplay}
%        \cs{item} [\cs{href}\{file\textcolor{red}{\textbackslash\_}name.pdf\}\{text\}] \textbackslash
%   \end{sourcedisplay}
%   See \cref{sec:filenameexamples} for examples of naming and numbering \HTML\ files.
%
% \ItemDescribeOption{HTMLFilename} \DescribeDefault{<empty>}
%   A filename prefix for the rest of the \HTML\ web pages.
%   Useful for numbered web pages with a common prefix.  May be empty.
%   See \cref{sec:filenameexamples} for examples of naming and numbering \HTML\ files.
%
% \ItemDescribeOption{latexmk} \DescribeDefault{false}
%   Controls whether \pkg{lwarp} uses |latexmk| to
%   compile the document.  This setting is written to |lwarpmk|'s configuration
%   files.
%
% \ItemDescribeOption{mathsvg} \DescribeDefault{true}
%   Selects \SVG\ display for math output.  (The default.)
%
% \ItemDescribeOption{mathjax} \DescribeDefault{false}
%   Selects MathJax for math output.
%
%   \end{description} \bigskip
%
% \item[Placed in the preamble before \texttt{\cs{begin}\{document\}}:] \
%
%   \begin{description}
%
% \ItemDescribeCounter{tocdepth} Sectioning depth of the table of contents.
%   See \cref{sec:stackdepths} for a list of \LaTeX{} stack depths.
%
% \ItemDescribeCounter{SideTOCDepth} \DescribeDefault{1}
%   Sectioning depth of the side\TOC.
%   Defaults to 1, causing the side\TOC\ to show sections but not subsections.
%
%   Each subpage of the website has its own small table of contents
%   \margintag{side\TOC}
%   on the side (the ``side\TOC'').  Its depth is set by |SideTOCDepth|.
%   This side\TOC\ is only shown if the web page is wide enough.
%   When using a narrow web browser window,
%   ``responsive web design'' is used to show the side\TOC\ at the top of the
%   page and a link back to ``Home'' at the bottom.
%
%   \label{sec:filedepth}
%   It is recommended to set:
%   \begin{sourcedisplay}
%   |SideTOCDepth|\,=\,|FileDepth|
%   \end{sourcedisplay}
%   or
%   \begin{sourcedisplay}
%   |SideTOCDepth|\,=\,|FileDepth|+1
%   \end{sourcedisplay}
%
%   If |SideTOCDepth|\,<\,|FileDepth|,
%       \watchout[inaccessible pages]
%       web pages will be inaccessible via the side\TOC.
%   \index{file>inaccessible}
%   \index{page>inacessible}
%   \index{missing sections}
%   \index{section>missing}
%
% \ItemDescribeCounter{FileDepth}  \DescribeDefault{-5}
%   Sectioning depth of file splits.
%   Defaults to -5, causing the entire \HTML\ website to be one single file.
%   \begin{itemize}
%   \item To place the entire file into one \HTML\ page, use:
%       \begin{sourcedisplay}
%       \cs{setcounter}\{FileDepth\}\{-5\}
%       \end{sourcedisplay}
%   \item To split the \HTML\ file at \cs{section} depth, use:
%       \begin{sourcedisplay}
%       \cs{setcounter}\{FileDepth\}\{1\}
%       \end{sourcedisplay}
%   \item To ensure that the \HTML\ pages/files are accessible:
%       \watchout\\
%       Place a \cs{tableofcontents} somewhere before the first section
%       break (therefore in the ``home page''), and set
%       \begin{sourcedisplay}
%       tocdepth\,>=\,FileDepth
%       \end{sourcedisplay}
%       \index{file>inaccessible}
%       \index{page>inacessible}
%       \index{missing sections}
%       \index{section>missing}
%   \end{itemize}
%
% \ItemDescribeBoolean{CombineHigherDepths}  \DescribeDefault{true}
%   Combine a higher section with
%   its first lower subsections, down to the |FileDepth|.
%   Defaults to true.  Set to false to simulate the concept of a chapter
%   opening on its own page, for example.
%
%   The file splits are controlled by the counter |FileDepth| and
%   the boolean |CombineHigherDepths|.
%   Setting |FileDepth| to 0 splits the file
%   at chapters, 1 at sections, etc.  |CombineHigherDepths| controls whether
%   to combine pages at levels higher than the chosen |FileDepth|, such as
%   in this tutorial where the page which opens the chapter also contains the
%   first section.
%   Be careful to set |tocdepth| and |SideTOCDepth| to allow
%   \watchout[Inaccesible pages!]
%   access to each page of the website.  Set |tocdepth| and |SideTOCDepth| to be
%   greater than or equal to |FileDepth|.
%
%   When making changes to the file structure,
%   \watchout[Lost in an old page!]
%   it is possible to end up
%   with the web browser pointing to an old file which is no longer in use.
%   When this occurs, changes to the web site will not appear in the browser,
%   even if reloading the page, because that page is no longer in use.
%   It is best to return to the home page, clean the files (|lwarpmk cleanall|),
%   change |FileDepth| and/or |CombineHigherDepths|, then finally recompile and
%   renavigate to the desired page using the new file structure.
%
% \ItemDescribeBoolean{FileSectionNames} \DescribeDefault{true}
%   If true, web page filenames are derived from a sanitized version
%   of the section names.  If false, web pages are numbered.
%   Either way, the |HTMLFilename| option is used as a prefix.
%   See \cref{sec:filenameexamples} for examples of naming and numbering \HTML\ files.
%
% \ItemDescribeCounter{FootnoteDepth} \DescribeDefault{5}
%   Determines where to place pending footnotes.
%   |5| places footnotes before each break down to the \cs{subparagraph} level.
%   |1| places footnotes before each \cs{section} break.
%   Any pending footnotes are also placed at the bottom of each page
%   before each file break.
%
% \ItemDescribeMacro{\abstractname}  \DescribeDefault{Abstract}
%   The name of the abstract.
%   This may also be over-written
%   by the \pkg{babel} package.  Defaults to ``Abstract''.
%
% \end{description}
%
% \needspace{2\baselineskip}
% \item[Placed before \texttt{\cs{begin}\{document\}},
%   or before any sectioning command which causes a file break:] \
%
% \begin{description}
% \ItemDescribeMacro{\CSSFilename}  \marg{filename.css}  \DescribeDefault{lwarp.css} \quad
%   Sets the \CSS\ file to use for the following
%   files.  May be changed before each each sectioning command which would
%   cause a file split.
%
%   The \CSS\ styles of the web pages are set by the \cs{CSSFilename} command.
%   If \cs{CSSFilename} is not used, a default plain style is used to mimic printed
%   \LaTeX\ output.  |lwarp_sagebrush.css| is a semi-fancy colored style as shown
%   in this tutorial.  Change it to |lwarp_formal.css| for a more formal look,
%   or comment out the \cs{CSSFilename} command to see the default.
%   \cs{CSSFilename} may be used before each file break to set the \CSS\ for
%   individual pagess of the website.
%
% \ItemDescribeMacro{\HTMLLanguage}  \marg{langauge} \DescribeDefault{en-US} \quad
%   The \HTML\ file's |html lang| meta tag.
%   Defaults to |en-US|.
%
% \ItemDescribeMacro{\HTMLTitle}  \marg{title} \DescribeDefault{\cs{thetitle}} \quad
%   Overrides \cs{title} for the \HTML\ header's meta title.
%   Defaults to \cs{thetitle}, which is set by \cs{title}, or empty otherwise.
%   Unlike the author, \cs{thetitle} is set by \cs{title} even if not using the \pkg{titling} package.
%
% \ItemDescribeMacro{\HTMLAuthor}  \marg{author} \DescribeDefault{\cs{theauthor}} \quad
%   The \HTML\ header's meta author.
%   Defaults to \cs{theauthor},
%   which is set by \cs{author} if using the \pkg{titling} package,
%   but is empty otherwise.
%   There are several ways to represent the author and affiliations,
%   especially if using the \pkg{authblk} package, most of which do not result in
%   a sensible \cs{theauthor}, so \cs{HTMLAuthor} is useful to create a list of
%   authors without their affiliations.
%
% \ItemDescribeMacro{\HTMLDescription} \marg{description}  \DescribeDefault{<empty>} \quad
%   Sets the \HTML\ \attribute{description} tag for
%   the following files.  May be changed before each each sectioning command which would
%   cause a file split.
%
% \ItemDescribeMacro{\HTMLFirstPageTop} \marg{contents}  \DescribeDefault{<empty>} \quad
%   A user-definable custom action applied
%   to the top of the home page.  Useful for logos, etc.
%   Defaults empty.
%   Ignored in print output.
%
% \ItemDescribeMacro{\HTMLPageTop}  \marg{contents}  \DescribeDefault{<empty>} \quad
%   A user-definable custom action applied to
%   the top of pages other than the home page.   Useful for logos, etc.
%   Defaults empty.
%   |\LinkHome| may be used to place a link back to the homepage.
%   Ignored in print output.
%
% \ItemDescribeMacro{\HTMLPageBottom}  \marg{contents}  \DescribeDefault{<empty>} \quad
%   A user-definable custom action applied to the
%   bottom of each web page.
%   Useful for authors, copyright notices, contact information, etc.
%   Defaults empty.
%   |\LinkHome| may be used to place a link back to the homepage.
%   Ignored in print output.
%
% \end{description}
%
%
% \needspace{2\baselineskip}
% \item[Placed in the home page before the first sectioning command which causes a file break:] \
%
% \begin{description}
% \ItemDescribeMacro{\tableofcontents}
% Used to place a table of contents on the home page.
% This command must be used before the first file split,
% \watchout[TOC on the homepage!]
% so that a way is available to navigate to other files from the homepage.
%
% Links to each chapter/section are provided, as selected by |tocdepth|.
% \end{description}
%
%
% \needspace{2\baselineskip}
% \item[Placed in the document wherever necessary:] \
%
% \begin{description}
% \ItemDescribeEnv{warpprint} An environment which is only used
%   while generating print output.  Place here anything which does not
%   apply to \HTML\ and which may cause problems with \pkg{lwarp}.
%   If \pkg{lwarp} knows about and emulates or supports
%   a package then its related macros, lengths, counters, etc. probably won't have
%   to be placed inside a \env{warpprint} environment, but unknown packages
%   may cause problems which may be isolated from \pkg{lwarp} using this environment.
%
% \ItemDescribeEnv{warpHTML} An environment which is only used
%   while generating \HTML\ output.  This is useful for website logos and
%   other items which have no purpose in printed output.
%
% \ItemDescribeMacro{\warpprintonly} \marg{contents} \quad
%   A macro version of the \env{warpprint} environment.
%
% \ItemDescribeMacro{\warpHTMLonly} \marg{contents} \quad
%   A macro version of the \env{warpHTML} environment.
% \end{description}
%
% \end{description}
%
%
% \subsubsection{Example HTML file naming}
% \label{sec:filenameexamples}
% \index{HTML>filename generation}
% \changes{v0.20}{2016/09/11}{Docs: Examples for generating \HTML\ file names.}
%
%   Examples of ways to name or number \HTML\ files:
%   \begin{description}
%   \item[Numbered \HTML\ nodes:] \
%
%   Example: Homepage |index.html|, and |node-1|, |node-2|.
%   \footnote{See \cs{SetHTMLFileNumber} to number in groups by chapter, for example.}
%   \begin{Verbatim}[gobble=2,frame=lines,obeytabs,tabsize=4]
%   \usepackage[
%       HomeHTMLFilename=index,
%       HTMLFilename={node-}
%   ]{lwarp}
%   \boolfalse{FileSectionNames}
%   \end{Verbatim}
%
%   \item[Named \HTML\ sections, no prefix:] \
%
%   Example: |index.html|, and |About.html|, |Products.html|
%   \begin{Verbatim}[gobble=2,frame=lines,obeytabs,tabsize=4]
%   \usepackage[
%       HomeHTMLFilename=index,
%       HTMLFilename={}
%   ]{lwarp}
%   \booltrue{FileSectionNames}
%   \end{Verbatim}
%
%   \item[Named \HTML\ sections, with prefix:] \
%
%   Example: Homepage |mywebsite.html|, and additional pages such
%   as \\
%   |mywebsite-About.html|, |mywebsite-Products|, etc.
%   \begin{Verbatim}[gobble=2,frame=lines,obeytabs,tabsize=4]
%   \usepackage[
%       HomeHTMLFilename=mywebsite,
%       HTMLFilename={mywebsite-}
%   ]{lwarp}
%   \booltrue{FileSectionNames}
%   \end{Verbatim}
%   \end{description}
%
%
% \subsection{Customizing the CSS}
% \label{sec:csscustomization}
%
% \DescribeMacro{\CSSFilename} \DescribeDefault{lwarp.css}
% \cs{CSSFilename} may be used to choose which |.css| file is used to display
% each page of the web site.  Use \cs{CSSFilename} before |\begin{document}|
% to assign the style of the home page.
% If different parts of the website should have different styles,
% call \cs{CSSFilename} again before each section heading which creates a new file.
% This may be changed numerous times throughout the file, resulting in
% different \HTML\ pages having different \CSS\ files assigned:
%   \begin{Verbatim}[gobble=2,tabsize=4]
%       ...
%       \newCSS{myCSS.css}
%       \chapter{Another Chapter}
%       ...
%   \end{Verbatim}
% \index{CSS>file selection}
% \index{CSS>per HTML page}
% \index{settings>CSS selection}
%
% The styles provided by \pkg{lwarp} include:
% \begin{description}
% \item[|lwarp.css|:] A default style if \cs{CSSFilename} is not used.  This
%   style is comparable to a plain \LaTeX\ document.
%   To set this style, you may use |\CSSFilename{lwarp.css}|, or no \cs{CSSFilename} call at all.
% \item[|lwarp\_formal.css|:] A formal style with a serif fonts and a traditional
%   look.
% \item[|lwarp\_sagebrush.css|:] A style with muted colors, gradient backgrounds,
%   additional borders, and rounded corners.
% \end{description}
%
% To see each style in use, change the \cs{CSSFilename} entry in the tutorial,
% |lwarpmk html| again, and then reload the tutorial webpage.
%
% A customized style may also be created.
% \margintag{Custom \CSS}
% For each new project a file
% called |sample_project.css| is generated.  This may be renamed to
% |<project>.css| then used by assigning |\CSSFilename{<project>.css}|.
%
% Note that |sample_project.css| is overwritten whenever \pkg{lwarp}
% is loaded in print mode.
% It is therefore important to rename the file \watchout[Rename it!]
% to something like |<project>.css| before
% using it, so that your own changes are not overwritten.
%
% |<project>.css| has an entry which loads |lwarp.css|, and this
% entry may be changed to load |lwarp_formal.css| or |lwarp_sagebrush.css| if
% desired.  Additional changes to the \CSS\ may be made by making entries
% later in the |<project>.css| file.
%
% \label{sec:projectcss}
% \DescribeFile{lwarp.css}\DescribeFile{project.css}\DescribeFile{sample_project.css}\label{sec:lwarpcss}
% It is best to make a local project-specific \CSS\ file such as |project.css|, containing only
% things which are different from |lwarp.css|.
% The file |project.css| should refer to |lwarp.css| as follows:
%   \index{CSS>project-specific changes}\index{CSS>lwarp.css}
%   \index{settings>\CSS\ project-specific}
% \vspace{-2ex}
% \VerbatimInput[frame=lines]{sample_project.css}
%
% Finally use |\CSSFilename{<project>.css}| in the document to activate the custom \CSS.
% 
% 
% \subsection{Selecting the operating system}
% \label{sec:OSportabilityusage}
% \changes{v0.11}{2016/03/11}{Added section: Selecting the operating system.}
%
% \osportabilityusage
%
% 
% \subsection{Selecting actions for print or HTML output}
% \label{sec:selectingoutput}
% \index{settings>selecting output}
% \changes{v0.15}{2016/04/05}{Docs: Clarify print/\HTML\ output.}
%
% The following environments and macros are used to select actions which only apply
% to either traditional \LaTeX{} print-formatted PDF generation,
% or to \HTML\ generation.
%
% For most of built-in \LaTeX\ and many additional packages
% there is user-level source code support or emulation,
% so no special handling will be required.
% For those cases which \pkg{lwarp} does not handle by itself, the
% following environments and macros may be used to isolate sections
% of code for print-only or \HTML-only.
%
% These environments are also useful for creating a special version of
% the titlepage for print and another for \HTML.

% \DescribeEnv{warpHTML}
% Anything which is to be done only for \HTMLfive{} output
% is surrounded by a |warpHTML| environment:
% \begin{Verbatim}[gobble=2,frame=lines,obeytabs,tabsize=4]
% \begin{warpHTML}
%  ... something to be done only during HTML generation
% \end{warpHTML}
% \end{Verbatim}
%
% \DescribeEnv{warpprint}
% Anything which is to be done only for print output
% is surrounded by a |warpprint| environment:
% \begin{Verbatim}[gobble=2,frame=lines,obeytabs,tabsize=4]
% \begin{warpprint}
%  ... something to be done only during traditional PDF generation
% \end{warpprint}
% \end{Verbatim}
%
% \DescribeEnv{warpall}
% Anything which is to be done for any output
% may be surrounded by a |warpall| environment.  Doing so is optional.
% \begin{Verbatim}[gobble=2,frame=lines,obeytabs,tabsize=4]
% \begin{warpall}
%  ... something to be done during print PDF or HTML output
% \end{warpall}
% \end{Verbatim}
%
%
% Macros are also provided for print-only or \HTML-only code:
%
% \DescribeMacro{\warpprintonly} \marg{actions}
%
% Performs the given actions only when print output is being generated.
%
% \DescribeMacro{\warpHTMLonly} \marg{actions}
%
% Performs the given actions only when \HTML\ output is being generated.
%
%
%
% \subsection{Commands to be placed into the \env{warpprint} environment}
% \label{sec:printcommands}
%
% \changes{v0.14}{2016/03/26}{Docs: Commands into a warpprint environment.}
%
% Certain print-related commands should always be placed
% inside a \env{warpprint} environment, or may need other special handling.
% These are unrelated to \HTML\ output, but are hard to isolate automatically.
% For example:
%
% \begin{itemize}
% \item Paragraph formatting: \cs{parindent} \cs{parskip}
% \item Manual page positions such as the \pkg{textpos} package, which is
%	emulated but only in a limited way.
% \end{itemize}
%
% Some packages require additional setup commands.  Where these packages are emulated
% for \HTML, setup commands may work for the emulated \HTML\ output as well as for print
% output.  See the details for each package in this document for more information.
%
% Also see \cref{sec:troubleshooting}: \nameref{sec:troubleshooting}.
%
%
%
%
% 
%
% \subsection{Title page}
% \label{sec:settitle}
% \index{settings>title page}
%
% In the preamble, place an additional block of code to set the following:
% \vspace{-2em}
% \begin{Verbatim}[gobble=2,frame=lines,obeytabs,tabsize=4]
% \title{Document Title} % One line only
% \author{Author One\affiliation{Affiliation One} \and 
%     Author Two\affiliation{Affiliation Two} }
% \date{Optional date}
% \end{Verbatim}
% 
% The title is used in the meta tags in the \HTML\ files,
% unless overridden by \cs{HTMLTitle}, and the rest are used in |\maketitle|.
% To use a \cs{subtitle} or \cs{published} field, see \cref{sec:publishedsubtitle}.
%
%
% \DescribeMacro{\maketitle}
% Use |\maketitle| just after the |\begin{document}|, as this will establish
% the title of the homepage.  Optionally, use a |titlepage| environment instead.
%
% \DescribeEnv{titlepage}
% The \env{titlepage} environment may be used to hold a custom title page.
% The titlepage will be set in a \element{div} class |titlepage|, and \cs{printtitle}, etc.\ may be used
% inside this environment.
%
% \DescribeEnv{titlingpage}
% Another form of custom title page, where \cs{maketitle} is allowed, and
% additional information may be included as well.
%
% \DescribeMacro{\title} \marg{title}
% 
% Avoid newlines in the |\title|; these will interfere with the
% file break and \CSS\ detection.
% \watchout
% Use a |\subtitle| command instead (\cref{sec:publishedsubtitle}).
% The title will appear in the document \cs{maketitle} as a heading \element{h1}.
% The \HTML\ meta |title| tag will also have this title, unless \cs{HTMLTitle}
% is used to set the meta title to something else instead.
%
% \DescribeMacro{\author} \marg{author}
%
% In |\author|, use |\protect| before formatting commands such as |\textsc|.
% \watchout
% In \HTML, the author will appear in a \element{div} of class |author| in the
% \cs{maketitle}.
% If the \pkg{titling} package is used, the author will also appear in a \HTML\ meta tag, but
% \cs{HTMLAuthor} may be necessary to create a plain list of names if
% \cs{author} had affiliations added.
% \cs{affiliation} is a new addition to \pkg{lwarp}.
%
% \DescribeMacro{\date} \marg{date}
%
% |\date| works as expected.
% In \HTML, this will appear in a \element{div} class |titledate|.
%
%
% \DescribeMacro{\thanks} \marg{text}
%
% \cs{thanks} are allowed in the titlepage fields, and will be rendered
% as \HTML\ notes at the bottom of the title page.
%
%
% \subsection{HTML page meta descriptions}
%
% \label{sec:htmldescription}
% \index{HTML>meta tag>description}
% \index{description>HTML meta tag}
% \index{meta tag, HTML>description}
% \DescribeMacro{\HTMLDescription} \marg{A description of the web page.}
% \quad The default is no description.
%
% Each page of \HTML\ output should have its own \HTML\ meta description,
% which usually shows up in web search results,
% \margintag{limitations}
% is limited to around
% 150 characters in length, and should not include the \acro{ASCII} double quote character (").
%
% Use \cs{HTMLDescription}
% \margintag{placement}
% just before |\begin{document}| to set the description of the home page,
% and also just before each sectioning command such as \cs{chapter} or \cs{section}
% where a new file will be generated, depending on |FileDepth|.  For example, if |FileDepth| is 1,
% use \cs{HTMLDescription} just before each \cs{section} command, and that description will be
% placed inside the \HTML\ page for that \cs{section}.  The same descrition will be used for
% all following \HTML\ files as well, until reset by a new \cs{HTMLDescription}.  It is best
% to use a unique description for each \HTML\ file.
%
% To disable the generation of \HTML\ description meta tags,
% \margintag{disabling}
% use:\\
% \hspace*{1em} |\HTMLDescription{}|
%
%
% \subsection{HTML page meta title}
%
% \index{HTML>meta tag>title}
% \index{title>HTML meta tag}
% \index{meta tag, HTML>title}
% \DescribeMacro{\HTMLTitle} \marg{title} \quad Sets the contents
%   of the web page \element{meta name="title"} element.
%   Defaults to |\HTMLtitle{\thetitle}|.
%   May be set empty to cancel the meta title tag.
%
%
% \subsection{HTML page meta author}
%
% \index{HTML>meta tag>author}
% \index{author>HTML meta tag}
% \index{meta tag, HTML>author}
% \DescribeMacro{\HTMLAuthor} \marg{author} \quad Sets the contents
%	of the web page \element{meta name="author"} element.
%	Defaults to |\HTMLAuthor{\theauthor}|.
%	May be set empty to cancel the meta author tag.
%
% \cs{author} may be used to create a list of authors and their affiliations,
% in several formats if using \pkg{authblk}, and these may not successfully parse
% properly into a sensible list for \cs{theauthor}.
% \cs{HTMLAuthor} may be used to set the meta tag to a simple list of names.
%
%
% \subsection{Modifying \protect\texttt{xindy} index processing}
% \label{sec:modifyxindy}
%
% \DescribeProgram{xindy}
% \DescribeFile{lwarp.xdy}
% \pkg{lwarpmk} uses the file |lwarp.xdy| to process the index.
% \index{lwarp.xdy>customizing}
% \index{xindy>customizing}
% This file is over-written by \pkg{lwarp} whenever a print version of
% the document is processed.
%
% To customize index processing:
% \begin{enumerate}
% \item Copy |lwarp.xdy| to a new filename such as |projectname.xdy|
% \item Make changes to |projectname.xdy|.
%	Keep the line which says
%	\begin{Verbatim}[gobble=2,tabsize=4]
%		(markup-locref :open "\hyperindexref{" :close "}")
%	\end{Verbatim}
%	This line creates the hyperlinks for the \HTML\ index.  During print output
%	\cs{hyperindexref} becomes a null function.
% \item In the document source use the |xdyFilename| option for \pkg{lwarp}:
% \DescribeOption{xdyFilename}
%	\begin{Verbatim}[gobble=2,tabsize=4]
%		\usepackage[
%			... other options ...
%			xdyFilename=projectname.xdy,
%		]{lwarp}
%	\end{Verbatim}
% \item Recompile the print version, which causes
%	\pkg{lwarp} to rewrite the |lwarpmk.conf| configuration file.
%	This tells |lwarpmk| to use the custom |projectname.xdy| file instead of |lwarp.xdy|.
% \end{enumerate}
%
%
%
%
% \section{Special cases and limitations}
% \label{sec:limitations}
%
% \label{sec:successfulcommands}
% \index{HTML>commands for a successful conversion}
%
% \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 to allow
% for a smooth conversion to both \HTML\ and print-formatted outputs:
%
%
% \subsection{Formatting}
%
%
% \subsubsection{Text formatting}
%
% \limitstext
%
% \subsubsection{Horizontal space}
%
% \limitshspace
%
%
% \subsubsection{Text alignment}
%
% Use the environments \env{center}, \env{flushright}, \env{flushleft} instead
% of the macros \cs{centering}, \cs{raggedright}, \cs{raggedleft}.
%
%
% \subsubsection{Accents}
%
% \limitsaccents
%
%
% \subsubsection{Textcomp}
%
% \limitstextcomp
%
%
% \subsubsection{Superscripts and other non-math uses of math mode}
%
%	Use \cs{textsuperscript\{x\}} instead of |$^{x}$|
%
% \subsubsection{Empty \cs{item} followed by a new line of text or a nested list:}
%
%	Use a trailing backslash: |\item[label] \|
%	\index{item>empty}\index{list item, empty}
%
%
% \subsubsection{Filenames and URLs in lists or footnotes}
%
%	\index{underscore>filename}\index{file>underscore}
%	\changes{v0.24}{2017/03/13}{Docs: Filename underscore.}
%	Escape underscores in
%	\margintag{filename underscore}
%	the filenames:
%	\begin{sourcedisplay}
%	|\item[\href{file\_name.pdf}{text}]|
%	\end{sourcedisplay}
%
% \subsubsection{\pkg{relsize} package}
%
% \limitsrelsize
%
%
% \subsection{Boxes and minipages}
%
% \subsubsection{Marginpars}
%
% \limitsmarginpars
%
% \subsubsection{Save Boxes}
%
% \changes{v0.27}{2017/04/04}{Docs: Limitations of saveboxes.}
%
% \limitssaveboxes
%
%
% \subsubsection{Minipages}
% \label{sec:minipages}
%
% \limitsminipage
%
%
% \subsubsection{Side-by-side minipages}
%
%	Place side-by-side minipages inside a |center| environment,
%	with horizontal space between them, such as \cs{quad}, \cs{qquad},
%	\cs{hspace}, or \cs{hfill}.  The result is similar in print and
%	\HTML.  Do not use space commands at the start or end of the line.
%
% \subsubsection{Framed minipages and other environments}
%	\label{sec:framedminipages}
%
%	\cs{fbox} can only be used around inline \element{span} items during
%	\HTML\ output, but \HTML\ cannot place a block element such as a \element{div} for a minipage
%	or a list inside of a \element{span}.  Several options are provided for framing an object,
%	depending on which kind of object and which packages are loaded:
%
%	For a framed object, options include:
%	\DescribeMacro{\fbox}
%	\DescribeMacro{\fboxBlock}
%	\DescribeEnv{fminipage}
%	\index{fbox>around a minipage}
%	\index{minipage>framed}
%	\index{framed objects}
%	\begin{description}[style=unboxed]
%	\item [To remove the frame in HTML output:] Place the \cs{fbox} command and
%		its closing brace inside \env{warpprint} environments.
%		This will nullify the frame for \HTML\ output.
%	\item [To frame the contents inline with some formatting losses in HTML:]
%		This is the default action of \cs{fbox} when enclosing a minipage.
%		\margintag{For inline text:}
%		During \HTML\ output, \cs{fbox} nullifies the \HTML\ tags
%		for \env{minipage}, \cs{parbox},
%		and lists.  The contents are included as inline text inside the
%		\cs{fbox}'s \element{span} of class |framebox|.
%		For lists, line breaks are converted to \HTML\ breaks.
%		The result is a plain-text inline version of the contents, framed inline
%		with the surrounding text, but lacking any extra \HTML\ markup.
%	\item [To frame the contents on their own line with improved formatting in HTML:] A new
%		command \cs{fboxBlock} is included,
%		\margintag{For inline \env{minipage} and lists:}
%		intended to be a direct replacement
%		for \cs{fbox} for cases where the \cs{fbox} surrounds a minipage, table, or list.
%		For print output, this behaves as \cs{fbox}.
%		For \HTML\ output, the contents are placed
%		inside an \HTML\ \element{div} with the class |framed|, resulting in the contents
%		being placed on their own line with a frame surrounding them.
%		The contents preserve their \HTML\ formatting, so lists and minipages look nicer,
%		and valid \HTML\ is created for a \env{tabular}.
%		While an \cs{fbox} containing a \env{tabular} is valid \LaTeX\ code, the result
%		in \HTML\ is problematic since a table is a \element{div} not a \element{span},
%		so use \cs{fboxBlock} around a \env{tabular}, or else place the \env{tabular}
%		inside a \env{minipage}, or use \env{fminipage}, described next.
%		Also see below regarding the ``Misplaced alignment tab character \&'' error.
%	\item [To create a framed minipage in both print and HTML:] A new environment \env{fminipage}
%		\margintag{For display \env{tabular}, minipages, and lists:}
%		is included.  For print output, this is identical to \env{minipage}, except that
%		it is also framed.
%		For \HTML\ output, this forms a \element{div} of class |framed|, the contents
%		preserve their \HTML\ formatting, and valid \HTML\ is created for a \env{tabular}.
%		Also see below regarding the ``Misplaced alignment tab character \&'' error.
%	\item [To create colored frames and boxes:] See \cref{sec:xcolor} for \pkg{xcolor}'s
%		\margintag{colored boxes and frames:}
%		\cs{colorbox} and \cs{fcolorbox},
%		and \pkg{lwarp}'s additional \cs{colorboxBlock} and \cs{fcolorboxBlock}.
%	\item [To frame tables or verbatim environments:] Place the contents
%		inside a \env{fminipage}, or perhaps a \cs{fboxBlock} for a \env{tabular}.
%		Also, if using \cs{fboxblock} with \env{tabular},
%		\watchout[Misplaced alignment tab character \&]
%		you will have to use \cs{StartDefiningTabulars}
%		before the start of the macro which uses \cs{fboxBlock} and the \env{tabular},
%		and \cs{EndDefiningTabulars} afterwards.
%		Also see the \pkg{lwarp} documentation for the \pkg{fancybox} package.
%	\item [To frame equations:] See \cref{sec:fancybox} for the \pkg{fancybox} package.
%	\item [For fancy framed minipages:] See packages \pkg{boxedminipage},
%		\pkg{shadow}, \pkg{fancybox}, \pkg{framed}, \pkg{mdframed}.
%	\item [Custom environments:] Use a custom environment to create a sidebar,
%		containing a \env{BlockClass} environment
%		with custom \CSS\ formatting,
%		 and |\warpprintonly{\hrule}| command:
% \begin{Verbatim}[gobble=2,frame=lines]
% \begin{BlockClass}{frameminipage}% ignored in print output
%   % use CSS to format div class ``framedminipage''
% \warpprintonly{\hrule} % only appears in print output
% Contents
% \warpprintonly{\hrule} % only appears in print output
% \end{BlockClass}
% \end{Verbatim}
% \end{description}
%
%
% \subsubsection{\pkg{fancybox} package}
%
% \limitsfancybox
%
% 
% \subsubsection{\pkg{mdframed} package}
%
% \limitsmdframed
%
%
%
%
% \subsection{Cross-references}
%
% \index{math>labels --- valid characters}
% \index{label>valid characters}
% \limitsreferences
%
% \subsubsection{Page references} The printed page does not translate
% to the \HTML\
% \watchout[\LaTeX\ page numbers]
% page, so \cs{pageref} references are converted to parentheses containing
% \cs{pagerefPageFor}, which defaults to ``see~'',
% followed by a hyperlink to the appropriate
% object.
%
% Ex:
% \begin{sourcedisplay}
%    \cs{ref}\{sec:name\} on page \cs{pageref}\{sec:name\} \\
%    \rmfamily
% \hspace*{-2em} in \HTML\ becomes: \\
%    ``Sec.~\textcolor{red}{1.23}
%    on page (\textbf{see}
%    sec.~\textcolor{red}{1.23})''.
% \end{sourcedisplay}
% \cs{pagerefPageFor} may be redefined to ``page for '', empty, etc.
% See \cpageref{sec:pagerefpagefor}.
%
%
% \subsubsection{\pkg{cleveref} and \pkg{varioref} packages}
%
% \changes{v0.22}{2017/03/01}{\pkg{varioref}: Supported.}
%
% \limitscpageref
%
% \subsubsection{Hyperlinks, \pkg{hyperref}, and \pkg{url}}
%
% \limitshyperlinks
%
%
% \subsubsection{Footnotes and page notes}
%
% \limitsfootnotes
%
%
%
% \subsection{Front and back matter}
% \label{sec:frontbackmatter}
%
% \subsubsection{Starred chapters and sections}
% \label{sec:forcesectionstar}
%
% \changes{v0.38}{2017/08/24}{Docs: Starred sections.}
%
% The following describes \cs{ForceHTMLPage} and \cs{ForceHTMLTOC},
% which may be used for \pkg{endnotes}, \pkg{glossaries}, \pkg{tocbibind},
% and the index.  See the following sections where applicable.
% Continue here if interested in the reason for adding these commands to \pkg{lwarp}.
%
% Some packages use \cs{chapter*} or \cs{section*} to introduce reference
% material such as notes or lists, often to be placed in the back matter of a book.
% These starred sections are placed inline instead of on their own \HTML\ pages,
% and they are not given \acro{TOC} entries.
% 
% \pkg{lwarp} provides a method to cause a starred section to be on its own \HTML\ page,
% subject to \texttt{FileDepth}, and also a method to cause the starred section
% to have its own \acro{TOC} entry during \HTML\ output.
% 
% \DescribeMacro{\ForceHTMLPage}
% To place a starred section on its own \HTML\ page, use \cs{ForceHTMLPage} just before
% the \cs{chapter*} or \cs{section*}.  \pkg{lwarp} will create a new page for the
% starred sectional unit.
% 
% A starred sectional unit does not have a \acro{TOC} entry unless one is placed
% manually.  The typical method using \cs{phantomsection} and \cs{addcontentsline}
% works for inline text but fails when the new starred section is given its own
% webpage after the \acro{TOC} entry is created.
% If the starred section has its own \HTML\ page but no correct \acro{TOC} entry
% \watchout[inaccessible \HTML\ page]
% pointing to that page, the page will be inaccessible unless some other link is created.
% 
% \DescribeMacro{\ForceHTMLTOC}
% To automatically force the \HTML\ version of the document to have a \acro{TOC} entry
% for a starred section, use \cs{ForceHTMLTOC} just before the \cs{chapter*} or
% \cs{section*}.  The \acro{TOC} will only be assigned for \HTML\ output, not
% for print output, and it will appear in the main \acro{TOC} and also the side\acro{TOC}
% per page.
% 
% For print output, \cs{ForceHTMLTOC} and \cs{ForceHTMLPage} have no effect.
%
%
%
% \subsubsection{\pkg{abstract} package}
%
% \limitsabstract
%
%
% \subsubsection{\pkg{titling} and \pkg{authblk}}
%
% \limitstitlepage
%
%
% \subsubsection{\pkg{tocloft} package}
%
% \DescribeOption[tocloft]{titles}
% \limitstocloft
%
%
% \subsubsection{\pkg{appendix} package}
%
% \limitsappendix
%
%
% \subsubsection{\pkg{pagenote} package}
%
% \limitspagenote
%
%
% \subsubsection{\pkg{endnotes} package}
%
% \limitsendnotes
%
%
% \subsubsection{\pkg{glossaries} package}
% \label{sec:glossaries}
%
% \DescribePackage{glossaries}
% \limitsglossaries
%
%
% \subsubsection{Index and the \pkg{tocbibind} package}
% \label{sec:indextocbibind}
% \index{index>placement and \acro{TOC} options}
%
% \changes{v0.38}{2017/08/24}{Docs: Index, \protect\pkg{tocbibind}.}
%
% \limitsindex
%
% See \cref{sec:index} for \pkg{lwarp}'s core index and glossary code,
% and \cref{sec:tocbibind} for \pkg{tocbibind}.
%
%
%
%
% \subsection{Math}
%
% \changes{v0.42}{2017/10/30}{Docs: Reorganized math limitations}
% \label{sec:limitsmath}
% \limitsmath
%
%
%
% \subsubsection{\pkg{ntheorem} package}
%
% \limitsntheorem
%
%
% \subsubsection{\pkg{siunitx} package}
% \label{sec:limitssiunitx}
%
% \DescribePackage{siunitx}
% \limitssiunitx
% 
%
% \subsubsection{\pkg{units} and \pkg{nicefrac} packages}
%
% \DescribePackage{units}
% \DescribePackage{nicefrac}
% \limitsnicefrac
% 
%
% \subsubsection{\pkg{newtxmath} package}
%
% \DescribePackage{newtxmath}
% \limitsnewtxmath
%
%
% \subsection{Graphics}
% \label{sec:limitsgraphics}
%
% \limitsgraphics
%
%
% \subsubsection{\pkg{grffile} package}
%
% \limitsgrffile
%
%
% \subsubsection{\pkg{color} package}
%
% \limitscolor
%
%
% \subsubsection{\pkg{xcolor} package}
%
% \limitsxcolor
%
% \subsubsection{\pkg{overpic} package}
%
% \limitsoverpic
%
%
% \subsection{Tabular}
% \label{sec:limitstabular}
% \changes{v0.39}{2017/08/30}{Docs: Reorganized tabular discussion.}
% \limitstabular
%
%
% \subsubsection{\pkg{longtable} package}
%
% \limitslongtable
%
%
% \subsubsection{\pkg{supertabular} and \pkg{xtab} packages}
%
% \limitssupertabular
%
% \subsubsection{\pkg{bigdelim} package}
%
% \limitsbigdelim
%
%
% \subsection{Floats}
%
% \subsubsection{\pkg{float}, \pkg{trivfloat}, and/or \pkg{algorithmicx} together}
%
% \limitscombiningfloats
%
%
% \subsubsection{\pkg{caption} and \pkg{subcaption} packages}
%
% \limitscaption
%
%
%
%
% \subsubsection{\pkg{subfig} package}
%
% \limitssubfig
%
%
% \subsubsection{\pkg{floatrow} package}
%
% \limitsfloatrow
%
%
% \subsubsection{\pkg{keyfloat} package}
%
% \limitskeyfloat
%
%
% \subsection{Koma-Script}
%
% \limitskomascript
%
%
% \subsection{Miscellaneous}
%
%
% \subsubsection{\pkg{verse} and \pkg{memoir}}
%
% \limitsverse
%
%
% \subsubsection{\pkg{newclude} package}
%
% \changes{v0.14}{2016/03/29}{Docs: Newclude limitations.}
%
% \DescribePackage{newclude}
% \limitsnewclude
%
%
%
% \subsubsection{\pkg{babel} package}
%
% \DescribePackage{babel}
% ^^A \limitsbabelone
%
% \limitsbabeltwo
%
%
% \subsubsection{\pkg{todonotes} and \pkg{luatodonotes} packages}
%
% \limitstodonotes
%
%
% \subsubsection{\pkg{fixme}}
%
% \limitsfixme
%
%
% \clearpage
%
% \section{EPUB conversion}
% \label{sec:epub}
%
% \pkg{lwarp} does not produce \EPUB\ documents,
% but it may be told to modify its \HTML\ output
% to greatly assist in the conversion.
% An external program may then be used to finish the conversion
% to \EPUB.
%
% To assign the author's name for regular \pkg{lwarp} \HTML\
% \margintag{\element{meta} author}
% files, and also for the \EPUB,
% use \cs{HTMLAuthor} \marg{name}.  This assigns the name to the
% \element{meta} author element.  It may be set empty, and it defaults to
% \cs{theauthor}.
%
% A special boolean is provided to simplify the process of
% converting \pkg{lwarp} \HTML\ output to \EPUB:
%
% \DescribeBoolean{FormatEPUB}  \DescribeDefault{false}
% \begin{docsidebar}[\texttt{FormatEPUB}]
%	\raggedright
%	|FormatEPUB| changes \HTML\ output for easy \EPUB\ conversion
%	via an external program. Removes per-file headers, footers, and nav.
%	Adds footnotes per chapter/section.
% \end{docsidebar}
%	\index{EPUB>HTML conversion settings}
%	\index{HTML>conversion settings>EPUB}
%
% To help convert \pkg{lwarp} \HTML\ output to \EPUB, add
%	\begin{sourcedisplay}
%	|\booltrue{FormatEPUB}|
%	\end{sourcedisplay}
% to the project's source preamble after |\usepackage{lwarp}|.
% The \EPUB\ version of the document cannot co-exist with the
% regular \HTML\ version, so
% \userentry{lwarpmk cleanall}
% \userentry{lwarpmk html}
% \userentry{lwarpmk limages}
% to recompile with the |FormatEPUB| boolean turned on.
% Several changes are then made to the \HTML\ output:
%	\begin{itemize}
%	\item Headers, footers, and navigation are removed at file splits.
%	\item Any accumulated footnotes are printed at the bottom of each section.
%	\end{itemize}
%
% The resulting files will be ready to be loaded into an \EPUB\ conversion
% program, such as the open-source program Calibre (\url{https://calibre-ebook.com/}).
% \index{Calibre}\index{EPUB>conversion software}\margintag{Calibre}
%
% The \EPUB\ conversion program must know what order the files are included.
% For \pkg{lwarp} projects, set the \EPUB\ conversion software to
% \watchout[search order]
% do a breadth-first search of the files.
% For Calibre, this option is found in
% \begin{UIdisplay}
%	\textsf{Preferences $\to$ Plugins $\to$ File type plugins $\to$ HTML to Zip}
% \end{UIdisplay}
% Check the box \textsf{Add linked files in breadth first order.}
% 
% The \EPUB-conversion program must also know where the section breaks are located.
% \watchout[section breaks]
% For a list of \pkg{lwarp}'s section headings,
% see \cref{tab:depthsheadings}.
% For example, an |article|
% class document would break at \cs{section}, which is mapped to \HTML\
% heading level \element{h4}, whereas a |book| class document would break at \cs{chapter},
% which is \HTML\ heading level \element{h3}.
% For Calibre, this option is found in
% \begin{UIdisplay}
%	\textsf{Preferences $\to$ Conversion (Common Options) $\to$
%	Structure Detection $\to$ Detect chapters at (XPath expression)}
% \end{UIdisplay}
% Select the ``magic wand'' to the right of this entry box, and set
% the first entry
% \begin{UIdisplay}
%	Match HTML tags with tag name:
% \end{UIdisplay}
% to ``h4''.  (Or ``h3'' for document classes with \cs{chapter}s.)
% The \textsf{Detect chapters at} field should then show
% \begin{UIdisplay}
%	//h:h4 \qquad \textrm{---\,or\,---} \qquad //h:h3
% \end{UIdisplay}
%
% This option is also available on the main tool bar at the \textsf{Convert books}
% button.
%
% Once these settings have been made, the \pkg{lwarp}-generated \HTML\ files
% may be loaded by Calibre, and then converted to an \EPUB.
%
% \begin{docsidebar}[MathJax support]
% MathJax may be used in \EPUB\ documents.
% Some e-readers include MathJax, but any given reader
% may or may not have a recent version, and may or may not include
% extensions such as support for \pkg{siunitx}.
%
% \pkg{lwarp} adds some modifications to \MathML\ to support equations numbered
% by chapter.  These modifications may not be compatible with the e-reader's
% version of MathJax, so \pkg{lwarp} requests that a known version be loaded
% instead.  In some cases chapter numbering of equations still doesn't work.
%
% Until math support in \EPUB\ documents is improved, it is recommended to use
% \SVG\ images instead of MathJax, especially for equations numbered by chapter,
% or where \pkg{siunitx} support is important.
% \end{docsidebar}
%
%
%
%
% \clearpage
%
% \section{Word-processor conversion}
% \label{sec:wordprocessorconversion}
%   \index{word processor>HTML conversion settings}
%   \index{HTML>conversion settings>word processor}
%   \index{LibreOffice>import into}
%   \index{export>to word processor}
%
% \pkg{lwarp} may be told to modify its \HTML\ output to make it
% easier to import the \HTML\ document into a word processor.
% At the time of this writing, it seems that LibreOffice works best at
% preserving table layout, but it still has some limitations, such as
% an inability to automatically assign figure and table
% frames and captions according to user-selected \HTML\ classes.
% \pkg{lwarp} provides some assistance in locating these frame boundaries,
% as shown below.
%
%
% \subsection{Activating word-processor conversion}
%
% A special boolean is provided to simplify the process of
% converting \pkg{lwarp} \HTML\ output to \EPUB:
%
% \DescribeBoolean{FormatWP} \DescribeDefault{false}
% \begin{docsidebar}[\texttt{FormatWP}]
%	\raggedright
%	Changes \HTML\ output for easier conversion
%	by a word processor.
%	Removes headers and nav, prints footnotes per section,
%	and also forces single-file output and turns off \HTML\ debug
%	comments.
%   Additionally, honors the booleans |WPMarkFloats|, |WPMarkMinipages|,
%   |WPMarkTOC|, and |WPMarkLOFT|.
%	\end{docsidebar}
%
% To help modify \pkg{lwarp} \HTML\ output for easier
% import to a word processor, add
%	\begin{sourcedisplay}
%	|\booltrue{FormatWP}|
%	\end{sourcedisplay}
% to the project's source preamble after \pkg{lwarp} is loaded.
% The following changes are then made to the \HTML\ output:
% \margintag{formatting adjustments}
%	\begin{itemize}
%   \item If using a class without chapters, \cs{section} and lower are
%       shifted up in level for the \HTML\ heading tags.  The \CSS\ has
%       not been changed, so the section heading formats will not match the normal
%       \HTML\ output, but when imported to LibreOffice Writer the higher
%       section headings will import as \UI{Heading~1} for the title, \UI{Heading~2}
%       for \cs{section}, etc.
%	\item Headers, footers, and navigation are removed at file splits.
%	\item Any accumulated footnotes are printed at the bottom of each section.
%	\item Forces single-file output.
%	\item Turns off \HTML\ debugging comments.
%		These are comments appearing inside the \HTML\ code,
%		marking the opening/closing of sections and \element{div}s,
%		but they are no longer useful when the document has been
%		imported into a word processor.
%   \item An additional \element{div} with an \attribute{id} encapsulates
%       each float and minipage, which on import into LibreOffice Writer
%       causes a thin frame to appear around the text block for each.
%   \item Float captions are given an explicit italic formatting.
%   \item Tabular rule borders are made explicit for LibreOffice Writer.
%       LibreOffice displays a light border around each cell while editing,
%       even those which have no border when printed,
%       and \pkg{lwarp} also uses a light border for thin rules,
%       so it will be best to judge the results using
%       the print preview instead of while editing in LibreOffice.
%   \item \cs{includegraphics} and \SVG\ math width and height
%       are made explicit for LibreOffice.
%   \item \cs{hspace} is approximated by a number of \cs{quad}s,
%       and rules are approximated by a number of underscores.
%   \item Explicit \HTML\ styles are given to:
%       \begin{itemize}
%       \item \cs{textsc}, etc.
%       \item \cs{underline}, \pkg{soul} and \pkg{ulem} markup.
%       \item \env{center}, \env{flushleft}, \env{flushright}.
%       \item \cs{marginpar}, \pkg{keyfloat}, \pkg{sidenotes}, \pkg{floatflt},
%           and \pkg{wrapfig}.
%       \item \pkg{fancybox} \cs{shadowbox}, etc.
%       \item The \LaTeX\ and \TeX\ logos.
%       \end{itemize}
%   \item Honors several booleans:
%       \begin{description}
%       \item[\texttt{WPMarkFloats}:] Marks the begin and end of floats.
%       \item[\texttt{WPMarkMinipages}:] Marks the begin and end of minipages.
%       \item[\texttt{WPMarkTOC}:] Marks the location of the Table of Contents.
%       \item[\texttt{WPMarkLOFT}:] Marks the locations of the List of Figures/Tables.
%       \item[\texttt{WPMarkMath}:] Prints \LaTeX\ math instead of using images.
%       \item[\texttt{WPTitleHeading}:] Adjusts title and section headings.
%       \end{description}
%       Several of these may be used to add markers to the HTML text
%       which help determine where to adjust the word processor document after
%       import.

%	\end{itemize}
%
%
% \subsection{Additional modifications}
%
% \newcommand{\describeWPMarkFloats}{
%   Adds
%   \begin{sourcedisplay}
%   === begin table === \\
%   \dots \\
%   === end ===
%   \end{sourcedisplay}
%   or
%   \begin{sourcedisplay}
%   === begin figure === \\
%   \dots \\
%   === end ===
%   \end{sourcedisplay}
%   around floats while formatting for word processors.
%   This helps identify boundaries of floats to be manually converted
%   to word-processor frames and captions.
% }
%
% \DescribeBoolean{WPMarkFloats} \DescribeDefault{false}
%	\begin{docsidebar}[\texttt{WPMarkFloats}]
%	\raggedright
%   \describeWPMarkFloats
%	\end{docsidebar}
%
%
% \newcommand{\describeWPMarkMinipages}{
%   Adds
%   \begin{sourcedisplay}
%   === begin minipage === \\
%   \dots \\
%   === end minipage ===
%   \end{sourcedisplay}
%   around minipages while formatting for word processors.
%   This helps identify boundaries of minipages to be manually converted
%   to word-processor frames.
% }
%
% \DescribeBoolean{WPMarkMinipages} \DescribeDefault{false}
%   \begin{docsidebar}[\texttt{WPMarkMinipages}]
%   \raggedright
%   \describeWPMarkMinipages
%   \end{docsidebar}
%
%
% \newcommand{\describeWPMarkTOC}{
%   While formatting for word processors, adds
%   \begin{sourcedisplay}
%   === table of contents === \\
%   \end{sourcedisplay}
%   where the Table of Contents would have been.
%   This helps identify where to insert the actual \acro{TOC}.
%
%   \emph{If set |false|, the actual \acro{TOC} is printed instead.}
% }
%
% \DescribeBoolean{WPMarkTOC} \DescribeDefault{true}
%   \begin{docsidebar}[\texttt{WPMarkTOC}]
%   \raggedright
%   \describeWPMarkTOC
%   \end{docsidebar}
%
%
% \newcommand{\describeWPMarkLOFT}{
%   While formatting for word processors, adds
%   \begin{sourcedisplay}
%   === list of figures === \quad \textrm{\textit{and\,/\,or}} \\
%   === list of tables === \\
%   \end{sourcedisplay}
%   where each of these lists would have been.
%   This helps identify where to insert the actual lists.
%
%   \emph{If set |false|, the actual lists are printed instead.}
% }
%
% \DescribeBoolean{WPMarkLOFT} \DescribeDefault{false}
%   \begin{docsidebar}[\texttt{WPMarkLOFT}]
%   \raggedright
%   \describeWPMarkLOFT
%   \end{docsidebar}
%
%
% \newcommand{\describeWPMarkMath}{
%   While formatting for word processors,
%   prints math as \LaTeX\ code instead of creating \SVG\ images or MathJax.
%   This is useful for cut/paste into the LibreOffice Writer TeXMaths extension.
% }
%
% \DescribeBoolean{WPMarkMath} \DescribeDefault{false}
% \DescribeProgram{TeXMaths}
%   \margintag{siunitx}
%   \begin{docsidebar}[\texttt{WPMarkMath}]
%   \raggedright
%   \describeWPMarkMath
%
%   When using the \pkg{siunitx} package, enter
%   \begin{sourcedisplay}
%   \cs{usepackage}\{siunitx\}
%   \end{sourcedisplay}
%   in the TeXMaths preamble.
%   Equation numbering is problematic for \AmS\ math environments.
%   \end{docsidebar}
%   \index{siunitx>with TeXMaths}
%   \index{math>word processor conversion}
%
%
% \newcommand*{\describeWPTitleHeading}{
%   While formatting for word processors,
%   |true| sets the document title to \element{h1}, which is expected for \HTML\ documents,
%   but also causes the lower-level section headings to start at \UI{Heading 2} when
%   imported into LibreOffice.
%   Set to |false| to cause the title to be plain text, and the section headings
%   to begin at \UI{Heading 1}.
%
%   See \cref{tab:WPsectionheadings} on \cpageref{tab:WPsectionheadings}.
% }
%
% \DescribeBoolean{WPTitleHeading} \DescribeDefault{false}
%   \margintag{section headings}
%   \begin{docsidebar}[\texttt{WPTitleHeading}]
%   \raggedright
%   \describeWPTitleHeading
%   \end{docsidebar}
% \index{section>heading, word processor}
% \index{heading, word processor}
% \index{word processor>section headings}
% \index{LibreOffice>section headings}
%
% \begin{table}
% \centering
% \begin{threeparttable}
% \caption{Section HTML headings for word-processor conversion}
% \label{tab:WPsectionheadings}
% \begin{tabular}{lcccc}
% \toprule
% ~ & \multicolumn{4}{c}{HTML headings\tnote{\textasteriskcentered}} \\
% \cmidrule{2-5}
% ~ & \multicolumn{2}{c}{With \cs{chapter}} & \multicolumn{2}{c}{Without \cs{chapter}} \\
% \cmidrule(r){2-3} \cmidrule(l){4-5}
% ~ & \multicolumn{2}{c}{|WPTitleHeading|} & \multicolumn{2}{c}{|WPTitleHeading|} \\
% Section & |true| & |false| & |true| & |false| \\
% \midrule
% Title & \element{h1} & plain & \element{h1} & plain \\
% \cs{part} & \element{h2} & \element{h1} & \element{h2} & \element{h1} \\
% \cs{chapter} & \element{h3} & \element{h2} & --- & --- \\
% \cs{section} & \element{h4} & \element{h3} & \element{h3} & \element{h2} \\
% \cs{subsection} & \element{h5} & \element{h4} & \element{h4} & \element{h3} \\
% \cs{paragraph} & \element{h6} & \element{h5} & \element{h5} & \element{h4} \\
% \cs{subparagraph} & span & \element{h6} & \element{h6} & \element{h5} \\
% \bottomrule
% \end{tabular}
% \begin{tablenotes}
% \footnotesize
% \item[\textasteriskcentered] For default depths when not |FormatWP|,
%   see \cref{tab:depthsheadings} on \cpageref{tab:depthsheadings}.
% \end{tablenotes}
% \end{threeparttable}
% \smallskip\hrule
% \end{table}
%
% \subsection{Recommendations}
%   \index{word processor>conversion recommendations}
%   \index{LibreOffice>conversion recommendations}
%
% For use with LibreOffice Writer, it is recommended to:
% \margintag{TOC, LOF, LOT}
% \begin{enumerate}[nosep]
% \item Set \cs{booltrue}\{FormatWP\}.
% \item Set \cs{booltrue}\{WPMarkTOC\} and \cs{boolfalse}\{WPMarkLOFT\}.
% \item Use \pkg{lwarp} to generate the \HTML\ document.
% \item Copy/paste from the \HTML\ document into an empty LibreOffice Writer document.
% \item Manually insert a LibreOffice \acro{TOC} in the LibreOffice document.
% \item Manually add frames around each float, adding a caption which is cut/pasted from
%   each float's simulated caption.
% \item Manually create cross references.
% \end{enumerate}
% This process yields a document with an actual LibreOffice Table of Contents,
% but a simulated List of Figures and List of Tables.
%
% For \pkg{siunitx}, remember to adjust the preamble as mentioned above.
% \margintag{siunitx}
%
% LibreOffice has options in the View menu to turn on/off the display of
% \margintag{LO view border options}
% thin borders around table cells and text objects.
%
%
% \subsection{Limitations}
%
% Floats and captions are not explicitly converted to LibreOffice floats with their
% own captions.  Floats are surrounded by a thin frame in the LibreOffice editor,
% and may be marked with |WPMarkFloats|, but are not given a proper LibreOffice
% object frame.
% Captions are given an explicit italic formatting,
% but not a proper LibreOffice paragraph style.
%
% Cross references are not actual LibreOffice linked cross references.
%
% The List of Figures and List of Tables are not linked.
% The pasted pseudo \acro{LOF} and \acro{LOT} match the numbering
% of the \LaTeX\ and \HTML\ versions.
%
% Equation numbering is not automatic, but the equation numbers in \SVG\ math
% will match the \LaTeX\ and \HTML\ output.
% SVG math is recommended when using the \AmS\ environments, which may have
% multiple numbered equations per object.
%
% As of when last checked, LibreOffice ignores the following:
% \begin{itemize}
% \item Minipage alignment.
% \item Tabular cell vertical alignment.
% \item Image rotation and scaling.
% \item Rounded border corners, which are also used by:
%   \begin{itemize}
%   \item \cs{textcircled}
%   \item \pkg{booktabs} trim
%   \end{itemize}
% \item \cs{hspace} and rules, also used by \pkg{algorithmic}.
% \item Coloring of text decorations, used by \pkg{soul} and \pkg{ulem}.
% \item Overline text decoration, used by \pkg{romanbar}.
% \end{itemize}
%
% Libreoffice also has limitations with frames and backgrounds:
% \begin{itemize}
% \item Multiple lines in an object are framed individually instead of as a whole.
% \item Nested frames are not handled correctly.
% \item Images inside boxes are not framed correctly.
% \item Spans with background colors and frames are not displayed correctly.
% \end{itemize}
%
%
%
%
%
%
% \clearpage
%
% \section{Modifying \protect\pkg{lwarp}}
% \pagestyle{pageheadfoot}
%
% Purely text-based packages probably will work as-is when generating
% \HTML.
%
% Look to existing code for ideas on how to expand into new code.
%
% An environment may be converted to a |lateximage| then displayed
% with an image of the resulting \LaTeX{} output.
% See \cref{sec:picture} for an example of the |picture| environment.
%
% To create a custom \HTML\ block or inline \CSS\ class,
% see \cref{sec:highlevelclasses}.
%
% \subsection{Creating an \protect\pkg{lwarp} version of a package}
%
% When creating \HTML,
% \pkg{lwarp} redefines the \cs{usepackage} and \cs{RequirePackage}
% macros such that it first looks to see if a |lwarp-<packagename>.sty|
% version exists.  If so, the \pkg{lwarp} version is used instead.
% This modular system allows users to create their own
% versions of packages for \pkg{lwarp} to use for \HTML, simply by creating
% a new package with a |lwarp-| prefix.  If placed in the local
% directory along with the source code, it will be seen by that project
% alone.  If placed alongside the other |lwarp-| packages where \TeX\
% can see it, then the user's new package will be seen by any documents
% using \pkg{lwarp}.  (Remember |mktexlsr| or |texhash|.)
%
% An |lwarp-<packagename>.sty| package is only used during \HTML\
% generation.  Its purpose is to pretend to be the original package,
% while modify anything necessary to create a successful \HTML\ conversion.
% For many packages it is sufficient to simply provide nullified macros,
% lengths, counters, etc. for anything which the original package does,
% while passing the raw text on to be typeset.  See the pre-existing
% |lwarp-| packages for examples.
%
% Anything the user might expect of the original package
% must be replaced or emulated by the new |lwarp-| package, including
% package options, user-adjustable counters, lengths, and booleans, and
% conditional behaviors.
% In many of these packages, most of the new definitions have a ``local'' prefix
% according to the package name, and |@| characters inside the name,
% which hides these names from the user.  In most cases these macros
% will not need to be emulated for \HTML\ output.  Only the ``user-facing''
% macros need to be nullified or emulated.
%
% Each |lwarp-| package should first call either
% \begin{sourcedisplay}
%   \cs{LWR@ProvidesPackageDrop}
% \end{sourcedisplay}
% or
% \begin{sourcedisplay}
%   \cs{LWR@ProvidesPackagePass}
% \end{sourcedisplay}
% If |Drop|ped, the original print-version
% package is ignored, and only the |lwarp-| version is used.
% Use this where the original print version is useless for \HTML.
% If |Pass|ed, the original package is loaded first, with the user-supplied options,
% then the |lwarp-| version continues loading as well.
% See \cref{sec:ntheorem} (\nameref{sec:ntheorem})
% for an example of selectively disabling user options for a package.
% Use this when \HTML\
% output only requires some modifications of the original package.
% For a case where the original package is usable without changes, there is no
% need to create a |lwarp-| version.
%
% \subsection{Adding a package to the \pkg{lwarp.dtx} file}
%
% When adding a package to |lwarp.dtx| for permanent inclusing in \pkg{lwarp},
% provide the |lwarp-<packagename>| code in |lwarp.dtx|,
% add its entry into |lwarp.ins|, and also remember to add
% \begin{sourcedisplay}
%   \cs{LWR@loadafter}\{\textless{}packagename\textgreater\}
% \end{sourcedisplay}
% to |lwarp.dtx| in \cref{sec:loadafter}.  This causes \pkg{lwarp} to stop with
% an error if \pkg{packagename} is loaded before \pkg{lwarp}.
%
%
% \subsection{Testing \protect\pkg{lwarp}}
%
% \changes{v0.25}{2017/03/22}{Docs: Testing \protect\pkg{lwarp}.}
%
% When changes have been made, test the print output before testing the
% \HTML.  The print output compiles faster, and any errors in the printed
% version will be easier to figure out than the \HTML\ version.
%
% Remember that the configuration files are only rewritten when compiling the
% printed version of the document.
%
% Sometimes it is worth checking the |<project>_html.pdf| file, which is the
% \PDF\ containing \HTML\ tags.  Also, |<project>_html.html| has
% the text conversion of these tags, before the file is split into individual
% \HTML\ files.
%
% It is also worth checking the browser's tools for verifying the correctness
% of \HTML\ and \CSS\ code.
%
%
% \subsection{Modifying \protect\texttt{lwarpmk}}
% \label{sec:modifylwarpmk}
%
% \changes{v0.28}{2017/04/14}{Docs: Modfying lwarpmk and index processing.}
%
% \DescribeProgram{lwarpmk}
% \DescribeFile{lwarpmk.lua}
% In most installations, |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
% compile documents:
% \begin{enumerate}
% \item Add the |lwarpmk| option to the \pkg{lwarp} package.
% \item Recompile the printed version of the document.
%	The |lwarpmk| option causes \pkg{lwarp} to create a local copy of |lwarpmk.lua|
% \item The |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|.
% \end{enumerate}
%
% To adjust the command-line arguments for compiling the document,
% look in |mymake.lua| for ``|latexname|''.
%
% To adjust the command-line arguments for processing the index,
% look for ``|xindy|''.
%
%
%
%
% \clearpage
%
% \section{Troubleshooting}
% \label{sec:troubleshooting}
% \index{FAQ}\index{Frequently Asked Questions}\index{bugs}
% \index{troubleshooting}\index{problems}\index{error messages}
% \index{debugging}
%
% \subsection{Using the \protect\texttt{lwarp.sty} package}
%
% Also see: \\
% \Cref{sec:printcommands}: \nameref{sec:printcommands} \\
% \Cref{sec:limitations}: \nameref{sec:limitations}
%
% \changes{v0.14}{2016/03/26}{Docs: Troubleshooting cross-references.}
% \changes{v0.16}{2016/04/08}{Docs: Text not converting.}
% \changes{v0.34}{2017/08/08}{Docs: Misplaced alignment character.}
% \changes{v0.42}{2017/10/13}{Docs: Improper \cs{prevdepth}.}
%
% \begin{description}
%
% \item [Text is not converting:] ~
%	\begin{itemize}
%	\item Font-related UTF-8 information must be embedded in the \PDF\ file.
%		See \cref{sec:fonts} regarding vector fonts.
%	\end{itemize}
%
% \item [Undefined HTML settings:] \
%	\begin{itemize}
%	\item See the warning regarding the placement of the \HTML\ settings
%		at \cref{sec:htmlsettings}.
%	\end{itemize}
%
% \item [Tabular problems:] See \cref{sec:limitstabular}.
%
% \item [Obscure error messages:] ~
%   \begin{description}
%	    \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.
%
%       \item [``Missing \$ inserted.'':] If using a filename or URL in a
%           footnote or \cs{item}, escape underscores with \cs{\_}.
%
%         \item [``Leaders not followed by proper glue'':] This can be caused by
%         a missing |l@<floattype>| or |l@<sectiontype>| definition.
%         See \pkg{lwarp}'s definitions for examples.
% 
%         \item [``Improper \cs{prevdepth}'':] Something tried to use
%         \cs{ensuremath} where \pkg{lwarp} then tries to create a \env{lateximage}.
%         If you can locate what used \cs{ensuremath}, have it temporarily set:
%         \begin{sourcedisplay}
%         \cs{LetLtxMacro}\cs{@ensuredmath}\cs{LWR@origensuredmath}
%         \end{sourcedisplay}
%         inside a group first.
%   \end{description}
%
% \item [Missing sections:] ~
%	\begin{itemize}
%	\item See \cref{sec:filedepth} regarding the
%		|FileDepth| and |SideTOCDepth| counters,
%		and the use of \cs{tableofcontents} in the home page.
%	\end{itemize}
%
% \item [Missing HTML files:] \
%   \begin{itemize}
%	\item See the warning regarding changes to the \HTML\ settings
%		at \cref{sec:htmlsettings}.
%   \end{itemize}
%
% \item [Missing / incorrect cross-references:] ~
% \index{cross-references>missing or incorrect}
%	\begin{itemize}
%	\item Use |lwarpmk again| followed
% 		by |lwarpmk html| or |lwarpmk print| to compile the document one more time.
%	\item \limitsreferences
%	\item \limitscpageref
%	\end{itemize}
%
% \item [Em-dashes or En-dashes in listing captions and titles:] \
%
%	Use	\XeLaTeX\ or \LuaLaTeX.
%
% \item [Floats out of sequence:] ~
%	\begin{description}
%	\item [Mixed ``Here'' and floating:] Floats [H]ere and regular floats may
%		become out of order.  \cs{clearpage} if necessary.
%	\item [Caption setup:] With \cs{captionsetup} set the positions for
%		the captions |above| or |below| to match their use in the source code.
%	\end{description}
%
% \item [Print document contains \HTML\ tags:] ~
%	\begin{itemize}
%	\item Be sure that the document
%		selects |\usepackage[warpprint]{lwarp}| instead of |[warpHTML]|.
%	\end{itemize}

% \item [Images are appearing in strange places:] ~
% \index{images>in strange places}
%	\begin{itemize}
%	\item |lwarpmk limages| to refresh the |lateximage| images.
%	\end{itemize}
%
% \item[SVG images:] \
%
% \limitssvgimages
%
% \item [Plain-looking document:] \
%	\begin{itemize}
%	\item The document's \CSS\ stylesheet may not be available, or may be
%		linked incorrectly.  Verify any \cs{CSSFilename} statements point to
%		a valid \CSS\ file.
%	\end{itemize}
%
% \item [Broken fragments of HTML:] ~
%	\begin{itemize}
%	\item Check the \PDF\ file used to create \HTML\
%		to see if the tags overflowed the margin.
%		(This is why such large page size and margins are used.)
%	\end{itemize}
%
% \item [Changes do not seem to be taking effect:] ~
%	\begin{itemize}
%	\item Be sure to |lwarpmk clean|, recompile, then start by reloading the home page.
%		You may have been looking at an older version of the document.
%		If you changed a section name, you may have been looking at
%		the file for the old name.
%	\item See the warning regarding changes to the \HTML\ settings
%		at \cref{sec:htmlsettings}.
%	\item Verify that the proper \CSS\ is actually being used.
%	\item The browser may compensate for some subtle changes, such as
%		automatically generating ligatures, reflowing text, etc.
%	\end{itemize}
%
% \item [Un-matched conditional compiles:] ~
%	\begin{itemize}
%	\item Verify the proper |begin|/|end| of |warpprint|, |warpHTML|, and |warpall| environments.
%	\end{itemize}
%
% \end{description}
%
%
% \subsubsection{Debug tracing output}
%
% \DescribeMacro{\tracinglwarp}
%	When \cs{tracinglwarp} is used, \pkg{lwarp} will add extra
%	tracing messages to the |.log| file.  The last several messages
%	may help track down errors.
%
%	Place \cs{tracinglwarp} just after |\usepackage{lwarp}| to
%	activate tracing.
%
%
%
%
% \subsection{Compiling the \protect\texttt{lwarp.dtx} file}
%
% \begin{description}
% \item [\texttt{lwarp\_tutorial.tex}:] Copy or link |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:] ~
%	\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.
%	\end{enumerate}
%
% \item [Un-nested environments:]~
%
%	Be sure to properly nest:
%	\begin{itemize}
%	\item |\begin{macrocode}| and |\end{macrocode}|
%	\item |\begin{macro}| and |\end{macro}|
%	\item |\begin{environment}| and |\end{environment}|
%	\end{itemize}
% \end{description}
%
% 
%
%
% \StopEventually{\PrintChanges\PrintIndex}
% 
%
%
% \part{lwarp.sty}
%
%
% \section{Implementation}
%
%
% This package is perhaps best described as a large collection of smaller
% individual technical challenges,
% in many cases solved through a number of \sout{crude hacks} clever tricks.
% Reference sources are
% given for many of the solutions, and a quick internet search will provide
% additional possibilities.
%
% Judgement calls were made, and are often commented.  Improvements are possible.
% The author is open to ideas and suggestions.
%
% Packages were patched for re-use where they provided significant functionality.
% 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}.
%
% Packages were emulated where their primary purpose was visual formatting which is not
% relevent to \HTML\ output.  For example, packages related to sectioning
% are already patched by numerous other packages, creating a difficult number of
% combinations to try to support, and yet in \HTML\ output all of the
% formatting is thrown away, so these packages are merely emulated.
%
% Packages with graphical output are allowed as-is, but must be nested inside a
% \env{lateximage} environment to preserve the graphics.
%
%
%
% Testing has primarily been done with the Iceweasel/Firefox browser.
%
%
% \section{Section depths and HTML headings}
% \label{sec:stackdepths}
% \index{HTML>headings}
% \index{section>depths}\index{stack depths}
%
% Stacks are created to track depth inside the \LaTeX{} document structure.
% This depth is translated to \HTML\ headings as shown
% in \cref{tab:depthsheadings}.
% ``Depth'' here is not
% depth in the traditional computer-science stack-usage sense, but rather a
% representation of the nesting depth inside the \LaTeX{} document structure.
%
% When starting a new section, the program first must close out any existing
% sections and lists of a deeper level to keep the \HTML\ tags nested correctly.
%
% \begin{table}
% \centering
% \begin{threeparttable}
% \caption{Section depths and HTML headings\label{tab:depthsheadings}}
% \begin{tabular}{lcl}
% \toprule
% Section & \parbox[b]{.35in}{\centering\LaTeX\ depth} &
%   HTML headings \tnote{\textasteriskcentered} \\
% \midrule
% title of the entire website & & \element{h1} \\
% none			& -5	& new for this package \\
% book			& -2	& \textbf{not yet used} \\
% part			& -1	& \element{h2} \\
% chapter		& 0 	& \element{h3} \\
% section		& 1		& \element{h4} \\
% subsection	& 2		& \element{h5} \\
% subsubsection	& 3		& \element{h6} \\
% paragraph		& 4		& \element{span class = "paragraph"} \\
% subparagraph	& 5		& \element{span class = "subparagraph"} \\
% listitem		& 7		& new for this package, used for list items \\
% \bottomrule
% \end{tabular}
% \begin{tablenotes}
% \footnotesize 
% \item{\textasteriskcentered} If |FormatWP| is true,
% section headings may be adjusted, depending on |WPTitleHeading|.
% See \cref{tab:WPsectionheadings} on \cpageref{tab:WPsectionheadings}.
% \end{tablenotes}
% \end{threeparttable}
% \smallskip
% \hrule
% \end{table}
%
% Support for the \pkg{memoir} package will require the addition of a |book|
% level, which may push the \HTML\ headings down a step, and also cause
% |subsubsection| to become a \element{div} due to a limit of six \HTML\ headings.
%
% It is possible to use \HTMLfive{} \element{section} and \element{h1} for all levels,
% but this may not be well-recognized by older browsers.
%
% Fixed levels for parts and chapters allow the \CSS\ to remain fixed as well.
%
%
% \clearpage
%
% 
% 
% \section{Source Code}
% This is where the documented source code for \pkg{lwarp} begins,
% continuing through the following sections all the way to the
% change log and index at the end of this document.
%
% \index{numbers>left margin}\index{line numbers}
% \index{margin>numbers}\index{margin>tags}
% \documentationnotes
% \index{warning icon}\index{danger icon}\index{icon>warning}
% \index{for>HTML output}\index{for>PRINT output}\index{for>HTML \& PRINT}
% \changes{v0.15}{2016/04/05}{Docs: Added warning icons for items needing
% 	special attention.}
%
% \vfill
% 
% \begin{center}
% --- \pkg{lwarp} source code begins on the following page ---
% \end{center}
%
%
%
% \clearpage
%
% \section{Detecting the \TeX\ Engine — pdflatex, lualatex, xelatex}
%
%    \begin{macrocode}
\RequirePackage{iftex}

\ifLuaTeX
\RequirePackage{luatex85}% until the geometry package is updated
\fi
%    \end{macrocode}
%
%
% \section{pdfLaTeX T1 and UTF8 encoding}
%
% When using pdf\LaTeX, \pkg{lwarp} required T1 and UTF8 encoding.
%
% \XeLaTeX\ and Lua\LaTeX\ are both UTF8 by nature.
%
% \changes{v0.44}{2017/11/16}{If pdfLaTeX, require T1 and UTF8 encoding.}
%
%    \begin{macrocode}
\ifPDFTeX
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\fi
%    \end{macrocode}
%
%
%
% \section{Unicode input characters}
% \changes{v0.18}{2016/05/17}{PDF Unicode input characters.}
% \index{Unicode>input characters}
%
% \codeall
%
% If using |pdflatex|, convert a minimal set of Unicode characters.
% Additional characters may be defined by the user, as needed.
%
% A commonly-used multiply symbol is declared to be \cs{texttimes}.
%
% The first arguments of \cs{newunicodechar} below are text ligatures in
% the source code, even though they are not printed in the following
% listing.
%    \begin{macrocode}

\RequirePackage{newunicodechar}

\newunicodechar{⨯}{\texttimes}

\ifPDFTeX
\newunicodechar{ﬀ}{ff}% the first arguments are ligatures
\newunicodechar{ﬁ}{fi}
\newunicodechar{ﬂ}{fl}
\newunicodechar{ﬃ}{ffi}
\newunicodechar{ﬄ}{ffl}
\newunicodechar{—}{---}
\newunicodechar{–}{--}
%    \end{macrocode}
% In PDF\TeX, preserve upright quotes in verbatim text:
%    \begin{macrocode}
\RequirePackage{upquote}
\else
\fi
%    \end{macrocode}
%


% \clearpage
%
% \section{Early package requirements}
%
% \DescribePackage{etoolbox}
% Provides |\ifbool| and other functions.
%
% \DescribePackage{xpatch}
% Patches macros with optional arguments.
%    \begin{macrocode}
\RequirePackage{etoolbox}[2011/01/03]% v2.6 for \BeforeBeginEnvironment, etc.
\RequirePackage{xpatch}
%    \end{macrocode}


% \DescribePackage{ifplatform}
% Provides \cs{ifwindows} to try to automatically detect
% Windows OS.
%
%    \begin{macrocode}
\RequirePackage{ifplatform}% sense op-system platform
%    \end{macrocode}
%
%
%
%
% \DescribePackage{letltxmacro}
% Used to redefine \cs{textbf} and friends.
%
%    \begin{macrocode}
\RequirePackage{letltxmacro}
%    \end{macrocode}
%

% \clearpage
%
%
% \section{Operating-System portability}
% \label{sec:OSportability}
% \changes{v0.11}{2016/03/11}{Added section: Operating-System portability.}
%
% \osportabilityusage
%
%
%
% \subsection{Common portability code}
%
% \DescribeBoolean{usingOSWindows} Set if the |OSWindows| option is used.
%    \begin{macrocode}
\newbool{usingOSWindows}
\boolfalse{usingOSWindows}
%    \end{macrocode}

%
% \subsection{Unix, Linux, and Mac\,OS}

% \begin{macro}{\OSPathSymbol}
% Symbol used to separate directories in a path.
%    \begin{macrocode}
\newcommand*{\OSPathSymbol}{/}
%    \end{macrocode}
% \end{macro}


% \subsection{MS-Windows}

% For MS-Windows:
%
% \begin{macro}{\LWR@setOSWindows}
% Set defaults for the MS-Windows operating system.
% \pkg{lwarp} attempts to auto-detect the operatings system,
% and the |OSWindows| option may also be used to force
% MS-Windows compatibility.
%
% \changes{v0.20}{2016/12/19}{Auto-detects operating system.}
%
%    \begin{macrocode}
\newcommand*{\LWR@setOSWindows}
{
\booltrue{usingOSWindows}
\renewcommand*{\OSPathSymbol}{\@backslashchar}
}
%    \end{macrocode}
% \end{macro}
%
% Test for windows during compile.  The user may also specify
% |OSWindows| package option in case this test fails.
%    \begin{macrocode}
\ifwindows
\LWR@setOSWindows
\fi
%    \end{macrocode}





%
% \section{Package options}
% \label{sec:handlingpackageoptions}
%
%


% \DescribePackage{kvoptions}
% Allows key/value package options.
%    \begin{macrocode}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{family=LWR,prefix=LWR@}
%    \end{macrocode}


% \DescribeBoolean{warpingprint}
% \DescribeBoolean{warpingHTML}
% \DescribeBoolean{mathjax}
%
% Set to true/false depending on the package option selections for
% print/\HTML/\EPUB\ output and mathsvg/mathjax:
%    \begin{macrocode}
\newbool{warpingprint}
\newbool{warpingHTML}
\newbool{mathjax}
%    \end{macrocode}
%
%
% The default is print output,
% \margintag{defaults}
% and \SVG\ math if the user chose \HTML\ output.
%    \begin{macrocode}
\booltrue{warpingprint}%
\boolfalse{warpingHTML}%
\boolfalse{mathjax}%
%    \end{macrocode}
%
%
%
% \DescribeOption{warpprint}
% If the |warpprint| option is given, boolean |warpingprint| is true and boolean |warpingHTML| is false,
% and may be used for |\ifbool| tests.
%
%
%    \begin{macrocode}
\DeclareVoidOption{warpprint}{%
\PackageInfo{lwarp}{Using option 'warpprint'}
\booltrue{warpingprint}%
\boolfalse{warpingHTML}%
}
%    \end{macrocode}

% \begin{environment}{warpHTML}
% Anything in the |warpHTML| environment will be generated for \HTML\ output only.
%
% \DescribeOption{warpHTML}
% If the |warpHTML| option is given, boolean |warpingHTML| is true and boolean |warpingprint| is false,
% and may be used for |\ifbool| tests.
%
%    \begin{macrocode}
\DeclareVoidOption{warpHTML}{%
\PackageInfo{lwarp}{Using option 'warpHTML'}%
\booltrue{warpingHTML}%
\boolfalse{warpingprint}%
}
%    \end{macrocode}
% \end{environment}
%
%
%


%
% \changes{v0.19}{2016/05/25}{Options: mathsvg and mathjax}
% \DescribeOption{mathsvg}
% Option |mathsvg| selects \SVG\ math display:
% \index{math>mathsvg option}
% \index{SVG>mathsvg option}
% If the |mathsvg| option is given, boolean |mathjax| is false, and may be used for |\ifbool| tests.
%    \begin{macrocode}
\DeclareVoidOption{mathsvg}{%
\PackageInfo{lwarp}{Using option 'mathsvg'}
\boolfalse{mathjax}%
}
%    \end{macrocode}
%
% \DescribeOption{mathjax}
% Option |mathjax| selects MathJax math display:
% \index{math>mathjax option}
% \index{MathJax>mathjax option}
% If the |mathjax| option is given, boolean |mathjax| is true, may be used for |\ifbool| tests.
%    \begin{macrocode}
\DeclareVoidOption{mathjax}{%
\PackageInfo{lwarp}{Using option 'mathjax'}
\booltrue{mathjax}%
}
%    \end{macrocode}



% \DescribeOption{BaseJobname}
% Option |BaseJobname| sets the \cs{BaseJobname} for this document.
%
% This is the \cs{jobname} of the printed version, even if currently
% compiling the \HTML\ version.
% I.e. this is the \cs{jobname} without |_html| appended.
% This is used to set \cs{HomeHTMLFilename} if the user did not provide one.
%    \begin{macrocode}
\DeclareStringOption[\jobname]{BaseJobname}
%    \end{macrocode}



% \DescribeOption{IndexLanguage} Sets the language to be assigned
%	in |lwarpmk|'s configuration files.  This is then used by |lwarpmk| while
%	processing the index and glossary.
%
% \changes{v0.29}{2017/04/15}{Add: \protect\texttt{lwarpmklang} option for \pkg{lwarp}.}
% \changes{v0.30}{2017/04/28}{Option \protect\texttt{lwarpmklang} changed
%		to \protect\texttt{IndexLanguage}.}
%
%    \begin{macrocode}
\DeclareStringOption[english]{IndexLanguage}
%    \end{macrocode}



% \DescribeOption{xdyFilename} Selects a custom |.xdy| file.
% The default is |lwarp.xdy|.
% A customized file should be based on |lwarp.xdy|, and must retain
% the line
% \begin{Verbatim}[gobble=2]
% (markup-locref :open "\hyperindexref{" :close "}")
% \end{Verbatim}
%
% \changes{v0.30}{2017/04/28}{Option \protect\texttt{xdyFilename} added.}
%
%    \begin{macrocode}
\DeclareStringOption[lwarp.xdy]{xdyFilename}
%    \end{macrocode}


% \DescribeOption{lwarpmk} Tells \pkg{lwarp} to
%	generate a local copy of |lwarpmk| called |lwarpmk.lua|.
%	Useful for archiving for future use.
%	This file may be made executable and acts just like |lwarpmk|.
%
% If |lwarpmk| option, creates a local copy of |lwarpmk.lua|:
%    \begin{macrocode}
\newbool{LWR@creatinglwarpmk}
\boolfalse{LWR@creatinglwarpmk}

\DeclareVoidOption{lwarpmk}{
\PackageInfo{lwarp}{Using option 'lwarpmk'}
\booltrue{LWR@creatinglwarpmk}
}
%    \end{macrocode}



% \DescribeOption{OSWindows} Tells \pkg{lwarp} to use MS-Windows compatibility.
% Auto-detection of the operating system is attempted, and this option is only
% necessary if the auto-detection fails.
% See the automatically-generated |lwarpmk.conf| file to find out
% whether the operating system was detected correctly.
%
% \changes{v0.30}{2017/04/27}{Option \texttt{OSWindows} replaces macro \cs{warpOSwindows}.}
%
%    \begin{macrocode}
\DeclareVoidOption{OSWindows}{
\PackageInfo{lwarp}{Using option 'OSWindows'}
\LWR@setOSWindows
}
%    \end{macrocode}



% \DescribeOption{HomeHTMLFilename} \DescribeDefault{\cs{\BaseJobname}}
% The filename of the homepage.
% The default is the jobname.
% This option is stored into \cs{LWR@HomeHTMLFilename},
% and later transferred into \cs{HomeHTMLFilename} for internal use.
%
% \changes{v0.30}{2017/04/27}{Options \texttt{HomeHTMLFilename} and \texttt{HTMLFilename}
%	replace macros \cs{HomeHTMLFilename} and \cs{HTMLFilename}.}
%
%    \begin{macrocode}
\DeclareStringOption[]{HomeHTMLFilename}
%    \end{macrocode}


% \DescribeOption{HTMLFilename} \DescribeDefault{<empty>}
% The filename prefix of web pages after the homepage.
% The default is empty, no prefix.
% This option is stored into \cs{LWR@HTMLFilename},
% and later transferred into \cs{HTMLFilename} for internal use.
%
%    \begin{macrocode}
\DeclareStringOption[]{HTMLFilename}
%    \end{macrocode}



% \DescribeOption{latexmk}
% Option |latexmk| tells |lwarpmk| to use |latexmk| when compiling documents.
%
% \changes{v0.30}{2017/04/29}{Option \protect\texttt{latexmk} replaces macro \cs{UseLatexmk}.}
%
%    \begin{macrocode}
\DeclareBoolOption[false]{latexmk}
%    \end{macrocode}


% Execute the package options, with the defaults which have been set just above:
% \margintag{Execute options}
%    \begin{macrocode}
\ProcessKeyvalOptions*\relax
%    \end{macrocode}


% Assign the \cs{BaseJobname} if the user hasn't provided one:
%    \begin{macrocode}
\providecommand*{\BaseJobname}{\LWR@BaseJobname}
%    \end{macrocode}


% Defaults unless already over-ridden by the user:
%    \begin{macrocode}
\ifcsempty{LWR@HomeHTMLFilename}{
\newcommand*{\HomeHTMLFilename}{\BaseJobname}
}{
\csedef{HomeHTMLFilename}{\LWR@HomeHTMLFilename}
}

\csedef{HTMLFilename}{\LWR@HTMLFilename}
%    \end{macrocode}
% 
%
%
% \subsection{Conditional compilation}
%
%
%
% \begin{macro}{\warpprintonly} \marg{contents}
%
% Only process the contents if producing printed output.
% \changes{v0.19}{2016/06/06}{Replaces \cs{rowprintedonly}.}
%    \begin{macrocode}
\newcommand{\warpprintonly}[1]{\ifbool{warpingprint}{#1}{}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\warpHTMLonly} \marg{contents}
%
% Only process the contents if producing \HTML\ output.
% \changes{v0.19}{2016/06/06}{Added.}
%    \begin{macrocode}
\newcommand{\warpHTMLonly}[1]{\ifbool{warpingHTML}{#1}{}}
%    \end{macrocode}
% \end{macro}
%
%
% \DescribePackage{comment} Provides conditional code blocks.
%
%    \begin{macrocode}
\RequirePackage{comment}
%    \end{macrocode}


% Use |comment_print.cut| for print mode, and
% |comment_html.cut| for \HTML\ mode.
% This helps |latexmk| to more reliably know whether to recompile.
%
% \changes{v0.37}{2017/08/19}{\pkg{comment}: Maintains independent
%   cutfiles for print, \protect\HTML.}
%
%    \begin{macrocode}
\ifbool{warpingHTML}{
\def\DefaultCutFileName{\def\CommentCutFile{comment_html.cut}}
}{}

\ifbool{warpingprint}{
\def\DefaultCutFileName{\def\CommentCutFile{comment_print.cut}}
}{}
%    \end{macrocode}


%    \begin{macrocode}
\excludecomment{testing}
%    \end{macrocode}


% \begin{environment}{warpall}
% Anything in the |warpall| environment will be generated for print or \HTML\ outputs.
%    \begin{macrocode}
\includecomment{warpall}
%    \end{macrocode}
% \end{environment}




% \begin{environment}{warpprint}
% \begin{environment}{warpHTML}
% Anything in the |warpprint| environment will be generated for print output only.
%
% For \HTML\ output:
%    \begin{macrocode}
\ifbool{warpingHTML}{%
\includecomment{warpHTML}
}
{\excludecomment{warpHTML}}%
%    \end{macrocode}

%    \begin{macrocode}
\ifbool{warpingprint}
{\includecomment{warpprint}}
{\excludecomment{warpprint}}
%    \end{macrocode}

% \end{environment}
% \end{environment}


% Optionally generate a local copy of |lwarpmk|.
% Default to no.
%    \begin{macrocode}
\ifbool{LWR@creatinglwarpmk}
{\includecomment{LWR@createlwarpmk}}
{\excludecomment{LWR@createlwarpmk}}
%    \end{macrocode}
%
%
%
%
%
%
%
% \section{Misplaced packages}
%
% \changes{v0.21}{2017/02/22}{Add: Errors for misplaced packages.}


% Several packages should only be loaded before \pkg{lwarp}, and
% others should only be loaded after.
%
% Packages which should only be loaded before \pkg{lwarp} have their own
%	\begin{sourcedisplay}
%	|lwarp-<packagename>.sty|
%	\end{sourcedisplay}
% which will trigger an error if they are loaded after
% \pkg{lwarp}.
% Examples include \pkg{fontspec}, \pkg{inputenc}, \pkg{fontenc},
% and \pkg{newunicodechar}.
%
%

% \begin{macro}{\LWR@loadafter} \marg{packagename} \quad
% Error if this package was loaded before \pkg{lwarp}.
%
% \label{sec:loadafter}
%
%    \begin{macrocode}
\newcommand*{\LWR@loadafter}[1]{%
\@ifpackageloaded{#1}
{
\PackageError{lwarp}
{Package #1, or one which uses #1, must be loaded after lwarp}
{Move \detokenize{\usepackage}{#1} after \detokenize{\usepackage}{lwarp}.
Package #1 may also be loaded by something else, which must also be moved
after lwarp.}
}
{}
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@loadbefore} \marg{packagename} \quad
% Error if this package is after \pkg{lwarp}.
%
% \changes{v0.33}{2017/07/06}{Fix: No \cs{PackageError} if already loaded.}
%
%    \begin{macrocode}
\newcommand*{\LWR@loadbefore}[1]{%
\@ifpackageloaded{#1}
{}
{
\PackageError{lwarp}
{Package #1 must be loaded before lwarp}
{Move \detokenize{\usepackage}{#1} before \detokenize{\usepackage}{lwarp}.}
}
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@loadnever} \marg{badpackagename} \marg{replacementpkgname}
%
% The first packages is not supported, so tell the user to use the second instead.
%
% \changes{v0.25}{2017/03/16}{Added the ability to prevent conflicting packages.}
%
%    \begin{macrocode}
\newcommand*{\LWR@loadnever}[2]{%
\PackageError{lwarp}
{Package #1 is not supported by lwarp's HTML conversion.
Package(s) #2 may be useful instead}
{Package #1 might conflict with lwarp in some way,
or is superceded by another package.
For a possible alternative, see package(s) #2.}
}
%    \end{macrocode}
% \end{macro}




% Packages which should only be loaded after \pkg{lwarp} are tested
% here to trip an error of they have already been loaded.
%
% \changes{v0.25}{2017/03/16}{Fix: Allows XE\LaTeX\ and
%	\LuaLaTeX\ to preload graphics and graphicx.}
%
% The following packages must be loaded after \pkg{lwarp}:
%    \begin{macrocode}
\LWR@loadafter{a4}
\LWR@loadafter{a4wide}
\LWR@loadafter{a5comb}
\LWR@loadafter{abstract}
\LWR@loadafter{adjmulticol}
\LWR@loadafter{addlines}
\LWR@loadafter{afterpage}
\LWR@loadafter{algorithmicx}
\LWR@loadafter{alltt}
\LWR@loadafter{amsmath}
\LWR@loadafter{amsthm}
\LWR@loadafter{anonchap}
\LWR@loadafter{anysize}
\LWR@loadafter{appendix}
\LWR@loadafter{arabicfront}
\LWR@loadafter{array}
\LWR@loadafter{atbegshi}
\LWR@loadafter{authblk}
\LWR@loadafter{balance}
\LWR@loadafter{bigdelim}
\LWR@loadafter{bigstrut}
\LWR@loadafter{bookmark}
\LWR@loadafter{booktabs}
\LWR@loadafter{boxedminipage}
\LWR@loadafter{boxedminipage2e}
\LWR@loadafter{breakurl}
\LWR@loadafter{cancel}
\LWR@loadafter{ccaption}
\LWR@loadafter{changepage}
\LWR@loadafter{chngpage}
\LWR@loadafter{chappg}
\LWR@loadafter{color}
\LWR@loadafter{crop}
\LWR@loadafter{cuted}
\LWR@loadafter{cutwin}
\LWR@loadafter{dblfnote}
\LWR@loadafter{dcolumn}
\LWR@loadafter{draftwatermark}
\LWR@loadafter{easy-todo}
\LWR@loadafter{ebook}
\LWR@loadafter{ellipsis}
\LWR@loadafter{emptypage}
\LWR@loadafter{enumerate}
\LWR@loadafter{enumitem}
\LWR@loadafter{epigraph}
\LWR@loadafter{eso-pic}
\LWR@loadafter{everypage}
\LWR@loadafter{everyshi}
\LWR@loadafter{extramarks}
\LWR@loadafter{fancybox}
\LWR@loadafter{fancyhdr}
\LWR@loadafter{fancyref}
\LWR@loadafter{fancyvrb}
\LWR@loadafter{figcaps}
\LWR@loadafter{fix2col}
\LWR@loadafter{fixme}
\LWR@loadafter{fixmetodonotes}
\LWR@loadafter{float}
\LWR@loadafter{floatflt}
\LWR@loadafter{floatpag}
\LWR@loadafter{floatrow}
\LWR@loadafter{flushend}
\LWR@loadafter{fncychap}
\LWR@loadafter{fnpos}
% fontenc must be loaded before lwarp
% fontspec must be loaded before lwarp
\LWR@loadafter{ftnright}
\LWR@loadafter{fullpage}
\LWR@loadafter{fullwidth}
\LWR@loadafter{geometry}
\LWR@loadafter{glossaries}
% \LWR@loadafter{graphics}% pre-loaded by xunicode
% \LWR@loadafter{graphicx}% pre-loaded by xunicode
\LWR@loadafter{grffile}
\LWR@loadafter{hang}
\LWR@loadafter{hyperref}
\LWR@loadafter{hyperxmp}
\LWR@loadafter{idxlayout}
\LWR@loadafter{ifoddpage}
\LWR@loadafter{indentfirst}
% inputenc must be loaded before lwarp
\LWR@loadafter{keyfloat}
\LWR@loadafter{layout}
\LWR@loadafter{letterspace}
\LWR@loadafter{lettrine}
\LWR@loadafter{lips}
\LWR@loadafter{listings}
\LWR@loadafter{longtable}
\LWR@loadafter{lscape}
\LWR@loadafter{ltcaption}
\LWR@loadafter{ltxtable}
\LWR@loadafter{luatodonotes}
\LWR@loadafter{marginfit}
\LWR@loadafter{marginfix}
\LWR@loadafter{marginnote}
\LWR@loadafter{mcaption}
\LWR@loadafter{mdframed}
\LWR@loadafter{metalogo}
\LWR@loadafter{microtype}
\LWR@loadafter{midfloat}
\LWR@loadafter{moreverb}
% morewrites must be loaded before lwarp
\LWR@loadafter{mparhack}
%\LWR@loadafter{multicol}% loaded by ltxdoc
\LWR@loadafter{multirow}
\LWR@loadafter{nameref}
\LWR@loadafter{needspace}
% newclude must be loaded before lwarp
\LWR@loadafter{newtxmath}
% newunicodechar must be loaded before lwarp
\LWR@loadafter{nextpage}
\LWR@loadafter{nonumonpart}
\LWR@loadafter{nopageno}
\LWR@loadafter{nowidow}
\LWR@loadafter{ntheorem}
\LWR@loadafter{overpic}
\LWR@loadafter{pagenote}
\LWR@loadafter{paralist}
\LWR@loadafter{parskip}
\LWR@loadafter{pdflscape}
\LWR@loadafter{pdfsync}
\LWR@loadafter{pfnote}
\LWR@loadafter{placeins}
\LWR@loadafter{prelim2e}
\LWR@loadafter{preview}
\LWR@loadafter{quotchap}
\LWR@loadafter{ragged2e}
\LWR@loadafter{realscripts}
\LWR@loadafter{relsize}
\LWR@loadafter{romanbar}
\LWR@loadafter{romanbarpagenumber}
\LWR@loadafter{rotating}
\LWR@loadafter{rotfloat}
\LWR@loadafter{savetrees}
% \LWR@loadafter{scalefnt}% loaded by babel-french
\LWR@loadafter{scrextend}
\LWR@loadafter{scrhack}
\LWR@loadafter{scrlayer}
\LWR@loadafter{scrlayer-notecolumn}
\LWR@loadafter{scrlayer-scrpage}
\LWR@loadafter{section}
\LWR@loadafter{sectsty}
\LWR@loadafter{setspace}
\LWR@loadafter{shadow}
\LWR@loadafter{showidx}
\LWR@loadafter{showkeys}
\LWR@loadafter{sidecap}
\LWR@loadafter{sidenotes}
\LWR@loadafter{siunitx}
\LWR@loadafter{soul}
\LWR@loadafter{soulpos}
\LWR@loadafter{soulutf8}
\LWR@loadafter{stabular}
\LWR@loadafter{subfig}
\LWR@loadafter{supertabular}
\LWR@loadafter{tabls}
\LWR@loadafter{tabularx}
\LWR@loadafter{tabulary}
\LWR@loadafter{textarea}
% \LWR@loadafter{textcomp}% maybe before lwarp with font packages
\LWR@loadafter{textpos}
\LWR@loadafter{theorem}
\LWR@loadafter{threeparttable}
\LWR@loadafter{tikz}
\LWR@loadafter{titleps}
\LWR@loadafter{titlesec}
\LWR@loadafter{titletoc}
\LWR@loadafter{titling}
% \LWR@loadafter{tocbasic}% preloaded by koma-script classes
\LWR@loadafter{tocbibind}
\LWR@loadafter{tocloft}
\LWR@loadafter{tocstyle}
\LWR@loadafter{todo}
\LWR@loadafter{todonotes}
\LWR@loadafter{transparent}
\LWR@loadafter{trivfloat}
%    \end{macrocode}
% \changes{v0.44}{2017/11/19}{Adjustment for \pkg{koma-script}.}
%    \begin{macrocode}
% \LWR@loadafter{typearea}% preloaded by koma-script classes
\LWR@loadafter{ulem}
\LWR@loadafter{upref}
\LWR@loadafter{varioref}
\LWR@loadafter{verse}
\LWR@loadafter{wallpaper}
\LWR@loadafter{watermark}
\LWR@loadafter{wrapfig}
\LWR@loadafter{xcolor}
\LWR@loadafter{xfrac}
\LWR@loadafter{xltxtra}
\LWR@loadafter{xmpincl}
\LWR@loadafter{xtab}
\LWR@loadafter{zwpagelayout}
%    \end{macrocode}





% \section{Required packages}
% \label{sec:requiredpackages}
% \index{packages>required}
% \changes{v0.16}{2016/04/08}{Lwarp no longer selects fonts.}

% These packages are automatically loaded by \pkg{lwarp} when generating
% \HTML\ output.  Some of them are also automatically loaded when
% generating print output, but some are not.
%
% In the document preamble, create a \env{warpprint} environment, and place
% inside it any of the following packages which are required and which
% are labeled as ``Print: OK to Load in a \env{warpprint} environment''.
% Those packages which are labeled as ``Print: Pre-Loaded''
% need not be placed into the document preamble.



% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}


% \changes{v0.16}{2016/04/07}{Added XeLaTeX, LuaLaTeX support.}
% See: \url{http://tex.stackexchange.com/a/47579}.

% Detects \XeTeX{} and \LuaLaTeX:
% \index{XeLaTeX>detection}\index{LuaLaTeX>detection}
%    \begin{macrocode}
\RequirePackage{iftex}
\newif\ifxetexorluatex
\ifXeTeX
    \xetexorluatextrue
\else
    \ifLuaTeX
        \xetexorluatextrue
    \else
        \xetexorluatexfalse
    \fi
\fi
%    \end{macrocode}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
% ^^A 
% ^^A 
% ^^A % For \XeTeX{} or \LuaLaTeX, use \pkg{fontspec}.
% ^^A % \marginpar{\textcolor{blue}{\XeTeX{} or \LuaLaTeX{} only:}}
% ^^A %
% ^^A % See:\\
% ^^A % \href
% ^^A %	{http://tex.stackexchange.com/questions/2984/frequently-loaded-packages-differences-between-pdflatex-and-xelatex}
% ^^A %	{http://tex.stackexchange.com/questions/2984/\\
% ^^A %		\hspace*{.25in}frequently-loaded-packages-differences-between-pdflatex-and-xelatex}
% ^^A %
% ^^A % \index{font>during conversion}
% ^^A % For \XeLaTeX{} and \LuaLaTeX, uses DejaVu Serif for enhanced Cyrillic and Greek coverage.
% ^^A % \index{Unicode>XeLaTeX \& LuaLaTeX}
%    \begin{macrocode}
\ifxetexorluatex
% ^^A     \usepackage[no-math]{fontspec}
%    \end{macrocode}
% ^^A     \defaultfontfeatures{Ligatures=Common}
% ^^A     \setmainfont{DejaVu Serif}
% ^^A     \setsansfont{DejaVu Sans}
% ^^A     \setmonofont{DejaVu Sans Mono}
% The monospaced font is used for \HTML\ tags,
% so turn off its TeX ligatures and common ligatures:
%    \begin{macrocode}
\defaultfontfeatures[\rmfamily]{Ligatures={NoCommon,TeX}}
\defaultfontfeatures[\sffamily]{Ligatures={NoCommon,TeX}}
\defaultfontfeatures[\ttfamily]{Ligatures=NoCommon}
\else
%    \end{macrocode}
% ^^A % For |pdflatex|, use \pkg{fontenc} and \pkg{lmodern}:
% ^^A % \marginpar{\textcolor{blue}{|pdflatex| only:}}
% ^^A % \index{Unicode>pdfLaTeX}
% ^^A % \index{pdfLaTeX>Unicode support}
% ^^A %    \begin{macrocode}
% ^^A     \RequirePDFTeX % error if not pdflatex
% ^^A 
% ^^A     \input glyphtounicode.tex
% ^^A     \input glyphtounicode-cmr.tex% from the pdfx package
% ^^A     \pdfgentounicode=1 
% ^^A 
% ^^A     \usepackage{cmap}% help map Russian to unicode
% ^^A     \defaulthyphenchar=127%
% ^^A %    \end{macrocode}
% ^^A 
% ^^A % \DescribePackage{lmodern}
% ^^A %
% ^^A % \pdflatexonly
% ^^A %
% ^^A % |pdftotext| works better with a vector font.
% ^^A % This font choice does not control the \HTML\ file, but it does appear in the
% ^^A % images generated from math expressions.
% ^^A %    \begin{macrocode}
% ^^A \RequirePackage{lmodern}
% ^^A %    \end{macrocode}
% ^^A 
% ^^A 
% ^^A % \DescribePackage{fontenc}
% ^^A %
% ^^A % \pdflatexonly
% ^^A %
% ^^A %    \begin{macrocode}
% ^^A \RequirePackage[T1]{fontenc}
% ^^A %    \end{macrocode}
% ^^A 
% ^^A 
% ^^A % \DescribePackage{inputenc}
% ^^A %
% ^^A % \pdflatexonly
% ^^A %
% ^^A %    \begin{macrocode}
% ^^A \RequirePackage[utf8]{inputenc}
% ^^A %    \end{macrocode}
% ^^A 

% \pdflatexonly
%

% \DescribePackage{microtype}
% \changes{v0.18}{2016/05/18}{Microtype disabled during \HTML\ generation}
%
% Older browsers don't
% \index{ligatures}
% display ligatures.
% \margintag{ligatures}
% Turn off letter ligatures, keeping
% \LaTeX{} dash and quote ligatures, which may fail on older browers
% but at least won't corrupt written words.
%    \begin{macrocode}
\RequirePackage {microtype}

\microtypesetup{
    protrusion=false,
    expansion=false,
    tracking=false,
    kerning=false,
    spacing=false}

\DisableLigatures[f,q,t,T,Q]{encoding = *,family = *}
%    \end{macrocode}
% ^^A 
% ^^A 
% ^^A % \DescribePackage{newunicodechar}
% ^^A % 
% ^^A %
% ^^A % \pdflatexonly
% ^^A %
% ^^A % Note that the font used by the source code listing may not correctly display the
% ^^A % \watchout
% ^^A % actual Unicode character contained in the \cs{newunicode\{\}} expression.
% ^^A % The listing printout may not display ligatures or the dashes correctly.
% ^^A %    \begin{macrocode}
% ^^A \RequirePackage{newunicodechar}
% ^^A \newunicodechar{Í}{\IeC {\'I}}
% ^^A \newunicodechar{ﬀ}{ff}% ligatures
% ^^A \newunicodechar{ﬁ}{fi}
% ^^A \newunicodechar{ﬂ}{fl}
% ^^A \newunicodechar{ﬃ}{ffi}
% ^^A \newunicodechar{ﬄ}{ffl}
% ^^A %% \newunicodechar{°}{\degree}
% ^^A \newunicodechar{ρ}{\ensuremath{\rho}}
% ^^A \newunicodechar{⨯}{\texttimes}
% ^^A %% \newunicodechar{®}{\textregistered}
% ^^A %% \newunicodechar{©}{\textcopyright}
% ^^A \newunicodechar{—}{---}% emdash
% ^^A \newunicodechar{–}{--}% endash
% ^^A %% \newunicodechar{”}{''}% closing quote
% ^^A %% \newunicodechar{“}{``}% opening quote
% ^^A %% \newunicodechar{§}{\S}
% ^^A %% \newunicodechar{¶}{\P}
% ^^A %% \newunicodechar{†}{\dag}
% ^^A %% \newunicodechar{‡}{\ddag}
% ^^A %    \end{macrocode}
% ^^A 
% ^^A 
% ^^A % \DescribePackage{textcomp}
% ^^A % 
% ^^A %
% ^^A % \pdflatexonly
% ^^A %
% ^^A % Provides \cs{degree}, \cs{textquotesingle}, \cs{textmu}.
% ^^A %    \begin{macrocode}
% ^^A \RequirePackage{textcomp}
% ^^A %    \end{macrocode}
% ^^A 
%    \begin{macrocode}
\fi
%    \end{macrocode}
% ^^A % \marginpar{\textcolor{blue}{End of \XeLaTeX, \LuaLaTeX, |pdflatex| choices.}}
% ^^A 
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \DescribePackage{geometry}
% Tactics to avoid unwanted page breaks and margin overflow:
% \begin{itemize}
% \item Uses a very long and wide page to minimize page breaks and margin overflow.
% \item Uses a scriptsize font.
% \item Uses extra space at the margin to avoid \HTML\ tag overflow off the page.
% \item Forces a new PDF page before some environments.
% \item Forces line break between major pieces of long tags.
% \end{itemize}
%
% \changes{v0.20}{2017/01/12}{Page geometry set to 6in wide with large margins.}
% \changes{v0.27}{2017/04/04}{Page geometry modified to reduce line overflow.}
% \changes{v0.28}{2017/04/13}{Forced oneside to maintain large right margin.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
\RequirePackage[paperheight=190in,paperwidth=20in,%
left=2in,right=12in,%
top=1in,bottom=1in,%
]{geometry}
\@twosidefalse
\@mparswitchfalse
\end{warpHTML}
%    \end{macrocode}


% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \DescribePackage{xparse}
%
% \LaTeX{}3 command argument parsing
% ^^A \RequirePackage[log-declarations=false]{xparse}
%    \begin{macrocode}
\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}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}



% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \DescribePackage{expl3}
%
% \LaTeX{}3 programming
%    \begin{macrocode}
\RequirePackage{expl3}
%    \end{macrocode}

% ^^A % \DescribePackage{l3regex}
% ^^A %
% ^^A % \LaTeX{}3 regular expression handling
% ^^A %    \begin{macrocode}
% ^^A \RequirePackage{l3regex}
% ^^A %    \end{macrocode}



% ^^A % \begin{macro}{\EmulatesPackage} \marg{pkg name} \oarg{yyyy/mm/dd and comments}
% ^^A %
% ^^A % Similar to \cs{ProvidesPackage}.  Used where the \pkg{lwarp} package emulates
% ^^A % other packages.
% ^^A % For example, \pkg{trivfloat} wants to load \pkg{float}, which is emulated by \pkg{lwarp}.
% ^^A % Since |\EmulatesPackage{float}| is declared by \pkg{lwarp},
% ^^A % \pkg{trivfloat} will not load \pkg{float} on its own.
% ^^A % Doing so would have over-written the \pkg{lwarp} emulation.
% ^^A %
% ^^A % Do not use \cs{EmulatesPackage} for packages which are patched by other
% ^^A % \watchout
% ^^A % packages. The emulated code cannot be patched correctly.
% ^^A %
% ^^A %    \begin{macrocode}
% ^^A \NewDocumentCommand{\EmulatesPackage}{m O{}}{%
% ^^A \expandafter\xdef\csname ver@#1.sty\endcsname{#2 ---
% ^^A 	Emulated by package \@currname.}
% ^^A }
% ^^A \@onlypreamble\EmulatesPackage
% ^^A %    \end{macrocode}
% ^^A % \end{macro}
% ^^A 


% \DescribePackage{gettitlestring}
%
% Used to emulate \cs{nameref}.
%    \begin{macrocode}
\RequirePackage{gettitlestring}
%    \end{macrocode}


% \DescribePackage{everyhook}
%
% \pkg{everyhook} is used to patch paragraph handling.
%    \begin{macrocode}
\RequirePackage{everyhook}
\end{warpHTML}
%    \end{macrocode}


% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \DescribePackage{filecontents}
%
% Used to write helper files, done in print mode.
%
% Patched to work with \pkg{morewrites}, per
% \href
%	{https://tex.stackexchange.com/questions/312830/does-morewrites-not-support-filecontents-and-can-i-write-body-of-environment-us/312910}
%	{\texttt{https://tex.stackexchange.com/questions/312830/\\
%		does-morewrites-not-support-filecontents-and-can-i-write-body-of-environment-us/\\
%		312910}}
%
% \changes{v0.34}{2017/08/02}{\pkg{filecontents}: Required.  Patched for \protect\pkg{morewrites}.}
%
%    \begin{macrocode}
\RequirePackage{filecontents}

\@ifpackagelater{filecontents}{2011/10/09}%
{}
{
\newwrite\fcwrite
\let\LWR@origfilec@ntents\filec@ntents
\def\filec@ntents{\def\chardef##1\write{\let\reserved@c\fcwrite}\LWR@origfilec@ntents}
}
%    \end{macrocode}



%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}


% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \DescribePackage{xifthen}
%    \begin{macrocode}
\RequirePackage{xifthen}
%    \end{macrocode}


% \DescribePackage{xstring}
%    \begin{macrocode}
\RequirePackage{xstring}
%    \end{macrocode}


% \DescribePackage{xstring}
%    \begin{macrocode}
\RequirePackage{verbatim}
%    \end{macrocode}


% \DescribePackage{makeidx}
%    \begin{macrocode}
\RequirePackage{makeidx}
\makeindex
%    \end{macrocode}


% \DescribePackage{calc}
%    \begin{macrocode}
\RequirePackage{calc}
%    \end{macrocode}


% \DescribePackage{refcount}
%    \begin{macrocode}
\RequirePackage{refcount}
%    \end{macrocode}


% \DescribePackage{newfloat}
%    \begin{macrocode}
\RequirePackage{newfloat}
%    \end{macrocode}

% \DescribePackage{caption}
%    \begin{macrocode}
\RequirePackage{caption}
%    \end{macrocode}

% \changes{v0.24}{2017/03/06}{No longer preloads \pkg{subcaption};
%	conflicted with \pkg{subfig}.}


%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}


% \DescribePackage{environ}
%
% Used to encapsulate math environments for re-use in \HTML\ \element{alt} text.
%
%    \begin{macrocode}
\RequirePackage{environ}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}


% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \DescribePackage{zref}
%
% Used for cross-references.
%    \begin{macrocode}
\RequirePackage{zref}
%    \end{macrocode}


% \DescribePackage{amsmath}
% \changes{v0.16}{2016/04/09}{Fix: amsmath options clash}
%
% Equation numbers are placed to the left for \HTML.
%
% \pkg{newtxmath} automatically loads \pkg{amsmath},
% so the options |leqno| and |fleqn| are passed beforehand to be
% picked up both here and by \pkg{newtxmath} if it is used.
% \changes{v0.16}{2016/04/11}{Fix: newtxmath compatibility.}
% \changes{v0.33}{2016/06/21}{\protect\pkg{amsmath}: Removed \protect\texttt{fleqn} option.}
%
%    \begin{macrocode}
\PassOptionsToPackage{leqno}{amsmath}
\RequirePackage{amsmath}
%    \end{macrocode}



% \changes{v0.40}{2017/09/07}{No longer preloads \pkg{xfrac}.}

%
% Used to convert lengths for image width/height options.
%
%    \begin{macrocode}
\RequirePackage{printlen}
%    \end{macrocode}


%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}





% \section{Loading packages}
%
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% Remember the original \cs{RequirePackage}:
%    \begin{macrocode}
\LetLtxMacro{\LWR@origRequirePackage}{\RequirePackage}
%    \end{macrocode}

% \begin{macro}{\LWR@requirepackagenames} Stores the list of required package names.
%    \begin{macrocode}
\newcommand*{\LWR@requirepackagenames}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@findword} \oarg{1: separator} \marg{2: list}
%								\marg{3: index} \oarg{4: destination}
%
% Note that argument 4 is passed directly to \cs{StrBetween}.
%    \begin{macrocode}
\newcommand*\LWR@findword[3][,]{%
    \StrBetween[#3,\numexpr#3+1]{#1#2#1}{#1}{#1}%
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\LWR@lookforpackagename} \marg{index}
% If this is a package name, re-direct it to the \pkg{lwarp} version
% by renaming it |lwarp-| followed by the original name.
%    \begin{macrocode}
\newcommand*{\LWR@lookforpackagename}[1]{%
%    \end{macrocode}
% Find the n'th package name from the list:
%    \begin{macrocode}
\LWR@findword{\LWR@requirepackagenames}{#1}[\LWR@strresult]%
%    \end{macrocode}
% Remove blanks.
% The original name with blanks is in |LWR@strresult| and
% the final name with no blanks goes into |LWR@strresulttwo|.
%    \begin{macrocode}
\StrSubstitute[100]{\LWR@strresult}{ }{}[\LWR@strresulttwo]%
%    \end{macrocode}
% See if the package name was found:
%    \begin{macrocode}
\IfStrEq{\LWR@strresulttwo}{}%
{}% no filename
{% yes filename
%    \end{macrocode}
% If found, and if an \pkg{lwarp}-equivalent name exists, use |lwarp-|* instead.
%    \begin{macrocode}
\IfFileExists{lwarp-\LWR@strresulttwo.sty}%
{% lwarp-* file found
        \StrSubstitute%
            {\LWR@requirepackagenames}%
            {\LWR@strresult}%
            {lwarp-\LWR@strresulttwo}[\LWR@requirepackagenames]%
}%
{}% no lwarp-* file
}% yes filename
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\RequirePackage} \oarg{1: options} \marg{2: package names} \oarg{3: version}
%
% For each of many package names in a comma-separated list,
% if an \pkg{lwarp} version of a package exists,
% select it instead of the \LaTeX\ version.
%
% \changes{v0.32}{2017/06/09}{Fix: Ignores blanks in package list.}
%
%    \begin{macrocode}
\RenewDocumentCommand{\RequirePackage}{o m o}{%
%    \end{macrocode}
% Redirect up to nine names:
%    \begin{macrocode}
\renewcommand*{\LWR@requirepackagenames}{#2}
\LWR@lookforpackagename{1}
\LWR@lookforpackagename{2}
\LWR@lookforpackagename{3}
\LWR@lookforpackagename{4}
\LWR@lookforpackagename{5}
\LWR@lookforpackagename{6}
\LWR@lookforpackagename{7}
\LWR@lookforpackagename{8}
\LWR@lookforpackagename{9}
%    \end{macrocode}
% \cs{RequirePackage} depending on the options and version:
%    \begin{macrocode}
\IfValueTF{#1}
{% options given
    \IfValueTF{#3}% version given?
    {\LWR@origRequirePackage[#1]{\LWR@requirepackagenames}[#3]}
    {\LWR@origRequirePackage[#1]{\LWR@requirepackagenames}}
}
{% no options given
    \IfValueTF{#3}% version given?
    {\LWR@origRequirePackage{\LWR@requirepackagenames}[#3]}
    {\LWR@origRequirePackage{\LWR@requirepackagenames}}
}
}
\LetLtxMacro{\usepackage}{\RequirePackage}
%    \end{macrocode}
% \end{macro}




% \begin{macro}{\LWR@ProvidesPackagePass} \marg{pkgname} \oarg{version}
%
% Uses the original package, including options.
%    \begin{macrocode}
\NewDocumentCommand{\LWR@ProvidesPackagePass}{m o}{
\PackageInfo{lwarp}{Using package `#1' and adding lwarp modifications, including options,}%
\IfValueTF{#2}
{\ProvidesPackage{lwarp-#1}[#2]}
{\ProvidesPackage{lwarp-#1}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{#1}}
\ProcessOptions\relax

\IfValueTF{#2}
{\LWR@origRequirePackage{#1}[#2]}
{\LWR@origRequirePackage{#1}}
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@ProvidesPackageDrop} \marg{pkgname} \oarg{version}
%
% Ignores the original package and uses lwarp's version instead.
% Drops/discards all options.
%    \begin{macrocode}
\NewDocumentCommand{\LWR@ProvidesPackageDrop}{m o}{
\PackageInfo{lwarp}{Replacing package `#1' with the lwarp version, discarding options,}%
\IfValueTF{#2}
{\ProvidesPackage{lwarp-#1}[#2]}
{\ProvidesPackage{lwarp-#1}}
\DeclareOption*{}
\ProcessOptions\relax
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \section{File handles}

% Defines file handles for writes.

% \changes{v0.37}{2017/08/19}{File handles reorganized.}

% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \begin{macro}{\LWR@quickfile}
% For quick temporary use only.
% This is reused in several places.
%    \begin{macrocode}
\newwrite\LWR@quickfile%
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}


% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{macro}{\LWR@lateximagesfile}
% For |lateximages.txt|.
%    \begin{macrocode}
\newwrite\LWR@lateximagesfile
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \section{Include a file}
%
% During \HTML\ output, |\include{<filename>}| causes the following to occur:
%
% \begin{enumerate}
% \item \pkg{lwarp} creates |<filename>_html_inc.tex| whose contents are:
%       \begin{sourcedisplay}
%       \cs{input} \textless{}filename\textgreater.tex
%       \end{sourcedisplay}
% \item |<filename>_html_inc.tex| is then \cs{include}d instead of |<filename>.tex|.
% \item |<filename>_html_inc.aux| is automatically generated and used by \LaTeX.
% \end{enumerate}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{macro}{\include} \marg{filename}
%
% \changes{v0.37}{2017/08/19}{Maintains independent \protect\texttt{.aux} files for \protect\HTML.}
%
% \begin{macro}{\@include} \marg{filename} Modified to load |_html_inc| files.
%    \begin{macrocode}
\def\@include#1 {%
\immediate\openout\LWR@quickfile #1_html_inc.tex% new
\immediate\write\LWR@quickfile{\string\input{#1.tex}}% new
\immediate\closeout\LWR@quickfile% new
\LWR@origclearpage% \changed
\if@filesw
    \immediate\write\@mainaux{\string\@input{#1_html_inc.aux}}% changed
\fi
\@tempswatrue
\if@partsw
    \@tempswafalse
    \edef\reserved@b{#1}%
    \@for\reserved@a:=\@partlist\do
    {\ifx\reserved@a\reserved@b\@tempswatrue\fi}%
\fi
\if@tempswa
    \let\@auxout\@partaux
    \if@filesw
        \immediate\openout\@partaux #1_html_inc.aux % changed
        \immediate\write\@partaux{\relax}%
    \fi
    \@input@{#1_html_inc.tex}% changed
    \LWR@origclearpage% changed
    \@writeckpt{#1}%
    \if@filesw
        \immediate\closeout\@partaux
    \fi
\else
    \deadcycles\z@
    \@nameuse{cp@#1}%
\fi
\let\@auxout\@mainaux%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \section{Copying a file}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{macro}{\LWR@copyfile} \marg{source filename} \marg{destination filename}
%
% Used to copy the |.toc| file to |.sidetoc| to re-print the \TOC\ in
% the side\TOC\ navigation pane.
%    \begin{macrocode}
\newwrite\LWR@copyoutfile  % open the file to write to
\newread\LWR@copyinfile      % open the file to read from

\newcommand*{\LWR@copyfile}[2]{%
\immediate\openout\LWR@copyoutfile=#2
\openin\LWR@copyinfile=#1
\begingroup\endlinechar=-1
\makeatletter
\loop\unless\ifeof\LWR@copyinfile
  \read\LWR@copyinfile to\LWR@fileline  % Read one line and store it into \LWR@fileline
%   \LWR@fileline\par                   % print the content into the pdf
% print the content:
  \immediate\write\LWR@copyoutfile{\unexpanded\expandafter{\LWR@fileline}}%
\repeat
\closeout\LWR@copyoutfile
\endgroup
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \section{Debugging messages}

% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \DescribeBoolean{LWR@tracinglwarp} True if tracing is turned on.
%    \begin{macrocode}
\newbool{LWR@tracinglwarp}
%    \end{macrocode}
%
% \begin{macro}{\tracinglwarp} Turns on the debug tracing messages.
% \changes{v0.20}{2017/02/07}{Added.}
%    \begin{macrocode}
\newcommand{\tracinglwarp}{\booltrue{LWR@tracinglwarp}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LWR@traceinfo} \marg{text} \quad If tracing is turned on, writes
%	the text to the |.log| file.
%    \begin{macrocode}
\newcommand{\LWR@traceinfo}[1]{%
\ifbool{LWR@tracinglwarp}%
{%
    \typeout{*** lwarp: #1}%
    % \PackageInfo{lwarp}{#1 : }%
}%
{}%
}
%    \end{macrocode}
% \end{macro}


% \DescribeBoolean{HTMLDebugComments}  \DescribeDefault{false}
%	Add comments in \HTML\
%	about closing \element{div}s, sections, etc.
%	\index{HTML>conversion settings>debug comments}
%	\index{debugging>HTML debug comments}
%	\index{troubleshooting>HTML debug comments}
%
% \changes{v0.28}{2017/04/09}{Added boolean \texttt{HTMLDebugComments.}}
%
%    \begin{macrocode}
\newbool{HTMLDebugComments}
\boolfalse{HTMLDebugComments}
%    \end{macrocode}



% If \cs{tracinglwarp}, show where preamble hooks occur:
%    \begin{macrocode}
\AfterEndPreamble{
\LWR@traceinfo{AfterEndPreamble}
}

\AtBeginDocument{
\LWR@traceinfo{AtBeginDocument}
}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}


% \section{Koma-script}
%
% Load patches to \pkg{koma-script}.
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%    \begin{macrocode}
\@ifclassloaded{scrbook}{\RequirePackage{lwarp-patch-komascript}}{}
\@ifclassloaded{scrartcl}{\RequirePackage{lwarp-patch-komascript}}{}
\@ifclassloaded{scrreprt}{\RequirePackage{lwarp-patch-komascript}}{}
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \section{HTML-conversion output modifications}
%
% These booleans modify the \HTML\ output in various ways
% to improve conversion to \EPUB\ or word processor imports.
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}
%
% \subsection{User-level controls}
%
% \DescribeBoolean{FormatEPUB}   \DescribeDefault{false}
%	Changes \HTML\ output for easy \EPUB\ conversion
%	via an external program. Removes per-file headers, footers, and nav.
%	Adds footnotes per chapter/section.
%	\index{EPUB>HTML conversion settings}
%	\index{HTML>conversion settings>EPUB}
%
% \changes{v0.28}{2017/04/09}{Added boolean \texttt{FormatEPUB}.}
%
%    \begin{macrocode}
\newbool{FormatEPUB}
\boolfalse{FormatEPUB}
%    \end{macrocode}
%
%
% \DescribeBoolean{FormatWP}  \DescribeDefault{false}
%	Changes \HTML\ output for easier conversion
%	by a word processor.
%	Removes headers and nav, prints footnotes per section,
%	and also forces single-file output and turns off \HTML\ debug
%	comments.
%	\index{word processor>HTML conversion settings}
%	\index{HTML>conversion settings>word processor}
%
% \changes{v0.28}{2017/04/09}{Added boolean \texttt{FormatWP}.}
%
%    \begin{macrocode}
\newbool{FormatWP}
\boolfalse{FormatWP}
%    \end{macrocode}
%
%
% \DescribeBoolean{WPMarkFloats} \DescribeDefault{false}
% \describeWPMarkFloats
%	\footnote{Perhaps some day word processors will have \HTML\ import options
%	for identifying \element{figure} and \element{figcaption} tags
%   for figures and tables.}
%	\index{word processor>HTML conversion settings}
%	\index{HTML>conversion settings>word processor}
%
% \changes{v0.28}{2017/04/09}{Added boolean \protect\texttt{HTMLMarkFloats}, changed
%   to \protect\texttt{WPMarkFloats} as of v0.42.}
%
%    \begin{macrocode}
\newbool{WPMarkFloats}
\boolfalse{WPMarkFloats}
%    \end{macrocode}

% \DescribeBoolean{WPMarkMinipages} \DescribeDefault{false}
% \changes{v0.42}{2017/10/18}{Added boolean \protect\texttt{WPMarkMinipages}.}
% \describeWPMarkMinipages
%    \begin{macrocode}
\newbool{WPMarkMinipages}
\boolfalse{WPMarkMinipages}
%    \end{macrocode}

% \DescribeBoolean{WPMarkTOC} \DescribeDefault{true}
% \changes{v0.42}{2017/10/18}{Added boolean \protect\texttt{WPMarkTOC}.}
% \describeWPMarkTOC
%    \begin{macrocode}
\newbool{WPMarkTOC}
\booltrue{WPMarkTOC}
%    \end{macrocode}


% \DescribeBoolean{WPMarkLOFT} \DescribeDefault{false}
% \changes{v0.42}{2017/10/19}{Added boolean \protect\texttt{WPMarkLOFT}.}
% \describeWPMarkLOFT
%    \begin{macrocode}
\newbool{WPMarkLOFT}
\boolfalse{WPMarkLOFT}
%    \end{macrocode}


% \DescribeBoolean{WPMarkMath} \DescribeDefault{false}
% \changes{v0.42}{2017/10/19}{Added boolean \protect\texttt{WPMarkMath}.}
% \describeWPMarkMath
%    \begin{macrocode}
\newbool{WPMarkMath}
\boolfalse{WPMarkMath}
%    \end{macrocode}


% \DescribeBoolean{WPTitleHeading} \DescribeDefault{false}
% \changes{v0.42}{2017/10/19}{Added boolean \protect\texttt{WPTitleHeading}.}
% \describeWPTitleHeading
%    \begin{macrocode}
\newbool{WPTitleHeading}
\boolfalse{WPTitleHeading}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}

%
% \subsection{Heading adjustments}
%
% \changes{v0.42}{2017/10/19}{If \protect\texttt{FormatWP},
%                       shift section headings.}
% If formatting the \HTML\ for a word processor, adjust heading levels.
%
% If |WPTitleHeading| is true, adjust so that |part| is \UI{Heading~1}.
%
% If |WPTitleHeading| is false, use \element{h1} for the title,
%    and set |part| to \UI{Heading~2}.
%
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%    \begin{macrocode}
\AtBeginDocument{
\ifbool{FormatWP}{
\@ifundefined{chapter}{
\ifbool{WPTitleHeading}{% part and section starting at h2
\renewcommand*{\LWR@tagtitle}{h1}
\renewcommand*{\LWR@tagtitleend}{/h1}
\renewcommand*{\LWR@tagpart}{h2}
\renewcommand*{\LWR@tagpartend}{/h2}
\renewcommand*{\LWR@tagsection}{h3}
\renewcommand*{\LWR@tagsectionend}{/h3}
\renewcommand*{\LWR@tagsubsection}{h4}
\renewcommand*{\LWR@tagsubsectionend}{/h4}
\renewcommand*{\LWR@tagsubsubsection}{h5}
\renewcommand*{\LWR@tagsubsubsectionend}{/h5}
\renewcommand*{\LWR@tagparagraph}{h6}
\renewcommand*{\LWR@tagparagraphend}{/h6}
\renewcommand*{\LWR@tagsubparagraph}{span class="subparagraph"{}}
\renewcommand*{\LWR@tagsubparagraphend}{/span}
}% WPTitleHeading
{% not WPTitleHeading, part and section starting at h1
\renewcommand*{\LWR@tagtitle}{div class="title"}
\renewcommand*{\LWR@tagtitleend}{/div}
\renewcommand*{\LWR@tagpart}{h1}
\renewcommand*{\LWR@tagpartend}{/h1}
\renewcommand*{\LWR@tagsection}{h2}
\renewcommand*{\LWR@tagsectionend}{/h2}
\renewcommand*{\LWR@tagsubsection}{h3}
\renewcommand*{\LWR@tagsubsectionend}{/h3}
\renewcommand*{\LWR@tagsubsubsection}{h4}
\renewcommand*{\LWR@tagsubsubsectionend}{/h4}
\renewcommand*{\LWR@tagparagraph}{h5}
\renewcommand*{\LWR@tagparagraphend}{/h5}
\renewcommand*{\LWR@tagsubparagraph}{h6}
\renewcommand*{\LWR@tagsubparagraphend}{/h6}
}% not WPTitleHeading
}% chapter undefined
{% chapter defined
\ifbool{WPTitleHeading}{}
{% not WPTitleHeading, part and chapter starting at h1
\renewcommand*{\LWR@tagtitle}{div class="title"}
\renewcommand*{\LWR@tagtitleend}{/div}
\renewcommand*{\LWR@tagpart}{h1}
\renewcommand*{\LWR@tagpartend}{/h1}
\renewcommand*{\LWR@tagchapter}{h2}
\renewcommand*{\LWR@tagchapterend}{/h2}
\renewcommand*{\LWR@tagsection}{h3}
\renewcommand*{\LWR@tagsectionend}{/h3}
\renewcommand*{\LWR@tagsubsection}{h4}
\renewcommand*{\LWR@tagsubsectionend}{/h4}
\renewcommand*{\LWR@tagsubsubsection}{h5}
\renewcommand*{\LWR@tagsubsubsectionend}{/h5}
\renewcommand*{\LWR@tagparagraph}{h6}
\renewcommand*{\LWR@tagparagraphend}{/h6}
\renewcommand*{\LWR@tagsubparagraph}{span class="subparagraph"{}}
\renewcommand*{\LWR@tagsubparagraphend}{/span}
}% not WPTitleHeading
}% chapter defined
}{}% FormatWP
}% AtBeginDocument
%    \end{macrocode}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \section{Remembering original formatting macros}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% Remember original definitions of formatting commands.
% Will be changed to \HTML\ commands for most uses.
% Will be temporarily restored to original meaning inside any lateximage environment.
% Also nullify unused commands.
%    \begin{macrocode}
\LetLtxMacro{\LWR@origtextrm}{\textrm}
\LetLtxMacro{\LWR@origtextsf}{\textsf}
\LetLtxMacro{\LWR@origtexttt}{\texttt}
\LetLtxMacro{\LWR@origtextnormal}{\textnormal}
\LetLtxMacro{\LWR@origtextbf}{\textbf}
\LetLtxMacro{\LWR@origtextmd}{\textmd}
\LetLtxMacro{\LWR@origtextit}{\textit}
\LetLtxMacro{\LWR@origtextsl}{\textsl}
\LetLtxMacro{\LWR@origtextsc}{\textsc}
\LetLtxMacro{\LWR@origtextup}{\textup}
\LetLtxMacro{\LWR@origemph}{\emph}

\LetLtxMacro{\LWR@origrmfamily}{\rmfamily}
\LetLtxMacro{\LWR@origsffamily}{\sffamily}
\LetLtxMacro{\LWR@origttfamily}{\ttfamily}
\LetLtxMacro{\LWR@origbfseries}{\bfseries}
\LetLtxMacro{\LWR@origmdseries}{\mdseries}
\LetLtxMacro{\LWR@origupshape}{\upshape}
\LetLtxMacro{\LWR@origslshape}{\slshape}
\LetLtxMacro{\LWR@origscshape}{\scshape}
\LetLtxMacro{\LWR@origitshape}{\itshape}
\LetLtxMacro{\LWR@origem}{\em}
\LetLtxMacro{\LWR@orignormalfont}{\normalfont}

\let\LWR@origraggedright\raggedright
\let\LWR@origonecolumn\onecolumn

\let\LWR@origsp\sp
\let\LWR@origsb\sb
\LetLtxMacro\LWR@origtextsuperscript\textsuperscript
\LetLtxMacro\LWR@orig@textsuperscript\@textsuperscript
\AtBeginDocument{
\LetLtxMacro\LWR@origtextsubscript\textsubscript
\LetLtxMacro\LWR@orig@textsubscript\@textsubscript
}
\LetLtxMacro\LWR@origunderline\underline

\let\LWR@origscriptsize\scriptsize

\let\LWR@orignewpage\newpage

\let\LWR@origpagestyle\pagestyle
\let\LWR@origthispagestyle\thispagestyle
\let\LWR@origpagenumbering\pagenumbering

\LetLtxMacro{\LWR@origminipage}{\minipage}
\let\LWR@origendminipage\endminipage
\LetLtxMacro{\LWR@origparbox}{\parbox}

\let\LWR@orignewline\newline

\LetLtxMacro\LWR@origitem\item


\AtBeginDocument{% in case packages change definition
\LetLtxMacro{\LWR@origitemize}{\itemize}
\LetLtxMacro{\LWR@endorigitemize}{\enditemize}
\LetLtxMacro{\LWR@origenumerate}{\enumerate}
\LetLtxMacro{\LWR@endorigenumerate}{\endenumerate}
\LetLtxMacro{\LWR@origdescription}{\description}
\LetLtxMacro{\LWR@endorigdescription}{\enddescription}
}

\let\LWR@origpar\par

\LetLtxMacro{\LWR@origfootnote}{\footnote}
\let\LWR@orig@mpfootnotetext\@mpfootnotetext

\let\LWR@origclearpage\clearpage
%    \end{macrocode}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \section{Accents}
%
% \limitsaccents
%
% \changes{v0.37}{2017/08/18}{\protect\LaTeX\ accents: Added.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
% Without \cs{AtBeginDocument}, \cs{t} was being re-defined somewhere.
%    \begin{macrocode}
\AtBeginDocument{
%    \end{macrocode}
% The following are restored for print when inside a \env{lateximage}.
%
% For Unicode engines, only \cs{t} needs to be redefined:
%    \begin{macrocode}
\LetLtxMacro{\LWR@origt}{\t}
%    \end{macrocode}
% For pdf\LaTeX, additional work is required:
%    \begin{macrocode}
\ifPDFTeX
\LetLtxMacro{\LWR@origequalaccent}{\=}
\LetLtxMacro{\LWR@origdotaccent}{\.}
\LetLtxMacro{\LWR@origu}{\u}
\LetLtxMacro{\LWR@origv}{\v}
\LetLtxMacro{\LWR@origc}{\c}
\LetLtxMacro{\LWR@origd}{\d}
\LetLtxMacro{\LWR@origb}{\b}
%    \end{macrocode}
% The \HTML\ redefinitions follow.
%
% For pdf\LaTeX, Unicode diacritical marks are used:
%    \begin{macrocode}
\renewcommand*{\=}[1]{#1\HTMLunicode{0305}}
\renewcommand*{\.}[1]{#1\HTMLunicode{0307}}
\renewcommand*{\u}[1]{#1\HTMLunicode{0306}}
\renewcommand*{\v}[1]{#1\HTMLunicode{030C}}
\renewcommand*{\c}[1]{#1\HTMLunicode{0327}}
\renewcommand*{\d}[1]{#1\HTMLunicode{0323}}
\renewcommand*{\b}[1]{#1\HTMLunicode{0331}}
\fi
%    \end{macrocode}
% For all engines, a Unicode diacritical tie is used:
%    \begin{macrocode}
\def\LWR@t#1#2{#1\HTMLunicode{0361}#2}
\renewcommand*{\t}[1]{\LWR@t#1}
%    \end{macrocode}
%
% \begin{macro}{\LWR@restoreorigaccents}
% Called from \cs{restoreoriginalformatting} when a \env{lateximage} is begun.
%    \begin{macrocode}
\ifPDFTeX
\newcommand*{\LWR@restoreorigaccents}{%
\LetLtxMacro{\=}{\LWR@origequalaccent}%
\LetLtxMacro{\.}{\LWR@origdotaccent}%
\LetLtxMacro{\u}{\LWR@origu}%
\LetLtxMacro{\v}{\LWR@origu}%
\LetLtxMacro{\t}{\LWR@origt}%
\LetLtxMacro{\c}{\LWR@origc}%
\LetLtxMacro{\d}{\LWR@origd}%
\LetLtxMacro{\b}{\LWR@origb}%
}
\else% XeLaTeX, LuaLaTeX:
\newcommand*{\LWR@restoreorigaccents}{%
\LetLtxMacro{\t}{\LWR@origt}%
}
\fi
}% AtBeginDocument
%    \end{macrocode}
% \end{macro}
%
%
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}





% \section{Configuration Files}


% \changes{v0.20}{2016/12/20}{\pkg{lwarp-newproject}: Added.}
% \changes{v0.30}{2017/04/27}{\pkg{lwarp-newproject} removed, and combined with \pkg{lwarp}.}





%    \begin{macrocode}
\begin{warpprint}
\typeout{lwarp: generating configuration files}
\end{warpprint}
%    \end{macrocode}


% \subsection{project\_html.tex}
%
% \DescribeFile{project_html.tex} Used to allow an \HTML\ version of the
% document to exist alongside the print version.
%
% Only write |\jobname_html.tex| if generating the print version.
%    \begin{macrocode}
\begin{warpprint}
\immediate\openout\LWR@quickfile=\jobname_html.tex
\immediate\write\LWR@quickfile{%
\detokenize{\PassOptionsToPackage}%
{warpHTML,BaseJobname=\jobname}{lwarp}%
}
\immediate\write\LWR@quickfile{%
\detokenize{\input}\string{\jobname.tex\string }%
}
\immediate\closeout\LWR@quickfile
\end{warpprint}
%    \end{macrocode}




% \subsection{lwarpmk.conf}
%
% \DescribeFile{lwarpmk.conf}
% |lwarpmk.conf| is automatically (re-)created by the \pkg{lwarp} package when
% executing\\
% \hspace*{2ex} |pdflatex <project.tex>|,\\
% or similar for |xelatex| or |lualatex|, in print-document generation mode,
% which is the default unless the |warpHTML| option is given.
% |lwarpmk.conf| is then used by the utility |lwarpmk|.
%
% An example |lwarpmk.conf|:
% \begin{Verbatim}[gobble=2,frame=lines,obeytabs,tabsize=4,formatcom={\unskip}]
% opsystem = "Unix"   -- or "Windows"
% latexname = "pdflatex"   -- or "lualatex" or "xelatex"
% sourcename = "projectname"   -- your .tex source
% homehtmlfilename = "index"   -- or "projectname"
% htmlfilename = ""   -- or "projectname" if numbered HTML files
% \end{Verbatim}
%
% \changes{v0.29}{2017/04/15}{File \protect\texttt{lwarpmk.conf}: Add: \protect\texttt{language} option for config files.}
%
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\ifcsdef{LWR@quickfile}{}{\newwrite{\LWR@quickfile}}
\immediate\openout\LWR@quickfile=lwarpmk.conf
\ifbool{usingOSWindows}{
\immediate\write\LWR@quickfile{opsystem = "Windows"}
}{
\immediate\write\LWR@quickfile{opsystem = "Unix"}
}
\ifPDFTeX
\immediate\write\LWR@quickfile{latexname = "pdflatex"}
\fi
\ifXeTeX
\immediate\write\LWR@quickfile{latexname = "xelatex"}
\fi
\ifLuaTeX
\immediate\write\LWR@quickfile{latexname = "lualatex"}
\fi
\immediate\write\LWR@quickfile{sourcename = "\jobname"}
\immediate\write\LWR@quickfile{%
homehtmlfilename = "\HomeHTMLFilename"%
}
\immediate\write\LWR@quickfile{htmlfilename = "\HTMLFilename"}
\immediate\write\LWR@quickfile{latexmk = "\ifbool{LWR@latexmk}{true}{false}"}
\immediate\write\LWR@quickfile{language = "\LWR@IndexLanguage"}
\immediate\write\LWR@quickfile{xdyfile = "\LWR@xdyFilename"}
\immediate\closeout\LWR@quickfile
\end{warpprint}
%    \end{macrocode}



% \subsection{project.lwarpmkconf}
%
% \DescribeFile{project.lwarpmkconf} A project-specific configuration file for |lwarpmk|.
%
% \changes{v0.29}{2017/04/15}{File \protect\texttt{*.lwarpmkconf}: Add: \protect\texttt{language} option for config files.}
%
%    \begin{macrocode}
\begin{warpprint}
\ifcsdef{LWR@quickfile}{}{\newwrite{\LWR@quickfile}}
\immediate\openout\LWR@quickfile=\jobname.lwarpmkconf
\ifbool{usingOSWindows}{
\immediate\write\LWR@quickfile{opsystem = "Windows"}
}{
\immediate\write\LWR@quickfile{opsystem = "Unix"}
}
\ifPDFTeX
\immediate\write\LWR@quickfile{latexname = "pdflatex"}
\fi
\ifXeTeX
\immediate\write\LWR@quickfile{latexname = "xelatex"}
\fi
\ifLuaTeX
\immediate\write\LWR@quickfile{latexname = "lualatex"}
\fi
\immediate\write\LWR@quickfile{sourcename = "\jobname"}
\immediate\write\LWR@quickfile{%
homehtmlfilename = "\HomeHTMLFilename"%
}
\immediate\write\LWR@quickfile{htmlfilename = "\HTMLFilename"}
\immediate\write\LWR@quickfile{latexmk = "\ifbool{LWR@latexmk}{true}{false}"}
\immediate\write\LWR@quickfile{language = "\LWR@IndexLanguage"}
\immediate\write\LWR@quickfile{xdyfile = "\LWR@xdyFilename"}
\immediate\closeout\LWR@quickfile
\end{warpprint}
%    \end{macrocode}






% \subsection{lwarp.css}

% \DescribeFile{lwarp.css}
% This is the base \CSS\ layer used by \pkg{lwarp}.
%
% This must be present both when compiling the project
% and also when distributing the \HTML\ files.
%
% \changes{v0.26}{2017/03/30}{\texttt{lwarp.css}: Improved responsive
%	\texttt{marginpar} and \texttt{marginblock}.}
% \changes{v0.30}{2017/04/26}{Fix: \protect\texttt{*.css} files only written in print mode.}
%
%    \begin{macrocode}
\begin{warpprint}
\begin{filecontents*}{lwarp.css}
/*
  CSS stylesheet for the LaTeX lwarp package
  Copyright 2016-2017 Brian Dunn — BD Tech Concepts LLC
*/


/* a fix for older browsers: */
header, section, footer, aside, nav, main,
    article, figure { display: block; }


A:link {color:#000080 ; text-decoration: none ; }
A:visited {color:#800000 ; }
A:hover {color:#000080 ; text-decoration: underline ;}
A:active {color:#800000 ; }

a.tocpart {display: inline-block ; margin-left: 0em ;
    font-weight: bold ;}
a.tocchapter {display: inline-block ; margin-left: 0em ;
    font-weight: bold ;}
a.tocsection {display: inline-block ; margin-left: 1em ;
    text-indent: -.5em ; font-weight: bold ; }
a.tocsubsection {display: inline-block ; margin-left: 2em ;
    text-indent: -.5em ; }
a.tocsubsubsection {display: inline-block ; margin-left: 3em ;
    text-indent: -.5em ; }
a.tocparagraph {display: inline-block ; margin-left: 4em ;
    text-indent: -.5em ; }
a.tocsubparagraph {display: inline-block ; margin-left: 5em ;
    text-indent: -.5em ; }
a.tocfigure {margin-left: 0em}
a.tocsubfigure {margin-left: 2em}
a.toctable {margin-left: 0em}
a.tocsubtable {margin-left: 2em}
a.toctheorem {margin-left: 0em}
a.toclstlisting {margin-left: 0em}

body {
    font-family: "DejaVu Serif", "Bitstream Vera Serif",
        "Lucida Bright", Georgia, serif;
    background: #FAF7F4 ;
    color: black ;
    margin:0em ;
    padding:0em ;
    font-size: 100% ;
    line-height: 1.2 ;
}

p {margin: 1.5ex 0em 1.5ex 0em ;}

/* Holds a section number to add space between it and the name */
span.sectionnumber { margin-right: 0em }

/* Inserted in front of index lines */
span.indexitem {margin-left: 0em}
span.indexsubitem {margin-left: 2em}
span.indexsubsubitem {margin-left: 4em}

div.hidden, span.hidden { display: none ; }

kbd {
    font-family: "DejaVu Mono", "Bitstream Vera Mono", "Lucida Console",
        "Nimbus Mono L", "Liberation Mono", "FreeMono", "Andale Mono",
        "Courier New", monospace;
    font-size: 100% ;
}

pre { padding: 3pt ; }

span.strong { font-weight: bold; }

span.textmd { font-weight: normal; }

span.textsc { font-variant: small-caps; }

span.textsl { font-style: oblique; }

span.textup { font-variant: normal; }

span.textrm {
    font-family: "DejaVu Serif", "Bitstream Vera Serif",
    "Lucida Bright", Georgia, serif;
}

span.textsf {
     font-family: "DejaVu Sans", "Bitstream Vera Sans",
        Geneva, Verdana, sans-serif ;
}

span.textcircled { border: 1px solid black ; border-radius: 1ex ; }

span.underline {
    text-decoration: underline ;
    text-decoration-skip ;
}


/* For realscripts */
.supsubscript {
    display: inline-block;
    text-align:left ;
}

.supsubscript sup,
.supsubscript sub {
    position: relative;
    display: block;
    font-size: .5em;
    line-height: 1;
}

.supsubscript sup {
    top: .5em;
}

.supsubscript sub {
    top: .5em;
}

span.attribution {
  margin-left: 1em ; font-size: 80% ; font-variant: small-caps;
}

span.citetitle {
  margin-left: 1em ; font-size: 80% ; font-style: oblique;
}

span.poemtitle {
  font-size: 120% ; font-weight: bold;
}

pre.tabbing {
    font-family: "Linux Libertine Mono O", "Lucida Console",
        "Droid Sans Mono", "DejaVu Mono", "Bitstream Vera Mono",
        "Liberation Mono", "FreeMono", "Andale Mono",
        "Nimbus Mono L", "Courier New", monospace;
}

blockquote {
    margin-left: 0px ;
    margin-right: 0px ;
}

/* quotchap is for the quotchap package */
div.quotchap {
  font-style: oblique ;
  overflow-x: auto ;
  margin-left: 2em ;
  margin-right: 2em ;
}

blockquote p, div.quotchap p {
  line-height: 1.5;
    text-align: left ;
    font-size: .85em ;
    margin-left: 3em ;
    margin-right: 3em ;
}

/* qauthor is for the quotchap package */
div.qauthor {
  display: block ;
  text-align: right ;
  margin-left: auto ;
  margin-right: 2em ;
  font-size: 80% ;
  font-variant: small-caps;
}

div.qauthor p {
  text-align: right ;
}

blockquotation {
    margin-left: 0px ;
    margin-right: 0px ;
}

blockquotation p {
  line-height: 1.5;
    text-align: left ;
    font-size: .85em ;
    margin-left: 3em ;
    margin-right: 3em ;
}

div.epigraph, div.dictum {
  line-height: 1.2;
    text-align: left ;
    padding: 3ex 1em 0ex 1em ;
/*     margin: 3ex auto 3ex auto ; */ /* Epigraph centered */
    margin: 3ex 1em 3ex auto ; /* Epigraph to the right */
/*    margin: 3ex 1em 3ex 1em ; */ /* Epigraph to the left */
    font-size: .85em ;
    max-width: 27em ;
}



div.epigraphsource, div.dictumauthor {
    text-align:right ;
    margin-left:auto ;
/*     max-width: 50% ; */
    border-top: 1px solid #A0A0A0 ;
    padding-bottom: 3ex ;
    line-height: 1.2;
}

div.epigraph p, div.dictum p { padding: .5ex ; margin: 0ex ;}
div.epigraphsource p, div.dictumauthor p { padding: .5ex 0ex 0ex 0ex ; margin: 0ex ;}
div.dictumauthor { font-style:italic }


/* lettrine package: */
span.lettrine { font-size: 3ex ; float: left ; }
span.lettrinetext { font-variant: small-caps ; }

/* ulem and soul packages: */
span.uline {
    text-decoration: underline ;
    text-decoration-skip ;
}

span.uuline {
    text-decoration: underline ;
    text-decoration-skip ;
    text-decoration-style: double ;
}

span.uwave {
    text-decoration: underline ;
    text-decoration-skip ;
    text-decoration-style: wavy ;
}

span.sout {
    text-decoration: line-through ;
}

span.xout {
    text-decoration: line-through ;
}

span.dashuline {
    text-decoration: underline ;
    text-decoration-skip ;
    text-decoration-style: dashed ;
}

span.dotuline {
    text-decoration: underline ;
    text-decoration-skip ;
    text-decoration-style: dotted ;
}

span.letterspacing { letter-spacing: .2ex ; }

span.capsspacing {
    font-variant: small-caps ;
    letter-spacing: .1ex ;
}

span.highlight { background: #F8E800 ; }




html body {
  margin: 0 ;
  line-height: 1.2;
}


body div {
  margin: 0ex;
}


h1, h2, h3, h4, h5, h6, span.paragraph, span.subparagraph
{
    font-family: "Linux Libertine O", "Hoefler Text", "Garamond",
        "Bembo", "Janson", "TeX Gyre Pagella", "Palatino",
        "Liberation Serif", "Nimbus Roman No 9 L",  "FreeSerif", Times,
        "Times New Roman", serif;
    font-style: normal ;
    font-weight: bold ;
    text-align: left ;
}

h1 {    /* title of the entire website, used on each page */
    text-align: center ;
    font-size: 2.5em ;
    padding: .4ex 0em 0ex 0em ;
}
h2 { font-size: 2.25em }
h3 { font-size: 2em }
h4 { font-size: 1.75em }
h5 { font-size: 1.5em }
h6 { font-size: 1.25em }
span.paragraph {font-size: 1em ; font-variant: normal ;
    margin-right: 1em ; }
span.subparagraph {font-size: 1em ; font-variant: normal ;
    margin-right: 1em ;  }

div.minisec {
    font-family: "DejaVu Sans", "Bitstream Vera Sans",
        Geneva, Verdana, sans-serif ;
    font-style: normal ;
    font-weight: bold ;
    text-align: left ;
}

/* Title of the file */
h1 {
  margin: 0ex 0em 0ex 0em ;
  line-height: 1.3;
  text-align: center ;
}

/* Part */
h2 {
  margin: 1ex 0em 1ex 0em ;
  line-height: 1.3;
  text-align: center ;
}

/* Chapter */
h3 {
  margin: 3ex 0em 1ex 0em ;
  line-height: 1.3;
}

/* Section */
h4 {
  margin: 3ex 0em 1ex 0em ;
  line-height: 1.3;
}

/* Sub-Section */
h5 {
  margin: 3ex 0em 1ex 0em ;
  line-height: 1.3;
}

/* Sub-Sub-Section */
h6 {
  margin: 3ex 0em 1ex 0em ;
  line-height: 1.3;
}


div.titlepage {
  text-align: center ;
}

.footnotes {
    font-size: .85em ;
    margin: 3ex 1em 0ex 1em ;
    padding-bottom: 1ex ;
    border-top: 1px solid silver ;
}

.marginpar, .marginparblock {
    max-width:50%;
    float:right;
    text-align:left;
    margin: 1ex 0.5em 1ex 1em ;
    padding: 1ex 0.5em 1ex 0.5em ;
    font-size: 85% ;
    border-top: 1px solid silver ;
    border-bottom: 1px solid silver ;
    overflow-x: auto;
}

.marginpar br { margin-bottom: 2ex ; }

div.marginblock, div.marginparblock {
    max-width:50%;
    float:right;
    text-align:left;
    margin: 1ex 0.5em 1ex 1em ;
    padding: 1ex 0.5em 1ex 0.5em ;
    overflow-x: auto;
}

div.marginblock div.minipage,
div.marginparblock div.minipage {
    display: block ;
    margin: 0pt auto 0pt auto ;
}

div.marginblock div.minipage p ,
div.marginparblock div.minipage p
    { font-size: 85%}

div.marginblock br ,
div.marginparblock br
    { margin-bottom: 2ex ; }


section.textbody div.footnotes{
    margin: 3ex 0em 0ex 0em ;
    border-bottom: 2px solid silver ;
}

.footnoteheader {
    border-top: 2px solid silver ;
    margin-top: 3ex ;
    padding-top: 1ex ;
    font-weight: bold ;
}

.mpfootnotes {
    text-align: left ;
    font-size: .85em ;
    margin-left: 1em ;
    border-top: 1px solid silver ;
}

/* Remove footnote top border in the title page. */
div.titlepage div.mpfootnotes {
    border-top: none ;
}



ol {
  margin: 1ex 1em 1ex 0em;
  line-height: 1.2;
}

ul, body dir, body menu {
  margin: 1ex 1em 1ex 0em;
  line-height: 1.2;
}

li { margin: 0ex 0em 1ex 0em; }

html {
  margin: 0; 
  padding: 0;
}

.programlisting {
  font-family: "DejaVu Mono", "Bitstream Vera Mono", "Lucida Console",
        "Nimbus Mono L", "Liberation Mono", "FreeMono", "Andale Mono",
        "Courier New", monospace;
  margin: 1ex 0ex 1ex 0ex ;
  padding: .5ex 0pt .5ex 0pt ;
  overflow-x: auto;
}

section.textbody>pre.programlisting {
border-top: 1px solid silver ;
border-bottom: 1px solid silver ;
}


.inlineprogramlisting {
  font-family: "DejaVu Mono", "Bitstream Vera Mono", "Lucida Console",
        "Nimbus Mono L", "Liberation Mono", "FreeMono", "Andale Mono",
        "Courier New", monospace;
  overflow-x: auto;
}

span.listinglabel {
    display: inline-block ;
    font-size: 70% ;
    width: 4em ;
    text-align: right ;
    margin-right: 2em ;
}

div.abstract {
  margin: 2em 5% 2em 5% ;
  padding: 1ex 1em 1ex 1em ;
/*  font-weight: bold ; */
  font-size: 90% ;
    text-align: left ;
}

div.abstract dl {line-height:1.5;}
div.abstract dt {color:#304070;}

div.abstracttitle{
    font-family: "URW Classico", Optima, "Linux Biolinum O",
        "Linux Libertine O", "Liberation Serif", "Nimbus Roman No 9 L",
        "FreeSerif", "Hoefler Text", Times, "Times New Roman", serif;
    font-weight:bold;
    font-size:1.25em;
    text-align: center ;
}

span.abstractrunintitle{
    font-family: "URW Classico", Optima, "Linux Biolinum O",
        "Linux Libertine O", "Liberation Serif", "Nimbus Roman No 9 L",
        "FreeSerif", "Hoefler Text", Times, "Times New Roman", serif;
    font-weight:bold;
}


.verbatim {
    overflow-x: auto ;
}

.alltt {
    overflow-x: auto ;
}


.bverbatim {
    margin: 1ex 0pt 1ex 0pt ;
    padding: .5ex 0pt .5ex 0pt ;
    overflow-x: auto ;
}

.lverbatim {
    margin: 1ex 0pt 1ex 0pt ;
    padding: .5ex 0pt .5ex 0pt ;
    overflow-x: auto ;
}

.fancyvrb {
    font-size:.85em ;
    margin: 3ex 0pt 3ex 0pt
}

.fancyvrblabel {
    font-weight:bold;
    text-align: center ;
}


.verse {
    font-family: "Linux Libertine Mono O", "Lucida Console",
        "Droid Sans Mono", "DejaVu Mono", "Bitstream Vera Mono",
        "Liberation Mono", "FreeMono", "Andale Mono",
        "Nimbus Mono L", "Courier New", monospace;
    margin-left: 1em ;
}


div.singlespace { line-height: 1.2 ; }
div.onehalfspace { line-height: 1.5 ; }
div.doublespace { line-height: 2 ; }


/* Word processor format output: */
div.wpfigure { border: 1px solid red ; margin: .5ex ; padding: .5ex ; }
div.wptable { border: 1px solid blue ; margin: .5ex ; padding: .5ex ; }
div.wpminipage { border: 1px solid green ; margin: .5ex ; padding: .5ex ;}




/* Minipage environments, vertically aligned to top, center, bottom: */
.minipage, .fminipage, .fcolorminipage {
    /* display: inline-block ; */
        /* Mini pages which follow each other will be tiled. */
    margin: .25em .25em .25em .25em;
    padding: .25em .25em .25em .25em;
    display: inline-flex;
    flex-direction: column ;
    overflow: auto;
}

/* Paragraphs in the flexbox did not collapse their margins. */
/* Have not yet researched this. */
.minipage p {margin: .75ex 0em .75ex 0em ;}

.fboxBlock .minipage, .colorbox .minipage, .colorboxBlock .minipage,
.fcolorbox .minipage, .fcolorboxBlock .minipage
    {border: none ; background: none;}

.fbox, .fboxBlock { border: 1px solid black ; }

.fbox, .fboxBlock, .fcolorbox, .fcolorboxBlock, .colorbox, .colorboxBlock,
.fminipage, .fcolorminipage
    {display: inline-block}

.shadowbox, .shabox {
   border: 1px solid black;
    box-shadow: 3px 3px 3px #808080 ;
     border-radius: 0px ;
    padding: .4ex .3em .4ex .3em ;
    margin: 0pt .3ex 0pt .3ex ;
  display: inline-block ;
}

.doublebox {
   border: 3px double black;
     border-radius: 0px ;
    padding: .4ex .3em .4ex .3em ;
    margin: 0pt .3ex 0pt .3ex ;
  display: inline-block ;
}

.ovalbox, .Ovalbox {
   border: 1px solid black;
     border-radius: 1ex ;
    padding: .4ex .3em .4ex .3em ;
    margin: 0pt .3ex 0pt .3ex ;
  display: inline-block ;
}

.Ovalbox { border-width: 2px ; }

.framebox {
   border: 1px solid black;
     border-radius: 0px ;
    padding: .3ex .2em 0ex .2em ;
    margin: 0pt .1ex 0pt .1ex ;
  display: inline-block ;
}


.mdframed {
/*     padding: 0ex ; */
/*    border: 1px solid blafck; */
/*      border-radius: 0px ; */
    padding: 0ex ;
    margin: 3ex 5% 3ex 5% ;
/*   display: inline-block ; */
}

.mdframed p { padding: 0ex .5em 0ex .5em ; }

.mdframed dl { padding: 0ex .5em 0ex .5em ; }

.mdframedtitle {
    padding: .5em ;
    display: block ;
    font-size: 130%
}

.mdframedsubtitle {
    padding: 0ex .5em 0ex .5em ;
    display: block ;
    font-size: 115% ;
}

.mdframedsubsubtitle {
    padding: 0ex .5em 0ex .5em ;
    display: block ;
}

.mdtheorem {
    padding: 0ex .5em 0ex .5em ;
    margin: 3ex 5% 3ex 5% ;
/*   display: inline-block ; */
}


/* framed package */
.framed, pre.boxedverbatim, fcolorbox {
    margin: 3ex 0em 3ex 0em ;
   border: 1px solid black;
     border-radius: 0px ;
    padding: .3ex 1em 0ex 1em ;
  display: block ;
}

.snugframed {
    margin: 3ex 0em 3ex 0em ;
   border: 1px solid black;
     border-radius: 0px ;
  display: block ;
}

.framedleftbar {
    margin: 3ex 0em 3ex 0em ;
   border-left: 3pt solid black;
     border-radius: 0px ;
    padding: .3ex .2em .3ex 1em ;
  display: block ;
}

.framedtitle {
    margin: 0em ;
    padding: 0em ;
    font-size: 130%
}

.framedtitle p { padding: .3em }



dl {
  margin: 1ex 2em 1ex 0em;
  line-height: 1.3;
}

dl dt {
    margin-top: 1ex;
    margin-left: 1em ;
    font-weight: bold;
}

dl dd p { margin-top: 0em; }


nav {
    font-family: "URW Classico", Optima, "Linux Biolinum O",
        "DejaVu Sans", "Bitstream Vera Sans",
        Geneva, Verdana, sans-serif ;
    margin-bottom: 4ex ;
}

nav p {
    line-height: 1.2 ;
    margin-top:.5ex ;
    margin-bottom:.5ex;
    font-size: .9em ;
}



img, img.hyperimage, img.borderimage {
    max-width: 600px;
    border: 1px solid silver;
    box-shadow: 3px 3px 3px #808080 ;
    padding: .5% ;
    margin: .5% ;
    background: none ;
}

img.inlineimage{
    padding: 0px ;
    box-shadow: none ;
    border: none ;
    background: none ;
    margin: 0px ;
    display: inline-block ;
    border-radius: 0px ;
}

img.logoimage{
    max-width: 300px ;
    box-shadow: 3px 3px 3px #808080 ;
    border: 1px solid black ;
    background:none ;
    padding:0 ;
    margin:.5ex ;
    border-radius: 10px ;
}


.section {
/*
    To have each section float relative to each other:
*/
/*
    display: block ;
    float: left ;
    position: relative ;
    background: white ;
    border: 1px solid silver ;
    padding: .5em ;
*/
    margin: 0ex .5em 0ex .5em ;
    padding: 0 ;
}


figure {
    margin: 3ex auto 3ex auto ;
    padding: 1ex 1em 1ex 1em ;
    overflow-x: auto ;
}


/* To automatically center images in figures: */
/*
figure img.inlineimage {
    margin: 0ex auto 0ex auto ;
    display: block ;
}
*/

/* To automatically center minipages in figures: */
/*
figure div.minipage, figure div.minipage div.minipage {
    margin: 1ex auto 1ex auto ;
    display: block ;
}
*/

figure div.minipage p { font-size: 85% ; }

figure.subfigure, figure.subtable  {
    display: inline-block ; margin: 3ex 1em 3ex 1em ;
}

figcaption .minipage { margin:0 ; padding: 0 }

div.minipage figure { border: none ; box-shadow: none ; }

div.floatrow { text-align: center; }

div.floatrow figure { display: inline-block ; margin: 1ex 2% ; }

div.floatfoot { font-size: .85em ;
    border-top: 1px solid silver ; line-height: 1.2 ; }

figcaption , .lstlistingtitle {
    font-size: .85em ;
    text-align: center ;
    font-weight: bold ;
    margin-top: 1ex ;
    margin-bottom: 1ex ;
}

figure.subfigure figcaption, figure.subtable figcaption  {
    border-bottom: none ; background: none ;
}

div.nonfloatcaption {
    margin: 1ex auto 1ex auto ;
    font-size: .85em ;
    text-align: center ;
    font-weight: bold ;
}

/* For a \RawCaption inside a minipage inside a figure's floatrow: */
figure div.floatrow div.minipage figcaption {
    border: none ;
    background: none ;
}


table {
    margin: 1ex auto 1ex auto ;
    border-collapse: separate ;
    border-spacing: 0px ;
    line-height: 1.3 ;
    }

tr.hline td {border-top: 1px solid #808080 ; margin-top: 0ex ;
    margin-bottom: 0ex ; } /* for \hline */

tr.tbrule td {border-top: 1px solid black ; margin-top: 0ex ;
    margin-bottom: 0ex ; } /* for \toprule, \bottomrule */

td {padding: 1ex .5em 1ex .5em ;}

table td.tdl { text-align: left ; vertical-align: middle ; }
table td.tdc { text-align: center ; vertical-align: middle ; }
table td.tdat { text-align: center ; vertical-align: middle ; padding: 0px ; margin: 0px ; }
table td.tdbang { text-align: center ; vertical-align: middle ; }
table td.tdr { text-align: right ; vertical-align: middle ; }
table td.tdp { text-align: left ; vertical-align: bottom ; }
table td.tdm { text-align: left ; vertical-align: middle ; }
table td.tdb { text-align: left ; vertical-align: top ; }
table td.tdP { text-align: center ; vertical-align: bottom ; }
table td.tdM { text-align: center ; vertical-align: middle ; }
table td.tdB { text-align: center ; vertical-align: top ; }

table td.tvertbarl { border-left: 1px solid black }
table td.tvertbarr { border-right: 1px solid black }


/* for cmidrules: */
table td.tdrule {
    border-top: 1px solid #A0A0A0 ;
}

table td.tdrulel {
    border-top-left-radius:.5em ; 
    border-top: 1px solid #A0A0A0 ;
}

table td.tdruler {
    border-top-right-radius:.5em ; 
    border-top: 1px solid #A0A0A0 ;
}

table td.tdrulelr {
    border-top-left-radius:.5em ; 
    border-top-right-radius:.5em ; 
    border-top: 1px solid #A0A0A0 ;
}


/* Margins of paragraphs inside table cells: */
td.tdp p , td.tdprule p , td.tdP p , td.tdPrule p { padding-top: 1ex ;
    padding-bottom: 1ex ; margin: 0ex ; }
td.tdm p , td.tmbrule p , td.tdM p , td.tdMrule p { padding-top: 1ex ;
    padding-bottom: 1ex ; margin: 0ex ; }
td.tdb p , td.tdbrule p , td.tdB p , td.tdBrule p { padding-top: 1ex ;
    padding-bottom: 1ex ; margin: 0ex ; }

td.tdp , td.tdprule , td.tdP , td.tdPrule
    { padding: 0ex .5em 0ex .5em ; }
td.tdm , td.tdmrule , td.tdM , td.tdMrule
    { padding: 0ex .5em 0ex .5em ; }
td.tdb , td.tdbrule , td.tdB , td.tdBrule
    { padding: 0ex .5em 0ex .5em ; }


/* table notes: */
.tnotes {
    margin: 0ex 5% 1ex 5% ;
    padding: 0.5ex 1em 0.5ex 1em;
    font-size:.85em;
    text-align: left ;
}

.tnotes dl dt p {margin-bottom:0px;}

.tnoteitemheader {margin-right: 1em;}


/* for bigdelim */
.ldelim, .rdelim { font-size: 200% }


/* center, flushleft, flushright environments */
div.center{text-align:center;}
div.center table {margin-left:auto;margin-right:auto;}
div.flushleft{text-align:left;}
div.flushleft table {margin-left:0em ; margin-right:auto;}
div.flushright{text-align:right;}
div.flushright table {margin-left:auto ; margin-right: 0em ;}


/* Fancybox */
div.Btrivlist table tr td { padding: .2ex 0em ; }


/* program listing callouts: */
span.callout {
     font-family: "DejaVu Sans", "Bitstream Vera Sans",
        Geneva, Verdana, sans-serif ;
    border-radius: .5em;
    background-color:black;
    color:white;
    padding:0px .25em 0px .25em;
    margin: 0 ;
    font-weight: bold;
    font-size:.72em ;
}

div.programlisting pre.verbatim span.callout{
    font-size: .85em ;
}





div.published
{
    text-align: center ;
    font-variant: normal ;
    font-style: italic ;
    font-size: 1em ;
    margin: 3ex 0em 3ex 0em ;
}

div.subtitle
{
    text-align: center ;
    font-variant: normal ;
    font-style: italic ;
    font-size: 1.25em ;
    margin: 3ex 0em 3ex 0em ;
}

div.subtitle p { margin: 1ex ; }

div.author
{
    font-variant: normal ;
    font-style: normal ;
    font-size: 1em ;
    margin: 3ex 0em 3ex 0em ;
}

div.oneauthor {
    display: inline-block ;
    margin: 3ex 1em 0ex 1em ;
}

/*
div.author table {
    margin: 3ex auto 0ex auto ;
    background: none ;
}

div.author table tbody tr td { padding: .25ex ; }
*/

span.affiliation {font-size: .85em ; font-variant: small-caps; }

div.titledate {
    text-align: center ;
    font-size: .85em ;
    font-style: italic;
    margin: 6ex 0em 6ex 0em ;
}


nav.topnavigation{ 
    text-align: left ;
    padding: 0.5ex 1em 0.5ex 1em ;
/*     margin: 2ex 0em 3ex 0em ; */
    margin: 0 ;
    border-bottom: 1px solid silver ;
    border-top: 1px solid silver ;
    clear:right ;
}

nav.botnavigation{ 
    text-align: left ;
    padding: 0.5ex 1em 0.5ex 1em ;
/*     margin: 3ex 0em 2ex 0em ; */
    margin: 0 ;
    border-top: 1px solid silver ;
    border-bottom: 1px solid silver ;
    clear:right ;
}


header{
    line-height: 1.2 ;
    font-size: 1em ;
/*     border-bottom: 2px solid silver ; */
    margin: 0px ;
    padding: 0ex 1em 0ex 1em ;
    text-align:center ;
}

header p {margin:0ex;padding:4ex 0em 2ex 0em ;text-align:center;}


footer{
    font-size: .85em ;
    line-height: 1.2 ;
    margin-top: 1ex ;
    border-top: 2px solid silver ;
    padding: 2ex 1em 2ex 1em ;
    clear:right ;
    text-align:left ;
}


a.linkhome { font-weight:bold ; font-size: 1em ;}


div.lateximagesource { padding: 0px ; margin: 0px ; display: none; }

img.lateximage{
    padding: 0px 0px 0px 0px ;
    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 ;
}



nav.sidetoc {
    font-family: "DejaVu Serif", "Bitstream Vera Serif",
        "Lucida Bright", Georgia, serif;
    float:right ;
    width: 20%;
    border-left: 1px solid silver;
    border-top: 1px solid silver;
    border-bottom: 1px solid silver;
/*     border-top: 2px solid #808080 ; */
    background: #FAF7F4 ;
    padding: 2ex 0em 2ex 1em ;
    margin: 0ex 0em 2ex 1em ;
    font-size:.9em ;
    border-radius: 20px 0px 0px 20px ;
    }

div.sidetoccontents {
/*     border-top: 1px solid silver ; */
    overflow-y: auto ;
    width: 100% ;
    text-align: left ;
}


nav.sidetoc p {line-height:1.2 ; margin: 1ex .5em 1ex .5em ;
    text-indent: 0 ; }

nav.sidetoc p a {color:black ; font-size: .7em ;}

div.sidetoctitle {font-size: 1.2em; font-weight:bold; text-align:center;
    border-bottom: 1px solid silver ;    }

nav.sidetoc a:hover {text-decoration: underline ; }



section.textbody { margin: 0ex 1em 0ex 1em ;}


div.multicolsheading { -webkit-column-span: all;
    -moz-column-span: all; column-span: all; }
div.multicols { -webkit-columns: 3 380px ;
    -moz-columns: 3 380px ; columns: 3 380px ; }
div.multicols p {margin-top: 0ex}



/* Used to support algorithmicx: */
span.floatright { float: right ; }




/* Native LaTeX theorems: */

.theoremcontents { font-style: italic; margin-top: 3ex ; margin-bottom: 3ex ; }
.theoremlabel { font-style: normal; font-weight: bold ; margin-right: .5em ; }


/* theorem, amsthm, and ntheorem packages */

span.theoremheader, 
span.theoremheaderplain,
span.theoremheaderdefinition,
span.theoremheaderbreak,
span.theoremheadermarginbreak,
span.theoremheaderchangebreak,
span.theoremheaderchange,
span.theoremheadermargin
{
    font-style:normal ; font-weight: bold ; margin-right: 1em ;
}

span.amsthmnameplain,
span.amsthmnamedefinition,
span.amsthmnumberplain,
span.amsthmnumberdefinition
{
    font-style:normal ; font-weight: bold ;
}


span.amsthmnameremark,
span.amsthmnumberremark
{font-style:italic ; font-weight: normal ; }


span.amsthmnoteplain,
span.amsthmnotedefinition
{font-style:normal ;}


span.theoremheaderremark,
span.theoremheaderproof,
span.amsthmproofname
{font-style:italic ; font-weight: normal ; margin-right: 1em ; }

span.theoremheadersc
{
    font-style:normal ;
    font-variant: small-caps ;
    font-weight: normal ;
    margin-right: 1em ;
}

.theoremendmark {float:right}

div.amsthmbodyplain, div.theorembodyplain, div.theorembodynonumberplain,
div.theorembodybreak, div.theorembodynonumberbreak,
div.theorembodymarginbreak,
div.theorembodychangebreak,
div.theorembodychange,
div.theorembodymargin
{
    font-style:italic;
    margin-top: 3ex ; margin-bottom: 3ex ;
}

div.theorembodydefinition, div.theorembodyremark, div.theorembodyproof,
div.theorembodyplainupright, nonumberplainuprightsc,
div.amsthmbodydefinition, div.amsthmbodyremark,
div.amsthmproof
{
    font-style: normal ;
    margin-top: 3ex ; margin-bottom: 3ex ;
}

span.amsthmnoteremark {}



/*
For CSS LaTeX and related logos:
Based on:
http://edward.oconnor.cx/2007/08/tex-poshlet
http://nitens.org/taraborelli/texlogo
*/

.latexlogofont {
    font-family: "Linux Libertine O", "Nimbus Roman No 9 L",
        "FreeSerif", "Hoefler Text", Times, "Times New Roman", serif;
    font-variant: normal ;
}

.latexlogo {
    font-family: "Linux Libertine O", "Nimbus Roman No 9 L",
        "FreeSerif", "Hoefler Text", Times, "Times New Roman", serif;
    letter-spacing: .03em ;
    font-size: 1.1em;
}

.latexlogo sup {
  text-transform: uppercase;
  letter-spacing: .03em ;
  font-size: 0.85em;
  vertical-align: 0.15em;
  margin-left: -0.36em;
  margin-right: -0.15em;
}

.latexlogo sub {
  text-transform: uppercase;
  vertical-align: -0.5ex;
  margin-left: -0.1667em;
  margin-right: -0.125em;
  font-size: 1em;
}

.xetexlogo {
    font-family: "Linux Libertine O", "Nimbus Roman No 9 L",
        "FreeSerif", "Hoefler Text", Times, "Times New Roman", serif;
    letter-spacing: .03em ;
    font-size: 1.1em;
}

/* A smaller gap between Xe and Tex v.s. LaTeX: */
.xetexlogo sub {
  text-transform: uppercase;
  vertical-align: -0.5ex;
  margin-left: -0.0667em;
  margin-right: -0.2em;
  font-size: 1em;
  letter-spacing: .03em ;
}

/* A large gap between Xe and LaTeX v.s. TeX: */
.xelatexlogo sub {
  text-transform: uppercase;
  vertical-align: -0.5ex;
  margin-left: -0.0667em;
  margin-right: -.05em;
  font-size: 1em;
  letter-spacing: .03em ;
}

.amslogo {
    font-family: "TeXGyreChorus","URW Chancery L",
        "Apple Chancery","ITC Zapf Chancery","Monotype Corsiva",
        "Linux Libertine O", "Nimbus Roman No 9 L",  "FreeSerif",
        "Hoefler Text", Times, "Times New Roman", serif;
  font-style: italic;
}

.lyxlogo {
    font-family: "URW Classico", Optima, "Linux Biolinum O",
        "DejaVu Sans", "Bitstream Vera Sans", Geneva,
        Verdana, sans-serif ;
}




/* Only display top and bottom navigation if a small screen: */
/* Hide the sidetoc if a small screen: */
nav.topnavigation { display:none; }
nav.botnavigation { display:none; }

@media screen and (max-width: 45em) {
/*     nav.sidetoc {display:none;} */
    nav.sidetoc {
        float: none ;
        width: 100% ;
        margin: 5ex 0px 5ex 0px ;
        padding: 0 ;
        border-radius: 0 ;
        border-bottom: 1px solid black ;
        border-top: 1px solid black ;
        box-shadow: none ;
    }
/*     nav.topnavigation { display:block } */
    nav.botnavigation { display:block }
    .marginpar {
        max-width: 100%;
        float: none;
        display:block ;
        margin: 1ex 1em 1ex 1em ;
    }
}

@media print {
    body {
        font-family: "Linux Libertine O",
        "DejaVu Serif", "Bitstream Vera Serif",
        "Liberation Serif", "Nimbus Roman No 9 L",
        "FreeSerif", "Hoefler Text", Times, "Times New Roman", serif;
    }
    nav.sidetoc { display:none; }
    nav.topnavigation { display: none; }
    nav.botnavigation { display: none; }
}

@media handheld {
    nav.sidetoc { display:none; }
    nav.topnavigation { display:block }
    nav.botnavigation { display:block }
}

@media projection {
    nav.sidetoc { display:none; }
    nav.topnavigation { display:block }
    nav.botnavigation { display:block }
}
\end{filecontents*}
% \end{Verbatim}% for syntax highlighting
\end{warpprint}
%    \end{macrocode}




% \subsection{lwarp\_sagebrush.css}

% \DescribeFile{lwarp_sagebrush.css}
% An optional \CSS\ which may be used for
% a semi-modern appearance.
%
% If used, this must be present both when compiling the project
% and also when distributing the \HTML\ files.
%
%    \begin{macrocode}
\begin{warpprint}
\begin{filecontents*}{lwarp_sagebrush.css}
@import url("lwarp.css") ;


A:link {color:#105030 ; text-decoration: none ; }
A:visited {color:#705030 ; text-shadow:1px 1px 2px #a0a0a0;}
A:hover {color:#006000 ; text-decoration: underline ; text-shadow:0px 0px 2px #a0a0a0;}
A:active {color:#00C000 ; text-shadow:1px 1px 2px #a0a0a0;}



h1, h2, h3, h4, h5, h6, span.paragraph, span.subparagraph
{
    font-family: "URW Classico", Optima, "Linux Biolinum O",
        "Linux Libertine O", "Liberation Serif",
        "Nimbus Roman No 9 L",  "FreeSerif",
        "Hoefler Text", Times, "Times New Roman", serif;
    font-variant: small-caps ;
    font-weight: normal ;
    color: #304070 ;
    text-shadow: 2px 2px 3px #808080;
}

h1 {    /* title of the entire website, used on each page */
    font-variant: small-caps ;
    color: #304070 ;
    text-shadow: 2px 2px 3px #808080;
    background-color: #F7F7F0 ;
    background-image: linear-gradient(to bottom, #F7F7F0, #C0C0C4);
}

h1 {
  border-bottom: 1px solid #304070;
  border-top: 2px solid #304070;
}

h2 {
  border-bottom: 1px solid #304070;
  border-top: 2px solid #304070;
    background-color: #F7F7F0 ;
    background-image: linear-gradient(to bottom, #F7F7F0, #DAD0C0);
}



div.abstract {
    background: #f5f5eb ;
    background-image: linear-gradient(to bottom, #f5f5eb, #C8C8B8);

  border: 1px solid silver;
    border-radius: 1em ;
}

div.abstract dl {line-height:1.5;}
div.abstract dt {color:#304070;}

div.abstracttitle{
    font-family: "URW Classico", Optima, "Linux Biolinum O",
        "Linux Libertine O", "Liberation Serif", "Nimbus Roman No 9 L",
        "FreeSerif", "Hoefler Text", Times, "Times New Roman", serif;
    font-weight:bold;
    font-variant: small-caps ;
    font-size:1.5em;
    border-bottom: 1px solid silver ;
    color: #304070 ;
    text-align: center ;
    text-shadow: 1px 1px 2px #808080;
}

span.abstractrunintitle{
    font-family: "URW Classico", Optima, "Linux Biolinum O",
        "Linux Libertine O", "Liberation Serif", "Nimbus Roman No 9 L",
        "FreeSerif", "Hoefler Text", Times, "Times New Roman", serif;
    font-weight:bold;
}


div.epigraph, div.dictum {
    background: #f5f5eb ;
    background-image: linear-gradient(to bottom, #f5f5eb, #C8C8B8);

    border: 1px solid silver ;
    border-radius: 1ex ;
    box-shadow: 3px 3px 3px #808080 ;
}


.example {
    background-color: #f5f5eb ;
    background-image: linear-gradient(to bottom, #f5f5eb, #C8C8B8);

}

div.exampletitle{
    font-family: "URW Classico", Optima, "Linux Biolinum O",
        "Linux Libertine O", "Liberation Serif", "Nimbus Roman No 9 L",
        "FreeSerif", "Hoefler Text", Times, "Times New Roman", serif;
    font-weight:bold;
    font-variant: small-caps ;
    border-bottom: 1px solid silver ;
    color: #304070 ;
    text-align: center ;
    text-shadow: 1px 1px 2px #808080;
}


.sidebar {
    background-color: #f5f5eb ;
    background-image: linear-gradient(to bottom, #f5f5eb, #C8C8B8);

}

div.sidebartitle{
    font-family: "URW Classico", Optima, "Linux Biolinum O",
        "Linux Libertine O", "Liberation Serif", "Nimbus Roman No 9 L",
        "FreeSerif", "Hoefler Text", Times, "Times New Roman", serif;
    font-weight:bold;
    font-variant: small-caps ;
    border-bottom: 1px solid silver ;
    color: #304070 ;
    text-align: center ;
    text-shadow: 1px 1px 2px #808080;
}


.fancyvrblabel {
    font-family: "URW Classico", Optima, "Linux Biolinum O",
        "Linux Libertine O", "Liberation Serif", "Nimbus Roman No 9 L",
        "FreeSerif", "Hoefler Text", Times, "Times New Roman", serif;
    font-weight:bold;
    font-variant: small-caps ;
    font-size: 1.5em ;
    color: #304070 ;
    text-align: center ;
    text-shadow: 1px 1px 2px #808080;
}



div.minipage {
    background-color: #eeeee7 ;
    border: 1px solid silver ;
    border-radius: 1ex ;
}

section.textbody > div.minipage {
    box-shadow: 3px 3px 3px #808080 ;
}

div.fboxBlock div.minipage { box-shadow: none ; }

.framed .minipage , .framedleftbar .minipage {
    border: none ;
    background: none ;
    padding: 0ex ;
    margin: 0ex ;
}

figure.figure .minipage, figcaption .minipage { border: none; }

div.marginblock div.minipage ,
div.marginparblock div.minipage
    { border: none; }

figure , div.marginblock {
    background-color: #eeeee7 ;
    border: 1px solid silver ;
    border-radius: 1ex ;
    box-shadow: 3px 3px 3px #808080 ;
}

figure figure {
    border: 1px solid silver ;
    margin: 0em ;
    box-shadow: none ;
}

/*
figcaption {
    border-top: 1px solid silver ;
    border-bottom: 1px solid silver ;
    background-color: #e8e8e8 ;
}
*/


div.table {
    box-shadow: 3px 3px 3px #808080 ;
}

/*
.tnotes {
    background: #e8e8e8;
    border: 1px solid silver;
}
*/


nav.topnavigation{ 
    background-color: #b0b8b0 ;
    background-image: linear-gradient(to bottom,#e0e0e0,#b0b8b0) ;
}

nav.botnavigation{ 
    background-color: #b0b8b0 ;
    background-image: linear-gradient(to top,#e0e0e0,#b0b8b0) ;
}



header{
    background-color: #F7F7F0 ;
    background-image: linear-gradient(to top, #F7F7F0, #b0b8b0);
}

footer{
    background-color: #F7F7F0 ;
    background-image: linear-gradient(to bottom, #F7F7F0, #b0b8b0);
}



nav.sidetoc {
    background-color: #F7F7F0 ;
    background-image: linear-gradient(to bottom, #F7F7F0, #C0C0C0);
    box-shadow: 3px 3px 3px #808080 ;
    border-radius: 0px 0px 0px 20px ;
    }

div.sidetoctitle {color: #304070 ; }

nav.sidetoc a:hover {
    color:#006000 ;
    text-decoration: none ;
    text-shadow:0px 0px 2px #a0a0a0;
}


@media screen and (max-width: 45em) {
    nav.sidetoc { border-radius: 0 ; }
}


\end{filecontents*}
% \end{Verbatim}% for syntax highlighting
\end{warpprint}
%    \end{macrocode}




% \subsection{lwarp\_formal.css}

% \DescribeFile{lwarp_formal.css}
% An optional \CSS\ which may be used for
% a more formal appearance.
%
% If used, this must be present both when compiling the project
% and also when distributing the \HTML\ files.
%
%    \begin{macrocode}
\begin{warpprint}
\begin{filecontents*}{lwarp_formal.css}
@import url("lwarp.css") ;



A:link {color:#802020 ; text-decoration:none; }
A:visited {color:#802020 ; text-shadow:none ;}
A:hover {color:#400000 ; text-shadow:none ;}
A:active {color:#C00000 ; text-shadow:none ;}


body {
    font-family: "Linux Libertine O", "Hoefler Text", "Garamond",
        "Bembo", "Janson", "TeX Gyre Pagella", "Palatino",
        "Liberation Serif", "Nimbus Roman No 9 L",  "FreeSerif", Times,
        "Times New Roman", serif;
    background: #fffcf5;
}

span.textrm {
    font-family: "Linux Libertine O", "Hoefler Text", "Garamond",
        "Bembo", "Janson", "TeX Gyre Pagella", "Palatino",
        "Liberation Serif", "Nimbus Roman No 9 L",  "FreeSerif", Times,
        "Times New Roman", serif;
}

span.textsf {
     font-family: "DejaVu Sans", "Bitstream Vera Sans",
        Geneva, Verdana, sans-serif ;
}



h1, h2, h3, h4, h5, h6, span.paragraph, span.subparagraph
{
    font-family: "Linux Libertine O", "Hoefler Text", "Garamond",
        "Bembo", "Janson", "TeX Gyre Pagella", "Palatino",
        "Liberation Serif", "Nimbus Roman No 9 L",  "FreeSerif", Times,
        "Times New Roman", serif;
    color: #800000 ;
    text-shadow: none ;
}

h1, h2 {
    background-color: #fffcf5 ;
    background-image: none ;
    border-bottom: 1px solid #808080;
    border-top: 2px solid #808080;
}

div.abstracttitle {
    font-family: "Linux Libertine O", "Hoefler Text", "Garamond",
        "Bembo", "Janson", "TeX Gyre Pagella", "Palatino",
        "Liberation Serif", "Nimbus Roman No 9 L",  "FreeSerif", Times,
        "Times New Roman", serif;
    color: black ;
    text-shadow: none ;
}

span.abstractrunintitle {
    font-family: "Linux Libertine O", "Hoefler Text", "Garamond",
        "Bembo", "Janson", "TeX Gyre Pagella", "Palatino",
        "Liberation Serif", "Nimbus Roman No 9 L",  "FreeSerif", Times,
        "Times New Roman", serif;
    color: black ;
    text-shadow: none ;
}

div.abstract { font-size: 100% }

.sidebar {
    background: #fffcf5;
    background-image: none ;
  margin: 2em 5% 2em 5%;
  padding: 0.5em 1em;
  border: none ;
  border-top : 1px solid silver;
  border-bottom : 1px solid silver;
  font-size: 90% ;
}

div.sidebartitle{
    font-family: "Linux Libertine O", "Hoefler Text", "Garamond",
        "Bembo", "Janson", "TeX Gyre Pagella", "Palatino",
        "Liberation Serif", "Nimbus Roman No 9 L",  "FreeSerif", Times,
        "Times New Roman", serif;
    color: #800000 ;
    text-shadow: none ;
    border: none ;
}

.example {
    background: #fffcf5;
    background-image: none ;
  margin: 2em 5% 2em 5%;
  padding: 0.5em 1em;
  border: none ;
  border-top : 1px solid silver;
  border-bottom : 1px solid silver;
}

div.exampletitle{
    font-family: "Linux Libertine O", "Hoefler Text", "Garamond",
        "Bembo", "Janson", "TeX Gyre Pagella", "Palatino",
        "Liberation Serif", "Nimbus Roman No 9 L",  "FreeSerif", Times,
        "Times New Roman", serif;
    color: #800000 ;
    text-shadow: none ;
    border: none ;
}

div.fancyvrblabel{
    font-family: "Linux Libertine O", "Hoefler Text", "Garamond",
        "Bembo", "Janson", "TeX Gyre Pagella", "Palatino",
        "Liberation Serif", "Nimbus Roman No 9 L",  "FreeSerif", Times,
        "Times New Roman", serif;
    color: #800000 ;
    text-shadow: none ;
    border: none ;
}



.verse {
    font-family: "Linux Libertine O", "Hoefler Text", "Garamond",
        "Bembo", "Janson", "TeX Gyre Pagella", "Palatino",
        "Liberation Serif", "Nimbus Roman No 9 L",  "FreeSerif", Times,
        "Times New Roman", serif;
}


figure {
    margin: 3ex 5% 3ex 5% ;
    padding: 1ex 1em 1ex 1em ;
    background-color: #fffcf5 ;
    overflow-x: auto ;
    border: none ;
/*     border-top: 1px solid silver; */
/*     border-bottom: 1px solid silver; */
}


figcaption , .lstlisting {
    border: none ;
/*     border-top: 1px solid silver ; */
/*     border-bottom: 1px solid silver ; */
    background-color: #fffcf5 ;
}

.tnotes {
    background: #fffcf5 ;
}

.theorem {
        background: none ;
}

.minipage {
    background-color: #fffcf5 ;
    border: none ;
}

div.floatrow figure { border: none ; }

figure figure { border: none ; }


nav.toc, nav.lof, nav.lot, nav.lol {
    font-family: "Linux Libertine O", "Hoefler Text", "Garamond",
        "Bembo", "Janson", "TeX Gyre Pagella", "Palatino",
        "Liberation Serif", "Nimbus Roman No 9 L",  "FreeSerif", Times,
        "Times New Roman", serif;
}

nav.sidetoc {
    font-family: "Linux Libertine O", "Hoefler Text", "Garamond",
        "Bembo", "Janson", "TeX Gyre Pagella", "Palatino",
        "Liberation Serif", "Nimbus Roman No 9 L",  "FreeSerif", Times,
        "Times New Roman", serif;
    background-image: linear-gradient(to bottom, #fffcf5, #C0C0C0);
    border-radius: 0px 0px 0px 20px ;
}

div.sidetoctitle{
    color: #800000 ;
}

header{
    background-color: #e0e0e0 ;
    background-image: linear-gradient(to top, #fffcf5, #b0b0b0);
    text-align:center ;
}

footer{
    background-color: #e0e0e0 ;
    background-image: linear-gradient(to bottom, #fffcf5, #b0b0b0);
    padding: 2ex 1em 2ex 1em ;
    clear:right ;
    text-align:left ;
}

nav.botnavigation {
    background: #dedcd5 ;
    border-top: 1px solid black ;
}
\end{filecontents*}
% \end{Verbatim}% for syntax highlighting
\end{warpprint}
%    \end{macrocode}



% \subsection{sample\_project.css}

% \DescribeFile{sample_project.css}
% The project-specific \CSS\ file.  Use with \cs{CSSFilename}.
%
% If used, this must be present both when compiling the project
% and also when distributing the \HTML\ files.
%
%    \begin{macrocode}
\begin{warpprint}
\begin{filecontents*}{sample_project.css}
/* ( --- Start of project.css --- ) */
/* ( --- A sample project-specific CSS file for lwarp --- ) */

/* Load default lwarp settings: */
@import url("lwarp.css") ;
/* or lwarp_formal.css, lwarp_sagebrush.css */

/* Project-specific CSS setting follow here. */
/* . . . */

/* ( --- End of project.css --- ) */
\end{filecontents*}
% \end{Verbatim}% for syntax highlighting
\end{warpprint}
%    \end{macrocode}



% \subsection{lwarp.xdy}

% \DescribeFile{lwarp.xdy}
% Used to modify the index for \pkg{lwarp}.
%
% This must be present when compiling the project,
% but does not need to be present when distributing
% the resulting \HTML\ files.
%
% \changes{v0.30}{2017/04/28}{File: \protect\texttt{lwarp\_html.xdy} renamed to \protect\texttt{lwarp.xdy}.}
% \changes{v0.30}{2017/04/26}{Fix: \protect\texttt{lwarp.xdy} only written in print mode.}
%
%    \begin{macrocode}
\begin{warpprint}
\begin{filecontents*}{lwarp.xdy}
(require "tex/inputenc/latin.xdy")
(merge-rule "\\PS *" "Postscript")
(require "texindy.xdy")
(require "page-ranges.xdy")
(require "book-order.xdy")
(markup-locref :open "\hyperindexref{" :close "}")
\end{filecontents*}
% \end{Verbatim}% for syntax highlighting
\end{warpprint}
%    \end{macrocode}



% \subsection{lwarp\_mathjax.txt}

% \DescribeFile{lwarp_mathjax.txt}
% Used by \pkg{lwarp} when using MathJax.
%
% This must be present when compiling the project,
% but does not need to be present when distributing
% the resulting \HTML\ files.
%
% \changes{v0.28}{2017/04/11}{File \protect\texttt{lwarp\_mathjax.txt}: Updated \protect\acro{CDN} repository.}
% \changes{v0.30}{2017/04/26}{Fix: \protect\texttt{lwarp\_mathjax.txt}: Only written in print mode.}
% \changes{v0.34}{2017/07/27}{File: \protect\texttt{lwarp\_mathjax.txt}: Version change.}
% \changes{v0.42}{2017/10/16}{File: \protect\texttt{lwarp\_mathjax.txt}: Updated \pkg{siunitx} script.}
%
%
%    \begin{macrocode}
\begin{warpprint}
\begin{filecontents*}{lwarp_mathjax.txt}
<!-- https://groups.google.com/forum/#!topic/
                               mathjax-users/jUtewUcE2bY -->
<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("TeX AMSmath Ready",function () {
    var seteqsectionDefault = {name: "", num: 0};
    var seteqsections = {}, seteqsection = seteqsectionDefault;
    var TEX = MathJax.InputJax.TeX, PARSE = TEX.Parse;
    var AMS = MathJax.Extension["TeX/AMSmath"];
    TEX.Definitions.Add({
    macros: {
        seteqsection: "mySection",
        seteqnumber: "mySetEqNumber"
    }
    });

    PARSE.Augment({
    mySection: function (name) {
        seteqsection.num = AMS.number;
        var n = this.GetArgument(name);
        if (n === "") {
        seteqsection = seteqsectionDefault;
        } else {
        if (!seteqsections["_"+n])
            seteqsections["_"+n] = {name:n, num:0};
        seteqsection = seteqsections["_"+n];
        }
        AMS.number = seteqsection.num;
    },
    mySetEqNumber: function (name) {
        var n = this.GetArgument(name);
        if (!n || !n.match(/^ *[0-9]+ *$/))
            n = ""; else n = parseInt(n)-1;
        <!-- $ syntax highlighting -->
        if (n === "" || n < 1)
            TEX.Error
            ("Argument to "+name+" should be a positive integer");
        AMS.number = n;
    }
    });
    MathJax.Hub.Config({
    TeX: {
        equationNumbers: {
        formatTag: function (n)
            {return "("+(seteqsection.name+"."+n).replace(/^\./,"")+")"},
        formatID: function (n) {
            n = (seteqsection.name+'.'+n).replace
                (/[:"'<>&]/g,"").replace(/^\./,"");
            return 'mjx-eqn-' + n;
        }
        }
    }
    });
});
</script>

<!-- http://docs.mathjax.org/en/latest/options/ThirdParty.html -->
<script type="text/x-mathjax-config">
  MathJax.Ajax.config.path["Contrib"] =
    "https://cdn.mathjax.org/mathjax/contrib";
</script>

<!-- https://github.com/burnpanck/MathJax-siunitx -->

<script type="text/x-mathjax-config">
 MathJax.Hub.Config({
   extensions: ["tex2jax.js","[siunitx]/siunitx.js"],
   jax: ["input/TeX","output/HTML-CSS"],
   tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]},
   TeX: {extensions: ["AMSmath.js","AMSsymbols.js", "sinuitx.js"]}
 });
 MathJax.Ajax.config.path['siunitx']  = 'http://rawgit.com/burnpanck/MathJax-siunitx/master/';
 </script>

<script type="text/x-mathjax-config">
MathJax.Hub.Config({
    TeX: {
    equationNumbers: {
        autoNumber: "AMS"
    }
    }
});
</script>

<!-- Alternative CDN provider: -->
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS_HTML-full">
</script>

<!-- No longer supported after April 30, 2017: -->
<!--
<script
  src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML-full">
</script>
-->

\end{filecontents*}
% \end{Verbatim}% for syntax highlighting
\end{warpprint}
%    \end{macrocode}



% \subsection{lwarpmk option}

% The following is only generated if the |lwarpmk| option
%	was given to \pkg{lwarp}.
%    \begin{macrocode}
\begin{LWR@createlwarpmk}
%    \end{macrocode}

% \DescribeProgram{lwarpmk} Creates a local copy of |lwarpmk|:
%
% \changes{v0.21}{2017/02/11}{\protect\texttt{lwarpmk}: Fix: \protect\texttt{lwarpmk again} for Windows.}
% \changes{v0.21}{2017/02/22}{\protect\texttt{lwarpmk}: Fix: \protect\texttt{lwarpmk limages} for Windows.}
% \changes{v0.21}{2017/02/22}{\protect\texttt{lwarpmk}: Fix: \protect\texttt{lwarpmk} uses \texttt{lateximages} text file instead of shell script.}
% \changes{v0.28}{2017/04/14}{\protect\texttt{lwarpmk}: Add: \protect\texttt{printglossary} and \protect\texttt{htmlglossary} commands.}
% \changes{v0.29}{2017/04/15}{\protect\texttt{lwarpmk}: Add: \protect\texttt{language} option for config files.}
% \changes{v0.30}{2017/04/22}{\protect\texttt{lwarpmk}: \protect\texttt{language} now used for both index and glossary generation.}
% \changes{v0.30}{2017/04/22}{\protect\texttt{lwarpmk}: Fix: \protect\texttt{xindy} now used for print index generation with \protect\texttt{latexmk}.}
% \changes{v0.30}{2017/04/28}{\protect\texttt{lwarpmk}: Fix: \protect\texttt{xindy} and \protect\texttt{texindy}
%		adjusted for \protect\texttt{pdflatex}, \protect\texttt{xelatex} and \protect\texttt{lualatex}.}
% \changes{v0.30}{2017/04/28}{\protect\texttt{lwarpmk}: Add: \protect\texttt{xdyfile} configuration option.}
% \changes{v0.32}{2017/06/08}{\protect\texttt{lwarpmk}: Fix: \protect\texttt{io.lines()} changed to \protect\texttt{file:lines()}
%		due to \protect\texttt{luatex} changes.}
% \changes{v0.37}{2017/08/19}{\protect\texttt{lwarpmk}: Removes additional \HTML\ \protect\texttt{aux} files.}
% \changes{v0.38}{2017/08/24}{\protect\texttt{lwarpmk}: Added print1 and html1 actions.}
%
%    \begin{macrocode}
\begin{filecontents*}{lwarpmk.lua}
#!/usr/bin/env texlua

-- Copyright 2016-2017 Brian Dunn

-- Print the usage of the lwarpmk command:

printversion = "v0.44"

function printhelp ()
print ("lwarpmk: Use lwarpmk -h or lwarpmk --help for help.") ;
end

function printusage ()
print ( [[

lwarpmk print [project]: Compile the print version if necessary.
lwarpmk print1 [project]: Forced single compile of the print version.
lwarpmk printindex [project]: Process the index for the print version.
lwarpmk printglossary [project]: Process the glossary for the print version.
lwarpmk html [project]: Compile the HTML version if necessary.
lwarpmk html1 [project]: Forced single compile of the HTML version.
lwarpmk htmlindex [project]: Process the index for the html version.
lwarpmk htmlglossary [project]: Process the glossary for the html version.
lwarpmk again [project]: Touch the source code to trigger recompiles.
lwarpmk limages [project]: Process the "lateximages" created by lwarp.sty.
lwarpmk pdftohtml [project]:
    For use with latexmk or a Makefile:
    Convert project_html.pdf to project_html.html and
    individual HTML files.
lwarpmk clean [project]: Remove project.aux, .toc, .lof/t, .idx, .ind, .log, *_html_inc.*, .gl*
lwarpmk cleanall [project]: Remove auxiliary files and also project.pdf, *.html
lwarpmk -h: Print this help message.
lwarpmk --help: Print this help message.

]] )
printconf ()
end

-- Print the format of the configuration file lwarpmk.conf:

function printconf ()
print ( [[
An example lwarpmk.conf or <project>.lwarpmkconf project file:
--
opsystem = "Unix"   (or "Windows")
latexname = "pdflatex"  (or "lualatex", or "xelatex")
sourcename = "projectname"  (the source-code filename w/o .tex)
homehtmlfilename = "index"  (or perhaps the project name)
htmlfilename = ""  (or "projectname" - filename prefix)
latexmk = "false"  (or "true" to use latexmk to build PDFs)
languge = "english"  (use a language supported by xindy)
xdyfile = "lwarp.xdy" (or a custom file based on lwarp.xdy)
--
Filenames must contain only letters, numbers, underscore, or dash.
Values must be in "quotes".

]] ) ;
end


-- Split one large sourcefile into a number of files,
-- starting with destfile.
-- The file is split at each occurance of <!--|Start file|newfilename|*

function splitfile (destfile,sourcefile)
print ("lwarpmk: Splitting " .. sourcefile .. " into " .. destfile) ;
local sfile = io.open(sourcefile)
io.output(destfile)
for line in sfile:lines() do
i,j,copen,cstart,newfilename = string.find (line,"(.*)|(.*)|(.*)|") ;
if ( (i~= nil) and (copen == "<!--") and (cstart == "Start file")) then -- split the file
io.output(newfilename) ;
else -- not a splitpoint
io.write (line .. "\n") ;
end
end -- do
io.close(sfile)
end -- function

-- Incorrect value, so print an error and exit.

function cvalueerror ( line, linenum , cvalue )
    print ( linenum .. " : " .. line ) ;
    print ("lwarpmk: incorrect variable value \"" .. cvalue .. "\" in lwarpmk.conf.\n" ) ;
    printconf () ;
    os.exit(1) ;
end

-- Load settings from the project's "lwarpmk.conf" file:

function loadconf ()
-- Default configuration filename:
local conffile = "lwarpmk.conf"
-- Optional configuration filename:
if arg[2] ~= nil then conffile = arg[2]..".lwarpmkconf" end
-- Default language:
language = "english"
-- Default xdyfile:
xdyfile = "lwarp.xdy"
-- Verify the file exists:
if (lfs.attributes(conffile,"mode")==nil) then -- file not exists
print("lwarpmk: " .. conffile .." does not exist.")
print("lwarpmk: " .. arg[2] .. " does not appear to be a project name.\n")
printhelp () ;
os.exit(1) -- exit the entire lwarpmk script
else -- file exists
-- Read the file:
print ("lwarpmk: Reading " .. conffile ..".")
local cfile = io.open(conffile)
-- Scan each line:
local linenum = 0
for line in cfile:lines() do -- scan lines
linenum = linenum + 1
i,j,cvarname,cvalue = string.find (line,"([%w-_]*)%s*=%s*\"([%w%-_%.]*)\"") ;
-- Error if incorrect enclosing characters:
if ( i == nil ) then
print ( linenum .. " : " .. line ) ;
print ( "lwarpmk: Incorrect entry in " .. conffile ..".\n" ) ;
printconf () ;
os.exit(1) ;
end
if ( cvarname == "opsystem" ) then
    -- Verify choice of opsystem:
    if ( (cvalue == "Unix") or (cvalue == "Windows") ) then
        opsystem = cvalue
    else
        cvalueerror ( line, linenum , cvalue )
    end
elseif ( cvarname == "latexname" ) then
    -- Verify choice of LaTeX compiler:
    if (
        (cvalue == "pdflatex") or
        (cvalue == "xelatex") or
        (cvalue == "lualatex")
    ) then
        latexname = cvalue
    else
        cvalueerror ( line, linenum , cvalue )
    end
elseif ( cvarname == "sourcename" ) then sourcename = cvalue
elseif ( cvarname == "homehtmlfilename" ) then homehtmlfilename = cvalue
elseif ( cvarname == "htmlfilename" ) then htmlfilename = cvalue
elseif ( cvarname == "latexmk" ) then latexmk = cvalue
elseif ( cvarname == "language" ) then language = cvalue
elseif ( cvarname == "xdyfile" ) then xdyfile = cvalue
else
print ( linenum .. " : " .. line ) ;
print ("lwarpmk: Incorrect variable name \"" .. cvarname .. "\" in " .. conffile ..".\n" ) ;
printconf () ;
os.exit(1) ;
end
end -- do scan lines
io.close(cfile)
end -- file exists
-- Select some operating-system commands:
if opsystem=="Unix" then  -- For Unix / Linux / Mac OS:
rmname = "rm"
mvname = "mv"
touchnamepre = "touch"
touchnamepost = ""
dirslash = "/"
opquote= "\'"
elseif opsystem=="Windows" then -- For Windows
rmname = "DEL"
mvname = "MOVE"
touchnamepre = "COPY /b"
touchnamepost = "+,,"
dirslash = "\\"
opquote= "\""
else print ( "lwarpmk: Select Unix or Windows for opsystem" )
end --- for Windows

-- set xindycmd according to pdflatex vs xelatex/lualatex:
if ( latexname == "pdflatex" ) then
xindycmd = "texindy  -C utf8"
glossarycmd = "xindy -C utf8"
else
xindycmd = "xindy  -M texindy  -C utf8"
glossarycmd = "xindy -C utf8"
end

end -- loadconf


function refreshdate ()
os.execute(touchnamepre .. " " .. sourcename .. ".tex " .. touchnamepost)
end


-- Scan the LaTeX log file for the phrase "Rerun to get",
-- indicating that the file should be compiled again.
-- Return true if found.

function reruntoget (filesource)
local fsource = io.open(filesource)
for line in fsource:lines() do
if ( string.find(line,"Rerun to get") ~= nil ) then
    io.close(fsource)
    return true 
end
end
io.close(fsource)
return false
end


-- Compile one time, return true if should compile again.
-- fsuffix is "" for print, "_html" for HTML output.

function onetime (fsuffix)
print("lwarpmk: Compiling with " .. latexname .. " " .. sourcename..fsuffix)
err = os.execute(
--    "echo " ..
    latexname .. " " .. sourcename..fsuffix )
if ( err ~= 0 ) then print ( "lwarpmk: Compile error.") ; os.exit(1) ; end
return (reruntoget(sourcename .. fsuffix .. ".log") ) ;
end


-- Compile up to five times.
-- fsuffix is "" for print, "_html" for HTML output

function manytimes (fsuffix)
if onetime(fsuffix) == true then
if onetime(fsuffix) == true then
if onetime(fsuffix) == true then
if onetime(fsuffix) == true then
if onetime(fsuffix) == true then
end end end end end
end

-- Exit if the given file does not exist.

function verifyfileexists (filename)
if (lfs.attributes ( filename , "modification" ) == nil ) then
print ( "lwarpmk: " .. filename .. " not found." ) ;
os.exit (1) ;
end
end


-- Convert <project>_html.pdf into HTML files:

function pdftohtml ()
    -- Convert to text:
    print ("lwarpmk: Converting " .. sourcename
        .."_html.pdf to " .. sourcename .. "_html.html")
    os.execute("pdftotext  -enc UTF-8  -nopgbrk  -layout "
        .. sourcename .. "_html.pdf " .. sourcename .. "_html.html")
    -- Split the result into individual HTML files:
    splitfile (homehtmlfilename .. ".html" , sourcename .. "_html.html")
end


-- Remove auxiliary files:

function removeaux ()
    os.execute ( rmname .. " " ..
        sourcename ..".aux " .. sourcename .. "_html.aux " ..
        sourcename ..".toc " .. sourcename .. "_html.toc " ..
        sourcename ..".lof " .. sourcename .. "_html.lof " ..
        sourcename ..".lot " .. sourcename .. "_html.lot " ..
        sourcename ..".idx " .. sourcename .. "_html.idx " ..
        sourcename ..".ind " .. sourcename .. "_html.ind " ..
        sourcename ..".log " .. sourcename .. "_html.log " ..
        sourcename ..".gl* " .. sourcename .. "_html.gl* " ..
        "*_html_inc.*"
        )
end



-- Create lateximages based on lateximages.txt:
function createlateximages ()
print ("lwarpmk: Creating lateximages.")
local limagesfile = io.open("lateximages.txt")
-- Create the lateximages directory, ignore error if already exists
err = os.execute("mkdir lateximages")
-- Scan lateximages.txt
for line in limagesfile:lines() do
-- lwimgpage is the page number in the PDF which has the image
-- lwimgnum is the sequential lateximage number to assign for the image
i,j,lwimgpage,lwimgnum = string.find (line,"|(.*)|(.*)|")
-- For each entry:
if ( (i~=nil) ) then
-- Separate out the image into its own single-page pdf:
err = os.execute(
"pdfseparate -f " .. lwimgpage .. " -l " ..
 lwimgpage .. " " .. sourcename .."_html.pdf lateximagetemp-%d.pdf")
-- Crop the image:
err = os.execute(
"pdfcrop --hires lateximagetemp-" .. lwimgpage ..".pdf lateximage-" .. lwimgnum ..".pdf")
if ( err ~= 0 ) then print ( "lwarpmk: File error.") ; os.exit(1) ; end
-- Convert the image to svg:
err = os.execute(
"pdftocairo -svg lateximage-" .. lwimgnum ..".pdf lateximage-" .. lwimgnum ..".svg")
if ( err ~= 0 ) then print ( "lwarpmk: File error.") ; os.exit(1) ; end
-- Move the result into lateximages/:
err = os.execute(
mvname .. " lateximage-" .. lwimgnum ..".svg lateximages" .. dirslash )
if ( err ~= 0 ) then print ( "lwarpmk: File error.") ; os.exit(1) ; end
-- Remove the temporary files:
err = os.execute(
rmname .. " lateximage-" .. lwimgnum ..".pdf lateximagetemp-" .. lwimgpage ..".pdf")
if ( err ~= 0 ) then print ( "lwarpmk: File error.") ; os.exit(1) ; end
end
end -- do
io.close(limagesfile)
end -- function


-- Use latexmk to compile source and index:
-- fsuffix is "" for print, or "_html" for HTML
function compilelatexmk ( fsuffix )
    -- The recorder option is required to detect changes in <project>.tex
    -- while we are loading <project>_html.tex.
    err=os.execute ( "latexmk -pdf -dvi- -ps- -recorder "
        .. "-e "
        .. opquote
        .. "$makeindex = q/" -- $
        .. xindycmd
        .. "  -M " .. xdyfile
        .. "  -L " .. language .. " /"
        .. opquote
        .. " -pdflatex=\"" .. latexname .." %O %S\" "
        .. sourcename..fsuffix ..".tex" ) ;
    if ( err ~= 0 ) then print ( "lwarpmk: Compile error.") ; os.exit(1) ; end
end



-- lwarpmk --version :

if (arg[1] == "--version") then
print ( "lwarpmk: " .. printversion )

else -- not --version

-- print intro:

print ("lwarpmk: " .. printversion .. "  Automated make for the LaTeX lwarp package.")

-- lwarpmk print:

if arg[1] == "print" then
loadconf ()
if ( latexmk == "true" ) then
    compilelatexmk ("")
    print ("lwarpmk: Done.")
else -- not latexmk
    verifyfileexists (sourcename .. ".tex") ;
    -- See if up to date:
    if (
        ( lfs.attributes ( sourcename .. ".pdf" , "modification" ) == nil ) or
        (
            lfs.attributes ( sourcename .. ".tex" , "modification" ) >
            lfs.attributes ( sourcename .. ".pdf" , "modification" )
        )
    ) then
        -- Recompile if not yet up to date:
        manytimes("")
        print ("lwarpmk: Done.") ;
    else
        print ("lwarpmk: " .. sourcename .. ".pdf is up to date.") ;
    end
end -- not latexmk

elseif arg[1] == "print1" then
    loadconf ()
    verifyfileexists (sourcename .. ".tex") ;
    onetime("")
    print ("lwarpmk: Done.") ;

-- lwarp printindex:
-- Compile the index then touch the source
-- to trigger a recompile of the document:

elseif arg[1] == "printindex" then
loadconf ()
print ("lwarpmk: Processing the index.")
os.execute(
    xindycmd
    .. "  -M " .. xdyfile
    .. "  -L " .. language
    .. " " .. sourcename .. ".idx")
print ("lwarpmk: Forcing an update of " .. sourcename ..".tex.")
refreshdate ()
print ("lwarpmk: " .. sourcename ..".tex is ready to be recompiled.")
print ("lwarpmk: Done.")

-- lwarp printglossary:
-- Compile the glossary then touch the source
-- to trigger a recompile of the document:

elseif arg[1] == "printglossary" then
loadconf ()
print ("lwarpmk: Processing the glossary.")

os.execute(glossarycmd .. "  -L " .. language .. "  -I xindy -M " .. sourcename ..
    " -t " .. sourcename .. ".glg -o " .. sourcename .. ".gls "
    .. sourcename .. ".glo")
print ("lwarpmk: Forcing an update of " .. sourcename ..".tex.")
refreshdate ()
print ("lwarpmk: " .. sourcename ..".tex is ready to be recompiled.")
print ("lwarpmk: Done.")

-- lwarpmk html:

elseif arg[1] == "html" then
loadconf ()
if ( latexmk == "true" ) then
    compilelatexmk ("_html")
    pdftohtml ()
    print ("lwarpmk: Done.")
else -- not latexmk
    verifyfileexists ( sourcename .. ".tex" ) ;
    -- See if exists and is up to date:
    if (
        ( lfs.attributes ( homehtmlfilename .. ".html" , "modification" ) == nil ) or
        (
            lfs.attributes ( sourcename .. ".tex" , "modification" ) >
            lfs.attributes ( homehtmlfilename .. ".html" , "modification" )
        )
    ) then
        -- Recompile if not yet up to date:
        manytimes("_html")
        pdftohtml ()
        print ("lwarpmk: Done.")
    else
        print ("lwarpmk: " .. homehtmlfilename .. ".html is up to date.")
    end
end -- not latexmk

elseif arg[1] == "html1" then
    loadconf ()
    verifyfileexists ( sourcename .. ".tex" ) ;
    onetime("_html")
    pdftohtml ()
    print ("lwarpmk: Done.")

elseif arg[1] == "pdftohtml" then
    loadconf ()
    pdftohtml ()

-- lwarpmk htmlindex:
-- Compile the index then touch the source
-- to trigger a recompile of the document:

elseif arg[1] == "htmlindex" then
loadconf ()
print ("lwarpmk: Processing the index.")
os.execute(
    xindycmd
    .. "  -M " .. xdyfile
    .. "  -L " .. language
    .. " " .. sourcename .. "_html.idx"
)
print ("lwarpmk: Forcing an update of " .. sourcename ..".tex.")
refreshdate ()
print ("lwarpmk: " .. sourcename ..".tex is ready to be recompiled.")
print ("lwarpmk: Done.")

-- lwarpmk htmlglossary:
-- Compile the glossary then touch the source
-- to trigger a recompile of the document:

elseif arg[1] == "htmlglossary" then
loadconf ()
print ("lwarpmk: Processing the glossary.")

os.execute(glossarycmd .. "  -L " .. language .. "  -I xindy -M " ..sourcename ..
    "_html -t " .. sourcename .. "_html.glg -o " ..sourcename ..
    "_html.gls " ..sourcename .. "_html.glo")

print ("lwarpmk: Forcing an update of " .. sourcename ..".tex.")
refreshdate ()
print ("lwarpmk: " .. sourcename ..".tex is ready to be recompiled.")
print ("lwarpmk: Done.")

-- lwarpmk limages:
-- Scan the lateximages.txt file to create lateximages,
-- then touch the source to trigger a recompile.

elseif arg[1] == "limages" then
loadconf ()
print ("lwarpmk: Processing images.")
createlateximages ()
print ("lwarpmk: Forcing an update of " .. sourcename ..".tex.")
refreshdate ()
print ("lwarpmk: " .. sourcename ..".tex is ready to be recompiled.")
print ("lwarpmk: Done.")

-- lwarpmk again:
-- Touch the source to trigger a recompile.

elseif arg[1] == "again" then
loadconf ()
print ("lwarpmk: Forcing an update of " .. sourcename ..".tex.")
refreshdate ()
print ("lwarpmk: " .. sourcename ..".tex is ready to be recompiled.")
print ("lwarpmk: Done.")

-- lwarpmk clean:
-- Remove project.aux, .toc, .lof, .lot, .idx, .ind, .log, *_html_inc.*, .gl*

elseif arg[1] == "clean" then
loadconf ()
removeaux ()
print ("lwarpmk: Done.")

-- lwarpmk cleanall
-- Remove project.aux, .toc, .lof, .lot, .idx, .ind, .log, *_html_inc.*, .gl*
--    and also project.pdf, *.html

elseif arg[1] == "cleanall" then
loadconf ()
removeaux ()
os.execute ( rmname .. " " ..
    sourcename .. ".pdf " .. sourcename .. "_html.pdf " ..
    "*.html"
    )
print ("lwarpmk: Done.")

-- lwarpmk with no argument :

elseif (arg[1] == nil) then
printhelp ()

-- lwarpmk -h or lwarpmk --help :

elseif (arg[1] == "-h" ) or (arg[1] == "--help") then
printusage ()

else
print ("lwarpmk: Unknown command \""..arg[1].."\".\n")
printhelp ()
end

end -- not --version
\end{filecontents*}
% \end{Verbatim}% for syntax highlighting
%    \end{macrocode}
%
%    \begin{macrocode}
\end{LWR@createlwarpmk}
%    \end{macrocode}
%





% \section{Stacks}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}



% Stacks are used to remember how to close sections and list items.
% Before a new section is started, previously nested sections and items must
% be closed out (un-nested) in proper order.
% Note that starting a new section may close several levels of previously
% \watchout
% nested items at the same time.
% For example, starting a new |\section| would close any currently open
% subsection, subsubsection, and paragraph.
% General environments are not nested on the stack since they have their own close
% mechanism.  List environments are nested, and items inside those environments
% are nested one level deeper still.
% List environments may be nested inside other list environments, and list items
% are nested inside list environments as well.  Thus, the stack may have items
% which are not necessarily in order, since a description may contain an enumerate,
% for example.
% Depths to be recorded in |\LWR@closedepthone|, etc.

% \subsection{Assigning depths}

% initial depths for empty stack entries:
%    \begin{macrocode}
\newcommand*{\LWR@depthnone}{-5}
%    \end{macrocode}
% all sectioning depths are deeper than |LWR@depthfinished|:
%    \begin{macrocode}
\newcommand*{\LWR@depthfinished}{-4}
\newcommand*{\LWR@depthpart}{-1}
\newcommand*{\LWR@depthchapter}{0}
\newcommand*{\LWR@depthsection}{1}
\newcommand*{\LWR@depthsubsection}{2}
\newcommand*{\LWR@depthsubsubsection}{3}
\newcommand*{\LWR@depthparagraph}{4}
\newcommand*{\LWR@depthsubparagraph}{5}
%    \end{macrocode}
% used by |\itemize|, |\enumerate|, |\description|:
%    \begin{macrocode}
\newcommand*{\LWR@depthlist}{6}
%    \end{macrocode}
% used by |\item|:
%    \begin{macrocode}
\newcommand*{\LWR@depthlistitem}{7}
%    \end{macrocode}

% \subsection{Closing actions}

% A stack to record the action to take to close each nesting level:
% Add more levels of stack if necessary for a very deeply nested document,
% adding to |\pushclose| and |\popclose| as well.
%    \begin{macrocode}
\newcommand*{\LWR@closeone}{}% top of the stack
\newcommand*{\LWR@closetwo}{}
\newcommand*{\LWR@closethree}{}
\newcommand*{\LWR@closefour}{}
\newcommand*{\LWR@closefive}{}
\newcommand*{\LWR@closesix}{}
\newcommand*{\LWR@closeseven}{}
\newcommand*{\LWR@closeeight}{}
\newcommand*{\LWR@closenine}{}
\newcommand*{\LWR@closeten}{}
\newcommand*{\LWR@closeeleven}{}
\newcommand*{\LWR@closetwelve}{}
%    \end{macrocode}

% \subsection{Closing depths}

% A stack to record the depth of each level:
%
% Note that nested \LaTeX\ structures may push depths which are non-sequential.
% \watchout

% \begin{docsidebar}[Ex:]
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4]
% \begin{itemize} 
%    \item{A}
%    \begin{description}
%       \item{B}
%    \end{description}
% \end{itemize}
% \end{Verbatim}
% \end{docsidebar}

%    \begin{macrocode}
\newcommand*{\LWR@closedepthone}{\LWR@depthnone}% top of the stack
\newcommand*{\LWR@closedepthtwo}{\LWR@depthnone}
\newcommand*{\LWR@closedepththree}{\LWR@depthnone}
\newcommand*{\LWR@closedepthfour}{\LWR@depthnone}
\newcommand*{\LWR@closedepthfive}{\LWR@depthnone}
\newcommand*{\LWR@closedepthsix}{\LWR@depthnone}
\newcommand*{\LWR@closedepthseven}{\LWR@depthnone}
\newcommand*{\LWR@closedeptheight}{\LWR@depthnone}
\newcommand*{\LWR@closedepthnine}{\LWR@depthnone}
\newcommand*{\LWR@closedepthten}{\LWR@depthnone}
\newcommand*{\LWR@closedeptheleven}{\LWR@depthnone}
\newcommand*{\LWR@closedepthtwelve}{\LWR@depthnone}
%    \end{macrocode}

% \subsection{Pushing and popping the stack}

% \begin{macro}{\pushclose} \marg{action} \marg{depth}

% Pushes one return action and its \LaTeX\ depth onto the stacks.
%    \begin{macrocode}
\NewDocumentCommand{\pushclose}{m m}
{
\let\LWR@closetwelve\LWR@closeeleven
\let\LWR@closeeleven\LWR@closeten
\let\LWR@closeten\LWR@closenine
\let\LWR@closenine\LWR@closeeight
\let\LWR@closeeight\LWR@closeseven
\let\LWR@closeseven\LWR@closesix
\let\LWR@closesix\LWR@closefive
\let\LWR@closefive\LWR@closefour
\let\LWR@closefour\LWR@closethree
\let\LWR@closethree\LWR@closetwo
\let\LWR@closetwo\LWR@closeone
\let\LWR@closeone#1
\let\LWR@closedepthtwelve\LWR@closedeptheleven
\let\LWR@closedepthelevel\LWR@closedepthten
\let\LWR@closedepthten\LWR@closedepthnine
\let\LWR@closedepthnine\LWR@closedeptheight
\let\LWR@closedeptheight\LWR@closedepthseven
\let\LWR@closedepthseven\LWR@closedepthsix
\let\LWR@closedepthsix\LWR@closedepthfive
\let\LWR@closedepthfive\LWR@closedepthfour
\let\LWR@closedepthfour\LWR@closedepththree
\let\LWR@closedepththree\LWR@closedepthtwo
\let\LWR@closedepthtwo\LWR@closedepthone
\let\LWR@closedepthone#2
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\popclose}

% Pops one action and its depth off the stacks.
%    \begin{macrocode}
\newcommand*{\popclose}
{
\let\LWR@closeone\LWR@closetwo
\let\LWR@closetwo\LWR@closethree
\let\LWR@closethree\LWR@closefour
\let\LWR@closefour\LWR@closefive
\let\LWR@closefive\LWR@closesix
\let\LWR@closesix\LWR@closeseven
\let\LWR@closeseven\LWR@closeeight
\let\LWR@closeeight\LWR@closenine
\let\LWR@closenine\LWR@closeten
\let\LWR@closeten\LWR@closeeleven
\let\LWR@closeeleven\LWR@closetwelve
\let\LWR@closedepthone\LWR@closedepthtwo
\let\LWR@closedepthtwo\LWR@closedepththree
\let\LWR@closedepththree\LWR@closedepthfour
\let\LWR@closedepthfour\LWR@closedepthfive
\let\LWR@closedepthfive\LWR@closedepthsix
\let\LWR@closedepthsix\LWR@closedepthseven
\let\LWR@closedepthseven\LWR@closedeptheight
\let\LWR@closedeptheight\LWR@closedepthnine
\let\LWR@closedepthnine\LWR@closedepthten
\let\LWR@closedepthten\LWR@closedeptheleven
\let\LWR@closedeptheleven\LWR@closedepthtwelve
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}




% \section{Data arrays}
% \label{sec:dataarray}
% 
% These macros are similar to the \pkg{arrayjobx} package, except
% that \cs{LWR@setexparray}'s argument is expanded only once when assigned.
%
% |name| has no backslash, |index| can be a number or a text name,
% and an empty |value| must be |\relax| instead of empty.
%
% To assign an empty value:
%	\begin{sourcedisplay}
%	|\LWR@setexparray{name}{index}{}|
%	\end{sourcedisplay}
%
% \changes{v0.20}{2017/01/07}{Added single-expansion data arrays.}
%
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
% 
% \begin{macro}{\LWR@setexparray} \marg{name} \marg{index} \marg{contents}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@setexparray}{m m m}{%
\ifstrempty{#3}%
{\csdef{#1#2}{}}%
{\expandafter\edef\csname #1#2\endcsname{\expandonce#3}}%
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\LWR@getexparray} \marg{name} \marg{index}
%    \begin{macrocode}
\newcommand*{\LWR@getexparray}[2]{\csuse{#1#2}}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \section{HTML entities}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \HTML\ entites and \HTML\ Unicode entities:
%    \begin{macrocode}
\let\LWR@origampersand\&
%    \end{macrocode}
% \begin{macro}{\HTMLentity} \marg{entitytag}
%    \begin{macrocode}
\newcommand*{\HTMLentity}[1]{%
% \LWR@traceinfo{HTMLentity \detokenize{#1}}%
\begingroup%
\LWR@FBcancel%
\LWR@origampersand#1;%
\endgroup
% \LWR@traceinfo{HTMLentity done}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\HTMLunicode} \marg{hex\_unicode}
%    \begin{macrocode}
\newcommand*{\HTMLunicode}[1]{\HTMLentity{\#x#1}}
%    \end{macrocode}
% \end{macro}

% \DescribeMacro{\&}
%    \begin{macrocode}
\renewcommand*{\&}{\HTMLentity{amp}}
%    \end{macrocode}

% \begin{macro}{\textless}
% \begin{macro}{\textgreater}
%    \begin{macrocode}
\let\LWR@origtextless\textless
\renewcommand*{\textless}{\HTMLentity{lt}}

\let\LWR@origtextgreater\textgreater
\renewcommand*{\textgreater}{\HTMLentity{gt}}
%    \end{macrocode}
% \end{macro}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \section{HTML filename generation}
%

% The filename of the homepage is set to |\HomeHTMLFilename.html|.
% The filenames of additional sections start with |\HTMLFilename|, to which is
% appended a section number or a simplified section name, depending on |FileSectionNames|.
%

% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}


% \begin{macro}{\BaseJobname}
% The \cs{jobname} of the printed version, even if currently
% compiling the \HTML\ version.
% I.e. this is the \cs{jobname} without |_html| appended.
% This is used to set \cs{HomeHTMLFilename} if the user did not provide one.
%    \begin{macrocode}
\providecommand*{\BaseJobname}{\jobname}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\HTMLFilename}
% \changes{v0.19}{2016/05/28}{Docs: Escape filename underscores.}
% \changes{v0.20}{2016/12/18}{No longer escape underscores.}
% The prefix for all generated \HTML\ files other than the home page,
% defaulting to empty.  See \cref{sec:filenameexamples}.
%
%    \begin{macrocode}
\providecommand*{\HTMLFilename}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\HomeHTMLFilename}
% \changes{v0.19}{2016/05/28}{Docs: Escape filename underscores.}
% \changes{v0.20}{2016/12/18}{No longer escape underscores.}
% The filename of the home page, defaulting to the \cs{BaseJobname}.
% See \cref{sec:filenameexamples}.
%
%    \begin{macrocode}
\providecommand*{\HomeHTMLFilename}{\BaseJobname}
%    \end{macrocode}
% \end{macro}
%

% \begin{macro}{\SetHTMLFileNumber} \marg{number}
%
% \changes{v0.20}{2016/09/11}{Add: Control file numbers.}
% Sets the file number for the next
% file to be generated.  0 is the home page.
% Use just before the next sectioning command, and set it to one less than the
% desired number of the next section.
% May be used to generate numbered groups of nodes
% such as 100+ for one chapter, 200+ for another chapter, etc.
%    \begin{macrocode}
\newcommand*{\SetHTMLFileNumber}[1]{%
\setcounter{LWR@htmlfilenumber}{#1}%
}
%    \end{macrocode}
% \end{macro}

% \DescribeBoolean{FileSectionNames}
% Selects how to create \HTML\ file names.
%
% Defaults to use section names in the filenames.
%    \begin{macrocode}
\newbool{FileSectionNames}
\booltrue{FileSectionNames}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}



% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \DescribeCounter{LWR@htmlfilenumber}
% Records the number of each \HTML\ file as it is being created.
% Number 0 is the home page.
%    \begin{macrocode}
\newcounter{LWR@htmlfilenumber}
\setcounter{LWR@htmlfilenumber}{0}
%    \end{macrocode}


% \begin{macro}{\LWR@htmlsectionfilename} \marg{htmlfilenumber or name}
%
% \changes{v0.14}{2016/03/28}{Fix: Links to home page.}
% \changes{v0.17}{2016/04/11}{Fix: Links when entire doc is one \HTML\ page.}
% \changes{v0.20}{2016/09/11}{HTMLFilename: removed additional trailing '-', and may be empty.}
% \changes{v0.20}{2016/09/11}{Sections called ``Index'' or ``index'' have an underscore
% prepended to their filenames if no prefix.}
%
% Prints the filename for a given section: |\HTMLFilename{}filenumber/name.html|
%    \begin{macrocode}
\newcommand*{\LWR@htmlsectionfilename}[1]{%
\LWR@traceinfo{LWR@htmlsectionfilename A}%
%    \end{macrocode}
% Section 0 or empty is given the home filename.
% The filename must be detokenized for underscores.
%    \begin{macrocode}
\LWR@traceinfo{about to assign temp}%
\edef\LWR@tempone{#1}%
\LWR@traceinfo{about to compare with ??}%
\ifthenelse{\equal{\LWR@tempone}{??}}%
{\LWR@traceinfo{found ??}}%
{\LWR@traceinfo{not found ??}}%
\LWR@traceinfo{about to compare with zero or empty}%
\ifthenelse{%
    \equal{\LWR@tempone}{0}%
    \OR \equal{\LWR@tempone}{}%
    \OR \equal{\LWR@tempone}{??}%
}%
{%
    \LWR@traceinfo{LWR@htmlsectionfilename B \HomeHTMLFilename.html}%
    \HomeHTMLFilename.html%
}%
%    \end{macrocode}
% For a \LaTeX\ section named ``Index'' or ``index'' without a prefix, create a filename
% with a leading underscore to avoid colliding with the \HTML\ filename |index.html|:
%    \begin{macrocode}
{%
    \LWR@traceinfo{LWR@htmlsectionfilename C \LWR@tempone}%
    \ifthenelse{%
        \equal{\HTMLFilename}{} \AND
        \equal{\LWR@tempone}{Index} \OR
        \equal{\LWR@tempone}{index}%
    }%
    {%
        \LWR@traceinfo{Prefixing the index name with an underscore.}%
        \_#1.html%
    }%
%    \end{macrocode}
% Otherwise, create a filename with the chosen prefix:
%    \begin{macrocode}
    {\HTMLFilename#1.html}%
}%
\LWR@traceinfo{LWR@htmlsectionfilename Z}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@htmlrefsectionfilename} \marg{label}
%
% Prints the filename for the given label
%    \begin{macrocode}
\newcommand*{\LWR@htmlrefsectionfilename}[1]{%
\LWR@traceinfo{LWR@htmlrefsectionfilename A: !#1!}%
\LWR@htmlsectionfilename{\LWR@htmlfileref{#1}}%
\LWR@traceinfo{LWR@htmlrefsectionfilename B}%
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \section{Homepage link}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \begin{macro}{\LinkHome}
% |\LinkHome| may be used wherever you wish to place a link back to the homepage.
% The filename must be detokenized for underscores.
%    \begin{macrocode}
\newcommand*{\LinkHome}{%
\LWR@subhyperrefclass{%
\HomeHTMLFilename.html}%
{Home}{linkhome}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@topnavigation}
%
% Creates a link to the homepage at the top of the page for use when the window is too
% narrow for the side\TOC.
%    \begin{macrocode}
\newcommand*{\LWR@topnavigation}{
\LWR@htmlelementclassline{nav}{topnavigation}{\LinkHome}
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@botnavigation}
%
% Creates a link to the homepage at the bottom of the page for use when the window is too
% narrow for the side\TOC.
%    \begin{macrocode}
\newcommand*{\LWR@botnavigation}{
\LWR@htmlelementclassline{nav}{botnavigation}{\LinkHome}
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \section{\textbackslash{}PrintStack diagnostic tool}

% Diagnostics tool:
% Prints the \LaTeX\ nesting depth values for the stack levels.
% Must have |\LWR@startpars| active while printing the stack, so |\PrintStack| may
% \watchout
% be called from anywhere in the normal text flow.

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{macro}{\PrintStack} Prints the closedepth stack.
%    \begin{macrocode}
\newcommand*{\PrintStack}{
\LWR@startpars
\LWR@closedepthone{} \LWR@closedepthtwo{} \LWR@closedepththree{}
\LWR@closedepthfour{} \LWR@closedepthfive{} \LWR@closedepthsix{}
\LWR@closedepthseven{} \LWR@closedeptheight{} \LWR@closedepthnine{}
\LWR@closedepthten{} \LWR@closedeptheleven{} \LWR@closedepthtwelve{}
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \section{Closing stack levels}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% Close one nested level:
%    \begin{macrocode}
\newcommand*{\LWR@closeoneprevious}{%

\LWR@closeone

\popclose
}
%    \end{macrocode}

% \begin{macro}{\LWR@closeprevious} \marg{depth}
% Close everything up to the given depth:
%    \begin{macrocode}
\newcommand*{\LWR@closeprevious}[1]{
%    \end{macrocode}
% Close any pending paragraph:
%    \begin{macrocode}
\LWR@stoppars
%    \end{macrocode}
% Close anything nested deeper than the desired depth:
%    \begin{macrocode}
\whileboolexpr{not test{\ifnumcomp{\LWR@closedepthone}{<}{#1}}}%
    {\LWR@closeoneprevious}
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}




% \section{PDF pages and styles}

% \changes{v0.38}{2017/08/21}{Added \cs{markboth}, \cs{sloppy}, etc.}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \begin{macro}{\LWR@forcenewpage} New \PDF\ page a before major environment.
%
% This is used just before major environments, such as \env{verse}.
% Reduces the chance of an environment overflowing the \HTML\ \PDF\ output page.
%
% \changes{v0.28}{2017/04/13}{Forces new PDF page before major environments.}
%    \begin{macrocode}
\newcommand{\LWR@forcenewpage}{%
\LWR@stoppars\LWR@orignewpage\LWR@startpars%
}
%    \end{macrocode}
%
%
%
% \cs{pagestyle}, etc. are nullified for \HTML\ output.
%
%
% \begin{macro}{\pagestyle} \marg{style}
%    \begin{macrocode}
\renewcommand*{\pagestyle}[1]{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\thispagestyle} \marg{style}
%    \begin{macrocode}
\renewcommand*{\thispagestyle}[1]{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\markboth} \marg{left} \marg{right}
%    \begin{macrocode}
\renewcommand*{\markboth}[2]{}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\markright} \marg{right}
%    \begin{macrocode}
\renewcommand*{\markright}[1]{}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\raggedbottom}
%    \begin{macrocode}
\renewcommand*{\raggedbottom}{}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\flushbottom}
%    \begin{macrocode}
\renewcommand*{\flushbottom}{}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\sloppy}
%    \begin{macrocode}
\renewcommand*{\sloppy}{}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\fussy}
%    \begin{macrocode}
\renewcommand*{\fussy}{}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\pagenumbering} \marg{commands}
%    \begin{macrocode}
\renewcommand*{\pagenumbering}[1]{}
%    \end{macrocode}
% \end{macro}
%
%
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
% \end{macro}



% \section{HTML tags, spans, divs, elements}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \subsection{Mapping \LaTeX{} Sections to HTML Sections}

%    \begin{macrocode}
\newcommand*{\LWR@tagtitle}{h1}
\newcommand*{\LWR@tagtitleend}{/h1}
\newcommand*{\LWR@tagpart}{h2}
\newcommand*{\LWR@tagpartend}{/h2}
\newcommand*{\LWR@tagchapter}{h3}
\newcommand*{\LWR@tagchapterend}{/h3}
\newcommand*{\LWR@tagsection}{h4}
\newcommand*{\LWR@tagsectionend}{/h4}
\newcommand*{\LWR@tagsubsection}{h5}
\newcommand*{\LWR@tagsubsectionend}{/h5}
\newcommand*{\LWR@tagsubsubsection}{h6}
\newcommand*{\LWR@tagsubsubsectionend}{/h6}
\newcommand*{\LWR@tagparagraph}{span class="paragraph"{}}
\newcommand*{\LWR@tagparagraphend}{/span}
\newcommand*{\LWR@tagsubparagraph}{span class="subparagraph"{}}
\newcommand*{\LWR@tagsubparagraphend}{/span}

\newcommand*{\LWR@tagregularparagraph}{p}
%    \end{macrocode}



% \subsection{Babel-French}


% \changes{v0.34}{2017/08/03}{\pkg{babel-french}: Adds fixed-width HTML spaces to punctuation.}
% \changes{v0.36}{2017/08/15}{\pkg{babel-french}: Adjustements for French variants,
%   load order, footnotes, ellipses.}
% \changes{v0.37}{2017/08/19}{\pkg{babel-french}: Adjustment for load order.}
%
% Adjust \pkg{babel-french} for \HTML\ spaces.
% So far, this only works for |pdflatex| and |xelatex|.
%
% \credits{Daniel Flipo}
%
%    \begin{macrocode}
\providecommand*{\LWR@FBcancel}{}

\AtBeginDocument{%
\@ifundefined{frenchbsetup}%
{}%
{%
    \frenchbsetup{FrenchFootnotes=false}%
%    \end{macrocode}
% ^^A OR: redefine \insertfootnotemarkFB?
%    \begin{macrocode}
%
    \LetLtxMacro\LWR@FBcancel\NoAutoSpacing%
    \renewcommand*{\FBcolonspace}{%
        \begingroup%
        \LWR@FBcancel%
        \LWR@origampersand{}nbsp;%
        \endgroup%
    }%
    \renewcommand*{\FBthinspace}{%
        \begingroup%
        \LWR@FBcancel%
        \LWR@origampersand\#x202f;% \,
        \endgroup%
    }%
    \renewcommand*{\FBguillspace}{%
        \begingroup%
        \LWR@FBcancel%
        \LWR@origampersand{}nbsp;% ~,  for \og xyz \fg{}
        \endgroup%
    }%
    \DeclareDocumentCommand{\FBmedkern}{}{%
        \begingroup%
        \LWR@FBcancel%
        \LWR@origampersand\#x202f;% \,
        \endgroup%
    }%
    \DeclareDocumentCommand{\FBthickkern}{}{%
        \begingroup%
        \LWR@FBcancel%
        \LWR@origampersand{}nbsp;% ~
        \endgroup%
    }%
    \renewcommand*{~}{\HTMLentity{nbsp}}% was overwritten by babel-french
    \ifFBunicode%
    \else%
        \DeclareTextSymbol{\FBtextellipsis}{LY1}{133}%
        \DeclareTextCommandDefault{\FBtextellipsis}{\textellipsis\xspace}%
    \fi%
}%
}
%    \end{macrocode}


% \subsection{HTML tags}


% \begin{macro}{\LWR@htmltagc} \marg{tag}
% Break ligatures and use upright apostrophes in \HTML\ tags.
%
%|\protect| is in case the tag appears in TOC, LOF, LOT.
%    \begin{macrocode}
\newcommand*{\LWR@htmltagc}[1]{%
{%
% \LWR@traceinfo{LWR@htmltagc \detokenize{#1}}%
\begingroup%
\LWR@FBcancel%
\ifmmode\else\protect\LWR@origttfamily\fi%
\protect\LWR@origtextless#1\protect\LWR@origtextgreater%
\endgroup%
}%
}
%    \end{macrocode}
% \end{macro}
% 


% \begin{environment}{LWR@nestspan} Disable \env{minipage}, \cs{parbox},
%	and \HTML\ \element{div}s inside a \element{span}.
%
% |\begin{LWR@nestspan}| must follow the opening \element{span} tag to allow
% \watchout
% a paragraph to start if the span is at the beginning of a new paragraph.
%
% |\end{LWR@nestspan}| must follow the \element{/span} or a \element{p} may appear
% \watchout
%	inside the span.
%
% \changes{v0.20}{2016/12/24}{Fix: Minipages inside a span.}
% \changes{v0.34}{2017/07/29}{Fix: Minipages, BlocksClass, and lists inside a span.}
% \changes{v0.44}{2017/11/15}{Added \env{list} and \env{trivlist}.}
%
%    \begin{macrocode}
\newcommand*{\LWR@nestspanitem}{%
\if@newlist\else{\LWR@htmltagc{br /}}\fi%
\LWR@origitem%
}

\newenvironment*{LWR@nestspan}
{%
\LWR@traceinfo{LWR@nestspan}%
\ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
{%
    \LWR@traceinfo{LWR@nestspan: inside a lateximage}%
}%
{% not in a lateximage
    \LWR@traceinfo{LWR@nestspan: NOT inside a lateximage}%
    \addtocounter{LWR@spandepth}{1}%
    \RenewDocumentEnvironment{minipage}{O{t} o O{t} m}{}{}%
    \RenewDocumentEnvironment{BlockClass}{o m}{}{}%
    \renewcommand{\BlockClassSingle}[2]{##2}%
    \renewcommand{\LWR@forcenewpage}{}%
    \renewcommand{\LWR@liststart}{%
        \let\item\LWR@nestspanitem%
    }%
    \renewcommand{\LWR@listend}{\LWR@htmltagc{br /}\LWR@htmltagc{br /}}%
}% not in a lateximage
}% starting env
{% ending env
\ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
{}%
{\addtocounter{LWR@spandepth}{-1}}%
\LWR@traceinfo{LWR@nestspan: done}%
}

\AfterEndEnvironment{LWR@nestspan}{\global\let\par\LWR@closeparagraph}
%    \end{macrocode}
% \end{environment}


% \begin{macro}{\LWR@htmlspan} \marg{tag} \marg{text}
%
% \cs{LWR@spandepth} is used to ensure that paragraph tags are not
% generated inside a span.  The exact sequence of when to add and subtract
% \watchout
% the counter is important to correctly handle the paragraph tags before
% and after the span.
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@htmlspan}{m +m}{%
\LWR@ensuredoingapar%
\LWR@htmltagc{#1}%
\begin{LWR@nestspan}%
#2%
\LWR@htmltagc{/#1}%
\end{LWR@nestspan}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@htmlspanclass} \oarg{style} \marg{class} \marg{text}
%
% \changes{v0.34}{2017/08/02}{Moved optional argument in front of mandatory.}
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@htmlspanclass}{o m +m}{%
\LWR@traceinfo{LWR@htmlspanclass #2}%
\LWR@ensuredoingapar%
\LWR@subhtmlelementclass{span}[#1]{#2}%
\begin{LWR@nestspan}%
#3%
\LWR@htmltagc{/span}%
\LWR@traceinfo{LWR@htmlspanclass done}%
\end{LWR@nestspan}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@htmltag} \marg{tag}

% Print an \HTML\ tag: \textless{}tag\textgreater{}
%    \begin{macrocode}
\newcommand*{\LWR@htmltagb}[1]{%
\LWR@htmltagc{#1}%
\endgroup%
}

\newcommand*{\LWR@htmltag}{%
\begingroup\catcode`\_=12
\LWR@htmltagb%
}
%    \end{macrocode}
% \end{macro}

% \subsection{Block tags and comments}

% In the following, |\origttfamily| breaks ligatures, which may not be used for \HTML\ codes:
%
% \begin{macro}{\LWR@htmlopencomment}
% \begin{macro}{\LWR@htmlclosecomment}
%    \begin{macrocode}
\newcommand*{\LWR@htmlopencomment}{%
{%
% \LWR@traceinfo{LWR@htmlopencomment}%
\begingroup%
\LWR@FBcancel%
\ifmmode\else\protect\LWR@origttfamily\fi%
\LWR@origtextless{}!{-}{-}%
\endgroup%
}%
}

\newcommand*{\LWR@htmlclosecomment}{%
{%
% \LWR@traceinfo{LWR@htmlclosecomment}%
\begingroup%
\LWR@FBcancel%
\ifmmode\else\protect\LWR@origttfamily\fi%
{-}{-}\LWR@origtextgreater{}%
\endgroup%
}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}

% \begin{macro}{\LWR@htmlcomment} \marg{comment}
%
% \changes{v0.28}{2017/04/13}{Breaks ligatures in \HTML\ comments.}
%
%    \begin{macrocode}
\newcommand{\LWR@htmlcomment}[1]{%
\LWR@htmlopencomment{}%
{%
\LWR@origttfamily% break ligatures
#1%
}%
\LWR@htmlclosecomment{}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LWR@htmlblockcomment} \marg{comment}
%    \begin{macrocode}
\newcommand{\LWR@htmlblockcommentb}[1]
{\LWR@stoppars\LWR@htmlcomment{#1}\LWR@startpars\endgroup}

\newcommand{\LWR@htmlblockcomment}
{%
\begingroup\catcode`\_=12
\LWR@htmlblockcommentb%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@htmlblocktag} \marg{tag}  print a stand-alone \HTML\ tag
%    \begin{macrocode}
\newcommand*{\LWR@htmlblocktag}[1]{%
\LWR@stoppars%
\LWR@htmltag{#1}%
\LWR@startpars%
}
%    \end{macrocode}
% \end{macro}



% \subsection{Div class and element class}

% \begin{macro}{\LWR@subhtmlelementclass} \marg{element} \oarg{style} \marg{class}
%
% Factored and reused in several places.
%
% The trailing spaces allow more places for a line break.
%
% \changes{v0.20}{2017/01/17}{Factored code.}
% \changes{v0.34}{2017/08/02}{Moved optional argument in front of mandatory.}
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@subhtmlelementclass}{m O{} m}{%
\LWR@traceinfo{LWR@subhtmlelementclass #1 #3}%
\ifblank{#2}%
{\LWR@htmltag{#1 class="#3"}}% empty option
{\LWR@htmltag{#1 class="#3" style="#2"}}% non-empty option
\LWR@traceinfo{LWR@subhtmlelementclass done}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@htmlelementclass} \marg{element} \marg{class} \oarg{style}
%
% \changes{v0.20}{2017/01/17}{Added optional style.}
% \changes{v0.34}{2017/08/02}{Moved optional argument in front of mandatory.}
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@htmlelementclass}{m o m}{%
\LWR@stoppars%
\LWR@subhtmlelementclass{#1}[#2]{#3}%
\LWR@startpars%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@htmlelementclassend} \marg{element} \marg{class}
%    \begin{macrocode}
\newcommand*{\LWR@htmlelementclassend}[2]{%
\LWR@stoppars%
\LWR@htmltag{/#1}%
\ifbool{HTMLDebugComments}{%
    \LWR@htmlcomment{End of #1 ``#2''}%
}{}%
\LWR@startpars%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@htmldivclass} \oarg{style} \marg{class}
%
% \changes{v0.20}{2017/01/17}{Added optional style.}
% \changes{v0.34}{2017/08/02}{Moved optional argument in front of mandatory.}
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@htmldivclass}{o m}{%
\LWR@htmlelementclass{div}[#1]{#2}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@htmldivclassend} \marg{class}
%    \begin{macrocode}
\newcommand*{\LWR@htmldivclassend}[1]{%
\LWR@htmlelementclassend{div}{#1}%
}
%    \end{macrocode}
% \end{macro}

% \subsection{Single-line elements}

% A single-line element, without a paragraph tag for the line of text:

% \begin{macro}{\LWR@htmlelementclassline}
%				\marg{element} \oarg{style} \marg{class} \marg{text}
%
% \changes{v0.34}{2017/08/02}{Moved optional argument in front of mandatory.}
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@htmlelementclassline}{m o m +m}{%
\LWR@stoppars
\LWR@subhtmlelementclass{#1}[#2]{#3}%
#4%
\LWR@htmltag{/#1}
\LWR@startpars
}
%    \end{macrocode}
% \end{macro}
% 
% 


% \subsection{HTML5 semantic elements}


% \begin{macro}{\LWR@htmlelement} \marg{element}
%    \begin{macrocode}
\newcommand*{\LWR@htmlelement}[1]{%
\LWR@htmlblocktag{#1}
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@htmlelementend} \marg{element}
%    \begin{macrocode}
\newcommand*{\LWR@htmlelementend}[1]{%
\LWR@stoppars
\LWR@htmltag{/#1}
\LWR@startpars
}

\end{warpHTML}
%    \end{macrocode}
% \end{macro}



% \subsection{High-level block and inline classes}
% \label{sec:highlevelclasses}
%

% These are high-level commands which allow the creation of
% arbitrary block or inline
% sections which may be formatted with \CSS.
%
% Nullified versions are provided for print mode.
%
% For other direct-formatting commands, see \cref{sec:directformatting}.
%
%
% \begin{environment}{BlockClass} \oarg{style} \marg{class} \quad
% High-level interface for \element{div} classes.
%
% \qquad Ex: |\begin{BlockClass}{class}| text |\end{BlockClass}|
%
% \changes{v0.20}{2017/01/03}{Renamed from "blockclass".}
% \changes{v0.20}{2017/01/17}{Added optional style.}
% \changes{v0.34}{2017/08/02}{Moved optional argument in front of mandatory.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
\NewDocumentEnvironment{BlockClass}{o m}%
{
\LWR@htmldivclass[#1]{#2}
}
{
\LWR@htmldivclassend{#2}
}
\end{warpHTML}
%    \end{macrocode}
% 
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\NewDocumentEnvironment{BlockClass}{o m}{}{}%
\end{warpprint}
%    \end{macrocode}
% \end{environment}
% 
% 
% \begin{macro}{\BlockClassSingle} \marg{class} \marg{text} \quad
% A single-line \element{div}, without a paragraph tag for the line of text.
% 
% \changes{v0.20}{2017/01/03}{Renamed from "LWR@htmldivclassline".}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
\newcommand{\BlockClassSingle}[2]{%
\LWR@htmlelementclassline{div}{#1}{#2}%
}
\end{warpHTML}
%    \end{macrocode}
%
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\newcommand{\BlockClassSingle}[2]{#2}
\end{warpprint}
%    \end{macrocode}
% 
% \end{macro}


% \begin{macro}{\InlineClass} \oarg{style} \marg{class} \marg{text} \quad
% High-level interface for inline span classes.
%
% \changes{v0.20}{2017/01/03}{Renamed from "inlineclass".}
% \changes{v0.34}{2017/08/02}{Moved optional argument in front of mandatory.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
\NewDocumentCommand{\InlineClass}{o m +m}{%
\LWR@htmlspanclass[#1]{#2}{#3}%
}
\end{warpHTML}
%    \end{macrocode}
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\NewDocumentCommand{\InlineClass}{o m +m}{#3}%
\end{warpprint}
%    \end{macrocode}
% \end{macro}


% \begin{environment}{LWR@BlockClassWP} \marg{WPstyle} \marg{HTMLstyle} \marg{class} \quad
% Low-level interface for \element{div} classes with an automatic float ID.
% These are often used when |\ifbool{FormatWP}|.
%
% \changes{v0.42}{2017/10/26}{Added to factor code.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
\NewDocumentEnvironment{LWR@BlockClassWP}{m m m}%
{%
\LWR@stoppars%
\ifbool{FormatWP}%
{%
    \LWR@maybeincthisautoid%
    \LWR@htmltag{%
        div class="#3" %
        id="autoid-\arabic{LWR@thisautoid}"%
        \ifblank{#1}{}{ style="#1"}%
    }%
}% FormatWP
{% not FormatWP
    \LWR@htmltag{%
        div class="#3"%
        \ifblank{#2}{}{ style="#2"}%
    }%
}% not FormatWP
\LWR@startpars%
}
{\LWR@htmldivclassend{#3}}
\end{warpHTML}
%    \end{macrocode}
% 
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\NewDocumentEnvironment{LWR@BlockClassWP}{m m m}{}{}%
\end{warpprint}
%    \end{macrocode}
% \end{environment}
% 
% 



% \subsection{Closing HTML tags}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% Sections H1, H2, etc.\ do not need a closing \HTML\ tag, but we add a comment for readability:
%    \begin{macrocode}
\newcommand*{\LWR@printclosepart}
    {\ifbool{HTMLDebugComments}{\LWR@htmlcomment{Closing part}}{}}
\newcommand*{\LWR@printclosechapter}
    {\ifbool{HTMLDebugComments}{\LWR@htmlcomment{Closing chapter}}{}}
\newcommand*{\LWR@printclosesection}
    {\ifbool{HTMLDebugComments}{\LWR@htmlcomment{Closing section}}{}}
\newcommand*{\LWR@printclosesubsection}
    {\ifbool{HTMLDebugComments}{\LWR@htmlcomment{Closing subsection}}{}}
\newcommand*{\LWR@printclosesubsubsection}
    {\ifbool{HTMLDebugComments}{\LWR@htmlcomment{Closing subsubsection}}{}}
\newcommand*{\LWR@printcloseparagraph}
    {\ifbool{HTMLDebugComments}{\LWR@htmlcomment{Closing paragraph}}{}}
\newcommand*{\LWR@printclosesubparagraph}
    {\ifbool{HTMLDebugComments}{\LWR@htmlcomment{Closing subparagraph}}{}}
%    \end{macrocode}

% Lists require closing \HTML\ tags:
%    \begin{macrocode}
\newcommand*{\LWR@printcloselistitem}
    {\LWR@htmltag{/li}}
\newcommand*{\LWR@printclosedescitem}
    {\LWR@htmltag{/dd}}
\newcommand*{\LWR@printcloseitemize}
    {\LWR@htmltag{/ul}}
\newcommand*{\LWR@printcloseenumerate}
    {\LWR@htmltag{/ol}}
\newcommand*{\LWR@printclosedescription}
    {\LWR@htmltag{/dl}}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}





% \section{Paragraph handling}
% \label{sec:parhanding}
%
% These commands generate the \HTML\ paragraph tags when allowed and
% required.
%
% Paragraph tags are or are not allowed depending on many conditions.
% \Cref{sec:parstartstop} has high-level commands which allow
% paragraph-tag generation to start/stop.
% Even when allowed (\cs{LWR@doingstartpars}),
% tags are not generated until a \LaTeX{} paragraph
% is being used (\cs{LWR@doingapar}).
% |LWR@lateximagedepth| is used to prevent nesting tags inside
% a |lateximage|.
% |LWR@spandepth| is used to prevent nesting paragraph tags inside
% a paragraph, which became important inside \cs{fbox} commands and other spans.

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \DescribeCounter{LWR@spandepth}
% Do not create paragraph tags inside of an \HTML\ span.
%    \begin{macrocode}
\newcounter{LWR@spandepth}
\setcounter{LWR@spandepth}{0}
%    \end{macrocode}


% \DescribeBoolean{LWR@doingstartpars}
% Tells whether paragraphs may be generated.
%    \begin{macrocode}
\newbool{LWR@doingstartpars}
\boolfalse{LWR@doingstartpars}
%    \end{macrocode}

% \DescribeBoolean{LWR@doingapar}
%  Tells whether have actually generated and are currently processing paragraph text.
%    \begin{macrocode}
\newbool{LWR@doingapar}
\global\boolfalse{LWR@doingapar}
%    \end{macrocode}


% \begin{macro}{\LWR@ensuredoingapar}
% If are about to print something visible, and
% if allowed to start a new paragraph,
% ensure that are |LWR@doingapar|, so that paragraph tags are placed:
%    \begin{macrocode}
\newcommand*{\LWR@ensuredoingapar}{%
\ifbool{LWR@doingstartpars}%
{\global\booltrue{LWR@doingapar}}%
{}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@openparagraph}
%    \begin{macrocode}
\newcommand*{\LWR@openparagraph}
{%
%    \end{macrocode}
% See if paragraph handling is enabled:
%    \begin{macrocode}
\ifbool{LWR@doingstartpars}%
{% handling pars
%    \end{macrocode}
% See if have already started a \env{lateximage} or a \element{span}.
% If so, do not generate nested paragraph tags.
%    \begin{macrocode}
    \ifboolexpr{
        test {\ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}} or
        test {\ifnumcomp{\value{LWR@spandepth}}{>}{0}}
    }% nested par tags?
%    \end{macrocode}
% If so: Do nothing if already started a \env{lateximage} page.  Cannot nest a \env{lateximage}.
% Also do nothing if already inside a \element{span}.  Do not nest paragraph tags
% inside a \element{span}.
%    \begin{macrocode}
    {}% no nested par tags
%    \end{macrocode}
% Else: No \env{lateximage} or \element{span} has been started yet,
% so it's OK to generate paragraph tags.
%    \begin{macrocode}
    {% yes nest par tags
        \LWR@htmltagc{\LWR@tagregularparagraph}%
%    \end{macrocode}
% Manually indent item list labels to avoid left margin intrustion:
%
% See if are nested inside an item list:
%    \begin{macrocode}
        \ifnumcomp{\@listdepth}{>}{0}%
        {%
%    \end{macrocode}
% If so,  leave some horizontal room in the \LaTeX{} \PDF\ output for list labels:
%    \begin{macrocode}
        \LWR@orighspace{1in}%
        }%
        {}%
%    \end{macrocode}
% Now have started a paragraph.
%    \begin{macrocode}
        \global\booltrue{LWR@doingapar}%
%    \end{macrocode}
% At the endof each paragraph,
% generate closing tag and do regular |/par| stuff.
% (Attempting to use the \pkg{everyhook} |cr| hook
% for \cs{LWR@closeparagraph} does not work well.)
%    \begin{macrocode}
        \let\par\LWR@closeparagraph%
    }% end of yes nest par tags
}% end of handling pars
{}% not handling pars
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\LWR@closeparagraph}
% \changes{v0.20}{2017/01/17}{No break tags in the start/end of a tabular.}
% \changes{v0.20}{2017/01/17}{\cs{unskip} extra spaces.}
% \changes{v0.36}{2017/08/15}{Extra \protect\HTML\ source space after paragraphs.}
%    \begin{macrocode}
\newcommand*{\LWR@closeparagraph}
{%
%    \end{macrocode}
% See if paragraph handling is enabled:
%    \begin{macrocode}
\ifbool{LWR@doingapar}%
%    \end{macrocode}
% If currently in paragraph mode:
%    \begin{macrocode}
{% handling pars
%    \end{macrocode}
% See if already started a \env{lateximage} or a \element{span}:
%    \begin{macrocode}
    \ifboolexpr{
        test {\ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}} or
        test {\ifnumcomp{\value{LWR@spandepth}}{>}{0}}
    }%
%    \end{macrocode}
% Do nothing if already started a \env{lateximage} or a \element{span},
% but add a parbreak if in a span but not a \env{lateximage}.
%    \begin{macrocode}
    {% no nested par tags
        \ifboolexpr{
            test {\ifnumcomp{\value{LWR@spandepth}}{>}{0}} and
            test {\ifnumcomp{\value{LWR@lateximagedepth}}{=}{0}}
        }%
        {\ifbool{LWR@intabularmetadata}{}{\unskip\LWR@htmltagc{br /}}}%
        {}%
    }% no nested par tags
%    \end{macrocode}
% If have not already started a \env{lateximage} or a \element{span}:
%    \begin{macrocode}
    {% yes nest par tags
%    \end{macrocode}
% Print a closing tag and some extra vertical space:
%    \begin{macrocode}
        \unskip%
        \LWR@htmltagc{/\LWR@tagregularparagraph}%
        \LWR@orignewline%
%    \end{macrocode}
% No longer doing a paragraph:
%    \begin{macrocode}
        \global\boolfalse{LWR@doingapar}%
% Disable the special \env{minipage} \& \cs{hspace} interaction
% until a new minipage is found:
%    \begin{macrocode}
        \global\boolfalse{LWR@minipagethispar}%
    }% end of yes nest par tags
}% end of handling pars
%    \end{macrocode}
% Add a parbreak if in a span,
% but not in a table outside a row:
%    \begin{macrocode}
{% not handling pars
    \ifnumcomp{\value{LWR@spandepth}}{>}{0}%
    {\ifbool{LWR@intabularmetadata}{}{\unskip\LWR@htmltagc{br /}}}%
    {}%
}% not handling pars
%    \end{macrocode}
% Finish with regular paragraph processing
%    \begin{macrocode}
\LWR@origpar%
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \section{Paragraph start/stop handling}
% \label{sec:parstartstop}
% These commands allow/disallow the generation of \HTML\
% paragraph tags.
%
% \Cref{sec:parhanding} has the commands which actually generate
% the tags.
%
% The |everyhook| package is used to generate the opening
% paragraph tags.  The closing tags are generated by |\par|.

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \begin{macro}{\LWR@startpars}
% Begin handling \HTML\ paragraphs.
% This allows an \HTML\ paragraph to start, but one has not yet begun.
%    \begin{macrocode}
\newcommand*{\LWR@startpars}%
{%
%    \end{macrocode}
% Ignore if inside a span:
%    \begin{macrocode}
\ifnumcomp{\value{LWR@spandepth}}{>}{0}%
{}%
{%
%    \end{macrocode}
% See if currently handling \HTML\ paragraphs:
%    \begin{macrocode}
    \ifbool{LWR@doingstartpars}%
%    \end{macrocode}
% If already in paragraph mode, do nothing.
%    \begin{macrocode}
    {}%
%    \end{macrocode}
% If not currently in paragraph mode:
%    \begin{macrocode}
    {%
%    \end{macrocode}
%	At the start of each paragraph, generate an opening tag:
%    \begin{macrocode}
        \PushPreHook{par}{\LWR@openparagraph}%
%    \end{macrocode}
%	At the end of each paragraph, generate closing tag and do regular |/par| actions:
%    \begin{macrocode}
        \let\par\LWR@closeparagraph

    }% an intentionally blank line
%    \end{macrocode}
% Are now handling paragraphs, but have not yet actually started one:
%    \begin{macrocode}
    \global\setbool{LWR@doingstartpars}{true}%
%    \end{macrocode}
% No <par> tag yet to undo:
%    \begin{macrocode}
    \global\boolfalse{LWR@doingapar}%
}% nestspan
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@stoppars}
% Stop handling \HTML\ paragraphs.
% Any currently open \HTML\ paragraph is closed, and no more will be opened.
%
% \changes{v0.36}{2017/08/15}{Extra \protect\HTML\ source space after paragraphs.}
%    \begin{macrocode}
\newcommand*{\LWR@stoppars}%
{%
%    \end{macrocode}
% Ignore if inside a span:
%    \begin{macrocode}
\ifnumcomp{\value{LWR@spandepth}}{>}{0}%
{}%
{%
%    \end{macrocode}
% See if currently handling \HTML\ paragraphs:
%    \begin{macrocode}
    \ifbool{LWR@doingapar}%
%    \end{macrocode}
% if currently in an \HTML\ paragraph:
%    \begin{macrocode}
    {%
%    \end{macrocode}
% Print a closing tag:
%    \begin{macrocode}
        \unskip%
        \LWR@htmltagc{/\LWR@tagregularparagraph}%
        \LWR@orignewline%
%    \end{macrocode}
% No longer have an open \HTML\ paragraph:
%    \begin{macrocode}
        \global\boolfalse{LWR@doingapar}%
%    \end{macrocode}
% Disable the special \env{minipage} \& \cs{hspace} interaction
% until a new minipage is found:
%    \begin{macrocode}
        \global\boolfalse{LWR@minipagethispar}

    }% an intentionally blank line
%    \end{macrocode}
% If was not in an \HTML\ paragraph:
%    \begin{macrocode}
    {}%
%    \end{macrocode}
% See if currently allowing \HTML\ paragraphs:
%    \begin{macrocode}
    \ifbool{LWR@doingstartpars}%
%    \end{macrocode}
% If so: clear the |par| hook to no longer catch paragraphs:
%    \begin{macrocode}
    {\ClearPreHook{par}}%
%    \end{macrocode}
% Else: do nothing
%    \begin{macrocode}
    {}%
%    \end{macrocode}
% no longer in paragraph mode
%    \begin{macrocode}
    \global\setbool{LWR@doingstartpars}{false}%
%    \end{macrocode}
% no \element{p} tag to undo:
%    \begin{macrocode}
    \global\boolfalse{LWR@doingapar}%
}% nestspan
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \section{Page headers and footers}

% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% In the following, catcode is manually changed back and forth
% without groups, since new macros are being defined which must
% not be contained within the groups.
%    \begin{macrocode}
\newcommand{\LWR@firstpagetop}{}	% for the home page alone
\newcommand{\LWR@pagetop}{}			% for all other pages
\newcommand{\LWR@pagebottom}{}

\newcommand{\LWR@setfirstpagetopb}[1]{%
\renewcommand{\LWR@firstpagetop}{#1}
\catcode`\_=8
}
%    \end{macrocode}
% \begin{macro}{\HTMLFirstPageTop} \marg{text and logos}
%
% \changes{v0.30}{2017/04/28}{Renamed from \cs{SetFirstPageTop}.}
%
%    \begin{macrocode}
\newcommand{\HTMLFirstPageTop}{%
\catcode`\_=12
\LWR@setfirstpagetopb
}
%    \end{macrocode}
%
%
% \end{macro}
%    \begin{macrocode}
\newcommand{\LWR@setpagetopb}[1]{%
\renewcommand{\LWR@pagetop}{#1}
\catcode`\_=8
}
%    \end{macrocode}
%
%
% \begin{macro}{\HTMLPageTop} \marg{text and logos}
%
% \changes{v0.30}{2017/04/28}{Renamed from \cs{SetPageTop}.}
%
%    \begin{macrocode}
\newcommand{\HTMLPageTop}{%
\catcode`\_=12
\LWR@setpagetopb
}
%    \end{macrocode}
% \end{macro}
%
%
%    \begin{macrocode}
\newcommand{\LWR@setpagebottomb}[1]{%
\renewcommand{\LWR@pagebottom}{#1}
\catcode`\_=8
}
%    \end{macrocode}
%
%
% \begin{macro}{\HTMLPageBottom} \marg{text and logos}
%
% \changes{v0.30}{2017/04/28}{Renamed from \cs{SetPageBottom}.}
%
%    \begin{macrocode}
\newcommand{\HTMLPageBottom}{%
\catcode`\_=12
\LWR@setpagebottomb
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}



% \section{CSS}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{macro}{\LWR@currentcss} The \CSS\ filename to use.
% This may be changed mid-document using \cs{CSSFilename},
% allowing different \CSS\ files to be used
% for different sections of the document.

%    \begin{macrocode}
\newcommand*{\LWR@currentcss}{lwarp.css}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\CSSFilename} \marg{new-css-filename.css} \qquad
% Assigns the \CSS\ file to be used by the following \HTML\ pages.
%
% \changes{v0.30}{2017/04/28}{Renamed from \cs{NewCSS}.}
%
%    \begin{macrocode}
\newcommand*{\LWR@newcssb}[1]{%
\renewcommand*{\LWR@currentcss}{#1}
\catcode`\_=8
}

\newcommand*{\CSSFilename}{
\catcode`\_=12
\LWR@newcssb
}
\end{warpHTML}
%    \end{macrocode}
%
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\newcommand*{\CSSFilename}[1]{}
\end{warpprint}
%    \end{macrocode}
% \end{macro}



% \section{Title, HTML meta author, HTML meta description}
%
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
% \begin{macro}{\title} \marg{title}
% Modified to remember \cs{thetitle}, which is used to set the \HTML\ page titles.
% \index{HTML>meta tag>title}
% \index{title>HTML meta tag}
% \index{meta tag, HTML>title}
% \changes{v0.44}{2017/11/18}{Added \cs{thetitle}.}
%    \begin{macrocode}
\let\LWR@origtitle\title

\renewcommand*{\title}[1]{%
    \LWR@origtitle{#1}%
    \begingroup%
        \renewcommand{\thanks}[1]{}%
        \protected@xdef\thetitle{#1}%
    \endgroup%
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}
%
% \begin{macro}{\HTMLTitle} \marg{Titlename} \qquad
%   The Title to place into an \HTML\ meta tag.
%   The default is to use the document \cs{title}'s setting.
%
% \index{HTML>meta tag>Title}
% \index{Title>HTML meta tag}
% \index{meta tag, HTML>Title}
%
% \changes{v0.44}{2017/11/18}{Added.}
%
%    \begin{macrocode}
\providecommand{\thetitle}{}

\newcommand{\theHTMLTitle}{\thetitle}

\newcommand{\HTMLTitle}[1]{\renewcommand{\theHTMLTitle}{#1}}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\HTMLAuthor} \marg{authorname} \qquad
%   The author to place into an \HTML\ meta tag.
%   If none given, the default is \cs{theauthor}, which is empty unless
%   the \pkg{titling} package is used.
%
% \index{HTML>meta tag>author}
% \index{author>HTML meta tag}
% \index{meta tag, HTML>author}
%
% \changes{v0.28}{2017/04/06}{Added \cs{HTMLauthor}. (Renamed in v0.30.)}
% \changes{v0.30}{2017/04/28}{Renamed from \cs{HTMLauthor}.}
% \changes{v0.33}{2017/06/18}{Fix: Provides empty default author if none given.}
%
%    \begin{macrocode}
\providecommand{\theauthor}{}

\newcommand{\theHTMLAuthor}{\theauthor}

\newcommand{\HTMLAuthor}[1]{\renewcommand{\theHTMLAuthor}{#1}}
%    \end{macrocode}
% \end{macro}


% This is placed inside an \HTML\ meta tag at the start of each file.
% This may be changed mid-document using \cs{HTMLDescription},
% allowing different \HTML\ descriptions to be used
% for different sections of the document.
%
% Do not use double quotes, and do not exceed 150 characters.\watchout

% \begin{macro}{\HTMLDescription} \marg{New \HTML\ meta description.} \qquad
% Assigns the \HTML\ file's description meta tag.
%
% \index{HTML>meta tag>description}
% \index{description>HTML meta tag}
% \index{meta tag, HTML>description}
%
% \changes{v0.20}{2016/06/27}{Added \cs{NewHTMLdescription}.  (Renamed in v0.30.)}
% \changes{v0.30}{2017/04/28}{Renamed from \cs{NewHTMLdescription}.}
%
%    \begin{macrocode}
\newcommand{\LWR@currentHTMLDescription}{}

\newcommand{\HTMLDescription}[1]{%
\renewcommand{\LWR@currentHTMLDescription}{#1}
}

\end{warpall}
%    \end{macrocode}
% \end{macro}



% \section{Footnotes}
% \label{sec:footnotes}
%
% \index{footnotes}
%
% \limitsfootnotes
%
% \changes{v0.26}{2017/03/28}{Footnotes now are \LaTeX\ boxes instead of pagenotes.}
%
% Several kinds of footnotes are used: in a regular page, in a minipage, or
% as thanks in the titlepage.  Each of these is handle differently.
%
% \subsection{Regular page footnotes}
% In \HTML\ documents, footnotes are placed at the
% bottom of the web page using the \LaTeX\ box \cs{LWR@footnotes}.
% Using this instead of the original \cs{footins} box
% avoids having footnotes be printed by the output routine,
% since footnotes should be printed per \HTML\ page
% instead of per \PDF\ page.
%
% See \cref{sec:footnotesregular} for the implementation.
%
% \subsection{Minipage footnotes}
% See \cref{sec:footnotesminipage} for how minipage footnotes are gathered.
% See \cref{sec:footnotesminipageplaced} for how minipage footnotes are placed into
% the document.
%
% \subsection{Titlepage thanks}
% See \cref{sec:titlehtml} for titlepage footnotes.
%
% \subsection{Regular page footnote implementation}
% \label{sec:footnotesregular}
%
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \DescribeCounter{FootnoteDepth} \DescribeDefault{5} Determines how deeply
% to place footnotes in the \HTML\ files, similar to |tocdepth|.
% The default of |5| places footnotes before each \cs{subparagraph} or higher.
% See \cref{tab:depthsheadings} for a table of \LaTeX\ section headings.
% \changes{v0.43}{2017/11/08}{Added \protect\texttt{FootnoteDepth}.}
%    \begin{macrocode}
\newcounter{FootnoteDepth}
\setcounter{FootnoteDepth}{5}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}



% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% Patch \LaTeX\ footnotes to use a new \cs{box} for \pkg{lwarp} footnotes.
%    \begin{macrocode}
\newbox\LWR@footnotes
%    \end{macrocode}
%
% Much of the following has unneeded print-mode formatting removed.
%
% \begin{macro}{\@makefntext} \marg{text}
%    \begin{macrocode}
\long\def\@makefntext#1{\textsuperscript{\@thefnmark} #1}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@makefnmark}
%    \begin{macrocode}
\def\@makefnmark{\hbox{\textsuperscript{\@thefnmark}}}
%    \end{macrocode}
% \end{macro}
%
%
% Footnotes may be in regular text, in which case paragraphs are tagged,
% or in a table data cell or \env{lateximage},
% in which case paragraph tags must be added manually.
%
% In a \env{lateximage} during \HTML\ output, the \env{lateximage} is placed
% inside a print-mode \env{minipage}, but the footnotes are broken out by:
% \begin{sourcedisplay}
% \cs{def}\cs{@mpfn}\{footnote\} \\
% \cs{def}\cs{thempfn}\{\cs{thefootnote}\} \\
% \cs{let}\cs{@footnotetext}\cs{LWR@footnotetext}
% \end{sourcedisplay}
%
% \begin{macro}{\LWR@footnotetext} \marg{text}
%
% \changes{v0.27}{2017/04/04}{Fix for table footnote par tags.}
% \changes{v0.36}{2017/08/15}{Extra \protect\HTML\ source space after paragraphs.}
% \changes{v0.36}{2017/08/16}{Force \protect\HTML\ superscripts.}
%
%    \begin{macrocode}
\long\def\LWR@footnotetext#1{%
\LWR@traceinfo{LWR@footnotetext}%
\global\setbox\LWR@footnotes=\vbox{%
%    \end{macrocode}
% Add to any current footnotes:
%    \begin{macrocode}
    \unvbox\LWR@footnotes%
%    \end{macrocode}
% Remember the footnote number for \cs{ref}:
%    \begin{macrocode}
    \protected@edef\@currentlabel{%
        \csname p@footnote\endcsname\@thefnmark%
    }% @currentlabel
%    \end{macrocode}
% Open a group:
%    \begin{macrocode}
    \color@begingroup%
%    \end{macrocode}
% Use \HTML\ superscripts even inside a \env{lateximage}:
%    \begin{macrocode}
    \renewcommand{\textsuperscript}[1]{\LWR@htmlspan{sup}{##1}}%
%    \end{macrocode}
% Use paragraph tags if in a tabular data cell or a \env{lateximage}:
%    \begin{macrocode}
    \ifthenelse{%
        \boolean{LWR@doingstartpars} \AND%
        \cnttest{\value{LWR@lateximagedepth}}{=}{0}%
    }%
    {}%
    {\LWR@htmltagc{\LWR@tagregularparagraph}}%
%    \end{macrocode}
% Append the footnote to the list:
%    \begin{macrocode}
    \@makefntext{#1}%
%    \end{macrocode}
% Closing paragraph tag:
%    \begin{macrocode}
    \ifthenelse{%
        \boolean{LWR@doingstartpars} \AND%
        \cnttest{\value{LWR@lateximagedepth}}{=}{0}%
    }%
    {\par}%
    {%
        \LWR@htmltagc{/\LWR@tagregularparagraph}%
        \LWR@orignewline%
    }%
%    \end{macrocode}
% Close the group:
%    \begin{macrocode}
    \color@endgroup%
}% vbox
}%
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\@footnotetext} \marg{text}
%    \begin{macrocode}
\let\@footnotetext\LWR@footnotetext
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Minipage footnote implementation}
% \label{sec:footnotesminipage}
%
% \begin{macro}{\@mpfootnotetext} \marg{text}
%    \begin{macrocode}
\long\def\@mpfootnotetext#1{%
\global\setbox\@mpfootins\vbox{%
    \unvbox\@mpfootins
    \reset@font\footnotesize
    \hsize\columnwidth
    \@parboxrestore
    \protected@edef\@currentlabel
    {\csname p@mpfootnote\endcsname\@thefnmark}%
    \color@begingroup
%    \end{macrocode}
% Use paragraph tags if in a tabular data cell or a \env{lateximage}:
%    \begin{macrocode}
    \ifthenelse{%
        \boolean{LWR@doingstartpars} \AND%
        \cnttest{\value{LWR@lateximagedepth}}{=}{0}%
    }%
    {}%
    {\LWR@htmltagc{\LWR@tagregularparagraph}}%
%    \end{macrocode}
%    \begin{macrocode}
    \@makefntext{%
        \ignorespaces#1%
    }%
%    \end{macrocode}
% Don't add the closing paragraph tag if are inside a \env{lateximage}:
%    \begin{macrocode}
    \ifthenelse{\cnttest{\value{LWR@lateximagedepth}}{>}{0}}%
    {}%
    {%
        \LWR@htmltagc{/\LWR@tagregularparagraph}%
        \LWR@orignewline%
    }%
    \color@endgroup%
}% vbox
}
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Printing pending footnotes}
%
% \begin{macro}{\LWR@printpendingfootnotes}
% Enclose the footnotes in a class, print, then clear.
%    \begin{macrocode}
\newcommand*{\LWR@printpendingfootnotes}{%
\ifvoid\LWR@footnotes\else
    \LWR@forcenewpage
    \begin{BlockClass}{footnotes}
    \LWR@origmedskip
    \unvbox\LWR@footnotes
    \setbox\LWR@footnotes=\vbox{}
    \end{BlockClass}
\fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LWR@maybeprintpendingfootnotes} \marg{depth}
% Used to print footnotes before sections only if formatting for an \EPUB\ or word processor:
% \changes{v0.43}{2017/11/08}{Added \protect\texttt{FootnoteDepth}.}
%    \begin{macrocode}
\newcommand*{\LWR@maybeprintpendingfootnotes}[1]{%
\ifboolexpr{
    not test{\ifnumcomp{#1}{>}{\value{FootnoteDepth}}} or
    bool{FormatEPUB} or
    bool{FormatWP}
}%
{\LWR@printpendingfootnotes}%
{}%
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}




% \section{Marginpars}
%
% \limitsmarginpars
% 
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \begin{macro}{\marginpar} \oarg{left} \marg{right}
%
% \changes{v0.21}{2017/02/11}{Fixed source listing.}
% \changes{v0.42}{2017/10/26}{If \protect\texttt{FormatWP} emulate a wrapfig.}
%
%    \begin{macrocode}
\renewcommand{\marginpar}[2][]{%
\ifbool{FormatWP}%
{%
\begin{LWR@BlockClassWP}{width:2in; float:right; margin:10pt}{}{marginblock}
#2
\end{LWR@BlockClassWP}
}%
{%
    \LWR@htmlspanclass{marginpar}{#2}%
}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\marginparBlock} \oarg{left} \marg{right}
%
% For use when the marginpar will be more than one paragraph,
% and/or contains more than simple text.
%
% HTML version.
%
% \changes{v0.21}{2017/02/11}{Fixed source listing.}
% \changes{v0.42}{2017/10/26}{If \protect\texttt{FormatWP} emulate a wrapfig.}
% \changes{v0.44}{2017/11/10}{Added.}
%
%    \begin{macrocode}
\newcommand{\marginparBlock}[2][]{%
\ifbool{FormatWP}%
{%
\begin{LWR@BlockClassWP}{width:2in; float:right; margin:10pt}{}{marginblock}
#2
\end{LWR@BlockClassWP}
}%
{%
\begin{BlockClass}[width:2in; float:right; margin:10pt]{marginparblock}
#2
\end{BlockClass}
}%
}
%    \end{macrocode}
% \end{macro}
%

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \codeprint
%    \begin{macrocode}
\begin{warpprint}
%    \end{macrocode}
%
% \begin{macro}{\marginparBlock} \oarg{left} \marg{right}
%
% For use when the marginpar will be more than one paragraph,
% and/or contains more than simple text.
%
% Print version.
%
%    \begin{macrocode}
\LetLtxMacro\marginparBlock\marginpar
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\end{warpprint}
%    \end{macrocode}



% \section{Splitting HTML files}
%
% \begin{itemize}
% \item Files are split according to |FileDepth| and |CombineHigherDepths|.
% \item Filenames are sanitized by |\LWR@filenamenoblanks|.
% \item |\LWR@newhtmlfile| finishes an \HTML\ page,
%	adds a comment to tell where and how to split the file,
%	then starts a new \HTML\ page.
% \end{itemize}


% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \DescribeCounter{FileDepth} \marg{section depth} determines how deeply
% to break into new \HTML\ files, similar to |tocdepth|.
% The default of -5 produces one large \HTML\ file.
%    \begin{macrocode}
\newcounter{FileDepth}
\setcounter{FileDepth}{-5}
%    \end{macrocode}


% \DescribeBoolean{CombineHigherDepths} Combile higher-level sections
%		together into one file?
%    \begin{macrocode}
\newbool{CombineHigherDepths}
\booltrue{CombineHigherDepths}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}


% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{macro}{\LWR@thisfilename}
% The currently-active filename or number.
%    \begin{macrocode}
\newcommand*{\LWR@thisfilename}{}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@thisnewfilename}
% The filename being sanitized.
%    \begin{macrocode}
\newcommand*{\LWR@thisnewfilename}{}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@filenamenoblanks} \marg{filename}
%
% Convert blanks into dashes, removes short words,
% store result in \\ |\LWR@thisfilename|.
%
% Be sure that this does not result in filename collisions!
% \watchout
% Use the optional TOC caption entry parameter for formatting.
% Remember to |\protect| \LaTeX{} commands which appear in
% section names and TOC captions.
%    \begin{macrocode}
\newcommand*{\LWR@filenamenoblanks}[1]{%
\begingroup
%    \end{macrocode}

% Locally temporarily disable direct-formatting commands,
% not used in filenames:
%    \begin{macrocode}
\LWR@nullfonts
\renewcommand*{\LWR@htmltagc}[1]{}%
%    \end{macrocode}
% Replaces common symbols and short words with hyphens:
%
%    \begin{macrocode}
\edef\LWR@thisnewfilename{#1}
\fullexpandarg
%    \end{macrocode}
% Convert spaces into hyphens:
%    \begin{macrocode}
\StrSubstitute{\LWR@thisnewfilename}{ }{-}[\LWR@thisnewfilename]
%    \end{macrocode}
% Convert punctutation into hyphens:
% ^^A \StrSubstitute{\LWR@thisnewfilename}{é}{e}[\LWR@thisnewfilename]
%    \begin{macrocode}
\StrSubstitute{\LWR@thisnewfilename}{,}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{'}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}%
    {\LWR@origampersand}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{+}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{,}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{/}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{:}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{;}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{=}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{?}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{@}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{"}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}%
    {\textless}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}%
    {\textgreater}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{\#}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{\%}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{\{}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{\}}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{|}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}%
    {\textbackslash}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{^}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{~{}}{-}[\LWR@thisnewfilename]
%     "~{}" for babel
\StrSubstitute{\LWR@thisnewfilename}{[}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{]}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{`}{-}[\LWR@thisnewfilename]
%    \end{macrocode}
% Convert short words:
%    \begin{macrocode}
\StrSubstitute{\LWR@thisnewfilename}{-s-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-S-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-a-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-A-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-an-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-AN-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-to-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-TO-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-by-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-BY-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-of-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-OF-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-and-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-AND-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-for-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-FOR-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-the-}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{-THE-}{-}[\LWR@thisnewfilename]
%    \end{macrocode}
% Convert multiple hyphens:
%    \begin{macrocode}
\StrSubstitute{\LWR@thisnewfilename}{-----}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{----}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{---}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{--}{-}[\LWR@thisnewfilename]
\StrSubstitute{\LWR@thisnewfilename}{—}{-}[\LWR@thisnewfilename]
%     emdash
\StrSubstitute{\LWR@thisnewfilename}{–}{-}[\LWR@thisnewfilename]
%     endash
\global\let\LWR@thisfilename\LWR@thisnewfilename% return a global result
\endgroup
}
%    \end{macrocode}
% \end{macro}




% \begin{macro}{\LWR@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.}
% \changes{v0.28}{2017/04/06}{If \texttt{FormatEPUB} or \texttt{FormatWordProcessor}: skips headers, footers, nav.}
%
% Finishes the current \HTML\ page with footnotes, footer, navigation,
% then starts a new \HTML\ page with an \HTML\ comment telling where to
% split the page and what the new filename and \CSS\ are, then adds
% navigation, side TOC, header, and starts the text body.
%    \begin{macrocode}
\newcommand*{\LWR@newhtmlfile}[1]{
%    \end{macrocode}

% At the bottom of the ending file:

%    \begin{macrocode}
\LWR@htmlelementclassend{section}{textbody}

\LWR@printpendingfootnotes

%    \end{macrocode}
%
% No footer between files if \EPUB:
%
%    \begin{macrocode}
\ifbool{FormatEPUB}
{}
{
    \LWR@htmlelement{footer}

    \LWR@pagebottom

    \LWR@htmlelementend{footer}
}
%    \end{macrocode}
%
% No bottom navigation if are finishing the home page or
% formatting for \EPUB\ or a word-processor.
%    \begin{macrocode}
\ifthenelse{\boolean{FormatEPUB}\OR\boolean{FormatWP}}
{}
{\ifnumcomp{\value{LWR@htmlfilenumber}}{>}{0}{\LWR@botnavigation}{}}
%    \end{macrocode}

% End of this \HTML\ file:
%    \begin{macrocode}
\LWR@stoppars
\LWR@htmltag{/body}\LWR@orignewline
\LWR@htmltag{/html}\LWR@orignewline
\LWR@orignewpage

\addtocounter{LWR@htmlfilenumber}{1}%
%    \end{macrocode}

% If using a filename, create a version without blanks.
% The filename without blanks will be placed into \cs{LWR@thisfilename}.
% If not using a filename, the file number will be used instead.
% \changes{v0.12}{2016/03/13}{Bugfix: TOC with numbered files.}
%    \begin{macrocode}
\ifbool{FileSectionNames}%
{\LWR@filenamenoblanks{#1}}
{\renewcommand*{\LWR@thisfilename}{\arabic{LWR@htmlfilenumber}}}
%    \end{macrocode}

% Include an \HTML\ comment to instruct lwarpmk
% where to split the files apart.
% Uses pipe-separated fields for |split_html.gawk|.
% Uses monospaced font with ligatures disabled for everything except the title.
%    \begin{macrocode}
\LWR@htmlblockcomment{%
|Start file|%
\LWR@htmlsectionfilename{\LWR@thisfilename}|%
}
%    \end{macrocode}

% At the top of the starting file:
%    \begin{macrocode}
\LWR@stoppars

%    \end{macrocode}
%
%
%    \begin{macrocode}
\LWR@filestart{ — #1}% there is an EMdash in front of the #1

%    \end{macrocode}
%
% No navigation between files if formatting for an \EPUB\ or word processor:
%    \begin{macrocode}
\ifthenelse{\boolean{FormatEPUB}\OR\boolean{FormatWP}}
{}
{\LWR@topnavigation}

%    \end{macrocode}
%
% No header if between files if formatting for an \EPUB\ or word processor:
%    \begin{macrocode}
\ifthenelse{\boolean{FormatEPUB}\OR\boolean{FormatWP}}
{}
{
    \LWR@htmlelement{header}

    \LWR@pagetop

    \LWR@htmlelementend{header}
}

%    \end{macrocode}
%
% Print title only if there is one.
% Skip if formatting for an \EPUB\ or word processor:
%    \begin{macrocode}
\ifthenelse{\boolean{FormatEPUB}\OR\boolean{FormatWP}}
{}
{\ifcsvoid{thetitle}{}{\LWR@printthetitle}}

%    \end{macrocode}
%
% No side\TOC\ if formatting for an \EPUB\ or word processor:
%    \begin{macrocode}
\ifthenelse{\boolean{FormatEPUB}\OR\boolean{FormatWP}}
{}
{\LWR@sidetoc}

%    \end{macrocode}
%
% Start of the \element{textbody}:
%    \begin{macrocode}
\LWR@htmlelementclass{section}{textbody}

%    \end{macrocode}
%
% Keep paragraph tags disabled for now:
%    \begin{macrocode}
\LWR@stoppars

%    \end{macrocode}
%
% Track the page numbers:
%    \begin{macrocode}
\setcounter{LWR@latestautopage}{\value{page}}
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}




% \section{Sectioning}

%
% Sectioning and cross-references have been emulated from scratch, rather
% than try to patch several layers of existing \LaTeX{} code and packages.
% Formatting is handled by \CSS, so the emulated code has much less
% work to do than the print versions.
%
% Section names and the resulting filenames with accented characters
% \margintag{Unicode}
% are partially supported, depending on the ability of
% |pdflatex| to generate characters and |pdftotext| to read them.
% If extra symbols appear in the text,
% \watchout
% it may be that |pdflatex| is actually producing a symbol over or under a
% character, resulting in |pdftotext| picking up the accent symbol separately.
%
% \XeLaTeX{} and \LuaLaTeX{} directly support accented section and file names.
% \index{accents}\index{Unicode>file \& section names}\index{UTF-8>file \& section names}
% \index{XeLaTeX>file \& section names}
% \index{LuaLaTeX>file \& section names}
%
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
%
% \subsection{User-level starred section commands}
%
%
% \begin{macro}{\ForceHTMLPage}
%   For \HTML\ output, forces the next section to be on its own \HTML\ page,
%   if |FileDepth| allows, even if starred.
%   For use with \cs{printindex} and others which generate a starred section
%   which should be on its own \HTML\ page.  Also see \cs{ForceHTMLTOC}.
%
%   For print output, no effect.
%
% \changes{v0.38}{2017/08/22}{Added.}
%
%    \begin{macrocode}
\newbool{LWR@forcinghtmlpage}
\boolfalse{LWR@forcinghtmlpage}

\newcommand*{\ForceHTMLPage}{%
\global\booltrue{LWR@forcinghtmlpage}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\ForceHTMLTOC}
%   For \HTML\ output, forces the next section to have a TOC entry, even if starred.
%   For use with \cs{printindex} and others which generate a starred section
%   which should be in the \acro{TOC} so that it may be accessed via \HTML.
%   Not necessary if used with \pkg{tocbibind}.  Also see \cs{ForceHTMLPage}.
%
%   For print output, no effect.
%
% \changes{v0.38}{2017/08/22}{Added.}
%
%    \begin{macrocode}
\newbool{LWR@forcinghtmltoc}
\boolfalse{LWR@forcinghtmltoc}

\newcommand*{\ForceHTMLTOC}{%
\global\booltrue{LWR@forcinghtmltoc}%
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
%
%
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\newcommand*{\ForceHTMLPage}{}
\newcommand*{\ForceHTMLTOC}{}
\end{warpprint}
%    \end{macrocode}
%
%
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
%
%
% \subsection{Book class commands}
%
%
% \begin{macro}{\mainmatter}
%
% Declare the main matter section of the document.  Does not reset the page number,
% \watchout
% which must be consecutive arabic numbers for the \HTML\ conversion.
%    \begin{macrocode}
\newbool{LWR@mainmatter}
\DeclareDocumentCommand{\mainmatter}{}{%
\booltrue{LWR@mainmatter}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\frontmatter}
%
% Declare the front matter section of the document,
% using arabic numbering for the internal numbering.  Does not reset the page number.
%    \begin{macrocode}
\DeclareDocumentCommand{\frontmatter}{}{%
\boolfalse{LWR@mainmatter}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\backmatter}
%
% Declare the back matter section of the document.  Does not reset the page number.
%    \begin{macrocode}
\DeclareDocumentCommand{\backmatter}{}{%
\boolfalse{LWR@mainmatter}
}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Sectioning support macros}
%
% \begin{macro}{\LWR@sectionumber} \marg{section type}
%
% Typeset a section number and its trailing space with CSS formatting:
%    \begin{macrocode}
\newcommand*{\LWR@sectionnumber}[1]{%
\InlineClass{sectionnumber}{#1}%
}
%    \end{macrocode}
% \end{macro}


% \DescribeObject{autosec} A tag used by the TOC and index.
%
% \begin{macro}{\LWR@createautosec} \marg{section type}
%
% Create an autosection tag.
%    \begin{macrocode}
\newcommand*{\LWR@createautosec}[1]{%
\LWR@htmltag{#1 id="autosec-\thepage"{}}%
}
%    \end{macrocode}
% \end{macro}




% \begin{macro}{\LWR@pushoneclose} \marg{depth} \marg{printclose}
% Stacks the new sectioning level's closing tag,
% to be used when this section is closed some time later.
%
% |\LWR@stoppars| must be executed first.
% \watchout
%    \begin{macrocode}
\NewDocumentCommand{\LWR@pushoneclose}{m m}{\pushclose{#2}{#1}}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@startnewdepth} \marg{depth} \marg{printclose}
%
% Closes currently stacked tags of a lesser level,
% then opens the new nesting level by saving this new sectioning
% level's closing tag for later use.
%
% |\LWR@stoppars| must be executed first.
% \watchout
%    \begin{macrocode}
\NewDocumentCommand{\LWR@startnewdepth}{m m}{%
%    \end{macrocode}
% Close any stacked sections up to this new one.
%    \begin{macrocode}
\LWR@closeprevious{#1}%
%    \end{macrocode}
% Push a new section depth:
%    \begin{macrocode}
\LWR@pushoneclose{#1}{#2}%
}
%    \end{macrocode}
% \end{macro}
%
%
%
% \DescribeCounter{LWR@prevFileDepth} Remembers the previous |LWR@FileDepth|.
%
% Initialized to a deep level so that any section will trigger a new \HTML\
% page after the home page.
%    \begin{macrocode}
\newcounter{LWR@prevFileDepth}
\setcounter{LWR@prevFileDepth}{\LWR@depthsubparagraph}
%    \end{macrocode}
%
%
% \begin{macro}{\@seccntformat} \marg{sectiontype}
% \changes{v0.38}{2017/08/21}{Added for \pkg{appendix}.}
%
%    \begin{macrocode}
\def\@seccntformat#1{\csname the#1\endcsname\protect\quad}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\simplechapterdelim} Used by \pkg{tocbibind} and \pkg{anonchap}.
% \changes{v0.40}{2017/09/12}{Added for \pkg{tocbibind}, \pkg{anonchap}.}
%
%    \begin{macrocode}
\newcommand*{\simplechapterdelim}{}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@chapcntformat} \marg{sectiontype}
%
% \cs{let} to \cs{@seccntformat} by default, but may be redefined
% by \cs{simplechapter} and \cs{restorechapter} from \pkg{tocbibind} or
% \pkg{anonchap}.
%
% \changes{v0.40}{2017/09/12}{Added for \pkg{tocbibind}, \pkg{anonchap}.}
%
%    \begin{macrocode}
\let\@chapcntformat\@seccntformat
%    \end{macrocode}
% \end{macro}
%
%
% \DescribeCounter{LWR@currentautosec} Records the page number when the section
%   was created.  If a math expression is included in the section name,
%   and SVG math is used, the corresponding \env{lateximage} will cause the
%   page number to change by the time the following autosec label is created.
% \changes{v0.43}{2017/11/01}{\protect\texttt{LWR@currentautosec}: Added.}
%    \begin{macrocode}
\newcounter{LWR@currentautosec}
%    \end{macrocode}
%
%
%
% \begin{macro}{\LWR@section} * \oarg{TOC name} \marg{name} \marg{sectiontype}
%
% \changes{v0.20}{2017/01/09}{Combined higher-level sections together into files.}
% \changes{v0.36}{2017/08/15}{Improved spacing.}
% \changes{v0.38}{2017/08/21}{\cs{part*} starts a new \HTML\ page, for \pkg{appendix}.}
% \changes{v0.38}{2017/08/21}{Modified spacing, uses \cs{numberline}.}
%
% The common actions for the high-level sectioning commands.
%    \begin{macrocode}
\DeclareDocumentCommand{\LWR@section}{m m m m}{%
\LWR@traceinfo{LWR@section |#2| |#3|}%
\LWR@traceinfo{LWR@section: not an empty section}%
\LWR@stoppars%
%    \end{macrocode}
% Cancel special \env{minipage} horizontal space interaction:
%    \begin{macrocode}
\global\boolfalse{LWR@minipagethispar}%
%    \end{macrocode}
% Start a new \HTML\ file unless starred,
%   and if is a shallow sectioning depth.
%
% Exception: Also start a new \HTML\ file for \cs{part*}, for \pkg{appendix}.
%
% Generate a new \LaTeX\ page so that \TOC\ and index page number points to the section:
%    \begin{macrocode}
\LWR@traceinfo{LWR@section: testing whether to start a new HTML file}%
\IfBooleanTF{#1}{\LWR@traceinfo{LWR@section: starred}}{}%
\ifbool{LWR@forcinghtmlpage}{\LWR@traceinfo{LWR@section: forcinghtmlpage}}{}%
\ifthenelse{%
    \(%
        \(\NOT\equal{#1}{\BooleanTrue}\)\OR%
        \(\cnttest{\csuse{LWR@depth#4}}{=}{\LWR@depthpart}\)\OR%
        \(\boolean{LWR@forcinghtmlpage}\)%
    \)%
    \AND%
    \cnttest{\csuse{LWR@depth#4}}{<=}{\value{FileDepth}}%
    \AND%
    \(%
        \NOT\boolean{CombineHigherDepths}\OR%
        \cnttest{\csuse{LWR@depth#4}}{<=}{\value{LWR@prevFileDepth}}%
    \)%
    \AND%
%    \end{macrocode}
% \changes{v0.43}{2017/10/31}{Fix: Expansion in comparison.}
%    \begin{macrocode}
    \NOT\isempty{#3}% phantomsection
}%
%    \end{macrocode}
% If so: start a new \HTML\ file:
%    \begin{macrocode}
{% new file
    \LWR@traceinfo{LWR@section: new HTML file}%
%    \end{macrocode}
% See if there was an optional TOC name entry:
%    \begin{macrocode}
    \IfNoValueTF{#2}%
%    \end{macrocode}
% If no optional entry
%    \begin{macrocode}
    {\LWR@newhtmlfile{#3}}%
%    \end{macrocode}
% If yes an optional entry
%    \begin{macrocode}
    {\LWR@newhtmlfile{#2}}%
}% new file
%    \end{macrocode}
% Else: No new \HTML\ file:
%    \begin{macrocode}
{% not new file
%    \end{macrocode}
% Generate a new \LaTeX\ page so that \TOC\ and index page number points to the section:
%    \begin{macrocode}
    \LWR@traceinfo{LWR@section: not a new HTML file}%
    \LWR@orignewpage%

}% not new file
%    \end{macrocode}
% Remember this section's name for \cs{nameref}:
%    \begin{macrocode}
\IfValueT{#3}{%
\LWR@traceinfo{LWR@section: about to LWR@setlatestname}%
\IfValueTF{#2}{\LWR@setlatestname{#2}}{\LWR@setlatestname{#3}}%
}%
%    \end{macrocode}
% Print an opening comment with the level and the name;
% ex: ``section'' ``Introduction''
% \changes{v0.43}{2017/10/31}{Fix: Nullify fonts inside HTML comment.}
%    \begin{macrocode}

\ifbool{HTMLDebugComments}{%
    \begingroup%
    \LWR@nullfonts%
    \LWR@htmlcomment{Opening #4 ``#3''{}}%
    \endgroup%
}{}%

%    \end{macrocode}
% For inline sections paragraph and subparagraph, start a new paragraph now:
%    \begin{macrocode}
\ifthenelse{%
    \cnttest{\csuse{LWR@depth#4}}{>=}{\LWR@depthparagraph}%
}%
{\LWR@startpars}%
{}%
%    \end{macrocode}
% Create the opening tag with an autosec:
%    \begin{macrocode}
\LWR@createautosec{\csuse{LWR@tag#4}}%
%    \end{macrocode}
% \changes{v0.43}{2017/11/01}{Fix: Math in section name.}
%    \begin{macrocode}
\setcounter{LWR@currentautosec}{\value{page}}
%    \end{macrocode}
% Check if starred:
%    \begin{macrocode}
\IfBooleanTF{#1}%
{%
%    \end{macrocode}
% Starred, but also forcing a TOC entry, so
% add unnumbered TOC name or regular name:
%    \begin{macrocode}
\ifbool{LWR@forcinghtmltoc}%
{\addcontentsline{toc}{#4}{\IfValueTF{#2}{#2}{#3}}}%
{}%
}% starred
%    \end{macrocode}
% Not starred, so step counter and add to TOC:
%    \begin{macrocode}
{% not starred
%    \end{macrocode}
% Only add a numbered TOC entry if section number is not too deep:
%    \begin{macrocode}
    \ifthenelse{%
        \cnttest{\csuse{LWR@depth#4}}{<=}{\value{secnumdepth}}%
    }%
    {% if secnumdepth
%    \end{macrocode}
% If in the main matter, step the counter and add the TOC entry.
% For |article| class, \pkg{lwarp} assumes that all is mainmatter.
%    \begin{macrocode}
        \LWR@traceinfo{LWR@section: about to test main matter}%
        \ifbool{LWR@mainmatter}%
        {%
            \LWR@traceinfo{LWR@section: yes mainmatter}%
            \refstepcounter{#4}%
%    \end{macrocode}
% Add main matter numbered TOC entry with the TOC name or the regular name:
%    \begin{macrocode}
            \LWR@traceinfo{LWR@section: about to addcontentsline}%
            \addcontentsline{toc}{#4}%
            {%
                 \protect\numberline{\csuse{the#4}}%
                {\ignorespaces\IfValueTF{#2}{#2}{#3}\protect\relax}%
            }%
            \LWR@traceinfo{LWR@section: finished addcontentsline}%
        }% end of if main matter
%    \end{macrocode}
% If not main matter, add unnumbered TOC name or regular name:
%    \begin{macrocode}
        {% not main matter
            \LWR@traceinfo{LWR@section: no main matter}%
            \addcontentsline{toc}{#4}{\IfValueTF{#2}{#2}{#3}}%
        }% end of not main matter
    }% end of secnumdepth
%    \end{macrocode}
% Deeper than secnumdepth, so add an unnumbered TOC entry:
%    \begin{macrocode}
    {%
        \addcontentsline{toc}{#4}{\IfValueTF{#2}{#2}{#3}}%
    }%
%    \end{macrocode}
% For part, print the section type:
%    \begin{macrocode}
    \ifbool{LWR@mainmatter}%
    {%
        \ifthenelse{%
            \(\cnttest{\csuse{LWR@depth#4}}{<=}%
                {\value{secnumdepth}}\) \AND%
            \(\cnttest{\csuse{LWR@depth#4}}{<=}{\LWR@depthpart}\)%
        }%
        {\csuse{#4name}~{}}%
        {}%
%    \end{macrocode}
% Print the section number:
%    \begin{macrocode}
        \LWR@traceinfo{LWR@section: about to print section number}%
        \ifthenelse{%
            \cnttest{\csuse{LWR@depth#4}}{<=}{\value{secnumdepth}}%
        }%
        {%
            \ifstrequal{#4}{chapter}%
            {\protect\LWR@sectionnumber{\@chapcntformat{#4}}}%
            {\protect\LWR@sectionnumber{\@seccntformat{#4}}}%
        }%
        {}%
        \LWR@traceinfo{LWR@section: finished print section number}%
    }{}%
}% end of not starred
%    \end{macrocode}
% Print the section name:
%    \begin{macrocode}
#3%
%    \end{macrocode}
% Close the heading tag, such as /H2:
%    \begin{macrocode}
\LWR@htmltag{\csuse{LWR@tag#4end}}%
%    \end{macrocode}
% Generate a \LaTeX{} label:
% \changes{v0.43}{2017/11/01}{Fix: Math in section name.}
%    \begin{macrocode}
\label{autopage-\theLWR@currentautosec}%
%    \end{macrocode}
% Start paragraph handing unless is an inline paragraph or subparagraph:
%    \begin{macrocode}
\ifthenelse{%
    \cnttest{\csuse{LWR@depth#4}}{<}{\LWR@depthparagraph}%
}%
{\LWR@startpars}%
{}%
%    \end{macrocode}
% If not starred, remember the previous depth to
% possibly trigger a new \HTML\ page.
%
% HOWEVER, allow a \cs{part*} to start a new \HTML\ page.
% This is used by \pkg{appendix}.
%
% A starred section does not trigger a new \HTML\ page at the beginning
% of this macro, so it should not affect it here at the end either.
% This became an issue when a \cs{listoftables} was tested in the middle of
% the document.  The \cs{chapter*} for the list was not allowing
% a new \HTML\ page for the section following it
% while |CombineHigherDepths| was true.
%    \begin{macrocode}
\ifthenelse{%
    \NOT\equal{#1}{\BooleanTrue}\OR%
    \cnttest{\csuse{LWR@depth#4}}{=}{\LWR@depthpart}%
}%
{% not starred
    \setcounter{LWR@prevFileDepth}{\csuse{LWR@depth#4}}%
}% not starred
{}%
%    \end{macrocode}
% Reset to defaults if not a phantomsection:
%    \begin{macrocode}
\ifstrempty{#3}%
{}%
{%
\global\boolfalse{LWR@forcinghtmlpage}%
\global\boolfalse{LWR@forcinghtmltoc}%
}%
%
\LWR@traceinfo{LWR@section: done}%
}
%    \end{macrocode}
% \end{macro}



% \subsection{\textbackslash{}section and friends}

% \begin{macro}{\part} * \oarg{TOC name} \marg{name}
%
% \changes{v0.38}{2017/08/21}{Fix with \texttt{article} class.}
% \changes{v0.44}{2017/11/21}{Add preamble for \pkg{koma-script}.}
%
%    \begin{macrocode}
\newcommand{\part@preamble}{}% for koma-script

\DeclareDocumentCommand{\part}{s o m}{%
\LWR@maybeprintpendingfootnotes{\LWR@depthpart}%
\LWR@stoppars%

\LWR@startnewdepth{\LWR@depthpart}{\LWR@printclosepart}%

\LWR@section{#1}{#2}{#3}{part}%

\part@preamble% for koma-script
\renewcommand{\part@preamble}{}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\chapter} * \oarg{TOC name} \marg{name}
%
% \changes{v0.28}{2017/04/06}{If \EPUB, prints footnotes before each section.}
% \changes{v0.40}{2017/09/22}{Added support for \pkg{quotchap}.}
% \changes{v0.44}{2017/11/21}{Add preamble for \pkg{koma-script}.}
%    \begin{macrocode}
\let\@printcites\relax% for quotchap package

\newcommand{\chapter@preamble}{}% for koma-script

\@ifundefined{chapter}
{}
{%
\DeclareDocumentCommand{\chapter}{s o m}{%
\LWR@traceinfo{chapter #3}%
\LWR@maybeprintpendingfootnotes{\LWR@depthchapter}%
\LWR@stoppars%

\LWR@startnewdepth{\LWR@depthchapter}{\LWR@printclosechapter}%

\LWR@section{#1}{#2}{#3}{chapter}%

\@printcites% for quotchap package

\chapter@preamble% for koma-script
\renewcommand{\chapter@preamble}{}%
}
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\section} * \oarg{TOC name} \marg{name}
%    \begin{macrocode}
\DeclareDocumentCommand{\section}{s o m}{%
\LWR@maybeprintpendingfootnotes{\LWR@depthsection}%
\LWR@stoppars%

\LWR@startnewdepth{\LWR@depthsection}{\LWR@printclosesection}%

\LWR@section{#1}{#2}{#3}{section}%
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\subsection} * \oarg{TOC name} \marg{name}
%    \begin{macrocode}
\DeclareDocumentCommand{\subsection}{s o m}{%
\LWR@maybeprintpendingfootnotes{\LWR@depthsubsection}%
\LWR@stoppars%

\LWR@startnewdepth{\LWR@depthsubsection}{\LWR@printclosesubsection}%

\LWR@section{#1}{#2}{#3}{subsection}%
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\subsubsection} * \oarg{TOC name} \marg{name}
%    \begin{macrocode}
\DeclareDocumentCommand{\subsubsection}{s o m}{%
\LWR@maybeprintpendingfootnotes{\LWR@depthsubsubsection}%
\LWR@stoppars%

\LWR@startnewdepth{\LWR@depthsubsubsection}%
{\LWR@printclosesubsubsection}%

\LWR@section{#1}{#2}{#3}{subsubsection}%
}
%    \end{macrocode}
% \end{macro}




% \begin{macro}{\paragraph} * \oarg{TOC name} \marg{name}
%    \begin{macrocode}
\DeclareDocumentCommand{\paragraph}{s o m}{%
\LWR@maybeprintpendingfootnotes{\LWR@depthparagraph}%
\LWR@stoppars%

\LWR@startnewdepth{\LWR@depthparagraph}{\LWR@printcloseparagraph}%

\LWR@section{#1}{#2}{#3}{paragraph}%
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\subparagraph} * \oarg{TOC name} \marg{name}
%    \begin{macrocode}
\DeclareDocumentCommand{\subparagraph}{s o m}{%
\LWR@maybeprintpendingfootnotes{\LWR@depthsubparagraph}%
\LWR@stoppars%

\LWR@startnewdepth{\LWR@depthsubparagraph}{\LWR@printclosesubparagraph}%

\LWR@section{#1}{#2}{#3}{subparagraph}%
}
%    \end{macrocode}
% \end{macro}


%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}





% \section{Starting a new file}
% \label{sec:startingfile}

% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \begin{macro}{\HTMLLanguage} Default language for the \HTML\ |lang| tag.
% \index{language HTML metadata}
%
% \changes{v0.30}{2017/04/28}{Renamed from \cs{MetaLanguage}.}
%
%    \begin{macrocode}
\newcommand*{\LWR@currentHTMLLanguage}{en-US}

\newcommand*{\HTMLLanguage}[1]{%
\renewcommand*{\LWR@currentHTMLLanguage}{#1}%
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}


% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{macro}{\LWR@filestart} \marg{title\_suffix}

% Creates the opening \HTML\ tags.
% \changes{v0.19}{2016/05/25}{lwarp\_mathjax.txt loaded.}
% \changes{v0.20}{2016/06/27}{Adds meta description.}
% \changes{v0.21}{2017/02/22}{Skip title if not given.}
% \changes{v0.28}{2017/04/06}{Adds \HTML\ meta author.}
%
%    \begin{macrocode}
\newcommand*{\LWR@filestart}[1]{
\LWR@traceinfo{LWR@filestart}
%    \end{macrocode}
% Locally temporarily disable direct-formatting commands:
%    \begin{macrocode}
\begingroup
\LWR@traceinfo{LWR@filestart: A}
\LWR@nullfonts
\LWR@traceinfo{LWR@filestart: B}
%    \end{macrocode}
% Create the page's \HTML\ header:
%    \begin{macrocode}
\LWR@htmltag{!DOCTYPE html}\LWR@orignewline
\LWR@traceinfo{LWR@filestart: C}
%    \end{macrocode}
% The language is user-adjustable:
%    \begin{macrocode}
\LWR@htmltag{html lang="\LWR@currentHTMLLanguage"{}}\LWR@orignewline
%    \end{macrocode}
% Start of the meta data:
%    \begin{macrocode}
\LWR@htmltag{head}\LWR@orignewline
%    \end{macrocode}
% Charset is fixed at UTF-8:
%    \begin{macrocode}
\LWR@htmltag{meta charset="UTF-8" /}\LWR@orignewline
%    \end{macrocode}
%
% Author:
% \changes{v0.44}{2017/11/18}{Fix \cs{HTMLAuthor}.}
%    \begin{macrocode}
\ifthenelse{\equal{\theHTMLAuthor}{}}%
{}%
{\LWR@htmltag{meta name="author" content="\theHTMLAuthor" /}\LWR@orignewline}%
%    \end{macrocode}
%
% \pkg{lwarp} is the generator:
% \index{HTML>meta tag>generator}
% \index{generator>HTML meta tag}
% \index{meta tag, HTML>generator}
%    \begin{macrocode}
\LWR@htmltag{meta name="generator" content="LaTeX lwarp package" /}%
    \LWR@orignewline
%    \end{macrocode}
% If there is a description, add it now:
%    \begin{macrocode}
\ifdefempty{\LWR@currentHTMLDescription}{}{%
\LWR@htmltag{%
meta name="description" content="\LWR@currentHTMLDescription" /}%
    \LWR@orignewline
}%
%    \end{macrocode}
% Mobile-friendly viewport:
% \index{HTML>meta tag>viewport}
% \index{viewport>HTML meta tag}
% \index{meta tag, HTML>viewport}
%    \begin{macrocode}
\LWR@htmltag{meta name="viewport" %
content="width=device-width, initial-scale=1.0" /}%
    \LWR@orignewline
%    \end{macrocode}
% IE patch:
%    \begin{macrocode}
\LWR@htmltag{!{-}{-}[if lt IE 9]}\LWR@orignewline
\LWR@htmltag{%
script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"{}}%
\LWR@htmltag{/script}\LWR@orignewline
\LWR@htmltag{![endif]{-}{-}}\LWR@orignewline
%    \end{macrocode}
% The page's title:
% \changes{v0.44}{2017/11/18}{Add \cs{HTMLTitle}.}
%    \begin{macrocode}
\ifthenelse{\equal{\theHTMLTitle}{}}%
{}%
{\LWR@htmltag{title}\theHTMLTitle#1\LWR@htmltag{/title}\LWR@orignewline}%
%    \end{macrocode}
% The page's stylesheet:
%    \begin{macrocode}
\LWR@htmltag{%
link rel="stylesheet" type="text/css" href="\LWR@currentcss" /}%
\LWR@orignewline
%    \end{macrocode}
% Optional MathJax support.  The \HTML\ tags must be turned off
% during the verbatim input, and the paragraph handling which was
% turned on at the end of verbatim input must be immediately turned off
% again.
%    \begin{macrocode}
\ifbool{mathjax}%
{%
    \begingroup%
    \LWR@restoreoriglists%
    \boolfalse{LWR@verbtags}
    \verbatiminput{lwarp_mathjax.txt}%
    \booltrue{LWR@verbtags}
    \endgroup%
    \LWR@stoppars
}% end of mathjax
{}%
%    \end{macrocode}
% End of the header:
%    \begin{macrocode}
\LWR@htmltag{/head}\LWR@orignewline
%    \end{macrocode}
% Start of the body:
%    \begin{macrocode}
\LWR@htmltag{body}\LWR@orignewline
\endgroup
\LWR@traceinfo{LWR@filestart: done}
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}






% \section{Starting HTML output}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \begin{macro}{\LWR@LwarpStart}
% \changes{v0.19}{2016/06/01}{Enabled \textbackslash\textbackslash{} equal to \cs{newline}.}
% \changes{v0.21}{2017/02/22}{Changed \texttt{lateximages} to a \texttt{.txt} file.}
% \changes{v0.28}{2017/04/09}{\texttt{FormatWordProcessor} forces single-file output.}
% Executed at the beginning of the entire document.
%    \begin{macrocode}
\catcode`\$=\active
\newcommand*{\LWR@LwarpStart}
{%
\LWR@traceinfo{LWR@lwarpStart}
%    \end{macrocode}
%
% If formatting for a word processor,
%	force filedepth to single-file only,
%	force \HTML\ debug comments off.
%    \begin{macrocode}
\ifbool{FormatWP}{%
    \setcounter{FileDepth}{-5}%
    \boolfalse{HTMLDebugComments}%
}{}
%    \end{macrocode}
%
% Expand and detokenize \cs{HomeHTMLFilename} and \cs{HTMLFilename}:
%    \begin{macrocode}
\edef\LWR@strresult{\HomeHTMLFilename}
\edef\HomeHTMLFilename{\detokenize\expandafter{\LWR@strresult}}
\edef\LWR@strresult{\HTMLFilename}
\edef\HTMLFilename{\detokenize\expandafter{\LWR@strresult}}
%    \end{macrocode}
% Force onecolumn and empty page style:
%    \begin{macrocode}
\LWR@origonecolumn%
\LWR@origpagestyle{empty}
%    \end{macrocode}
% Reduce chance of line overflow in verbatim environments:
%    \begin{macrocode}
\LWR@origscriptsize%
%    \end{macrocode}
% In \PDF\ output, don't allow line breaks to interfere with \HTML\ tags:
%    \begin{macrocode}
\LWR@origraggedright%
\LetLtxMacro{\\}{\LWR@endofline}%
%    \end{macrocode}
% Spread the lines for |pdftotext| to read them well:
%    \begin{macrocode}
\linespread{1.3}%
%    \end{macrocode}
% For |pdftotext| to reliably identify paragraph splits:
%    \begin{macrocode}
\setlength{\parindent}{0pt}
\setlength{\parskip}{2ex}
%    \end{macrocode}
%
% For the |lateximages| record file:
%    \begin{macrocode}
\immediate\openout\LWR@lateximagesfile=lateximages.txt
%    \end{macrocode}
%
% Removes space after the caption in the \HTML:
%    \begin{macrocode}
\setlength{\belowcaptionskip}{-3ex}
%    \end{macrocode}
% Redefine the plain page style to be empty when used by index pages:
%    \begin{macrocode}
\renewcommand{\ps@plain}{}
%    \end{macrocode}
% Not used in the \HTML\ environment:
% \DescribeMacro{\centering}
% \DescribeMacro{\raggedleft}
% \DescribeMacro{\raggedright}
%    \begin{macrocode}
\renewcommand*{\centering}{}
\renewcommand*{\raggedleft}{}
\renewcommand*{\raggedright}{}
%    \end{macrocode}
% Plug in some new actions.
% This is done just before the document start
% so that they won't be over-written by some other package.
% \changes{v0.13}{2016/03/23}{\cs{up} and \cs{fup}}
%
% Tabular:
%    \begin{macrocode}
\LetLtxMacro{\LWR@origtabular}{\tabular}
\LetLtxMacro{\LWR@origendtabular}{\endtabular}
\LetLtxMacro{\tabular}{\LWR@tabular}
\LetLtxMacro{\endtabular}{\endLWR@tabular}
%    \end{macrocode}
% Float captions:
%    \begin{macrocode}
\let\LWR@origcaption\caption
%    \end{macrocode}
%
% Labels:
% \cs{ltx@label} is used in \pkg{amsmath} environments and is also
% patched by \pkg{cleveref}.
% \index{label>in HTML}
% \margintag{Label in \HTML}
% \changes{v0.20}{2017/01/30}{Fix: math cross references.}
%    \begin{macrocode}
\let\LWR@origltx@label\ltx@label
\let\ltx@label\LWR@htmlmathlabel
%    \end{macrocode}
% Logos:
%    \begin{macrocode}
\let\TeX\LWR@TeX
\let\LaTeX\LWR@LaTeX
\let\LuaTeX\LWR@LuaTeX
\let\LuaLaTeX\LWR@LuaLaTeX
\let\XeTeX\LWR@XeTeX
\let\XeLaTeX\LWR@XeLaTeX
\let\ConTeXt\LWR@ConTeXt
%    \end{macrocode}
% Not yet started any paragraph handling:
%    \begin{macrocode}
\global\boolfalse{LWR@doingapar}
\global\boolfalse{LWR@doingstartpars}
%    \end{macrocode}
% Start a new \HTML\ file and a header:
%    \begin{macrocode}
\LWR@traceinfo{LWR@lwarpStart: Starting new file.}
\LWR@filestart{}
\LWR@traceinfo{LWR@lwarpStart: Generating first header.}
\LWR@htmltag{header}\LWR@orignewline
\LWR@startpars
\LWR@firstpagetop
\LWR@stoppars
\LWR@htmltag{/header}\LWR@orignewline
\LWR@traceinfo{LWR@lwarpStart: Generating textbody.}
\LWR@htmltag{section class="textbody"{}}
%    \end{macrocode}
% Document and page settings:
%    \begin{macrocode}
\mainmatter
\LWR@origpagenumbering{arabic}
%    \end{macrocode}
%
% Patch the |itemize|, |enumerate|, and |description| environments and \cs{item}.
% This works with the native \LaTeX\ environments, as well as
% those provided by \pkg{enumitem}, \pkg{enumerate}, and \pkg{paralist}.
%    \begin{macrocode}
\LWR@patchlists
%    \end{macrocode}
%
% Ensure that math mode is active to call \pkg{lwarp}'s patches:
%    \begin{macrocode}
\catcode`\$=\active
%    \end{macrocode}
%
% Allow \HTML\ paragraphs to begin:
%    \begin{macrocode}
\LWR@startpars
\LWR@traceinfo{LWR@lwarpStart: done}
}
\catcode`\$=3% math shift until lwarp starts
%    \end{macrocode}
% \end{macro}


%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}





% \section{Ending HTML output}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \begin{macro}{\LWR@requesttoc} \marg{boolean} \marg{suffix}
% \changes{v0.18}{2016/05/19}{Reorganize \cs{HomeHTMLFilename} logic.}
% Requests that a toc, lof, or lot be generated.

%    \begin{macrocode}
\newcommand*{\LWR@requesttoc}[2]{%
\ifbool{#1}
{
    \expandafter\newwrite\csuse{tf@#2}
    \immediate\openout \csuse{tf@#2} \jobname.#2\relax
}{}
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@LwarpEnd}
% Final stop of all \HTML\ output:
%
% \changes{v0.28}{2017/04/06}{If \texttt{FormatEPUB} or \texttt{FormatWordProcessor}, no bottom nav.}
%    \begin{macrocode}
\newcommand*{\LWR@LwarpEnd}
{
\LWR@stoppars
\LWR@closeprevious{\LWR@depthfinished}
%    \end{macrocode}
% At the bottom of the ending file:

% Close the textbody:
%    \begin{macrocode}
\LWR@htmlelementclassend{section}{textbody}
%    \end{macrocode}
% Print any pending footnotes:
%    \begin{macrocode}
\LWR@printpendingfootnotes
%    \end{macrocode}
% Create the footer:
%    \begin{macrocode}
\LWR@htmlelement{footer}

\LWR@pagebottom

\LWR@htmlelementend{footer}
%    \end{macrocode}

% No bottom navigation if are finishing the home page,
% or if formatting for an \EPUB\ or word processor.
%
% Presumably has a table-of-contents.
%    \begin{macrocode}
\ifthenelse{\boolean{FormatEPUB}\OR\boolean{FormatWP}}
{}
{
    \ifnumcomp{\value{LWR@htmlfilenumber}}{>}{0}{\LWR@botnavigation}{}
}
%    \end{macrocode}
%    \begin{macrocode}
\LWR@stoppars% final stop of all paragraphs
%    \end{macrocode}
% Finish the \HTML\ file:
%    \begin{macrocode}
\LWR@htmltag{/body}\LWR@orignewline
\LWR@htmltag{/html}\LWR@orignewline
%    \end{macrocode}
% Seems to be required sometimes:
%    \begin{macrocode}
\LWR@orignewpage
%    \end{macrocode}
% For \env{lateximage} commands:
%    \begin{macrocode}
\immediate\closeout\LWR@lateximagesfile
}
%    \end{macrocode}
% \end{macro}


%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}






% \section{Title page}
% \label{sec:titles}
%
% \limitstitlepage
%
% \pkg{lwarp} provides for the \cs{author} macro an additional \cs{affiliation}
% \margintag{affiliation}
% macro to provide an affiliation and other additional information
% for each author in the title page.
% The affiliation information is removed when using
% \pkg{titlingpage}'s \cs{theauthor} in the main text.
%
% The \pkg{titling} package maintains the definitions of \cs{thetitle},
% \margintag{reusing titlepage information}
% \cs{theauthor}, etc., after the title has been typeset.
% These commands are to be used to refer to the document's title
% and author, etc., in the main text.
% These definitions
% have the \cs{thanks} and \cs{affiliation} removed, and for \cs{author} the
% \cs{and} is replaced to generate a simple inline list of authors separated
% by commas.
% Note: \cs{theauthor} does not work well
% \watchout[\cs{theauthor}, \pkg{authblk}]
% with \pkg{authblk} unless the traditional \LaTeX\ syntax is used.
%
% \cs{printtitle}, \cs{printauthor}, etc., are provided for use inside a custom
% \margintag{custom titlepages}
% \env{titlepage} or \env{titlingpage} environment, and these retain
% the \cs{thanks} and \cs{affiliation}.
%
% \DescribeMacro{\printthanks}
% \cs{printthanks} has been added to force the printing of thanks inside
% a \env{titlingpage} environment when \cs{maketitle} is not used.
%
% Inside a \cs{titlepage} or \cs{titlingpage} environment, use
% \watchout
% \cs{thanks} instead of \cs{footnote} for acknowledgements, etc.
%
%
% \subsection{Setting the title, etc.}
%
% The following provide setting commands for both \HTML\ and print outputs.
%
% \DescribeMacro{\author} \marg{author}
% \DescribeMacro{\and}
% While using \cs{maketitle} and print mode,
% the author is treated as a single-column \env{tabular}
% and the \cs{and} feature finishes the current \env{tabular} then starts a new one for
% the next author.  Each author thus is placed into its own \env{tabular}, and an
% affiliation may be placed on its own line such as
%
% |\author{Name \\ Affiliation \and Second Name \\ Second Affiliation}|
%
% For \HTML, the entire author block is placed inside
% a \element{div} of class \attribute{author},
% and each individual author is inside a \element{div} of class \attribute{oneauthor}.
%
% \DescribeMacro{\@title}
% \DescribeMacro{\@author}
% \DescribeMacro{\@date}
% \cs{@title}, \cs{@author}, etc.\ store the values
% as originally assigned, including any \cs{thanks}, \cs{and}, or \cs{affiliation}.
% These are low-level macros intended to be used by other macros
% only inside a \env{titlepage} or \env{titlingpage},
% and are used by \cs{maketitle}.
% The author is printed inside a single-column \env{tabular},
% which becomes multiple single-column \env{tabular}s if multiples authors are included.
% For \HTML\, these \env{tabular}s become side-by-side \element{div}s
% of class \attribute{oneauthor}, all of which are combined into one \element{div}
% of class \attribute{author}.
%
% \DescribeMacro{\printtitle}
% \DescribeMacro{\printauthor}
% \DescribeMacro{\printdate}
% \cs{printtitle}, etc.\ are user-level macros intended to
% be used in custom \env{titlepage} or \env{titlingpage} environments in cases where
% \cs{maketitle} is not desired.  These commands preserve the \cs{thanks}, etc.,
% and should not be used in the main text.
%
% \DescribeMacro{\thetitle}
% \DescribeMacro{\theauthor}
% \DescribeMacro{\thedate}
% \cs{thetitle}, \cs{theauthor}, and \cs{thedate} are available
% if \pkg{titling} has been loaded, and are sanitized user-level
% versions from which have been removed the \cs{thanks} and \cs{affiliation},
% and \cs{and} is changed for inline text usage.
% The author is printed inline without \cs{affiliation} or \cs{thanks},
% with \cs{and} placing commas between multiple authors.
% Thus, these commands are to be used in the main text whenever the user
% wishes to refer to the document's title and such.  One practical use for this
% is to place the authors at the bottom of each \HTML\ page, such as:
%
% \DescribeMacro{\HTMLPageBottom} \marg{text}
% \begin{Verbatim}[gobble=2,frame=lines,obeytabs,tabsize=4]
% \HTMLPageBottom{
% \begin{center}\textcopyright~2016 \theauthor\end{center}
% }
% \end{Verbatim}
%
% \cs{theauthor} does not work well if \pkg{authblk} is used.
% \watchout[\cs{theauthor}]
% If \cs{theauthor} is important, it is recommended to use the standard
% \LaTeX\ syntax for \cs{author}, optionally with
% \pkg{lwarp}'s \cs{affiliation} macro as well.
%
% After \cs{maketitle} has completed, \cs{theauthor} retains the definition of
% \watchout[affiliations]
% the author, but \cs{and} is changed to become a comma and a space, intending to
% print the authors names separated by spaces.  This fails when affiliations are
% included on their own table rows.
%
% A solution, provide here, is to define a macro \cs{affiliation} which,
% \margintag{\cs{affiliation}}
% during \cs{maketitle}, starts a new row and adds the affiliation,
% but after \cs{maketitle} is finished \cs{affiliation} is re-defined
% to discard its argument, thus printing only the author names
% when \cs{author} is later used inline.
%
%
%
% \subsection{Changes for \cs{affiliation}}
%
%
% \begin{macro}{\affiliation} \marg{text}
%
% Adds the affiliation to the author for use in \cs{maketitle}.
%
% Inside \env{titlepage}, this macro prints its argument.
% Outside, it is null.
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
\newrobustcmd{\affiliation}[1]{}
\end{warpall}
%    \end{macrocode}
% \end{macro}
%
%
%
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
%    \end{macrocode}
%
%    \begin{macrocode}
\AtBeginEnvironment{titlepage}{
\renewrobustcmd{\affiliation}[1]{\\ \textsc{\small#1}}
}

\AtBeginDocument{
\@ifpackageloaded{titling}{
\AtBeginEnvironment{titlingpage}{
\renewrobustcmd{\affiliation}[1]{\\ \textsc{\small#1}}
}
}{}% titling loaded
}% AtBeginDocument
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpprint}
%    \end{macrocode}
%
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
% \begin{environment}{titlepage}
% Sets up a \element{div} of class \attribute{titlepage}.
%
% \changes{v0.39}{2017/09/02}{Clear pending footnotes.}
% \changes{v0.39}{2017/09/03}{Removed minipages.}
%    \begin{macrocode}
\renewenvironment*{titlepage}
{
\renewrobustcmd{\affiliation}[1]{\\ \InlineClass{affiliation}{##1}}
\LWR@printpendingfootnotes
\LWR@forcenewpage
\BlockClass{titlepage}
}
{
\endBlockClass
\LWR@printpendingfootnotes
}
%    \end{macrocode}
% \end{environment}
%
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
%
% \subsection{Printing the thanks}
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}
% \DescribeMacro{\printthanks} Forces the \cs{thanks} to be printed.
%
% This is necessary in a \env{titlingpage} environment
% when \cs{maketitle} was not used.
%    \begin{macrocode}
\newcommand*{\printthanks}{\@thanks}
%    \end{macrocode}
%
%
%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}



% \subsection{Printing the title, etc.\ in HTML}
%
% \changes{v0.20}{2017/01/21}{Enhanced \pkg{titling} support.}
%
% The following are for printing the title, etc.
% in a \env{titlepage} or a \env{titlingpage}
% in \HTML:
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
%
% \begin{macro}{\printtitle}
%    \begin{macrocode}
\newcommand*{\printtitle}
{
\LWR@stoppars
\LWR@htmltag{\LWR@tagtitle}%
\@title%
\LWR@htmltag{\LWR@tagtitleend}
\LWR@startpars
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LWR@printthetitle}
%
% A private version which prints the title without footnotes,
% used to title each \HTML\ page.
%    \begin{macrocode}
\newcommand*{\LWR@printthetitle}
{
\LWR@stoppars
\LWR@htmltag{\LWR@tagtitle}%
\thetitle%
\LWR@htmltag{\LWR@tagtitleend}
\LWR@startpars
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\printauthor}
%   \HTML\ version.
%
% \changes{v0.39}{2017/09/01}{Supports \protect\pkg{authblk} with
% \element{div}s of class \attribute{oneauthor} instead of tabular.}
% \changes{v0.39}{2017/09/03}{Removed minipages.}
%
%    \begin{macrocode}
\newcommand*{\printauthor}{
%    \end{macrocode}
% The entire author block is contained in a \element{div} named \attribute{author}:
%    \begin{macrocode}
\begin{BlockClass}{author}
%    \end{macrocode}
% \cs{and} finishes one author and starts the next:
%    \begin{macrocode}
\renewcommand{\and}{%
\end{BlockClass}
\begin{BlockClass}{oneauthor}
}
%    \end{macrocode}
% Individual authors are contained in a \element{div} named \attribute{oneauthor}:
%    \begin{macrocode}
\begin{BlockClass}{oneauthor}
\@author
\end{BlockClass}
\end{BlockClass}
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\printdate}
%    \begin{macrocode}
\newcommand*{\printdate}{%
\begin{BlockClass}{titledate}
\@date
\end{BlockClass}
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \subsection{Printing the title, etc.\ in print form}
%
% The following are for printing the title, etc.
% in a \env{titlepage} or a \env{titlingpage}
% in print form:
%
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
%    \end{macrocode}

% \changes{v0.16}{2016/04/07}{\cs{titlingpage}: Improved print-output spacing.}
% \changes{v0.16}{2016/04/07}{Test Suite: Improved titlingpage.}
%

% \begin{macro}{\printtitle}
%    \begin{macrocode}
\newcommand*{\printtitle}{{\Huge\@title}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\printauthor}
%   Print mode.
%    \begin{macrocode}
\newcommand*{\printauthor}
    {{\large\begin{tabular}[t]{c}\@author\end{tabular}}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\printdate}
%    \begin{macrocode}
\newcommand*{\printdate}{{\small\textit{\@date}}}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\end{warpprint}
%    \end{macrocode}
%
%
%
% \subsection{\cs{maketitle} for HTML output}
% \label{sec:titlehtml}
%
% An \HTML\ \element{div} of class \attribute{titlepage} is used.
%
% |\thanks| are a form of footnotes used in the title page.
% See \cref{sec:footnotes} for other kinds of footnotes.
%
% See |\thanksmarkseries{series}|, below, to set the style of the footnote marks.
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
%    \begin{macrocode}
\if@titlepage
\newcommand{\LWR@setfootnoteseries}{%
    \renewcommand\thefootnote{\@arabic\c@footnote}%
}
\else
\newcommand{\LWR@setfootnoteseries}{%
    \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
}
\fi
%    \end{macrocode}
%
%
%\begin{macro}{\LWR@maketitlesetup} Patches \cs{thanks} macros.
%
%    \begin{macrocode}
\newcommand*{\LWR@maketitlesetup}{%
%    \end{macrocode}
%
% Redefine the footnote mark:
%
%    \begin{macrocode}
\LWR@setfootnoteseries%
\def\@makefnmark{\textsuperscript{\thefootnote}}
%    \end{macrocode}
%
% \begin{center}
% \begin{minipage}{.7\linewidth}
% \cs{thefootnote} \goesto\ \cs{nameuse}\{arabic\}\{footnote\}, or
%
% \cs{thefootnote} \goesto\  \cs{nameuse}\{fnsymbol\}\{footnote\}
% \end{minipage}
% \end{center}
%
% Redefine the footnote text:
%
%    \begin{macrocode}
\long\def\@makefntext##1{%
%    \end{macrocode}
% Make the footnote mark and some extra horizontal space for the tags:
%    \begin{macrocode}
\textsuperscript{\@thefnmark} \LWR@orighspace{1in}
%    \end{macrocode}
% \begin{center}
% \begin{minipage}{.7\linewidth}
% \cs{makethanksmark} \goesto\  \cs{thanksfootmark} \goesto\  \cs{tamark} \goesto\
%
% \hfill \cs{@thefnmark} \goesto\  \cs{itshape} a (or similar)
% \end{minipage}
% \end{center}
%
% Print the text:
%    \begin{macrocode}
##1%
}%
}
%    \end{macrocode}
% \end{macro}

% \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}.
%
% \changes{v0.34}{2017/08/07}{Text symbols instead of math.}
%
%    \begin{macrocode}
\def\@fnsymbol#1{\ifcase#1\or *\or \HTMLentity{dagger}\or \HTMLentity{Dagger}\or
   \HTMLentity{sect}\or \HTMLentity{para}\or \text{\HTMLunicode{2016}}\or
   **\or \HTMLentity{dagger}\HTMLentity{dagger} \or
   \HTMLentity{Dagger}\HTMLentity{Dagger} \else\@ctrerr\fi}
%    \end{macrocode}
% \end{macro}
%
%
%
%\begin{macro}{\maketitle}
%   \HTML\ mode.
%   Creates an \HTML\ titlepage div
%	and typesets the title, etc.
%
% Code from the \pkg{titling} package is adapted, simplified, and
% modified for \HTML\ output.
%
%    \begin{macrocode}
\renewcommand*{\maketitle}{%
%    \end{macrocode}
% An \HTML\ titlepage \element{div} is used for all classes.
%    \begin{macrocode}
\begin{titlepage}
%    \end{macrocode}
% Set up special patches:
%    \begin{macrocode}
\LWR@maketitlesetup
%    \end{macrocode}
% Typeset the title, etc:
%    \begin{macrocode}
\@maketitle
%    \end{macrocode}
% Immediately generate any |\thanks| footnotes:
%    \begin{macrocode}
\@thanks
%    \end{macrocode}
% Close the \HTML\ titlepage div and cleanup:
%    \begin{macrocode}
\end{titlepage}
\setcounter{footnote}{0}%
\global\let\thanks\relax
\global\let\maketitle\relax
\global\let\@maketitle\relax
\global\let\@thanks\@empty
\global\let\@author\@empty
\global\let\@date\@empty
\global\let\@title\@empty
\global\let\title\relax
\global\let\author\relax
\global\let\date\relax
\global\let\and\relax
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@maketitle}
%   \HTML\ mode.  Typesets the title, etc.:
%
% \changes{v0.39}{2017/09/01}{Supports \protect\pkg{authblk} with
% \element{div}s of class \attribute{oneauthor} instead of tabular.}
% \changes{v0.39}{2017/09/03}{Removed minipages.}
% \changes{v0.39}{2017/09/04}{Native \protect\LaTeX\ version.}
%
%    \begin{macrocode}
\DeclareDocumentCommand{\@maketitle}{}{%
    \LWR@stoppars\LWR@htmltag{\LWR@tagtitle}
    \@title
    \LWR@htmltag{\LWR@tagtitleend}\LWR@startpars
    \begin{BlockClass}{author}
        \renewcommand{\and}{
            \end{BlockClass}
            \begin{BlockClass}{oneauthor}
        }
        \begin{BlockClass}{oneauthor}
            \@author
        \end{BlockClass}
    \end{BlockClass}
    \begin{BlockClass}{titledate}
    \@date
    \end{BlockClass}
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\LWR@titlingmaketitle}
% \cs{maketitle} for use inside an \HTML\ \env{titlingpage} environment.
%    \begin{macrocode}
\newcommand*{\LWR@titlingmaketitle}{%
%    \end{macrocode}
% Keep pending footnotes out of the title block:
%    \begin{macrocode}
\@thanks
%    \end{macrocode}
% Set up special patches:
%    \begin{macrocode}
\LWR@maketitlesetup
%    \end{macrocode}
% Typeset the title, etc:
%    \begin{macrocode}
\@maketitle
%    \end{macrocode}
% Immediately generate any |\thanks| footnotes:
%    \begin{macrocode}
\@thanks
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
%
%
% \subsection{\cs{published} and \cs{subtitle}}
%
% \label{sec:publishedsubtitle}
%
% \changes{v0.39}{2017/09/05}{Titlepage \cs{published} and \cs{subtitle} removed.
%   \cs{AddSubtitlePublished} restores.}
%
% To add \cs{subtitle} and \cs{published} to the titlepage,
% \margintag{\cs{subtitle} and \cs{published}}
% \index{subtitle}\index{published}\index{titlepage>subtitle and published}
% load the \pkg{titling} package and use \cs{AddSubtitlePublished}
% in the preamble.
%
% 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.
% Do not use \cs{AddSubtitlePublished} if the user has patched the \pkg{titling}
% \watchout[\pkg{titling} hooks]
% hooks for some other reason.
% Portions are marked \cs{warpprintonly} to reduce extra tags in \HTML.
% Similarly, \env{BlockClass} has no effect in print mode.
% Thus, the following may be marked \env{warpall}.
%
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \begin{macro}{\AddSubtitlePublished}
% Adds \cs{published} and \cs{subtitle}, and related.
%
% \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}}%
}

}% \AddSubtitlePublished
}% AfterPackage
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}




% \section{Abstract}
%
% The following code replaces the \LaTeX\ default,
% and will itself be replaced later if the \pkg{abstract}
% package is loaded.
%
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{macro}{\abstractname}
% User-redefinable title for the abstract.
%
% Also over-written by the \pkg{babel} package.
%    \begin{macrocode}
\providecommand*{\abstractname}{Abstract}
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{abstract}
%    \begin{macrocode}
\DeclareDocumentEnvironment{abstract}{}
{
\LWR@forcenewpage
\BlockClass{abstract}
\BlockClassSingle{abstracttitle}{\abstractname}
}
{
\endBlockClass
}
%    \end{macrocode}
% \end{environment}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}






% \section{Quote and verse}

% \subsection{Citations and attributions}

% \begin{macro}{\attribution}
% for use inside quote, quotation, verse:

% ex: |\attribution{author name} --- \citetitle{book name}|

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
\newcommand{\attribution}[1]{%
\InlineClass{attribution}{—\,#1}}% emdash
\end{warpHTML}
%    \end{macrocode}
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\newcommand{\attribution}[1]{\textsc{---\,#1}}
\end{warpprint}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\citetitle}
% for use inside quote, quotation, verse:
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
\newcommand{\citetitle}[1]{%
\InlineClass{citetitle}{—\,#1}}% emdash
\end{warpHTML}
%    \end{macrocode}
%
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\newcommand{\citetitle}[1]{\textsl{---\,#1}}
\end{warpprint}
%    \end{macrocode}
% \end{macro}



% \subsection{Quotes, quotations}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
% \begin{environment}{quote}
%    \begin{macrocode}
\renewenvironment*{quote}
{
\LWR@forcenewpage
\LWR@htmlblocktag{blockquote}
}
{\LWR@htmlblocktag{/blockquote}}

\renewenvironment*{quotation}
{
\LWR@forcenewpage
\LWR@htmlblocktag{blockquotation}
}
{\LWR@htmlblocktag{/blockquotation}}
%    \end{macrocode}
% \end{environment}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \subsection{Verse}
%
% \limitsverse
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}
%
% The following lengths may be set in either print or \HTML\ output,
% but are only used in \HTML.
% This allows the user to set \cs{vleftskip} and \cs{leftmargini} for
% print output, and optionally select different values for \HTML.
%

% \DescribeLength{HTMLvleftskip}
% Sets \cs{vleftskip} inside a \env{verse} environment in \HTML.
%    \begin{macrocode}
\newlength{\HTMLvleftskip}
\setlength{\HTMLvleftskip}{1em}
%    \end{macrocode}

% \DescribeLength{HTMLleftmargini}
% Sets \cs{leftmargini} inside a \env{verse} environment in \HTML.
%    \begin{macrocode}
\newlength{\HTMLleftmargini}
\setlength{\HTMLleftmargini}{4.5em}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}






% \section{Verbatim and tabbing}

% \changes{v0.34}{2017/07/27}{Verbatim refactored to
%		remove \protect\pkg{fancyvrb} requirement.}


% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}
%
%
% \DescribeLength{\VerbatimHTMLWidth} Width to use in \HTML\ |Verbatim| environment.
%
% This width is used when placing line numbers to the right.
% Ignored during print output.
%    \begin{macrocode}
\newlength{\VerbatimHTMLWidth}
\setlength{\VerbatimHTMLWidth}{4in}
\end{warpall}
%    \end{macrocode}


% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \DescribeBoolean{LWR@verbtags} Used to temporarily turn off verbatim tags
%	while doing \cs{verbatiminput} in the \HTML\ head.
%    \begin{macrocode}
\newbool{LWR@verbtags}
\booltrue{LWR@verbtags}
%    \end{macrocode}


% \begin{macro}{\LWR@atbeginverbatim} \oarg{style} \marg{class}
%
% Encloses a verbatim environment with the given \CSS\ class.
%    \begin{macrocode}
\newcommand*{\LWR@atbeginverbatim}[2][]
{%
%    \end{macrocode}
% Avoid excessive space between lines:
%    \begin{macrocode}
\setlength{\parskip}{0ex}%
%    \end{macrocode}
% Stop generating \HTML\ paragraph tags:
%    \begin{macrocode}
\LWR@stoppars%
%    \end{macrocode}
% Create a new |pre| of the given class.
% The tags may temporarily be turned off for internal use, such
% as loading the MathJax script.
%    \begin{macrocode}
\ifbool{LWR@verbtags}{%
    \LWR@htmltag{pre class="#2"
    \ifthenelse{\equal{#1}{}}{}{style="#1"}%
}% pre
}{}%
%    \end{macrocode}
% Use a mono-spaced font to preserve horizontal positioning.
% If horizontal alignment is important for the user, use a mono-spaced font
% in the \CSS\ for the |verse| class.
%    \begin{macrocode}
\begingroup%
\LWR@origttfamily%
%    \end{macrocode}
% Since inside a \element{pre}, restore the original list processing:
%    \begin{macrocode}
\LWR@restoreoriglists%
%    \end{macrocode}
% Turn off \pkg{babel-french} extra space before punctuation:
%    \begin{macrocode}
\LWR@FBcancel%
%    \end{macrocode}
% Do not produce \HTML\ tags for \cs{hspace} inside a verse |par|.
% Restore plain \LaTeX{} \cs{hspace} functionality:
%    \begin{macrocode}
\LetLtxMacro{\hspace}{\LWR@orighspace}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@afterendverbatim} Finishes enclosing a verbatim environment.
%    \begin{macrocode}
\newcommand*{\LWR@afterendverbatim}{%
%    \end{macrocode}
% Remove excess vertical space at the end of the |pre|:
%    \begin{macrocode}
\endgroup%
\unskip%
%    \end{macrocode}
% At the end of the environment, close the |pre|:
%    \begin{macrocode}
\ifbool{LWR@verbtags}{\noindent\LWR@htmltag{/pre}

}{}%
%    \end{macrocode}
% Resume regular paragraph handling:
%    \begin{macrocode}
\LWR@startpars%
}
%    \end{macrocode}
% \end{macro}
%


% \begin{macro}{\verbatiminput} \marg{filename}
%
% Patch \cs{verbatiminput} to add \HTML\ tags:
%
%    \begin{macrocode}
\let\LWRV@origverbatim@input\verbatim@input

\renewcommand{\verbatim@input}[2]{%
\ifbool{LWR@verbtags}{\LWR@forcenewpage}{}%
\LWR@atbeginverbatim{Verbatim}\unskip\LWR@origvspace*{-\baselineskip}%%
\LWRV@origverbatim@input{#1}{#2}%
\unskip\LWR@origvspace*{-\baselineskip}\LWR@afterendverbatim%
}
%    \end{macrocode}
% \end{macro}



% \begin{environment}{verbatim}
%
% \changes{v0.20}{2016/12/24}{Added.}
%
%    \begin{macrocode}
\AfterEndPreamble{
\LWR@traceinfo{Patching verbatim.}
\AtBeginEnvironment{verbatim}{%
\LWR@forcenewpage
\LWR@atbeginverbatim{verbatim}\unskip\LWR@origvspace*{-\baselineskip}%
}
\AfterEndEnvironment{verbatim}{%
    \unskip\LWR@origvspace*{-\baselineskip}\LWR@afterendverbatim%
}
}
%    \end{macrocode}
% \end{environment}


% \begin{environment}{tabbing}
%
% \changes{v0.42}{2017/10/13}{Added.}
%
%    \begin{macrocode}
\AfterEndPreamble{
\LWR@traceinfo{Patching tabbing.}
\AtBeginEnvironment{tabbing}{%
\LWR@forcenewpage
\LWR@atbeginverbatim{tabbing}\unskip\LWR@origvspace*{-\baselineskip}%
}
\AfterEndEnvironment{tabbing}{%
    \unskip\LWR@origvspace*{-\baselineskip}\LWR@afterendverbatim%
}
}
%    \end{macrocode}
% \end{environment}


%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}






% \section{Theorems}
%
% \changes{v0.25}{2017/03/17}{Basic \LaTeX\ theorems: improved \CSS.}
%
%
% \DescribeMacro{\newtheorem} \marg{text} \oarg{counter} -or- \oarg{oldname} \marg{text}
%
% A few minor changes are made to supply \HTML\ tags.
%
% \begin{itemize}
% \item The entire theorem is placed into a \element{div} of class \attribute{theoremcontents}.
% \item The label for each theorem is placed inside a \element{span} of class \attribute{theoremlabel}.
% \item The contents are placed inside a \element{div} of class {theoremcontents}.
% \end{itemize}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{macro}{\@begintheorem} \marg{name} \marg{number}
%    \begin{macrocode}
\renewcommand{\@begintheorem}[2]{%
\LWR@forcenewpage
\BlockClass{theoremcontents}
\InlineClass{theoremlabel}{#1\ #2\ }
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@opargbegintheorem} \marg{name} \marg{number} \marg{oparg}
%    \begin{macrocode}
\renewcommand{\@opargbegintheorem}[3]{%
\LWR@forcenewpage
\BlockClass{theoremcontents}
\InlineClass{theoremlabel}{#1\ #2\ (#3)\ }
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@endtheorem}
%    \begin{macrocode}
\renewcommand*{\@endtheorem}{%
\endBlockClass% theoremcontents
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \section{Lists}
%
% ^^A \limitsbabelone
%
% The environments |itemize|, |enumerate|, and |description| are patched
% when \pkg{lwarp} is started.  These patches support the standard
% \LaTeX\ environments, as well as those of \pkg{enumerate}, \pkg{enumitem},
% and \pkg{paralist}, and at least the French version of \pkg{babel}.
% Additional patches are done on a package-specific basis.
%
% The \LaTeX\ source for |itemize| and |enumerate| are found in |source2e|, but
% the source for |description| is found in |article.cls|, etc.
%
% To have an empty
% item,\margintag{empty item}\index{item>empty}\index{list item, empty} use
% |\mbox{}| or a trailing backslash.
% This forces a new line in print output, matching the new line which
% will appear in \HTML\ output.
% Ex:
%\begin{Verbatim}[gobble=2,frame=lines,obeytabs,tabsize=4]
%\begin{itemize}
%\item \mbox{}
%     \begin{itemize}
%	...
%     \end{itemize}
%\item \
%     \begin{itemize}
%   ...
%     \end{itemize}
%\end{Verbatim}
%
% \changes{v0.34}{2017/07/27}{Lists refactored to remove \pkg{enumitem} requirement.}
%
% \subsection{List environment}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% The following may be locally redefined by \env{enumerate} or \env{description}.
%    \begin{macrocode}
\newcommand*{\LWR@printcloselist}{\LWR@printcloseitemize}
\newcommand*{\LWR@printopenlist}{ul style="list-style-type:none"}
%    \end{macrocode}

% \begin{macro}{\LWR@listitem} \oarg{label}
%
% Handles \cs{item} inside a \env{list}, \env{itemize}, or \env{enumerate}.
%
% See \cs{LWR@openparagraph} where extra \cs{hspace} is used to
% leave room for the label while inside a list during paragraph construction.
%
% \changes{v0.44}{2017/11/15}{Added \env{list} and \env{trivlist}.}
%    \begin{macrocode}
\newcommand*{\LWR@listitem}{%
\LWR@stoppars%
\LWR@startnewdepth{\LWR@depthlistitem}{\LWR@printcloselistitem}%
\LWR@htmltag{li}%
\LWR@startpars%
\LWR@origitem%
}
%    \end{macrocode}
% \end{macro}

% \begin{environment}{list} \marg{label} \marg{commands}
% \changes{v0.44}{2017/11/15}{Added \env{list} and \env{trivlist}.}
%    \begin{macrocode}
\newcommand*{\LWR@liststart}{%
\LWR@stoppars%
\LWR@pushoneclose{\LWR@depthlist}{\LWR@printcloselist}%
\LWR@htmltag{\LWR@printopenlist}\LWR@orignewline%
\LWR@startpars%
\setlength{\topsep}{0pt}%
\setlength{\partopsep}{0pt}%
\setlength{\itemsep}{0pt}%
\setlength{\parsep}{0pt}%
\setlength{\leftmargin}{0pt}%
\setlength{\rightmargin}{0pt}%
\setlength{\listparindent}{0pt}%
\setlength{\itemindent}{0pt}%
\setlength{\labelsep}{1em}%
}

\newcommand*{\LWR@listend}{%
\LWR@stoppars%
\LWR@closeprevious{\LWR@depthlistitem}%
\LWR@closeoneprevious%
\LWR@startpars%
}
%    \end{macrocode}
% \end{environment}


% \subsection{Itemize}

% \begin{macro}{\LWR@itemizeitem} \oarg{label}
%
% Handles |\item| inside an itemize or enumerate.
%
% See |\LWR@openparagraph| where extra |\hspace| is used to
% leave room for the label while inside a list during paragraph construction.
%    \begin{macrocode}
\newcommand*{\LWR@itemizeitem}{%
\LWR@stoppars%
\LWR@startnewdepth{\LWR@depthlistitem}{\LWR@printcloselistitem}%
\LWR@htmltag{li}%
\LWR@startpars%
\LWR@origitem%
}
%    \end{macrocode}
% \end{macro}

% \begin{environment}{itemize} \oarg{options}
%    \begin{macrocode}
\newcommand*{\LWR@itemizestart}{%
\renewcommand*{\LWR@printcloselist}{\LWR@printcloseitemize}
\renewcommand*{\LWR@printopenlist}{ul style="list-style-type:none"}
\let\item\LWR@itemizeitem%
}
%    \end{macrocode}
% \end{environment}



% \subsection{Enumerate}

% An \HTML\ unordered list is used with customized \LaTeX-generated labels.

% \begin{environment}{enumerate} \oarg{options}
%    \begin{macrocode}
\newcommand*{\LWR@enumeratestart}{%
\renewcommand*{\LWR@printcloselist}{\LWR@printcloseitemize}
\renewcommand*{\LWR@printopenlist}{ul style="list-style-type:none"}
\let\item\LWR@itemizeitem%
}
%    \end{macrocode}
% \end{environment}


% \subsection{Description}

% \begin{macro}{\LWR@descitem} \oarg{label}
% Handles an |\item| inside a description.
%    \begin{macrocode}
\newcommand*{\LWR@descitem}[1][]%
{%
\LWR@stoppars%
\LWR@setlatestname{#1}%
\LWR@startnewdepth{\LWR@depthlistitem}{\LWR@printclosedescitem}%
%    \end{macrocode}
% Temporarily disable \cs{hspace}, which |article.cls|, etc.\ use per \cs{item}
% for |description|s only.
% This causes \pkg{lwarp} to mistakenly place an empty span between
% \HTML\ list tags.
%    \begin{macrocode}
\LetLtxMacro{\hspace}{\LWR@nohspace}%
%    \end{macrocode}
% Process the original \cs{item} code:
%    \begin{macrocode}
\LWR@origitem[]%
%    \end{macrocode}
% Restore \cs{hspace} for use in the item text:
%    \begin{macrocode}
\LetLtxMacro{\hspace}{\LWR@hspace}%
%    \end{macrocode}
% Be sure the label doesn't print to the left of the rest of the file:
%    \begin{macrocode}
\LWR@orighspace{1in}
\LWR@htmltag{dt}#1\LWR@htmltag{/dt}%
\LWR@orignewline%
\LWR@htmltag{dd}%
\LWR@startpars%
}
%    \end{macrocode}
% \end{macro}

% \begin{environment}{description} \oarg{options}
%    \begin{macrocode}
\newcommand*{\LWR@descriptionstart}{%
\renewcommand*{\LWR@printcloselist}{\LWR@printclosedescription}
\renewcommand*{\LWR@printopenlist}{dl}
\let\item\LWR@descitem%
}
%    \end{macrocode}
% \end{environment}


% \subsection{Patching the lists}

%    \begin{macrocode}
\let\LWR@orig@trivlist\@trivlist
\let\LWR@origtrivlist\trivlist
\let\LWR@origendtrivlist\endtrivlist
%    \end{macrocode}

% \begin{macro}{\LWR@patchlists} Patches list environments.
%
% \cs{LWr@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
% those provided by \pkg{enumitem}, \pkg{enumerate}, and \pkg{paralist}.
%
% \changes{v0.44}{2017/11/15}{Added \env{list} and \env{trivlist}.}
%
%    \begin{macrocode}
\newcommand*{\LWR@patchlists}{%
    \let\item\LWR@listitem%
    \renewcommand*{\@trivlist}{%
        \LWR@liststart%
        \LWR@orig@trivlist%
    }%
    \renewcommand*{\endtrivlist}{\LWR@origendtrivlist\LWR@listend}%
    \renewcommand*{\trivlist}{%
        \LWR@origtrivlist%
        \def\makelabel####1{\LWR@orighspace{3em}####1}%
    }%
    \renewcommand*{\itemize}{\LWR@itemizestart\LWR@origitemize}%
    \renewcommand*{\enumerate}{\LWR@enumeratestart\LWR@origenumerate}%
    \renewcommand*{\description}{\LWR@descriptionstart\LWR@origdescription}%
%     \AtBeginEnvironment{itemize}{\LWR@itemizestart}%
%     \AtBeginEnvironment{enumerate}{\LWR@enumeratestart}%
%     \AtBeginEnvironment{description}{\LWR@descriptionstart}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@restoreoriglists} Restores the original \env{trivlist} environment.
%    \begin{macrocode}
\newcommand*{\LWR@restoreoriglists}{%
\let\@trivlist\LWR@orig@trivlist%
\let\trivlist\LWR@origtrivlist%
\let\endtrivlist\LWR@origendtrivlist%
\LetLtxMacro\item\LWR@origitem%
\LetLtxMacro\itemize\LWR@origitemize%
\LetLtxMacro\enditemize\LWR@endorigitemize%
\LetLtxMacro\enumerate\LWR@origenumerate%
\LetLtxMacro\endenumerate\LWR@endorigenumerate%
\LetLtxMacro\description\LWR@origdescription%
\LetLtxMacro\enddescription\LWR@endorigdescription%
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}






% \section{Tabular}
%
% This is arguably the most complicated part of the entire package.
% Numerous tricks are employed to handle the syntax which is involved.
%
% \subsection{Limitations}
%
% \limitstabular
%
% \changes{v0.20}{2017/01/07}{Added @, \protect\textless, \protect\textgreater\ columns.}
% \changes{v0.20}{2017/01/17}{Tabular: \cs{unskip} extra spaces.}
% \changes{v0.33}{2017/06/20}{New handling of \protect\texttt{\&} to localize catcode changes.}
% \changes{v0.33}{2017/07/10}{Add: Tabular at and bang columns now have their
%	own HTML columns.}
%
% \subsection{Token lookahead}

% Used by |\LWR@futurenonspacelet| to look at the next token.

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{macro}{\LWR@mynexttoken}
%    \begin{macrocode}
\newcommand\LWR@mynexttoken\relax
%    \end{macrocode}
% \end{macro}

% |\futurelet| copies the next token then executes a function to analyze

% |\LWR@futurenonspacelet| does the same, but ignores intervening white space

% Based on the \pkg{booktabs} style:

% \begin{macro}{\LWR@futurenonspacelet}
%    \begin{macrocode}
\def\LWR@futurenonspacelet#1{\def\LWR@cs{#1}%
\afterassignment\LWR@fnslone\let\nexttoken= }
\def\LWR@fnslone{\expandafter\futurelet\LWR@cs\LWR@fnsltwo}
\def\LWR@fnsltwo{%
\expandafter\ifx\LWR@cs\@sptoken\let\next=\LWR@fnslthree%
\else\let\next=\nexttoken\fi\next}
\def\LWR@fnslthree{\afterassignment\LWR@fnslone\let\next= }
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@getmynexttoken}
% Looks ahead and copies the next token into |\LWR@mynexttoken|.
%    \begin{macrocode}
\newcommand*{\LWR@getmynexttoken}{%
\LWR@traceinfo{LWR@getmynexttoken}%
% nothing must follow this next line
\LWR@futurenonspacelet\LWR@mynexttoken\LWR@tabledatacolumntag
}
%    \end{macrocode}
% \end{macro}

% \subsection{Booleans}

% \DescribeBoolean{LWR@startedrow}
% True if should print a row tag before this column.
%    \begin{macrocode}
\newbool{LWR@startedrow}
\boolfalse{LWR@startedrow}
%    \end{macrocode}

% \DescribeBoolean{LWR@tabularcelladded}
% True if have added a data cell for this position.
%    \begin{macrocode}
\newbool{LWR@tabularcelladded}
\boolfalse{LWR@tabularcelladded}
%    \end{macrocode}

% \DescribeBoolean{LWR@doinghline}
% True if the next row will have an hline or midrule above it.
% Also used for \cs{midrule}.
%    \begin{macrocode}
\newbool{LWR@doinghline}
\boolfalse{LWR@doinghline}
%    \end{macrocode}

% \DescribeBoolean{LWR@doingtbrule}
% True if the next row will have a top/bottom rule above it.
%    \begin{macrocode}
\newbool{LWR@doingtbrule}
\boolfalse{LWR@doingtbrule}
%    \end{macrocode}

% \DescribeBoolean{LWR@doingcmidrule}
% True if the next row will have a cmidrule above it.
%
% This is used by \cs{LWR@tabularfinishrow} to force a final empty row
% to create the border for the \cs{cmidrule}.
%    \begin{macrocode}
\newbool{LWR@doingcmidrule}
\boolfalse{LWR@doingcmidrule}
%    \end{macrocode}

% \DescribeBoolean{LWR@tableparcell}
% True if are handling a paragraph inside a table cell,
% so must close the paragraph tag before moving on.
%    \begin{macrocode}
\newbool{LWR@tableparcell}
%    \end{macrocode}

% \DescribeBoolean{LWR@skippingmrowcell}
% True if are doing an empty \cs{multirow} cell,
% and thus there is no data tag to close.
%    \begin{macrocode}
\newbool{LWR@skippingmrowcell}
%    \end{macrocode}

% \DescribeBoolean{LWR@skippingmcolrowcell}
% True if are doing an empty \cs{multicolumnrow} cell,
% and thus there is no data tag to close, and
% do not print |@| and |!| columns.
%    \begin{macrocode}
\newbool{LWR@skippingmcolrowcell}
%    \end{macrocode}


% \DescribeBoolean{LWR@skipatbang}
% True if just finished a \cs{multicolumn} so should not create the trailing
% |@| or |!| columns table data cells.
%    \begin{macrocode}
\newbool{LWR@skipatbang}
%    \end{macrocode}


% \DescribeBoolean{LWR@emptyatbang}
% True if finishing a row and should print empty |@| or |!| column table data cells.
%    \begin{macrocode}
\newbool{LWR@emptyatbang}
%    \end{macrocode}


% \DescribeBoolean{LWR@intabularmetadata}
% True if are in a tabular but not in a data cell.
% Used to prevent extra \HTML\ breaks if not inside table data.
%    \begin{macrocode}
\newbool{LWR@intabularmetadata}
\boolfalse{LWR@intabularmetadata}
%    \end{macrocode}



% \subsection{Handling \&, @, !, and bar}
%
% \begin{minipage}{\linewidth}
% For technical discussion regarding problems redefining |\&|, See: \\
% \href{http://tex.stackexchange.com/questions/11638/where-do-i-find-futurelets-nasty-behaviour-documented/11860#11860}
%	{http://tex.stackexchange.com/questions/11638/ \\ \hspace*{.25in} where-do-i-find-futurelets-nasty-behaviour-documented/11860\#11860}
% \end{minipage}
%

% \begin{macro}{\LWR@instertatbangcols}
%    \begin{macrocode}
\newcommand*{\LWR@insertatbangcols}{%
\ifbool{LWR@skipatbang}%
{}%
{%
    \LWR@printatbang{at}{\arabic{LWR@tablecolindex}}%
    \LWR@printatbang{bang}{\arabic{LWR@tablecolindex}}%
}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@closetabledatacell}
% If |LWR@skippingmrowcell| or |LWR@skippingmcolrowcell| then
% there is no data tag to close.
% Otherwise, close any paragraphs, then close the data tag.
%
% \changes{v0.41}{2017/10/02}{Add: Mute \protect\texttt{\protect\textgreater} for \cs{bottomrule}.}
%
%    \begin{macrocode}
\newcommand*{\LWR@closetabledatacell}{%
\global\booltrue{LWR@intabularmetadata}%
\ifbool{LWR@exitingtabular}{}%
{% not exiting tabular
    \ifboolexpr{bool{LWR@skippingmrowcell} or bool{LWR@skippingmcolrowcell}}%
    {%
%    \end{macrocode}
% If not skipping a \cs{multicolumnrow} cell,
% insert the |@| and |!| columns after this non-existant column.
% \changes{v0.41}{2017/10/03}{Fix: At/bang column with \cs{multirow}.}
%    \begin{macrocode}
        \ifbool{LWR@skippingmcolrowcell}%
        {}%
        {\LWR@insertatbangcols}%
    }%
    {% not skippingmrowcell
%    \end{macrocode}
% Insert any |<| then any |@| and |!| column contents, unless muted
% for the \cs{bottomrule} or a \cs{multicolumn}:
% \changes{v0.41}{2017/10/02}{Fix: Cancel \protect\texttt{\protect\textless} for \cs{multicolumn}.}
%    \begin{macrocode}
        \unskip%
        \ifboolexpr{%
            bool{LWR@tabularmutemods} or
            bool{LWR@skipatbang} or
            bool{LWR@emptyatbang}
        }%
        {}%
        {\LWR@getexparray{LWR@colafterspec}{\arabic{LWR@tablecolindex}}}%
%    \end{macrocode}
% Close paragraphs:
%    \begin{macrocode}
        \ifbool{LWR@tableparcell}{\LWR@stoppars}{}%
        \global\boolfalse{LWR@tableparcell}%
%    \end{macrocode}
% Close the table data cell.
% Skip the |@| and |!| cells if are closing a multicolumn cell.
%    \begin{macrocode}
        \leavevmode\unskip\LWR@htmltag{/td}\LWR@orignewline%
        \global\booltrue{LWR@tabularcelladded}%
        \LWR@insertatbangcols%
    }% not skipping mrowcell
}% not exiting tabular
\global\boolfalse{LWR@skippingmrowcell}%
\global\boolfalse{LWR@skippingmcolrowcell}%
\global\boolfalse{LWR@skipatbang}%
}
%    \end{macrocode}
% \end{macro}


% |LWR@tabulardepth| tracks whether |&| is being used inside a \env{tabular}.
%    \begin{macrocode}
\newcounter{LWR@tabulardepth}
\setcounter{LWR@tabulardepth}{0}

%    \end{macrocode}
% When not used inside a \env{tabular}, |&| performs its original
% function as recorded here ( with catcode 4 ).
%    \begin{macrocode}
\let\LWR@origampmacro&
%    \end{macrocode}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
%
%
% \subsubsection{Localizing \& catcodes}
% \label{sec:localizingampersand}
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}
%
% Place \cs{StartDefiningTabulars} and
%	\cs{EndDefiningTabulars}\watchout[misplaced alignment tab character \&]
% 	\index{alignment tab character \&, misplaced}
% 	\index{misplaced alignment tab character \&}
% before and after defining macros or environments which include
% the tabular \texttt{\&} character in their definitions.
%
% The catcode of \texttt{\&} must be changed before the definitions begin,
%	and must be restored afterwards.  Doing so avoids the error\\
%	\hspace*{.5in}\texttt{misplaced alignment tab character \&}
%
% \begin{macro}{\StartDefiningTabulars} Place before defining something with |&| in it.
% \changes{v0.33}{2017/06/20}{Add: Avoids error: \protect\texttt{misplaced alignment tab character \&}.}
%    \begin{macrocode}
\newcommand{\StartDefiningTabulars}{%
\LWR@traceinfo{StartDefiningTabulars}
\warpHTMLonly{\catcode`\&=\active}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\EndDefiningTabulars} Place after defining something with |&| in it.
%    \begin{macrocode}
\newcommand{\EndDefiningTabulars}{%
\LWR@traceinfo{EndDefiningTabulars}
\warpHTMLonly{\catcode`\&=4}%
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}
%
%
% \subsubsection{Handling \&}
%
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%

%
% \changes{v0.15}{2016/03/31}{Ampersand (\&): Fixed handling when passed as an argument.}
%
% \begin{macro}{&} Will behave depending on whether it is being used inside \env{tabular}.
%
% |&| is redefined to test whether it is inside a tabular environment,
% in which case it performs special processing for \HTML\ conversion.
% If not, it behaves normally.
%
%    \begin{macrocode}
\newcommand*{\LWR@tabularampersand}{%
\LWR@traceinfo{LWR@tabularampersand}%
\ifnumcomp{\value{LWR@tabulardepth}}{>}{0}%
{%
%    \end{macrocode}
% If not skipping a multirow cell, close the current data cell.
%    \begin{macrocode}
    \unskip%
    \LWR@closetabledatacell%
%    \end{macrocode}
% Move to the next column.
%    \begin{macrocode}
    \addtocounter{LWR@tablecolindex}{1}%
%    \end{macrocode}
% Have not yet added data in this column:
%    \begin{macrocode}
    \boolfalse{LWR@tabularcelladded}%
%    \end{macrocode}
% Look at the next token to decide multi or single column data tag.
%    \begin{macrocode}
    \LWR@getmynexttoken%
}%
%    \end{macrocode}
% If not inside a tabular, performs the original action:
%    \begin{macrocode}
{\LWR@origampmacro}%
}
%    \end{macrocode}
% |&| is left with its original catcode for now.
%
% \pkg{tikz} package seems to require |&| be left alone until after
% \pkg{tikz} has been loaded.  Also, \pkg{cleveref} uses the ampersand in
% one of its options.
%
% |&| is made active inside a \env{tabular}.
%
% |&| is left alone when in math alignments.
% \end{macro}



% \subsubsection{Filling an unfinished row}

% \begin{macro}{\LWR@tabularfinishrow}
% Adds empty table cells if necessary to finish the row.
%
% At the end of the table, if any bottom rules are requested then
% an empty row must be generated to form the borders which show the rules.
%
% \changes{v0.41}{2017/10/02}{Unfinished tabular rows automatically filled.}
%
%    \begin{macrocode}
\newcommand*{\LWR@tabularfinishrow}{%
%    \end{macrocode}
% If not exiting the tabular, or doing a rule, or have already started a row,
% finish this row:
%    \begin{macrocode}
\ifboolexpr{%
    not bool {LWR@exitingtabular} or%
    bool{LWR@doingtbrule} or%
    bool{LWR@doingcmidrule} or%
    bool{LWR@doinghline} or%
    bool{LWR@startedrow}%
}{%
%    \end{macrocode}
% To locally temporarily turn off |LWR@exitingtabular| so that
% table data tags will still be generated:
%    \begin{macrocode}
\begingroup%
%    \end{macrocode}
% If generating a final row for the \cs{bottomrule} borders,
% turn off the |@|, |!|, |<|, and |>| column output:
%    \begin{macrocode}
\ifbool{LWR@exitingtabular}{%
    \booltrue{LWR@tabularmutemods}%
}{}%
%    \end{macrocode}
% Reenable the table data tags until finished with the final row:
%    \begin{macrocode}
\global\boolfalse{LWR@exitingtabular}%
%    \end{macrocode}
% Generate table data tags and ampersands until the right edge:
%    \begin{macrocode}
\whileboolexpr{%
    test {
        \ifnumcomp{\value{LWR@tablecolindex}}{<}{\value{LWR@tabletotalcols}}
    } or %
    (%
        bool{LWR@intabularmetadata} and%
        not bool{LWR@tabularcelladded} and%
        test {
            \ifnumcomp{\value{LWR@tablecolindex}}{=}{\value{LWR@tabletotalcols}}
        }%
    )%
}%
{%
    \LWR@tabledatasinglecolumntag%
%    \end{macrocode}
% The following is essentially \cs{LWR@tabularampersand} with
% |LWR@emptyatbang| added to empty the following cells:
%    \begin{macrocode}
    \LWR@closetabledatacell%
    \addtocounter{LWR@tablecolindex}{1}%
    \boolfalse{LWR@tabularcelladded}%
    \global\booltrue{LWR@emptyatbang}%
%    \end{macrocode}
% Starts the next cell:
%    \begin{macrocode}
    \ifnumcomp{\value{LWR@tablecolindex}}{<}{\value{LWR@tabletotalcols}}%
    {\LWR@getmynexttoken}%
    {}%
}%
%    \end{macrocode}
% Reenable the original |LWR@exitingtabular| to close the entire table:
%    \begin{macrocode}
\endgroup%
\global\boolfalse{LWR@emptyatbang}%
}{}% ifboolexpr
}
%    \end{macrocode}
% \end{macro}




% \subsection{Handling \protect\textbackslash\protect\textbackslash}

% Inside tabular, |\\| is redefined to |\LWR@tabularendofline|
%
% Throws away options |\\[dim]| or |\\*|
%
% \begin{macro}{\LWR@tabularendofline}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@tabularendofline}{s o}{%
\ifnumcomp{\value{LWR@tablecolindex}}{<}{\value{LWR@tabletotalcols}}%
{\LWR@tabularfinishrow}%
{\LWR@closetabledatacell}%
%    \begin{macrocode}
\LWR@htmltag{/tr}\LWR@orignewline
\global\booltrue{LWR@intabularmetadata}
%    \end{macrocode}
% Not yet started a table row:
%    \begin{macrocode}
\global\boolfalse{LWR@startedrow}
%    \end{macrocode}
% Additional setup:
%    \begin{macrocode}
\global\boolfalse{LWR@doinghline}%
\global\boolfalse{LWR@doingtbrule}%
\global\boolfalse{LWR@doingcmidrule}%
\LWR@clearmidrules%
%    \end{macrocode}
% Start at first column:
%    \begin{macrocode}
\setcounter{LWR@tablecolindex}{1}%
%    \end{macrocode}
% Have not yet added data in this column:
%    \begin{macrocode}
\boolfalse{LWR@tabularcelladded}%
%    \end{macrocode}
% Look at the next token to decide between single column data tag
% or a special case:
%    \begin{macrocode}
\LWR@getmynexttoken%
}
%    \end{macrocode}
% \end{macro}

% \subsection{Variables}

%    \begin{macrocode}
\newcommand*{\LWR@colsresult}{}%temp storage for column format results
\newcommand*{\LWR@pposition}{}
\newcommand*{\LWR@pleft}{}
\newcommand*{\LWR@pright}{}
%    \end{macrocode}

% \begin{macro}{\LWR@tablecolspec} Holds the parsed column specification,
% of total width |LWR@tabletotalcols|, not counting |@| and |!| columns.
%
% Will contain a string such as |llrrccpc|, exactly one letter per \LaTeX\ table column,
% without |@|, |!|, |>|, |<|, or the vertical bar.
%
%    \begin{macrocode}
\newcommand*{\LWR@tablecolspec}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@strresult} Holds the result of |Str| functions.
% \changes{v0.44}{2017/11/19}{Fix: \cs{providecommand}.}
%    \begin{macrocode}
\providecommand*{\LWR@strresult}{}
\providecommand*{\LWR@strresulttwo}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@origcolspec} Holds the original column specs given to \env{tabular}.
%    \begin{macrocode}
\newcommand*{\LWR@origcolspec}{}
%    \end{macrocode}
% \end{macro}


% \DescribeCounter{LWR@tablecolspecwidth}
% Holds the number of tokens in the table columns specification.
%
% This is includes one for each |@|, |!|, |<|, |>| column,
% and also one for each of the parameters of |p|, |@|, |!|, |<|, |>| columns,
% and three for each |D| column.
%
% (This is not the total \# of \LaTeX\ columns in the table.)
%    \begin{macrocode}
\newcounter{LWR@tablecolspecwidth}
%    \end{macrocode}

% \DescribeCounter{LWR@tablecolspecindex}
% While parsing the \LaTeX\ table column specification,
% starts at 1 and is incremented per token of the specification.
% While producing the table, resets to 1 at the start of the table and
% also at each end of line, and is incremented by 1 by each ampersand.
%    \begin{macrocode}
\newcounter{LWR@tablecolspecindex}
%    \end{macrocode}

% \DescribeCounter{LWR@tablecolindex}
% While parsing the \LaTeX\ table column specification,
% starts at 1 and is incremented per token of the specification.
% While producing the table, resets to 1 at the start of the table and
% also at each end of line, and is incremented by 1 by each ampersand.
%    \begin{macrocode}
\newcounter{LWR@tablecolindex}
%    \end{macrocode}

% \DescribeCounter{LWR@tabletotalcols}
% While parsing a table column specification,
% begins at 0 and increments by 1 per \LaTeX\ table column.
% Eventually holds the final number of \LaTeX\ table columns in each row,
% not counting |@| and |!| columns.
% (In \HTML, |@| and |!| cells become their own columns, but are not included in
% |LWR@tabletotalcols|.)
%    \begin{macrocode}
\newcounter{LWR@tabletotalcols}
%    \end{macrocode}

% \DescribeCounter{LWR@tabletotalcolsnext}
% Holds the next \LaTeX\ table column index while parsing,
% equal to one more than |LWR@tabletotalcols|.
%    \begin{macrocode}
\newcounter{LWR@tabletotalcolsnext}
%    \end{macrocode}

% \DescribeObject{LWR@colatspec} A data array of specifications for |@| columns.
% The leftmost's index is |leftedge|, the others are counter values.
% See \cref{sec:dataarray}.
% 
% \DescribeObject{LWR@colbangspec} A data array of specifications for |!| columns.
% The leftmost's index is |leftedge|, the others are counter values.
% See \cref{sec:dataarray}.
% 
% \DescribeObject{LWR@colbeforespec} A data array of specifications for |>| columns.
% 
% \DescribeObject{LWR@colafterspec} A data array of specifications for |<| columns.
%
% \DescribeObject{LWR@colbarspec} A data array of specifications for vertical rules.


% \subsection{Parsing @, >, <, !, bar columns}
%
%
% Holds the parsed argument for |@|, |>|, |<|, or |!| columns:
%    \begin{macrocode}
\newcommand*{\LWR@colparameter}{}
%    \end{macrocode}
%
% \begin{macro}{\LWR@parseatcolumn}
%
% Handles |@{text}| columns.
%
% \changes{v0.33}{2017/07/07}{Fix: Column alignment with leftmost \protect\texttt{@}.}
%
%    \begin{macrocode}
\newcommand*{\LWR@parseatcolumn}{%
%    \end{macrocode}
% Move to the next token after the '@':
%    \begin{macrocode}
\LWR@traceinfo{at column}%
\addtocounter{LWR@tablecolspecindex}{1}%
%    \end{macrocode}
% Read the next token into \cs{LWR@colparameter}, expanding once:
%    \begin{macrocode}
\LWR@traceinfo{about to read the next token:}%
\expandarg%
\StrChar{\LWR@origcolspec}{\arabic{LWR@tablecolspecindex}}[\LWR@colparameter]
\fullexpandarg%
%    \end{macrocode}
% Store the result into a data array, expanding once out of \cs{LWR@colparameter}:
%    \begin{macrocode}
\LWR@traceinfo{have now read the next token}%
\ifnumcomp{\value{LWR@tabletotalcols}}{=}{0}%
{% left edge of the table:
    \LWR@traceinfo{at the left edge}%
    \LWR@setexparray{LWR@colatspec}{leftedge}{\LWR@colparameter}%
    \LWR@traceinfo{at the left edge: %
    \LWR@getexparray{LWR@colatspec}{leftedge}}%
}%
{% not at the left edge:
    \LWR@traceinfo{not at the left edge}%
    \LWR@setexparray{LWR@colatspec}{\arabic{LWR@tabletotalcols}}{\LWR@colparameter}%
    \LWR@traceinfo{at \arabic{LWR@tabletotalcols}: %
    \LWR@getexparray{LWR@colatspec}{\arabic{LWR@tabletotalcols}}}%
}%
\let\LWR@colparameter\relax%
\booltrue{LWR@validtablecol}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@parsebangcolumn}
% Handles |!{text}| columns.
%
% \changes{v0.22}{2017/02/28}{Added tabular \texttt{!!} column.}
%
%    \begin{macrocode}
\newcommand*{\LWR@parsebangcolumn}{%
%    \end{macrocode}
% Move to the next token after the '!':
%    \begin{macrocode}
\LWR@traceinfo{bang column}%
\addtocounter{LWR@tablecolspecindex}{1}%
%    \end{macrocode}
% Read the next token into \cs{LWR@colparameter}, expanding once:
%    \begin{macrocode}
\LWR@traceinfo{about to read the next token:}%
\expandarg%
\StrChar{\LWR@origcolspec}{\arabic{LWR@tablecolspecindex}}[\LWR@colparameter]
\fullexpandarg%
%    \end{macrocode}
% Store the result into a data array, expanding once out of \cs{LWR@colparameter}:
%    \begin{macrocode}
\LWR@traceinfo{have now read the next token}%
\ifnumcomp{\value{LWR@tabletotalcols}}{=}{0}%
{% left edge of the table:
    \LWR@traceinfo{at the left edge}%
    \LWR@setexparray{LWR@colbangspec}{leftedge}{\LWR@colparameter}%
}%
{% not at the left edge:
    \LWR@traceinfo{not at the left edge}%
    \LWR@setexparray{LWR@colbangspec}{\arabic{LWR@tabletotalcols}}{\LWR@colparameter}%
    \LWR@traceinfo{bang \arabic{LWR@tabletotalcols}: \LWR@colparameter!}%
}%
\let\LWR@colparameter\relax%
\booltrue{LWR@validtablecol}%
}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\LWR@parsebeforecolumn}
%
% Handles |>{text}| columns.
%
%    \begin{macrocode}
\newcommand*{\LWR@parsebeforecolumn}{%
%    \end{macrocode}
% Move to the next token after the '>':
%    \begin{macrocode}
\addtocounter{LWR@tablecolspecindex}{1}%
%    \end{macrocode}
% Read the next token, expanding once into \cs{LWR@colparameter}:
%    \begin{macrocode}
\expandarg%
\StrChar{\LWR@origcolspec}{\arabic{LWR@tablecolspecindex}}[\LWR@colparameter]%
\fullexpandarg%
%    \end{macrocode}
% Store the result into a data array, expanding once out of \cs{LWR@colparameter}:
%    \begin{macrocode}
\LWR@setexparray{LWR@colbeforespec}{\arabic{LWR@tabletotalcolsnext}}{\LWR@colparameter}%
\let\LWR@colparameter\relax%
\booltrue{LWR@validtablecol}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LWR@parseaftercolumn}
%
% Handles |<{text}| columns.
%
%    \begin{macrocode}
\newcommand*{\LWR@parseaftercolumn}{%
%    \end{macrocode}
% Move to the next token after the '<':
%    \begin{macrocode}
\addtocounter{LWR@tablecolspecindex}{1}%
%    \end{macrocode}
% Read the next token, expanding once into \cs{LWR@colparameter}:
%    \begin{macrocode}
\expandarg%
\StrChar{\LWR@origcolspec}{\arabic{LWR@tablecolspecindex}}[\LWR@colparameter]%
\fullexpandarg%
%    \end{macrocode}
% Store the result into a data array, expanding once out of \cs{LWR@colparameter}:
%    \begin{macrocode}
\LWR@setexparray{LWR@colafterspec}{\arabic{LWR@tabletotalcols}}{\LWR@colparameter}%
\let\LWR@colparameter\relax%
\booltrue{LWR@validtablecol}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@parsebarcolumn} \qquad Handles vertical rules.
%
% \changes{v0.41}{2017/10/07}{Added vertical rules.}
%
%    \begin{macrocode}
\newcommand*{\LWR@parsebarcolumn}{%
\LWR@traceinfo{bar column}%
%    \end{macrocode}
% Remember the bar at this position:
%    \begin{macrocode}
\ifnumcomp{\value{LWR@tabletotalcols}}{=}{0}%
{% left edge of the table:
    \LWR@setexparray{LWR@colbarspec}{leftedge}{tvertbarl}%
}%
{% not at the left edge:
    \LWR@setexparray{LWR@colbarspec}{\arabic{LWR@tabletotalcols}}{tvertbarr}%
}%
\booltrue{LWR@validtablecol}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Parsing `l', `c', or `r' columns}
%
% \begin{macro}{\LWR@parsenormalcolumn} \marg{thiscolumn}
%
% Add to the accumulated column specs, advance counters,
% and pre-clear another column of at, before, and after specs.
%    \begin{macrocode}
\newcommand*{\LWR@parsenormalcolumn}[1]{%
\appto\LWR@tablecolspec{#1}%
\addtocounter{LWR@tabletotalcols}{1}%
\addtocounter{LWR@tabletotalcolsnext}{1}%
\LWR@traceinfo{normal column \arabic{LWR@tabletotalcols}: #1}%
\LWR@setexparray{LWR@colatspec}{\arabic{LWR@tabletotalcolsnext}}{}%
\LWR@setexparray{LWR@colbangspec}{\arabic{LWR@tabletotalcolsnext}}{}%
\LWR@setexparray{LWR@colbeforespec}{\arabic{LWR@tabletotalcolsnext}}{}%
\LWR@setexparray{LWR@colafterspec}{\arabic{LWR@tabletotalcolsnext}}{}%
\LWR@setexparray{LWR@colbarspec}{\arabic{LWR@tabletotalcolsnext}}{}%
\booltrue{LWR@validtablecol}%
}
%    \end{macrocode}
% \end{macro}


% \subsection{Parsing `p', `m', or `b' columns}
%
% \begin{macro}{\LWR@parsepcolumn} \marg{thiscolumn}
% The width will be ignored.
%    \begin{macrocode}
\newcommand*{\LWR@parsepcolumn}[1]{%
%    \end{macrocode}
% Converts to the given column type:
%    \begin{macrocode}
\LWR@parsenormalcolumn{#1}%
%    \end{macrocode}
% Skips the following width token:
%    \begin{macrocode}
\addtocounter{LWR@tablecolspecindex}{1}%
}
%    \end{macrocode}
% \end{macro}


% \subsection{Parsing `D' columns}
%
% From the \pkg{dcolumn} package.
%
% \begin{macro}{\LWR@parseDcolumn} \marg{thiscolumn}
% The three parameters will be ignored.
%
% \changes{v0.22}{2017/02/24}{Added tabular \texttt{D} column.}
%
%    \begin{macrocode}
\newcommand*{\LWR@parseDcolumn}[1]{%
%    \end{macrocode}
% Converts to the given column type.
%    \begin{macrocode}
\LWR@parsenormalcolumn{#1}%
%    \end{macrocode}
% Skips the following three parameters.
%    \begin{macrocode}
\addtocounter{LWR@tablecolspecindex}{3}%
}
%    \end{macrocode}
% \end{macro}



% \subsection{Parsing the column specifications}

% \HTML\ \CSS\ cannot exactly match the \LaTeX{} concept of a baseline for
% a table row.
% \watchout
% \Cref{tab:baseline} shows the \LaTeX{} results for various
% vertical-alignment choices, with the baseline of the first column drawn across
% all the columns for comparison.
% See the |p| column specification in \cref{tab:columnconversions} for details.
%
% \begin{table}
% \caption{Tabular baseline\label{tab:baseline}}
% \index{tabular>baseline}\index{baseline>tabular}
% \centering
% \smallskip
% \begin{tabular}{lp{.25in}m{.25in}b{.25in}r}
% \toprule
% l & p & m & b & r \\
% \midrule
% l \rule{1.65in}{.4pt} \hspace{-1.4in} &
% par \newline par \newline par &
% mid \newline mid \newline mid &
% bot \newline bot \newline bot &
% r \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% \Cref{tab:columnconversions} describes how each kind of column is
% converted to \HTML.
%
% \begin{table}
% \caption{Tabular HTML column conversions\label{tab:columnconversions}}
% \index{tabular>HTML colummn conversion}
% \index{HTML>tabular column conversion}
%
% \medskip
%
% \hrule
% \begin{description}[parsep=.5ex]
% \item [l, r, c:] Converted to table cells without paragraph tags. \\
% Uses \CSS\ |vertical-align:middle| so that top or bottom-aligned cells may go above or below this cell.
% \item [p:] Converted to table cells with paragraph tags.
% Ref: \Cref{tab:baseline},
% \LaTeX{} places the top line of a parbox
% aligned with the rest of the text line, so \CSS\ |vertical-align:bottom| is used to
% have the \HTML\ result appear with the paragraph extending below the L, R, C cells at the middle, if possible.
% This may be confusing as a P cell may not top-align with an L,R,C cell in the \HTML\
% conversion, especially in the presence of a B cell, and two P cells side-by-side will
% be aligned at the bottom instead of the top.
% Some adjustment of the \CSS\ may be desired, changing
% |td.tdp|, |td.tdP|, |td.tdprule|, and |td.tdPrule| to |vertical-align: middle|.
% Another possibility is to change L,R,C, and P to |vertical-align: top| and not worry
% about the alignment of B and M cells or trying to approximate \LaTeX{} baselines.
% \item [m:] With paragraph tags, \CSS\ |vertical-align:middle|.
% \item [b:] With paragraph tags, \CSS\ |vertical-align:top| so that the bottom of the
% text is closest to the middle of the text line.
% \item [P, M, B:] Horizontally-centered versions.
% \item [S:] Converted to 'r'.  From the \pkg{siunitx} package.
% \item [D:] Converted to 'c'.  From the \pkg{dcolumn} package.
% \item [@, !, \textgreater{}, \textless{}:] One each, in that order.
% \item [\textbar:] Vertical rule.
% \item [Unknown:] Converted to 'l'.
% \item [\cs{newcolumn}:] Currently treated as unknown.
% \end{description}
% \hrule
% \end{table}
%
%
% \DescribeBoolean{LWR@validtablecol} True if found a valid table column type.
%    \begin{macrocode}
\newbool{LWR@validtablecol}
%    \end{macrocode}
%
%
%
% \begin{macro}{\LWR@parsetablecols} \marg{colspecs}
%
% Scans the column specification left to right.
%
% Builds \cs{LWR@tablecolspec} with the final specification,
% one column per entry.  The final number of cells in each row is
% stored in |LWR@tabletotalcols|.
%
% \changes{v0.22}{2017/02/28}{Unknown table column types become \texttt{l}.
%	Added tabular \texttt{D}, \texttt{!!}, \texttt{X} columns.}
%
% \changes{v0.23}{2017/03/02}{Fix for vert bar column type.}
% \changes{v0.28}{2017/04/11}{Added L, C, R, J column types.}
%
%    \begin{macrocode}
\newcommand*{\LWR@parsetablecols}[1]{%
\LWR@traceinfo{LWR@parsetablecols started}%
%    \end{macrocode}
% Remember the original supplied column spec:
%    \begin{macrocode}
\renewcommand*{\LWR@origcolspec}{#1}%
%    \end{macrocode}
% Remove spaces:
% \changes{v0.43}{2017/11/01}{Ignore spaces in col spec.}
%    \begin{macrocode}
\expandarg%
\StrSubstitute{\LWR@origcolspec}{ }{}[\LWR@origcolspec]%
%    \end{macrocode}
% Clear the parsed resulting column spec:
%    \begin{macrocode}
\renewcommand*{\LWR@tablecolspec}{}%
%    \end{macrocode}
% Total number of columns found so far.
% Also pre-initialize the first several columns of specs:
%    \begin{macrocode}
\setcounter{LWR@tabletotalcols}{0}%
\setcounter{LWR@tabletotalcolsnext}{1}%
\LWR@setexparray{LWR@colatspec}{leftedge}{}%
\LWR@setexparray{LWR@colatspec}{1}{}%
\LWR@setexparray{LWR@colatspec}{2}{}%
\LWR@setexparray{LWR@colatspec}{3}{}%
\LWR@setexparray{LWR@colbangspec}{leftedge}{}%
\LWR@setexparray{LWR@colbangspec}{1}{}%
\LWR@setexparray{LWR@colbangspec}{2}{}%
\LWR@setexparray{LWR@colbangspec}{3}{}%
\LWR@setexparray{LWR@colbeforespec}{1}{}%
\LWR@setexparray{LWR@colbeforespec}{2}{}%
\LWR@setexparray{LWR@colbeforespec}{3}{}%
\LWR@setexparray{LWR@colafterspec}{1}{}%
\LWR@setexparray{LWR@colafterspec}{2}{}%
\LWR@setexparray{LWR@colafterspec}{3}{}%
\LWR@setexparray{LWR@colbarspec}{leftedge}{}%
\LWR@setexparray{LWR@colbarspec}{1}{}%
\LWR@setexparray{LWR@colbarspec}{2}{}%
\LWR@setexparray{LWR@colbarspec}{3}{}%
%    \end{macrocode}
% Starting at the first column specification:
%    \begin{macrocode}
\setcounter{LWR@tablecolspecindex}{1}%
%    \end{macrocode}
% Place the colspecs string length into \cs{LWR@strresult},
% and remember the number of characters in the column specification:
%    \begin{macrocode}
\LWR@traceinfo{about to StrLen}%
\expandarg%
\StrLen{\LWR@origcolspec}[\LWR@strresult]%
\fullexpandarg%
\LWR@traceinfo{finished StrLen}%
\setcounter{LWR@tablecolspecwidth}{\LWR@strresult}%
%    \end{macrocode}
% Scan through the column specifications:
%    \begin{macrocode}
\whileboolexpr{%
    not test{%
        \ifnumcomp{\value{LWR@tablecolspecindex}}{>}{\value{LWR@tablecolspecwidth}}%
    }%
}%
{%
%    \end{macrocode}
% Place the next single-character column type into \cs{LWR@strresult}:
%    \begin{macrocode}
\expandarg%
\StrChar{\LWR@origcolspec}{\arabic{LWR@tablecolspecindex}}[\LWR@strresult]%
\LWR@traceinfo{position \arabic{LWR@tablecolspecindex}: \LWR@strresult}%
\fullexpandarg%
%    \end{macrocode}
% Not yet found a valid column type
%    \begin{macrocode}
\boolfalse{LWR@validtablecol}%
%    \end{macrocode}
% Note that the parameter for a |p{spec}| column is a token list which will NOT match l,c,r,p.
% \watchout
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{l}{\LWR@parsenormalcolumn{l}}{}%
\IfStrEq{\LWR@strresult}{c}{\LWR@parsenormalcolumn{c}}{}%
\IfStrEq{\LWR@strresult}{r}{\LWR@parsenormalcolumn{r}}{}%
\IfStrEq{\LWR@strresult}{L}{\LWR@parsenormalcolumn{l}}{}%
\IfStrEq{\LWR@strresult}{C}{\LWR@parsenormalcolumn{c}}{}%
\IfStrEq{\LWR@strresult}{R}{\LWR@parsenormalcolumn{r}}{}%
\IfStrEq{\LWR@strresult}{J}{\LWR@parsenormalcolumn{l}}{}%
\IfStrEq{\LWR@strresult}{S}{\LWR@parsenormalcolumn{r}}{}%
\IfStrEq{\LWR@strresult}{\detokenize{@}}{\LWR@parseatcolumn}{}%
\IfStrEq{\LWR@strresult}{!}{\LWR@parsebangcolumn}{}%
\IfStrEq{\LWR@strresult}{>}{\LWR@parsebeforecolumn}{}%
\IfStrEq{\LWR@strresult}{<}{\LWR@parseaftercolumn}{}%
\IfStrEq{\LWR@strresult}{|}{\LWR@parsebarcolumn}{}%
\IfStrEq{\LWR@strresult}{p}{\LWR@parsepcolumn{p}}{}%
\IfStrEq{\LWR@strresult}{m}{\LWR@parsepcolumn{m}}{}%
\IfStrEq{\LWR@strresult}{b}{\LWR@parsepcolumn{b}}{}%
%    \end{macrocode}
% From the \pkg{dcolumn} package:
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{D}{\LWR@parseDcolumn{c}}{}%
%    \end{macrocode}
% From the \pkg{tabularx} package.
% X column has no parameter, but will be given paragraph tags.
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{X}{\LWR@parsenormalcolumn{X}}{}%
%    \end{macrocode}
% \begin{docsidebar}
%	\raggedright
% Many people define centered versions ``|P|'', ``|M|'', and ``|B|'': \\
% \hspace*{1em}|\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}|
% \end{docsidebar}
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{P}{\LWR@parsepcolumn{P}}{}%
\IfStrEq{\LWR@strresult}{M}{\LWR@parsepcolumn{M}}{}%
\IfStrEq{\LWR@strresult}{B}{\LWR@parsepcolumn{B}}{}%
%    \end{macrocode}
% If this column was an invalid column type, convert it to an |l| column:
%    \begin{macrocode}
\ifbool{LWR@validtablecol}{}{%
    \LWR@traceinfo{invalid column type: \LWR@strresult}%
    \LWR@parsenormalcolumn{l}%
}%
\addtocounter{LWR@tablecolspecindex}{1}%
}% whiledo
}%
%    \end{macrocode}
% \end{macro}


% \subsection{Starting a new row}

% \begin{macro}{\LWR@maybenewtablerow}
%
% If have not yet started a new table row, begin one now.
% Creates a new row tag, adding a class for |hline| or |tbrule| if
% necessary.
%    \begin{macrocode}
\newcommand*{\LWR@maybenewtablerow}
{%
\ifbool{LWR@startedrow}%
{}% started the row
{% not started the row
%    \end{macrocode}
% Remember that now have started the row:
%    \begin{macrocode}
    \global\booltrue{LWR@startedrow}%
%    \end{macrocode}
% Create the row tag, with a class if necessary.
%    \begin{macrocode}
    \global\booltrue{LWR@intabularmetadata}%
    \ifbool{LWR@doinghline}%
    {%
        \LWR@htmltag{tr class="hline" }%
        \LWR@orignewline%
    }%
    {% not doing hline
        \ifbool{LWR@doingtbrule}%
        {%
            \LWR@htmltag{tr class="tbrule"}%
            \LWR@orignewline%
        }%
        {\LWR@htmltag{tr}\LWR@orignewline}%
    }% end of not doing hline
}% end of not started the row
}
%    \end{macrocode}
% \end{macro}


% \subsection{Printing vertical bar tags}

% \begin{macro}{\LWR@printbartag} \marg{index}
%
% Adds to a tabular data cell an \HTML\ class name for a left/right vertical bar.
%
% \changes{v0.41}{2017/10/07}{Added vertical rules.}
%
%    \begin{macrocode}
\newcommand*{\LWR@printbartag}[1]{%
\ifboolexpr{bool{LWR@tabularmutemods} or bool{LWR@emptyatbang}}%
{}% muting or empty
{% not muting
    \edef\LWR@tempone{\LWR@getexparray{LWR@colbarspec}{#1}}%
    \ifdefempty{\LWR@tempone}{}{ \LWR@tempone}%
}% not muting
}
%    \end{macrocode}
% \end{macro}


% \subsection{Printing at or bang tags}

% \begin{macro}{\LWR@printatbang} \marg{at -or- bang} \marg{index}
%
% \changes{v0.41}{2017/09/28}{Add: \cs{cmidrule} trims.}
% \changes{v0.41}{2017/10/02}{Add: Mute at and bang columns for \cs{bottomrule}.}
%    \begin{macrocode}
\newcommand*{\LWR@printatbang}[2]{%
%    \end{macrocode}
% Fetch the column at or bang spec:
%    \begin{macrocode}
\edef\LWR@atbangspec{\LWR@getexparray{LWR@col#1spec}{#2}}%
\LWR@traceinfo{atbang: #2 !\LWR@atbangspec!}%
%    \end{macrocode}
% Only generate if is not empty;
%    \begin{macrocode}
\ifdefempty{\LWR@atbangspec}%
{}%
{% not empty
    \LWR@htmltag{%
        td class="td#1%
        \LWR@subaddcmidruletrim{}{}%
        \LWR@printbartag{#2}%
        "%
        \LWR@tdstartstyles%
        \LWR@addcmidrulewidth%
        \LWR@tdendstyles%
    }%
%    \end{macrocode}
% Create an empty cell if muting for the \cs{bottomrule}:
%    \begin{macrocode}
    \ifboolexpr{bool{LWR@tabularmutemods} or bool{LWR@emptyatbang}}%
    {}%
    {\LWR@atbangspec}%
%
    \LWR@htmltag{/td}\LWR@orignewline%
    \global\booltrue{LWR@tabularcelladded}%
}% not empty
}%
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@addleftmostbartag}
%    \begin{macrocode}
\newcommand*{\LWR@addleftmostbartag}{%
\ifnumcomp{\value{LWR@tablecolindex}}{=}{1}{%
    \LWR@printbartag{leftedge}%
}{}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@tabularleftedge}
%    \begin{macrocode}
\newcommand*{\LWR@tabularleftedge}{%
\ifnumcomp{\value{LWR@tablecolindex}}{=}{1}%
{%
    \LWR@printatbang{at}{leftedge}%
    \LWR@printatbang{bang}{leftedge}%
}% left edge
{}% not left edge
}
%    \end{macrocode}
% \end{macro}



% \subsection{Data opening tag}


% \begin{macro}{\LWR@thiscolspec} Temporary storage.
%    \begin{macrocode}
\newcommand*{\LWR@thiscolspec}{}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@tabledatasinglecolumntag}
% Print a table data opening tag with style for alignment
%
% \changes{v0.33}{2017/06/22}{Fix: Macros in tabular could cause extra data cell.}
% \changes{v0.41}{2017/09/28}{Add: \cs{cmidrule} trims.}
% \changes{v0.41}{2017/10/02}{Add: Mute \protect\texttt{\protect\textless} for \cs{bottomrule}.}
%
%    \begin{macrocode}
\newcommand*{\LWR@tabledatasinglecolumntag}%
{%
\LWR@maybenewtablerow%
%    \end{macrocode}
% Don't start a new paragraph tag if have already started one:
%    \begin{macrocode}
\ifbool{LWR@intabularmetadata}%
{%
%    \end{macrocode}
% If have found the end of tabular command, do not create the next data cell:
%    \begin{macrocode}
    \ifbool{LWR@exitingtabular}{}%
    {% not exiting tabular
%    \end{macrocode}
% Print the |@| and |!| contents before first column:
%    \begin{macrocode}
        \LWR@tabularleftedge%
%    \end{macrocode}
% Fetch the current column's alignment character into |\LWR@strresult|:
%    \begin{macrocode}
        \StrChar{\LWR@tablecolspec}{\arabic{LWR@tablecolindex}}[\LWR@strresult]%
%    \end{macrocode}
% print the start of a new table data cell:
%    \begin{macrocode}
        \LWR@htmltag{td class="td%
%    \end{macrocode}
% append this column's spec:
%    \begin{macrocode}
        \LWR@strresult%
%    \end{macrocode}
% If this column has a cmidrule, add ``rule'' to the end of the \HTML\ class tag.
% Also add vertical bar tags.
%    \begin{macrocode}
        \LWR@addcmidruletrim%
        \LWR@addleftmostbartag%
        \LWR@printbartag{\arabic{LWR@tablecolindex}}%
        "%
%    \end{macrocode}
% \changes{v0.42}{2017/10/26}{If \protect\texttt{FormatWP} add cell alignment.}
%    \begin{macrocode}
        \LWR@tdstartstyles%
        \LWR@addcmidrulewidth%
        \StrChar{\LWR@tablecolspec}{\arabic{LWR@tablecolindex}}[\LWR@thiscolspec]%
        \LWR@addformatwpalignment{\LWR@thiscolspec}%
        \LWR@tdendstyles%
        }%
%    \end{macrocode}
% If this is a p, m, b, or X column, allow paragraphs:
%    \begin{macrocode}
        \ifboolexpr{%
            test{ \ifdefstring{\LWR@strresult}{p} } or
            test{ \ifdefstring{\LWR@strresult}{m} } or 
            test{ \ifdefstring{\LWR@strresult}{b} } or
            test{ \ifdefstring{\LWR@strresult}{P} } or
            test{ \ifdefstring{\LWR@strresult}{M} } or
            test{ \ifdefstring{\LWR@strresult}{B} } or
            test{ \ifdefstring{\LWR@strresult}{X} }
        }%
        {% allow pars
            \LWR@startpars%
            \global\booltrue{LWR@tableparcell}%
        }% allow pars
        {}% no pars
%    \end{macrocode}
% Print the |>| contents unless muted for the \cs{bottomrule}:
%    \begin{macrocode}
        \ifboolexpr{bool{LWR@tabularmutemods} or bool{LWR@emptyatbang}}%
        {}%
        {%
            \LWR@getexparray{LWR@colbeforespec}{\arabic{LWR@tablecolindex}}%
        }%
        \global\boolfalse{LWR@intabularmetadata}%
    }% not exiting tabular
}{}% in tabular metadata
}%
%    \end{macrocode}
% \end{macro}


% \subsection{Midrules}
%
% \DescribeObject{LWR@midrules}|LWR@midrules| is a data array
% (\cref{sec:dataarray}) of columns each containing a non-zero width
%  if a midrule should be created for this column.

% \DescribeObject{LWR@trimlrules}|LWR@trimlrules| is a data array
% (\cref{sec:dataarray}) of columns containing
% |l| if a midrule should be left trimmed for each column.

% \DescribeObject{LWR@trimrrules}|LWR@trimrrules| is a data array
% (\cref{sec:dataarray}) of columns containing
% |r| if a midrule should be right trimmed for each column.


% \DescribeCounter{LWR@midrulecounter}
% Indexes across the |LWR@midrules| and |LWR@trim<l/r>rules| data arrays.
%    \begin{macrocode}
\newcounter{LWR@midrulecounter}
%    \end{macrocode}



% \DescribeLength{\LWR@heavyrulewidth}
% The default width of the rule.
%    \begin{macrocode}
\newlength{\LWR@heavyrulewidth}
\setlength{\LWR@heavyrulewidth}{.08em}
%    \end{macrocode}


% \DescribeLength{\LWR@lightrulewidth}
% The default width of the rule.
%    \begin{macrocode}
\newlength{\LWR@lightrulewidth}
\setlength{\LWR@lightrulewidth}{.05em}
%    \end{macrocode}


% \DescribeLength{\LWR@cmidrulewidth}
% The default width of the rule.
%    \begin{macrocode}
\newlength{\LWR@cmidrulewidth}
\setlength{\LWR@cmidrulewidth}{.03em}
%    \end{macrocode}


% \DescribeLength{\LWR@thiscmidrulewidth}
% The width of the next rule, defaulting to \cs{LWR@cmidrulewidth}.
%
% If not \cs{LWR@cmidrulewidth}, a style will be used to generate
% the custom width.
%
% Assigned from the |LWR@midrules| array.
%    \begin{macrocode}
\newlength{\LWR@thiscmidrulewidth}
\setlength{\LWR@thiscmidrulewidth}{\LWR@cmidrulewidth}
%    \end{macrocode}


% \begin{macro}{\LWR@clearmidrules}
% Start new midrules.  Called at beginning of tabular and also at |\\|.
%
% Clears all |LWR@midrules| and |LWR@trimruels| markers for this line.
%
% \changes{v0.41}{2017/09/28}{Add: \cs{cmidrule} trims.}
%    \begin{macrocode}
\newcommand*{\LWR@clearmidrules}
{%
\setcounter{LWR@midrulecounter}{1}%
\whileboolexpr{%
    not test{%
        \ifnumcomp{\value{LWR@midrulecounter}}{>}{\value{LWR@tablecolspecwidth}}%
    }%
}%
{%
\LWR@setexparray{LWR@midrules}{\arabic{LWR@midrulecounter}}{0pt}%
\setlength{\LWR@thiscmidrulewidth}{\LWR@cmidrulewidth}%
\LWR@setexparray{LWR@trimlrules}{\arabic{LWR@midrulecounter}}{}%
\LWR@setexparray{LWR@trimrrules}{\arabic{LWR@midrulecounter}}{}%
\addtocounter{LWR@midrulecounter}{1}%
}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@subcmidrule} \marg{width} \marg{trim} \marg{leftcolumn} \marg{rightcolumn}
%
% Marks |LWR@midrules| data array elements to be
% non-zero widths from left to right columns.
% Also marks trimming for the L and/or R columns.
%
% |LWR@doingcmidrule| is set to force an empty row at the end of the tabular
% to create the rule.
%
% \changes{v0.41}{2017/09/28}{Add: \cs{cmidrule} trims.}
%
%    \begin{macrocode}
\newcommand*{\LWR@subcmidrule}[4]{%
\setcounter{LWR@midrulecounter}{#3}%
\whileboolexpr{%
    not test {%
        \ifnumcomp{\value{LWR@midrulecounter}}{>}{#4}%
    }%
}%
{%
    \LWR@setexparray{LWR@midrules}{\arabic{LWR@midrulecounter}}{#1}%
    \addtocounter{LWR@midrulecounter}{1}%
}% whiledo
\IfSubStr{#2}{l}{\LWR@setexparray{LWR@trimlrules}{#3}{l}}{}%
\IfSubStr{#2}{r}{\LWR@setexparray{LWR@trimrrules}{#4}{r}}{}%
\booltrue{LWR@doingcmidrule}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@docmidrule} \oarg{width} \marg{trim} \marg{leftcolumn-rightcolumn}
%
% Marks |LWR@midrules| array elements to be ``Y'' from left to right columns.
% Also marks trimming for the L and/or R columns.
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@docmidrule}{O{\LWR@cmidrulewidth} D(){} >{\SplitArgument{1}{-}}m}%
{\LWR@subcmidrule{#1}{#2}#3}
%    \end{macrocode}
% \end{macro}



% Used to compute margins, tabular trims:
%    \begin{macrocode}
\newlength{\LWR@templengthone}%
\newlength{\LWR@templengthtwo}%
%    \end{macrocode}


% Used to add a style to a table data cell:
%    \begin{macrocode}
\newboolean{LWR@tdhavecellstyle}
%    \end{macrocode}

% \begin{macro}{\LWR@tdstartstyles}
% Begins possibly adding a table data cell style.
%    \begin{macrocode}
\newcommand*{\LWR@tdstartstyles}{\global\boolfalse{LWR@tdhavecellstyle}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@tdaddstyle}
% Starts adding a table data cell style.
%    \begin{macrocode}
\newcommand*{\LWR@tdaddstyle}{%
\ifbool{LWR@tdhavecellstyle}%
{; }%
{ style="}%
\booltrue{LWR@tdhavecellstyle}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@tdendstyles}
% Finishes possibly adding a table data cell style.
% Prints the closing quote.
%    \begin{macrocode}
\newcommand*{\LWR@tdendstyles}{%
\ifbool{LWR@tdhavecellstyle}{%
    "%
    \global\boolfalse{LWR@tdhavecellstyle}%
}{}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@subaddcmidruletrim} \marg{lefttrim} \marg{righttrim}
% Adds a \cs{cmidrule} with optional trim.
%
% \changes{v0.41}{2017/10/05}{Added.}
% \changes{v0.42}{2017/10/19}{0pt if no rule given.}
%
%    \begin{macrocode}
\newcommand*{\LWR@subaddcmidruletrim}[2]{%
\setlength{\LWR@templengthone}{\LWR@getexparray{LWR@midrules}{\arabic{LWR@tablecolindex}}}%
\ifdimcomp{\LWR@templengthone}{>}{0pt}%
{%
%    \end{macrocode}
% Print the class without left and right trim letters appended:
%    \begin{macrocode}
    \LWR@origtilde tdrule#1#2%
%    \end{macrocode}
%   Remember the width of the rule:
%    \begin{macrocode}
    \setlength{\LWR@thiscmidrulewidth}{\LWR@templengthone}%
}%
{%
    \setlength{\LWR@thiscmidrulewidth}{0pt}%
}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@addcmidruletrim}
% Adds left or right trim to a \cs{cmidrule}.
%
% \changes{v0.41}{2017/09/28}{Add: \cs{cmidrule} trims.}
%
%    \begin{macrocode}
\newcommand*{\LWR@addcmidruletrim}{%
\LWR@subaddcmidruletrim%
{\LWR@getexparray{LWR@trimlrules}{\arabic{LWR@tablecolindex}}}%
{\LWR@getexparray{LWR@trimrrules}{\arabic{LWR@tablecolindex}}}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@addrulewidth} \marg{thiswidth} \marg{defaultwidth}
%
% If not default width, add a custom style with width and color
% depending on |thiswidth|.
%
% Must be placed between \cs{LWR@tdstartstyles} and \cs{LWR@tdendstyles}.
%
% \changes{v0.42}{2017/10/10}{If \protect\texttt{FormatWP} force explicit border.}
%
%    \begin{macrocode}
\newcommand{\LWR@addrulewidth}[2]{%
%    \end{macrocode}
% Only add a custom width if |thiswidth| is different than the |defaultwidth|:
%    \begin{macrocode}
\ifboolexpr{%
    test{\ifdimcomp{#1}{=}{0pt}}%
    or ( test{\ifdimcomp{#1}{=}{#2}} and not bool{FormatWP} )%
}%
{}% default width
{% custom width
%    \end{macrocode}
% Ensure that the width is wide enough to display in the browser:
%    \begin{macrocode}
    \LWR@forceminwidth{#1}%
%    \end{macrocode}
% Begin adding a style:
%    \begin{macrocode}
    \LWR@tdaddstyle%
%    \end{macrocode}
% The style itself:
%    \begin{macrocode}
    \uselengthunit{PT}%
    border-top:\rndprintlength{\LWR@atleastonept} solid %
%    \end{macrocode}
% The darkness of the color depends on the thickness of the rule:
%    \begin{macrocode}
    \ifdimcomp{#1}{<}{\LWR@lightrulewidth}%
    {\#A0A0A0}%
    {% lightrule or heaver
        \ifdimcomp{#1}{<}{\LWR@heavyrulewidth}%
        {\#808080}%
        {black}%
    }% lightrule or heavier
}% custom width
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@addcmidrulewidth}
% Adds a \attribute{style} for the rule width.
%
% Must be placed between \cs{LWR@tdstartstyles} and \cs{LWR@tdendstyles}.
%    \begin{macrocode}
\newcommand{\LWR@addcmidrulewidth}{%
\LWR@addrulewidth{\LWR@thiscmidrulewidth}{\LWR@cmidrulewidth}%
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\LWR@WPcell} \marg{text-align} \marg{vertical-align}
%    \begin{macrocode}
\newcommand*{\LWR@WPcell}[2]{%
\LWR@tdaddstyle%
text-align:#1; vertical-align:#2%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@addformatwpalignment}
% If |FormatWP|, adds a \attribute{style} for the alignment.
%
% Must be placed between \cs{LWR@tdstartstyles} and \cs{LWR@tdendstyles}.
%
% \changes{v0.42}{2017/10/26}{If \protect\texttt{FormatWP} add explicit style
%   for cell alignment.}
% \changes{v0.44}{2017/11/08}{Fix for multicolumn alignment if \protect\texttt{FormatWP}.}
%    \begin{macrocode}
\newcommand*{\LWR@addformatwpalignment}[1]{%
\ifbool{FormatWP}{%
\IfSubStr{#1}{l}{\LWR@WPcell{left}{middle}}{}%
\IfSubStr{#1}{c}{\LWR@WPcell{center}{middle}}{}%
\IfSubStr{#1}{r}{\LWR@WPcell{right}{middle}}{}%
\IfSubStr{#1}{p}{\LWR@WPcell{left}{bottom}}{}%
\IfSubStr{#1}{m}{\LWR@WPcell{left}{middle}}{}%
\IfSubStr{#1}{b}{\LWR@WPcell{left}{top}}{}%
\IfSubStr{#1}{P}{\LWR@WPcell{center}{bottom}}{}%
\IfSubStr{#1}{M}{\LWR@WPcell{center}{middle}}{}%
\IfSubStr{#1}{B}{\LWR@WPcell{center}{top}}{}%
}{}%
}
%    \end{macrocode}
% \end{macro}


% \subsection{Multicolumns}

% \subsubsection{Parsing multicolumns}

%    \begin{macrocode}
\newcounter{LWR@tablemulticolswidth}
%    \end{macrocode}
%
% Indexes into the multicolumn specification:
%    \begin{macrocode}
\newcounter{LWR@tablemulticolspos}
%    \end{macrocode}

% Remembers multicolumn vertical rules if found in the column spec.
%    \begin{macrocode}
\newbool{LWR@mcolvertbarl}
\newbool{LWR@mcolvertbarr}
%    \end{macrocode}

% \begin{macro}{\LWR@printmccoltype} \marg{colspec}
% Print any valid column type found.  Does not print |@|, |!|, |>|, or |<| columns
% or their associated tokens.
%
% This is printed as part of the table data tag's |class|.
%    \begin{macrocode}
\newcommand*{\LWR@printmccoltype}[1]{%
\LWR@traceinfo{lwr@printmccoltype -#1-}%
%    \end{macrocode}
% Get one token of the column spec:
%    \begin{macrocode}
\StrChar{#1}{\arabic{LWR@tablemulticolspos}}[\LWR@strresult]%
%    \end{macrocode}
% Add to the \HTML\ tag depending on which column type is found:
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{l}{l}{}%
\IfStrEq{\LWR@strresult}{c}{c}{}%
\IfStrEq{\LWR@strresult}{r}{r}{}%
\IfStrEq{\LWR@strresult}{p}{p}{}%
\IfStrEq{\LWR@strresult}{m}{m}{}%
\IfStrEq{\LWR@strresult}{b}{b}{}%
\IfStrEq{\LWR@strresult}{P}{P}{}%
\IfStrEq{\LWR@strresult}{M}{M}{}%
\IfStrEq{\LWR@strresult}{B}{B}{}%
\IfStrEq{\LWR@strresult}{S}{r}{}%
\IfStrEq{\LWR@strresult}{X}{p}{}%
%    \end{macrocode}
% \changes{v0.43}{2017/11/07}{Added vertical rules.}
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{|}{%
    \ifnumcomp{\value{LWR@tablemulticolspos}}{=}{1}%
        {\booltrue{LWR@mcolvertbarl}}%
        {\booltrue{LWR@mcolvertbarr}}%
}{}%
\LWR@traceinfo{lwr@printmccoltype done}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@multicolpartext}
% Print the data with paragraph tags:
%    \begin{macrocode}
\newcommand*{\LWR@multicolpartext}{%
\LWR@startpars%
\LWR@multicoltext%
\LWR@stoppars%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@multicolother} \marg{colspec}
% For |@|, |!|, |>|, |<|, print the next token without paragraph tags:
%    \begin{macrocode}
\newcommand*{\LWR@multicolother}[1]{%
\addtocounter{LWR@tablemulticolspos}{1}%
\StrChar{#1}{\arabic{LWR@tablemulticolspos}}[\LWR@strresult]%
\LWR@strresult%
%    \end{macrocode}
% A valid column data type was found:
%    \begin{macrocode}
\booltrue{LWR@validtablecol}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@multicolskip}
% Nothing to print for this column type.
%    \begin{macrocode}
\newcommand*{\LWR@multicolskip}{%
%    \end{macrocode}
% A valid column data type was found:
%    \begin{macrocode}
\booltrue{LWR@validtablecol}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@printmccoldata} \marg{colspec}
% Print the data for any valid column type found.
%
% \changes{v0.22}{2017/02/28}{Added tabular \texttt{D}, \texttt{!!},
%	and \texttt{X} columns.}
%
% \changes{v0.23}{2017/03/02}{Fix for vert bar column type.}
%
%    \begin{macrocode}
\newcommand*{\LWR@printmccoldata}[1]{%
\LWR@traceinfo{lwr@printmccoldata -#1}%
%    \end{macrocode}
% Not yet found a valid column type:
%    \begin{macrocode}
\boolfalse{LWR@validtablecol}%
%    \end{macrocode}
% Get one token of the column spec:
%    \begin{macrocode}
\StrChar{#1}{\arabic{LWR@tablemulticolspos}}[\LWR@strresult]%
%    \end{macrocode}
% Print the text depending on which column type is found.
% Also handles |@|, |>|, |<| as it comes to them.
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{l}{\LWR@multicoltext}{}%
\IfStrEq{\LWR@strresult}{c}{\LWR@multicoltext}{}%
\IfStrEq{\LWR@strresult}{r}{\LWR@multicoltext}{}%
\IfStrEq{\LWR@strresult}{D}{%
\addtocounter{LWR@tablemulticolspos}{3}% skip parameters
\LWR@multicoltext%
}{}%
\IfStrEq{\LWR@strresult}{p}{\LWR@multicolpartext}{}%
\IfStrEq{\LWR@strresult}{m}{\LWR@multicolpartext}{}%
\IfStrEq{\LWR@strresult}{b}{\LWR@multicolpartext}{}%
\IfStrEq{\LWR@strresult}{P}{\LWR@multicolpartext}{}%
\IfStrEq{\LWR@strresult}{M}{\LWR@multicolpartext}{}%
\IfStrEq{\LWR@strresult}{B}{\LWR@multicolpartext}{}%
\IfStrEq{\LWR@strresult}{S}{\LWR@multicolpartext}{}%
\IfStrEq{\LWR@strresult}{X}{\LWR@multicolpartext}{}%
\IfStrEq{\LWR@strresult}{|}{\LWR@multicolskip}{}%
\IfStrEq{\LWR@strresult}{\detokenize{@}}{\LWR@multicolother{#1}}{}%
\IfStrEq{\LWR@strresult}{\detokenize{!}}{\LWR@multicolother{#1}}{}%
\IfStrEq{\LWR@strresult}{\detokenize{>}}{\LWR@multicolother{#1}}{}%
\IfStrEq{\LWR@strresult}{\detokenize{<}}{\LWR@multicolother{#1}}{}%
%    \end{macrocode}
% If an invalid column type:
%    \begin{macrocode}
\ifbool{LWR@validtablecol}{}{\LWR@multicoltext}%
%    \end{macrocode}
% Tracing:
%    \begin{macrocode}
\LWR@traceinfo{lwr@printmccoldata done}%
}
%    \end{macrocode}
% \end{macro}




% \begin{macro}{\parsemulticolumnalignment}
%		\marg{1: colspec} \marg{2: printresults}
%
% Scan the multicolumn specification and execute the printfunction
% for each entry.
%
% Note that the spec for a |p{spec}| column, or |@|, |>|, |<|, is a token list
% which will NOT match |l|, |c|, |r|, or |p|.
%    \begin{macrocode}
\newcommand*{\LWR@parsemulticolumnalignment}[2]{%
\setcounter{LWR@tablemulticolspos}{1}%
\StrLen{#1}[\LWR@strresult]%
\setcounter{LWR@tablemulticolswidth}{\LWR@strresult}%
%    \end{macrocode}
% Scan across the tokens in the column spec:
%    \begin{macrocode}
\whileboolexpr{%
    not test {%
        \ifnumcomp{\value{LWR@tablemulticolspos}}{>}{\value{LWR@tablemulticolswidth}}%
    }
}%
{%
%    \end{macrocode}
% Execute the assigned print function for each token in the column spec:
%    \begin{macrocode}
#2{#1}%
%    \end{macrocode}
% Move to the next token in the column spec:
%    \begin{macrocode}
\addtocounter{LWR@tablemulticolspos}{1}%
}%
}
%    \end{macrocode}
% \end{macro}



% \subsubsection{Multicolumn factored code}


%    \begin{macrocode}
\newcommand{\LWR@multicoltext}{}
%    \end{macrocode}

% To find multicolumn right trim:
%    \begin{macrocode}
\newcounter{LWR@lastmulticolumn}
%    \end{macrocode}


% \begin{macro}{\LWR@domulticolumn}
%   \oarg{1: vpos} \oarg{2: \#rows}
%   \marg{3: numLaTeXcols} \marg{4: numHTMLcols}
%   \marg{5: colspec} \marg{6: text}
%
% \changes{v0.39}{2017/08/30}{Add: Optional \protect\texttt{vpos} and \# rows.}
% \changes{v0.41}{2017/09/28}{Add: \cs{cmidrule} trims.}
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@domulticolumn}{o o m m m +m}{%
\LWR@traceinfo{LWR@domulticolumn -#1- -#2- -#4- -#5-}%
%    \end{macrocode}
% Remember the text to be inserted, and
% remember that a valid column type was found:
%    \begin{macrocode}
\renewcommand{\LWR@multicoltext}{%
#6%
\booltrue{LWR@validtablecol}%
}%
%    \end{macrocode}
% Compute the rightmost column to be included.
% This is used to create the right trim.
% \changes{v0.43}{2017/11/07}{Fix: Multicolumn trim.}
%    \begin{macrocode}
\setcounter{LWR@lastmulticolumn}{\value{LWR@tablecolindex}}%
\addtocounter{LWR@lastmulticolumn}{#3}%
\addtocounter{LWR@lastmulticolumn}{-1}%
%    \end{macrocode}
% Row processing:
%    \begin{macrocode}
\LWR@maybenewtablerow%
%    \end{macrocode}
% Begin the opening table data tag:
%    \begin{macrocode}
\LWR@htmltag{td colspan="#4" %
%    \end{macrocode}
% 
%    \begin{macrocode}
\IfValueT{#2}{ % rows?
rowspan="#2" %
%    \end{macrocode}
% 
%    \begin{macrocode}
\IfValueT{#1}{% vpos?
\ifstrequal{#1}{b}{style="vertical-align:bottom" }{}%
\ifstrequal{#1}{t}{style="vertical-align:top" }{}%
}% vpos?
}% rows?
%    \end{macrocode}
% 
%    \begin{macrocode}
 class="td%
%    \end{macrocode}
% Print the column type and vertical bars:
%    \begin{macrocode}
\boolfalse{LWR@mcolvertbarl}%
\boolfalse{LWR@mcolvertbarr}%
\LWR@parsemulticolumnalignment{#5}{\LWR@printmccoltype}%
%    \end{macrocode}
% If this column has a cmidrule, add ``rule'' to the end of the \HTML\ class tag.
%
% If this position had a ``Y'' then add ``rule'' for a horizontal rule:
% \changes{v0.43}{2017/11/07}{Fix: Multicolumn trim.}
%    \begin{macrocode}
\LWR@subaddcmidruletrim%
{\LWR@getexparray{LWR@trimlrules}{\arabic{LWR@tablecolindex}}}%
{\LWR@getexparray{LWR@trimrrules}{\arabic{LWR@lastmulticolumn}}}%
%    \end{macrocode}
% Also add vertical bar class.
% \changes{v0.41}{2017/10/07}{Added vertical rules.}
% \changes{v0.43}{2017/11/07}{Fix for vertical rules.}
%    \begin{macrocode}
\ifbool{LWR@mcolvertbarl}{ tvertbarl}{}%
\ifbool{LWR@mcolvertbarr}{ tvertbarr}{}%
%    \end{macrocode}
% Close the class tag's opening quote:
%    \begin{macrocode}
"%
%    \end{macrocode}
% \changes{v0.42}{2017/10/26}{If \protect\texttt{FormatWP} add cell alignment.}
%    \begin{macrocode}
\LWR@tdstartstyles%
\LWR@addcmidrulewidth%
\LWR@addformatwpalignment{#5}%
\LWR@tdendstyles%
}% end of the opening table data tag
\global\boolfalse{LWR@intabularmetadata}%
\LWR@parsemulticolumnalignment{#5}{\LWR@printmccoldata}%
}
%    \end{macrocode}
% \end{macro}


% \subsubsection{Multicolumn}

% \begin{macro}{\LWR@htmlmulticolumn} \marg{numcols} \marg{alignment} \marg{text}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@htmlmulticolumn}{m m +m}%
{%
%    \end{macrocode}
% Figure out how many extra \HTML\ columns to add for |@| and |!| columns:
%    \begin{macrocode}
\LWR@tabularhtmlcolumns{\arabic{LWR@tablecolindex}}{#1}
%    \end{macrocode}
% Create the multicolumn tag:
%    \begin{macrocode}
\LWR@domulticolumn{#1}{\arabic{LWR@tabhtmlcoltotal}}{#2}{#3}%
%    \end{macrocode}
% Move to the next \LaTeX\ column:
%    \begin{macrocode}
\addtocounter{LWR@tablecolindex}{#1}%
\addtocounter{LWR@tablecolindex}{-1}%
%    \end{macrocode}
% Skip any trailing |@| or |!| columns for this cell:
%    \begin{macrocode}
\booltrue{LWR@skipatbang}%
}
%    \end{macrocode}
% \end{macro}
%
%
%
%
% \subsubsection{Longtable captions}
%
% \pkg{longtable} captions use \cs{multicolumn}.

% \DescribeBoolean{LWR@starredlongtable}
% Per the \pkg{caption} pacakge, step the counter if |longtable*|.
%
%    \begin{macrocode}
\newbool{LWR@starredlongtable}
\boolfalse{LWR@starredlongtable}
%    \end{macrocode}
%
%
% Per the \pkg{caption} package.  User-redefinable float type.
%    \begin{macrocode}
\providecommand*{\LTcaptype}{table}
%    \end{macrocode}
%
%
% \begin{macro}{\LWR@longtabledatacaptiontag} * \oarg{toc entry} \marg{caption}
%
% \changes{v0.20}{2017/01/08}{Fix: Pars in captions.}
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@longtabledatacaptiontag}{s o +m}
{%
%    \end{macrocode}
% Remember the latest name for \cs{nameref}:
%    \begin{macrocode}
\IfValueTF{#2}{% optional given?
    \ifblank{#2}% optional empty?
    {\LWR@setlatestname{#3}}% empty
    {\LWR@setlatestname{#2}}% given and non-empty
}% optional given
{\LWR@setlatestname{#3}}% no optional
%    \end{macrocode}
% Create a multicolumn across all the columns:
%
% Figure out how many extra \HTML\ columns to add for |@| and |!| columns
% found between the first and the last column:
%    \begin{macrocode}
\LWR@tabularhtmlcolumns{1}{\arabic{LWR@tabletotalcols}}
%    \end{macrocode}
% Create the multicolumn tag:
%    \begin{macrocode}
\LWR@domulticolumn{\arabic{LWR@tabletotalcols}}{\arabic{LWR@tabhtmlcoltotal}}{P}%
{% \LWR@domulticolumn
\IfBooleanTF{#1}% star?
%    \end{macrocode}
% Star version, show a caption but do not make a LOT entry:
%    \begin{macrocode}
{% yes star
    \LWR@figcaption%
    #3%
    \endLWR@figcaption%
}%
{% No star:
%    \end{macrocode}
% Not the star version:
%
% Don't step the counter if |\caption[]{A caption.}|
%    \begin{macrocode}
    \ifbool{LWR@starredlongtable}%
    {%
        \ifblank{#2}% TOC entry
        {}%
        {%
            \refstepcounter{\LTcaptype}%
            \protected@edef\@currentlabel{%
            \csuse{p@\LTcaptype}\csuse{the\LTcaptype}}%
        }%
    }{}%
%    \end{macrocode}
% Create an \HTML\ caption.  Afterwards, maybe make a LOT entry.
%    \begin{macrocode}
    \LWR@figcaption%
    \csuse{fnum@\LTcaptype}\CaptionSeparator#3%
    \endLWR@figcaption%
%    \end{macrocode}
% See if an optional caption was given:
%    \begin{macrocode}
    \ifblank{#2}% TOC entry empty
%    \end{macrocode}
% if the optional caption was given, but empty, do not form a TOC entry
%    \begin{macrocode}
    {}%
%    \end{macrocode}
% If the optional caption was given, but might only be |[]|:
%    \begin{macrocode}
    {% TOC entry not empty
        \IfNoValueTF{#2}% No TOC entry?
%    \end{macrocode}
% The optional caption is |[]|:
%    \begin{macrocode}
        {% No TOC entry
            \addcontentsline%
            {\csuse{ext@\LTcaptype}}%
            {\LTcaptype}%
            {%
            \protect\numberline%
            {\csuse{p@\LTcaptype}\csuse{the\LTcaptype}}%
            {\ignorespaces #3\protect\relax}%
            }%
        }% end of No TOC entry
%    \end{macrocode}
% The optional caption has text enclosed:
%    \begin{macrocode}
        {% yes TOC entry
            \addcontentsline%
            {\csuse{ext@\LTcaptype}}%
            {\LTcaptype}%
            {%
            \protect\numberline%
            {\csuse{p@\LTcaptype}\csuse{the\LTcaptype}}%
            {\ignorespaces #2\protect\relax}%
            }%
        }% end of yes TOC entry
    }% end of TOC entry not empty
}% end of no star
%    \end{macrocode}
% Skip any trailing |@| or |!| columns for this cell:
%    \begin{macrocode}
\booltrue{LWR@skipatbang}%
}% end of \LWR@domulticolumn

\addtocounter{LWR@tablecolindex}{\arabic{LWR@tabletotalcols}}
\addtocounter{LWR@tablecolindex}{-1}

}
%    \end{macrocode}
% \end{macro}



% \subsubsection{Counting HTML tabular columns}

% The \LaTeX\ specification for a table includes a number of columns separated
% by the |&| character.  These columns differ in content from line to line.
% Additional virtual columns may be specified by the special |@| and |!| columns.
% These columns are identical from line to line, but may be skipped during a
% multicolumn cell.
%
% For \HTML\ output, |@| and |!| columns are placed into their own tabular columns.
% Thus, a \LaTeX\ \cs{multicolumn} command may span several additional |@| and |!|
% columns in \HTML\ output.  These additional columns must be added to the total
% number of columns spanned by an \HTML\ multi-column data cell.

%    \begin{macrocode}
\newcounter{LWR@tabhtmlcolindex}
\newcounter{LWR@tabhtmlcolend}
\newcounter{LWR@tabhtmlcoltotal}
%    \end{macrocode}


% \begin{macro}{\LWR@subtabularhtmlcolumns} \marg{index}
%
% Factored from \cs{LWr@tabularhtmlcolumns}, which follows.
%    \begin{macrocode}
\newcommand*{\LWR@subtabularhtmlcolumns}[1]{%
%    \end{macrocode}
% Temporarily define a macro equal to the |@| specification for this column:
%    \begin{macrocode}
    \edef\LWR@atbangspec{\LWR@getexparray{LWR@colatspec}{#1}}%
%    \end{macrocode}
% If the |@| specification is not empty, add to the count:
%    \begin{macrocode}
    \ifdefempty{\LWR@atbangspec}%
        {}%
        {\addtocounter{LWR@tabhtmlcoltotal}{1}}%
%    \end{macrocode}
% Likewise for the |!| columns:
%    \begin{macrocode}
    \edef\LWR@atbangspec{\LWR@getexparray{LWR@colbangspec}{#1}}%
    \ifdefempty{\LWR@atbangspec}%
        {}%
        {\addtocounter{LWR@tabhtmlcoltotal}{1}}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@tabularhtmlcolumns}
%   \marg{starting \LaTeX\ column} \marg{number \LaTeX\ columns}
%
% Compute the total number of \HTML\ columns being spanned, considering the
% starting \LaTeX\ table column and the number of \LaTeX\ tabular columns being
% spanned.  Any |@| and |!| columns within this span are included in the total count.
% The resulting number of \HTML\ columns is returned in the counter |LWR@tabhtmlcoltotal|.
%    \begin{macrocode}
\newcommand*{\LWR@tabularhtmlcolumns}[2]{%
%    \end{macrocode}
% Count the starting index, compute ending index,
% and begin with the count being the \LaTeX\ span, to which additional |@| and |!|
% columns may be added:
%    \begin{macrocode}
\setcounter{LWR@tabhtmlcolindex}{#1}%
\setcounter{LWR@tabhtmlcoltotal}{#2}%
\setcounter{LWR@tabhtmlcolend}{#1}%
\addtocounter{LWR@tabhtmlcolend}{#2}%
%    \end{macrocode}
% If at the left edge, add the at/bang columns for the left edge:
%    \begin{macrocode}
\ifnumcomp{\value{LWR@tabhtmlcolindex}}{=}{1}{%
    \LWR@subtabularhtmlcolumns{leftedge}%
}{}%
%    \end{macrocode}
% Walk across the \LaTeX\ columns looking for |@| and |!| columns:
%    \begin{macrocode}
\whileboolexpr{%
    test {%
        \ifnumcomp{\value{LWR@tabhtmlcolindex}}{<}{\value{LWR@tabhtmlcolend}}%
    }%
}%
{%
    \LWR@subtabularhtmlcolumns{\arabic{LWR@tabhtmlcolindex}}%
    \addtocounter{LWR@tabhtmlcolindex}{1}%
}% whiledo
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
%
%
%
% \subsection{Multicolumnrow}
%
% \label{sec:printmultirow}
%
% A print-mode version is defined here, and is also used during \HTML\ output
% while inside a \env{lateximage}.
%
% See \cref{sec:multirow} for the \HTML\ versions.
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}
%
% \begin{macro}{\multicolumnrow}
%   \marg{1:cols} \marg{2:halign}
%   \oarg{3:vpos} \marg{4:numrows} \oarg{5:bigstruts}
%       \marg{6:width} \oarg{7:fixup} \marg{8:text}
%
% For discussion of the use of \cs{DeclareExpandableDocumentCommand}, see: \\
%   \href
%    {https://tex.stackexchange.com/questions/168434/problem-with-abbreviation-of-multirow-and-multicolumn-latex}
%    {https://tex.stackexchange.com/questions/168434/\\%
%       problem-with-abbreviation-of-multirow-and-multicolumn-latex}
%
% \changes{v0.39}{2017/08/31}{Added.}
% \changes{v0.40}{2017/09/22}{Fix: Adapts to older \pkg{multirow} and \pkg{xparse}.}
%
% After the user may have 
%    \begin{macrocode}
\AtBeginDocument{
%    \end{macrocode}
%
% |\@ifundefined{@xmultirow}| determines if \pkg{multirow} was never loaded.
%
%    \begin{macrocode}
\@ifundefined{@xmultirow}
{}% no version of multirow was loaded
{% \@xmultirow defined, so some version of multirow was loaded
%    \end{macrocode}
%
% |\@ifpackageloaded{multirow}| determines if v2.0 or later of
% \pkg{multirow} was used, which included the \cs{ProvidesPackage} macro.
%
%    \begin{macrocode}
\@ifpackageloaded{multirow}{% v2.0 or newer
\@ifpackagelater{multirow}{2016/09/01}% 2016/09/27 for v2.0
{% v2.0+:
\DeclareExpandableDocumentCommand{\LWR@origmulticolumnrow}%
    {+m +m +O{c} +m +O{0} +m +O{0pt} +m}%
{\multicolumn{#1}{#2}{\@xmultirow[#3]{#4}[#5]{#6}[#7]{#8}}}%
}
{% loaded but older, probably not executed:
\DeclareExpandableDocumentCommand{\LWR@origmulticolumnrow}%
    {+m +m +O{c} +m +O{0} +m +O{0pt} +m}%
{\multicolumn{#1}{#2}{\@xmultirow{#4}[#5]{#6}[#7]{#8}}}%
}
}% packageloaded{multirow}
%    \end{macrocode}
%
% If not |\@ifpackageloaded{multirow}| but \cs{@xmultirow} is defined,
% then this must be v1.6 or earlier, which did not |\ProvidesPackage{multirow}|,
% and did not have the |vposn| option.
%
%    \begin{macrocode}
{% v1.6 or older did not \ProvidePackage
\DeclareExpandableDocumentCommand{\LWR@origmulticolumnrow}%
    {+m +m +O{c} +m +O{0} +m +O{0pt} +m}%
{\multicolumn{#1}{#2}{\@xmultirow{#4}[#5]{#6}[#7]{#8}}}%
}
%    \end{macrocode}
%
% The user-level interface.  This is provided if the \HTML\ version was
% not already given.
%
%    \begin{macrocode}
\providecommand*{\multicolumnrow}{\LWR@origmulticolumnrow}
}% \@xmultirow defined, so multirow was loaded
}% AtBeginDocument
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}
%
%
%
% \subsection{Utility macros inside a table}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\LWR@donothing}{}
%    \end{macrocode}
%
% In case \pkg{bigdelim} is not loaded:
%    \begin{macrocode}
\newcommand*{\ldelim}{}
\newcommand*{\rdelim}{}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \subsection{Special-case tabular markers}

% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}
%
% \begin{macro}{\TabularMacro}
% Place this just before inserting a custom macro in a table data cell.
% Doing so tells \pkg{lwarp} not to automatcally start a new \HTML\ table data cell yet.
% See \cref{sec:limitstabular}.
%
% \changes{v0.39}{2017/08/29}{Added.}
% \changes{v0.43}{2017/11/07}{\cs{newcommand} instead of \cs{relax} to fix \pkg{supertabular} and \pkg{xtab}.}
%    \begin{macrocode}
\newcommand*{\TabularMacro}{}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}



% \begin{macro}{\ResumeTabular} Used to resume tabular entries after resuming
%   an environment.
%
% \changes{v0.39}{2017/08/29}{Added.}
%
% \limitsresumetabular
% \bigskip
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\ResumeTabular}{%
\global\boolfalse{LWR@exitingtabular}%
\global\boolfalse{LWR@tabularmutemods}%
\LWR@getmynexttoken%
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \codeprint
%    \begin{macrocode}
\begin{warpprint}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\ResumeTabular}{}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpprint}
%    \end{macrocode}



% \subsection{Checking for a new table cell}


% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \DescribeBoolean{LWR@exitingtabular}
% When \cs{end} is found, turns off the next opening data tag.
%    \begin{macrocode}
\newbool{LWR@exitingtabular}
%    \end{macrocode}


% \DescribeBoolean{LWR@tabularmutemods}
% Mutes \HTML\ output for |@|, |!|, |<| and |>|.
%
% This is used while printing the final row to generate \cs{bottomrule}s.
%    \begin{macrocode}
\newbool{LWR@tabularmutemods}
%    \end{macrocode}



% \begin{macro}{\LWR@tabledatacolumntag}
% Open a new \HTML\ table cell unless the next token is for a macro
% which does not create data, such as |\hline|, |\toprule|, etc:
%
% \changes{v0.34}{2017/08/08}{\pkg{booktabs}: Works inside \env{lateximage}.}
% \changes{v0.39}{2017/08/29}{Don't start a data cell if see \cs{TabularMacro}.}
% \changes{v0.40}{2017/09/09}{Fix for \pkg{bigdelim}: \cs{ldelim}, \cs{rdelim}.}
%
%    \begin{macrocode}
\newcommand*{\LWR@tabledatacolumntag}%
{%
\LWR@traceinfo{LWR@tabledatacolumntag}%
%    \end{macrocode}
% \hspace*{.5in} |\show\LWR@mynexttoken| to see what tokens to look for
%    \begin{macrocode}
%    \end{macrocode}
% If not any of the below, start a new table cell:
%    \begin{macrocode}
\let\mynext\LWR@tabledatasinglecolumntag%
%    \end{macrocode}
% If exiting the tabular:
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\end}%
    {\global\booltrue{LWR@exitingtabular}}{}%
%    \end{macrocode}
% \env{longtable} can have a caption in a cell
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\caption}%
    {\let\mynext\LWR@donothing}{}%
%    \end{macrocode}
% Look for other things which would not start a table cell:
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\multicolumn}%
    {\let\mynext\LWR@donothing}{}%
\ifdefequal{\LWR@mynexttoken}{\multirow}%
    {\let\mynext\LWR@donothing}{}%
\ifdefequal{\LWR@mynexttoken}{\multicolumnrow}%
    {\let\mynext\LWR@donothing}{}%
%    \end{macrocode}
% If an |\mrowcell|, this is a cell to be skipped over:
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\mrowcell}%
    {\let\mynext\LWR@donothing}{}%
%    \end{macrocode}
% If an |\mcolrowcell|, this is a cell to be skipped over:
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\mcolrowcell}%
    {\let\mynext\LWR@donothing}{}%
%
\ifdefequal{\LWR@mynexttoken}{\TabularMacro}%
    {\let\mynext\LWR@donothing}{}%
%
\ifdefequal{\LWR@mynexttoken}{\hline}%
    {\let\mynext\LWR@donothing}{}%
%
\ifdefequal{\LWR@mynexttoken}{\toprule}%
    {\let\mynext\LWR@donothing}{}%
%
\ifdefequal{\LWR@mynexttoken}{\midrule}%
    {\let\mynext\LWR@donothing}{}%
%
\ifdefequal{\LWR@mynexttoken}{\cmidrule}%
    {\let\mynext\LWR@donothing}{}%
%
\ifdefequal{\LWR@mynexttoken}{\specialrule}%
    {\let\mynext\LWR@donothing}{}%
%
\ifdefequal{\LWR@mynexttoken}{\cline}%
    {\let\mynext\LWR@donothing}{}%
%
\ifdefequal{\LWR@mynexttoken}{\bottomrule}%
    {\let\mynext\LWR@donothing}{}%
%
\ifdefequal{\LWR@mynexttoken}{\warpprintonly}%
    {\let\mynext\LWR@donothing}{}%
%
\ifdefequal{\LWR@mynexttoken}{\warpHTMLonly}%
    {\let\mynext\LWR@donothing}{}%
%
\ifdefequal{\LWR@mynexttoken}{\ldelim}%
    {\let\mynext\LWR@donothing}{}%
%
\ifdefequal{\LWR@mynexttoken}{\rdelim}%
    {\let\mynext\LWR@donothing}{}%
%    \end{macrocode}
% no action for an |\end| token
%
% Add similar to the above for any other non-data tokens
% which might appear in the table.
%
% Start the new table cell if was not any of the above:
%    \begin{macrocode}
\mynext%
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \subsection{\textbackslash{}mrowcell}

% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \begin{macro}{\mrowcell}
% The user must insert |\mrowcell| into any \cs{multirow} cells which must be skipped.
% This command has no action during print output.
% \watchout
%    \begin{macrocode}
\newcommand*{\mrowcell}{}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}
% \end{macro}


% \subsection{\textbackslash{}mcolrowcell}

% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \begin{macro}{\mcolrowcell}
% The user must insert |\mcolrowcell| into any \cs{multicolumnrow} cells
% which must be skipped.
% This command has no action during print output.
% \watchout
% \changes{v0.41}{2017/10/05}{Added for \cs{multicolumrow} cells.}
%    \begin{macrocode}
\newcommand*{\mcolrowcell}{}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}
% \end{macro}





% \subsection{New \textbackslash{}tabular definition}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
% These are default defininitions in case \pkg{booktabs} is not loaded,
% and are not expected to used, but must exist as placeholders.
%
% \changes{v0.34}{2017/08/08}{\pkg{booktabs}: Works inside \env{lateximage}.}
%    \begin{macrocode}
\newcommand*{\LWR@origtoprule}[1]{\hline}
\newcommand*{\LWR@origmidrule}[1]{\hline}
\LetLtxMacro\LWR@origcmidrule\cline
\newcommand*{\LWR@origbottomrule}[1]{\hline}
\newcommand*{\LWR@origaddlinespace}[1][]{}
\newcommand*{\LWR@origmorecmidrules}{}
\newcommand*{\LWR@origspecialrule}[3]{\hline}
%    \end{macrocode}
%
%
% \begin{macro}{\LWR@hline}
% The definition of \cs{hline} depends on whether \pkg{tabls} has been loaded.
% If so, optional space below the line may be specified, but will be ignored.
%
% \changes{v0.40}{2017/09/06}{Added.}
% \changes{v0.42}{2017/10/19}{If \protect\texttt{FormatWP} force explicit border.}
%
%    \begin{macrocode}
\AtBeginDocument{
\@ifpackageloaded{lwarp-tabls}
{
\newcommand*{\LWR@hline}[1][]{%
    \ifbool{FormatWP}%
    {\LWR@docmidrule{1-\arabic{LWR@tabletotalcols}}}%
    {\booltrue{LWR@doinghline}}%
    \LWR@getmynexttoken}%
}
{
\newcommand*{\LWR@hline}{%
    \ifbool{FormatWP}%
    {\LWR@docmidrule{1-\arabic{LWR@tabletotalcols}}}%
    {\booltrue{LWR@doinghline}}%
    \LWR@getmynexttoken}%
}
}% AtBeginDocument
%    \end{macrocode}
% \end{macro}
%
%

% \begin{macro}{\LWR@nullifyNoAutoSpacing}
% For \pkg{babel-french}, turn off auto spacing at the start of the tabular,
% then nullify the autospacing commands inside the tabular,
% since they were not compatible with the tabular column parsing code,
% which uses \pkg{xstring}.
% \changes{v0.41}{2017/10/06}{Fix: \cs{NoAutoSpacing} in a tabular
%   with \protect\pkg{babel-french}.}
%    \begin{macrocode}
\AtBeginDocument{
\@ifundefined{frenchbsetup}%
{% no babel-french
    \newcommand*{\LWR@nullifyNoAutoSpacing}{}
}% no babel-french
{% yes babel-french
    \newcommand*{\LWR@nullifyNoAutoSpacing}{%
        \NoAutoSpacing%
        \renewcommand*{\NoAutoSpacing}{}%
        \renewcommand*{\LWR@FBcancel}{}%
    }
}% yes babel-french
}% AtBeginDocument
%    \end{macrocode}
% \end{macro}

%
% \begin{environment}{LWR@tabular} \oarg{vertposition} \marg{colspecs}
%
% The new tabular environment will be |\let| in |\LWR@LwarpStart|,
% since \pkg{siunitx} might redefine tabular in the user's document.
%
% \changes{v0.34}{2017/08/08}{\pkg{booktabs}: Works inside \env{lateximage}.}
% \changes{v0.36}{2017/08/16}{Fix for \protect\pkg{babel-french}.}
%
%    \begin{macrocode}
\StartDefiningTabulars

\newenvironment*{LWR@tabular}[2][]
{%
\LWR@traceinfo{LWR@tabular started}%
\addtocounter{LWR@tabulardepth}{1}%
%    \end{macrocode}
% Not yet started a table row:
%    \begin{macrocode}
\global\boolfalse{LWR@startedrow}%
%    \end{macrocode}
% Not yet doing any rules:
%    \begin{macrocode}
\global\boolfalse{LWR@doinghline}%
\global\boolfalse{LWR@doingtbrule}%
\global\boolfalse{LWR@doingcmidrule}%
%    \end{macrocode}
%
% For \pkg{babel-french}, turn off auto spacing one time, then nullify
% the autospacing commands since were not compatible with the tabular parsing code.
%
% \changes{v0.41}{2017/10/06}{Fix: \cs{NoAutoSpacing} in a tabular
%   with \protect\pkg{babel-french}.}
%
%    \begin{macrocode}
\LWR@nullifyNoAutoSpacing%
%    \end{macrocode}
% Have not yet found the end of tabular command.
% Unmute the |@| and |!| columns.
%    \begin{macrocode}
\global\boolfalse{LWR@exitingtabular}%
\global\boolfalse{LWR@tabularmutemods}%
%    \end{macrocode}
% Create the |table| tag:
%    \begin{macrocode}
\global\booltrue{LWR@intabularmetadata}%
\LWR@forcenewpage
\LWR@htmlblocktag{table}%
%    \end{macrocode}
% Parse the table columns:
%    \begin{macrocode}
\LWR@parsetablecols{#2}%
%    \end{macrocode}
% Table col spec is: \cs{LWR@tablecolspec} which is a string of |llccrr|, etc.
%
% Do not place the table inside a paragraph:
%    \begin{macrocode}
\LWR@stoppars%
%    \end{macrocode}
% Track column \#:
%    \begin{macrocode}
\setcounter{LWR@tablecolindex}{1}%
%    \end{macrocode}
% Have not yet added data in this column:
%    \begin{macrocode}
\boolfalse{LWR@tabularcelladded}%
%    \end{macrocode}
% Start looking for midrules:
%    \begin{macrocode}
\LWR@clearmidrules%
%    \end{macrocode}
% |\\| becomes a macro to end the table row:
%    \begin{macrocode}
\LetLtxMacro{\\}{\LWR@tabularendofline}%
%    \end{macrocode}
% The following may appear before a data cell is created,
% so after doing their actions, we look ahead with |\LWR@getmynextoken|
% to see if the next token might create a new data cell:
%
% The optional parameter for \cs{hline} supports the \pkg{tabls} package.
%    \begin{macrocode}
\LWR@traceinfo{LWR@tabular: redefining macros}%
\renewcommand*{\hline}{\LWR@hline}%
%
\RenewDocumentCommand{\cline}{m}%
{\LWR@docmidrule{##1}\LWR@getmynexttoken}%
%    \end{macrocode}
% \changes{v0.41}{2017/10/03}{Improved rules.}
% \changes{v0.42}{2017/10/19}{If \protect\texttt{FormatWP} force explicit border.}
%    \begin{macrocode}
\DeclareDocumentCommand{\toprule}{o d()}
    {%
        \IfValueTF{##1}%
            {\LWR@docmidrule[##1](){1-\arabic{LWR@tabletotalcols}}}%
            {%
                \ifbool{FormatWP}%
                {\LWR@docmidrule[##1](){1-\arabic{LWR@tabletotalcols}}}%
                {\booltrue{LWR@doingtbrule}}%
            }%
    \LWR@getmynexttoken}%
%
\DeclareDocumentCommand{\midrule}{o d()}%
    {%
        \IfValueTF{##1}%
            {\LWR@docmidrule[##1](){1-\arabic{LWR@tabletotalcols}}}%
            {%
                \ifbool{FormatWP}%
                {\LWR@docmidrule[##1](){1-\arabic{LWR@tabletotalcols}}}%
                {\booltrue{LWR@doinghline}}%
            }%
    \LWR@getmynexttoken}%
%
\DeclareDocumentCommand{\cmidrule}{O{\LWR@cmidrulewidth} d() m}%
{\LWR@docmidrule[##1](##2){##3}\LWR@getmynexttoken}%
%
\DeclareDocumentCommand{\bottomrule}{o d()}
    {%
        \IfValueTF{##1}%
            {\LWR@docmidrule[##1](){1-\arabic{LWR@tabletotalcols}}}%
            {%
                \ifbool{FormatWP}%
                {\LWR@docmidrule[##1](){1-\arabic{LWR@tabletotalcols}}}%
                {\booltrue{LWR@doingtbrule}}%
            }%
    \LWR@getmynexttoken}%
%
\DeclareDocumentCommand{\addlinespace}{o}{}%
\DeclareDocumentCommand{\morecmidrules}{}{}%
\DeclareDocumentCommand{\specialrule}{m m m d()}%
    {\LWR@docmidrule[##1](){1-\arabic{LWR@tabletotalcols}}\LWR@getmynexttoken}%
%    \end{macrocode}
% The following create data cells and will have no more data in this cell,
% so we do not want to look ahead for a possible data cell,
% so do not want to use |\LWR@getmynexttoken|.
%    \begin{macrocode}
\renewcommand{\multicolumn}{\LWR@htmlmulticolumn}%
\renewcommand*{\mrowcell}{%
    \LWR@maybenewtablerow%
    \LWR@tabularleftedge%
    \global\booltrue{LWR@skippingmrowcell}%
}%
\renewcommand*{\mcolrowcell}{%
    \LWR@maybenewtablerow%
    \global\booltrue{LWR@skippingmcolrowcell}%
}%
\LetLtxMacro{\caption}{\LWR@longtabledatacaptiontag}%
%    \end{macrocode}
% Reset for new processing:
%    \begin{macrocode}
\global\boolfalse{LWR@tableparcell}%
\global\boolfalse{LWR@skippingmrowcell}%
\global\boolfalse{LWR@skippingmcolrowcell}%
\global\boolfalse{LWR@skipatbang}%
\global\boolfalse{LWR@emptyatbang}%
%    \end{macrocode}
% Set |&| for its special meaning inside the tabular:
%    \begin{macrocode}
\StartDefiningTabulars%
\protected\gdef&{\LWR@tabularampersand}%
%    \end{macrocode}
% Look ahead for a possible table data cell:
%    \begin{macrocode}
\LWR@traceinfo{LWR@tabular: about to LWR@getmynexttoken}%
\LWR@getmynexttoken%
}%
%    \end{macrocode}
% Ending the environment:
%    \begin{macrocode}
{%
\LWR@traceinfo{LWR@tabular ending}%
\ifboolexpr{%
    test {%
        \ifnumcomp{\value{LWR@tablecolindex}}{<}{\value{LWR@tabletotalcols}}
    } or %
    (%
        bool{LWR@intabularmetadata} and%
        not bool{LWR@tabularcelladded} and%
        test {%
            \ifnumcomp{\value{LWR@tablecolindex}}{=}{\value{LWR@tabletotalcols}}%
        }%
    )%
}%
{%
    \LWR@tabularfinishrow%
}%
{%
    \LWR@closetabledatacell%
}%
\LWR@htmlblocktag{/tr}%
\LWR@htmlblocktag{/table}%
\global\boolfalse{LWR@intabularmetadata}%
%    \end{macrocode}
%
% Unnest one level of tabular:
%    \begin{macrocode}
\addtocounter{LWR@tabulardepth}{-1}%
%    \end{macrocode}
%
% Restore |&| to its usual meaning:
%    \begin{macrocode}
\protected\gdef&{\LWR@origampmacro}%
\EndDefiningTabulars%
\LWR@traceinfo{LWR@tabular finished ending}%
}

\EndDefiningTabulars
%    \end{macrocode}
% \end{environment}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}





% \subsection{Array}
% \label{sec:array}

% \DescribePackage{array}
%
% \pkg{array} is also automatically loaded by siunitx.





% \section{Cross-references}
%
% Sectioning commands have been emulated from scratch, so the cross-referencing
% commands are custom-written for them.
% Emulating both avoids several layers of patches.
%
% The \pkg{zref} package is used to remember section name, file, and
% lateximage depth and number for each label.
%
% \Cref{tab:crossrefdata} shows the data structures related to cross-referencing.
%
% \changes{v0.14}{2016/03/29}{Docs: Table: Cross-referencing data structures.}
% \changes{v0.19}{2016/05/25}{Docs: Table: Cross-referencing data structures, updated.}
% \begin{table}
% \small
% \caption{Cross-referencing data structures\label{tab:crossrefdata}}
% \medskip
% \hrule
% \smallskip
% \begin{description}[nosep]
% \raggedright
% \item [Original \LaTeX:] \hfill (print and \HTML)
%	\begin{description}
%	\item [\cs{refstepcounter}:] Steps the couunter and sets \cs{@currentlabel}.
%	\item [\cs{@currentlabel}:] \cs{p@<ctr>}\cs{the<ctr>} Updated by \cs{refstepcounter}.
%	\item [\cs{label}:] Writes to the |.aux| file:
%		\qquad |\newlabel{<label>}{{\@currentlabel}{\thepage}}|
%	\item [\cs{newlabel}:] When the |.aux| file is read, sets \cs{r@<label>}.
%	\item [\cs{r@<label>}:] Set to: |{{\@currentlabel}{\thepage}}|
%	\item [\cs{ref}:] Returns the first part of \cs{r@<label>}.
%	\item [\cs{pageref}:] Returns the second part of \cs{r@<label>}.
%	\end{description}
% \item [Added by \pkg{lwarp}:] \hfill (\HTML\ only)
%	\begin{description}
%	\item [\cs{label}:] Adds \HTML\ tags (\cref{sec:labels}),
%		plus \cs{splabel} data (\cref{sec:zrefsetup}):
%		\begin{description}
%		\item [zLWR@name:] The section name for this label.
%		\item [zLWR@htmlfilenumer:] The filenumber or name for this label.
%		\item [zLWR@lateximagedepth:] The |lateximagedepth| for this label.
%		\item [zLWR@lateximagenumber:] The |lateximagenumber| for this label.
%		\end{description}
%	\item [\cs{nameref}:] Emualted from \pkg{hyperref} for \pkg{lwarp}.
%		See \cref{sec:references}.
%	\item [\cs{ref} and \cs{nameref}:] Adds \HTML\ tags.
%		See \cref{sec:references}.
%	\end{description}
% \item [Added by \pkg{amsmath}:] \hfill (print and \HTML)
%	\begin{description}
%	\item [\cs{label}:] Execution is delayed until the math environment is completed.
%	\item [\cs{ltx@label}:] \LaTeX\ \cs{label},
%		(\HTML: patched by \pkg{lwarp},) later patched by \pkg{cleveref}.
%	\end{description}
% \item [Added by \pkg{cleveref}:] \hfill (print and \HTML)
%	\begin{description}
%	\item [\cs{refstepcounter:}] Added: sets \cs{cref@currentlabel}.
%	\item [\cs{cref@currentlabel}:] (|<type>|=|<ctr>| unless an alias is used):
%		\qquad |[<type>][\arabic{<ctr>}][<parent ctrs>]{\p@<ctr>\the<ctr>}|
%		Also see \cref{sec:footnotesregular} for use with footnotes.
%	\item [\cs{label}:] Writes to the |.aux| file:
%		\qquad |\newlabel{<label>@cref}{{\cref@currentlabel}{\thepage}}|
%	\item [\cs{newlabel}:] (Unchanged.) When the |.aux| file is read, sets \cs{r@<label>@cref}.
%	\item [\cs{r@<label>@cref}:] Set to: |{{\cref@currentlabel}{\thepage}}|
%	\item [Utility functions:] See \cs{cref@getlabel}, \cs{cref@gettype},
%		\cs{cref@getcounter}, \cs{cref@getprefix}.
%	\item [Cross-referencing names:] \cs{crefname} and \cs{Crefname} assign
%		human-readable names for references to this counter type.
%	\end{description}
% \item [Additionally patched by \pkg{lwarp}:] \hfill (\HTML\ only)
%	\begin{description}
%	\item [\cs{cref}, etc.:] Modified for \pkg{lwarp}.
%		See \cref{sec:cleveref}.
%	\item [\cs{label} inside math:] See \cref{sec:amsmathsupport}.
%	\end{description}
% \item [Footnotes:] See \cs{noteentry} in \cref{sec:footnotesregular}.
% \end{description}
% \hrule
% \end{table}
%
%
% ^^A % See:
% ^^A %
% ^^A % \href{http://tex.stackexchange.com/questions/85956/redefining-label-and-ref-when-using-hyperref}
% ^^A %     {\texttt{http://tex.stackexchange.com/questions/85956/redefining-label-and-ref-when-\\using-hyperref}}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \subsection{Setup}

%
%
% \begin{macro}{\@currentlabelname}
% To remember the most recently defined section name,
% description, or caption, for \cs{nameref}.
%
% \changes{v0.44}{2017/11/19}{Adjustment for \pkg{koma-script}.}
%    \begin{macrocode}
\providecommand*{\@currentlabelname}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LWR@stripperiod} \marg{text} \oarg{.}
%
% Removes a trailing period.
%    \begin{macrocode}
\def\LWR@stripperiod#1.\ltx@empty#2\@nil{#1}%
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@setlatestname} \marg{object name}
%
% Removes \cs{label}, strips any final period, and remembers the result.
%    \begin{macrocode}
\newcommand*{\LWR@setlatestname}[1]{%
%    \end{macrocode}
% Remove \cs{label} and other commands from the name, the strip any final period.
% See \pkg{zref-titleref} and \pkg{gettitlestring}.
%    \begin{macrocode}
\GetTitleStringExpand{#1}%
\edef\@currentlabelname{\detokenize\expandafter{\GetTitleStringResult}}%
\edef\@currentlabelname{%
\expandafter\LWR@stripperiod\@currentlabelname%
\ltx@empty.\ltx@empty\@nil%
}%
}
%    \end{macrocode}
% \end{macro}


% \subsection{Zref setup}
% \label{sec:zrefsetup}

% See: \\
% \href{http://tex.stackexchange.com/questions/57194/extract-section-number-from-equation-reference}
%    {\ttfamily http://tex.stackexchange.com/questions/57194/ \\
%		\hspace*{2em}extract-section-number-from-equation-reference}
%
% Create a new property list called special:
%    \begin{macrocode}
\zref@newlist{special}
%    \end{macrocode}
% Define a new property which has the name of the most recently declared section:
%    \begin{macrocode}
\zref@newprop{zLWR@name}{\@currentlabelname}
%    \end{macrocode}
% Define a new property which has either a filename or a file number:
%    \begin{macrocode}
\zref@newprop{zLWR@htmlfilenumber}{%
\ifbool{FileSectionNames}{\LWR@thisfilename}{\arabic{LWR@htmlfilenumber}}%
}%
%    \end{macrocode}
% Additional properties for lateximages:
%    \begin{macrocode}
\zref@newprop{zLWR@lateximagedepth}{\arabic{LWR@lateximagedepth}}
\zref@newprop{zLWR@lateximagenumber}{\arabic{LWR@lateximagenumber}}
%    \end{macrocode}
%
% |zLWR@htmlfilenumber| property holds the file number or name
%
% Add a |LWR@htmlfilenumber| property, and lateximage properties to special:
%    \begin{macrocode}
\zref@addprop{special}{zLWR@name}
\zref@addprop{special}{zLWR@htmlfilenumber}
\zref@addprop{special}{zLWR@lateximagedepth}
\zref@addprop{special}{zLWR@lateximagenumber}
%    \end{macrocode}
% Returns the selected field:
%    \begin{macrocode}
\newcommand*{\LWR@spref}[2]{%
\zref@extractdefault{#1}{#2}{??}}
%    \end{macrocode}
% \begin{macro}{\LWR@nameref} \marg{label}
% Returns the section name for this label:
%    \begin{macrocode}
\newcommand*{\LWR@nameref}[1]{%
\LWR@spref{#1}{zLWR@name}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LWR@htmlfileref} \marg{label}
% \changes{v0.24}{2017/03/13}{Fix: Index links while \cs{tracinglwarp}.}
% Returns the file number for this label:
%    \begin{macrocode}
\newcommand*{\LWR@htmlfileref}[1]{%
% DO NOT USE \LWR@traceinfo HERE!  Will be expanded.
\LWR@spref{#1}{zLWR@htmlfilenumber}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LWR@lateximagedepthref} \marg{label}
% Returns the |lateximagedepth| for this label:
%    \begin{macrocode}
\newcommand*{\LWR@lateximagedepthref}[1]{%
\LWR@spref{#1}{zLWR@lateximagedepth}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LWR@lateximagenumberref} \marg{label}
% Returns the |lateximagenumber| for this label:
%    \begin{macrocode}
\newcommand*{\LWR@lateximagenumberref}[1]{%
\LWR@spref{#1}{zLWR@lateximagenumber}%
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LWR@splabel} \marg{label}
% Sanitize the name and then creates the label:
%    \begin{macrocode}
\newcommand*{\LWR@splabel}[1]{%
\LWR@setlatestname{\@currentlabelname}%
\zref@labelbylist{#1}{special}}
%    \end{macrocode}
% \end{macro}




% \subsection{Labels}
% \label{sec:labels}


% \begin{macro}{\LWR@subsublabel} \marg{label} \quad
% Creates an \HTML\ id tag.
%    \begin{macrocode}
\newcommand*{\LWR@subsublabel}[1]{%
%    \end{macrocode}
% Create an \HTML\ id tag unless are inside a lateximage,
% since it would appear in the image:
%    \begin{macrocode}
\ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
{}%
{% not lateximage
%    \end{macrocode}
% If not doing a lateximage, create an \HTML\ ID tag:
% (To be factored\dots)
%    \begin{macrocode}
    \ifbool{LWR@doingstartpars}%
    {% pars allowed
        \ifbool{LWR@doingapar}
        {% par started
            \LWR@htmltag{a id="#1"{}}\LWR@htmltag{/a}%
        }% par started
        {% par not started
            \LWR@stoppars%
            \LWR@htmltag{a id="#1"{}}\LWR@htmltag{/a}%
            \LWR@startpars%
        }% par not started
    }% pars allowed
    {% pars not allowed
        \LWR@htmltag{a id="#1"{}}\LWR@htmltag{/a}%
    }% pars not allowed
}% not lateximage
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@newlabel} \marg{label} \oarg{type}
%
% \cs{label} during \HTML\ output when not in math mode,
% removing extra spaces around the label, as done by regular \LaTeX\ \cs{label}.
%
% \pkg{clevereref} later encases this to add its own cross-referencing.
%
% The optional \meta{type} is per the \pkg{ntheorem} package, and is ignored.
%    \begin{macrocode}
\NewDocumentCommand{\LWR@newlabel}{m o}{%
\LWR@traceinfo{LWR@newlabel: starting}%
\LWR@traceinfo{LWR@newlabel: !#1!}%
% \@bsphack%
%    \end{macrocode}
% Create a traditional \LaTeX\ label, as modified by \pkg{cleveref}:
%    \begin{macrocode}
\LWR@origlabel{#1}%
%    \end{macrocode}
% Create a special label which holds the section number,
% |LWR@htmlfilenumber|, |LWR@lateximagedepth|, and |LWR@lateximagenumber|:
%    \begin{macrocode}
\LWR@traceinfo{LWR@newlabel: filesectionnames is \ifbool{FileSectionNames}{true}{false}}%
\LWR@traceinfo{LWR@newlabel: LWR@thisfilename is !\LWR@thisfilename!}%
\LWR@traceinfo{LWR@newlabel: LWR@htmlfilenumber is \arabic{LWR@htmlfilenumber}}%
\LWR@splabel{#1}%
\LWR@subsublabel{#1}%
% \@esphack%
\LWR@traceinfo{LWR@newlabel: done}%
}
%    \end{macrocode}
% \end{macro}
%




% \subsection{References}
% \label{sec:references}

% \begin{macro}{\LWR@startref} \marg{label} \quad
% (Common code for |\ref| and |\nameref|.)
%
% Open an \HTML\ tag reference to a filename, \# character, and a label.
%
% \changes{v0.28}{2017/04/13}{Removed space.}
%
%    \begin{macrocode}
\newcommand*{\LWR@startref}[1]
{%
\edef\LWR@lidref{\LWR@lateximagedepthref{#1}}%
\LWR@traceinfo{LWR@startref A: !#1!}%
%    \end{macrocode}
% Create the filename part of the link:
%    \begin{macrocode}
\LWR@htmltag{a href="%
\LWR@traceinfo{LWR@startref B}%
\LWR@htmlrefsectionfilename{#1}%
\LWR@traceinfo{LWR@startref C}%
\#%
%    \end{macrocode}
% Create the destination id:
%
% See if |LWR@lateximagedepth| is unknown:
%    \begin{macrocode}
\LWR@traceinfo{LWR@startref D: !#1!}%
\ifthenelse{\equal{\LWR@lidref}{??}}%
%    \end{macrocode}
% ``|??|'' if |LWR@lateximagedepth| is unknown,
% so create a link with an unknown destination:
%    \begin{macrocode}
{%
    \LWR@traceinfo{LWR@startref D0: ??}%
    ??%
}%
%    \end{macrocode}
% If |LWR@lateximagedepth| is known.
% Use a lateximage if the depth is greater than zero,
% or a regular link otherwise:
%    \begin{macrocode}
{%
    \LWR@traceinfo{LWR@startref D1: \LWR@lidref}%
    \ifthenelse{\cnttest{\LWR@lidref}{>}{0}}%
    {%
        \LWR@traceinfo{LWR@startref D2: \LWR@lidref}%
        lateximage\LWR@lateximagenumberref{#1}%
    }%
    {%
        \LWR@traceinfo{LWR@startref D3}%
        #1%
    }%
}%
\LWR@traceinfo{LWR@startref E}%
%    \end{macrocode}
% Closing quote:
%    \begin{macrocode}
"{}}%
\LWR@traceinfo{LWR@startref F}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@subnewref} \marg{label} \marg{label or sub@label}
%
% Factored for the \pkg{subfig} package.
% Uses the original label for the hyper-reference,
% but prints its own text, such as ``|1(b)|''.
%    \begin{macrocode}
\NewDocumentCommand{\LWR@subnewref}{m m}{%
\LWR@traceinfo{LWR@subnewref #1 #2}%
\LWR@startref{#1}%
\LWR@origref{#2}%
\LWR@htmltag{/a}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\ref} * \marg{label} \quad \cs{ref} is \cs{let} to \cs{LWR@newref}
% \begin{macro}{\LWR@newref} * \marg{label} \quad
% Create an internal document reference link,
% or without a link if starred per \pkg{hyperref}.
%    \begin{macrocode}
\NewDocumentCommand{\LWR@newref}{s m}{%
\LWR@traceinfo{LWR@newref #2}%
\IfBooleanTF{#1}%
{\LWR@origref{#2}}%
{\LWR@subnewref{#2}{#2}}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}


% \label{sec:pagerefpagefor}
% \begin{macro}{\pagerefPageFor} Text for page references.
%
%    \begin{macrocode}
\newcommand*{\pagerefPageFor}{see }
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\pageref} * \marg{label} \quad
% Create an internal document reference,
% or just the unlinked number if starred, per \pkg{hyperref}.
%
% \changes{v0.20}{2017/01/03}{Added.}
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@newpageref}{s m}{%
\IfBooleanTF{#1}%
{(\pagerefPageFor\LWR@origref{#2})}%
{(\cpageref{#2})}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\nameref} \marg{label}
%
% \changes{v0.43}{2017/10/31}{Made robust.}
%    \begin{macrocode}
\DeclareRobustCommand*{\nameref}[1]{%
\LWR@traceinfo{nameref A}%
\LWR@startref{#1}%
\LWR@traceinfo{nameref B}%
\LWR@nameref{#1}%
\LWR@traceinfo{nameref C}%
\LWR@htmltag{/a}%
\LWR@traceinfo{nameref D}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\Nameref} \marg{label}
% In print, adds the page number.  In \HTML, does not.
%    \begin{macrocode}
\let\Nameref\nameref
%    \end{macrocode}
% \end{macro}

% \subsection{Hyper-references}
%
% Note that the code currently only sanitizes the underscore character.
% \watchout
% Additional characters should be rendered inert as well.
% See the |hyperref.sty| definition of  \cs{gdef}\cs{hyper@normalise} for an example.
%

% \DescribePackage{hyperref}

% Do not tell other packages that \pkg{hyperref} is emulated.
% \watchout
% Some packages patch various commands if \pkg{hyperref} is present,
% which will probably break something, and the emulation already handles
% whatever may be emulated anyhow.
%
% Any reference to |\usepackage{hyperref}| must be placed inside a \env{warpprint} environment.
% \watchout
%    \begin{macrocode}
% DO NOT TELL OTHER PACKAGES TO ASSUME HYPERREF, lest they attempt to patch it:
% \EmulatesPackage{hyperref}[2015/08/01]% Disabled.  Do not do this.
%    \end{macrocode}

% Create a link with a text name:

% \begin{macro}{\LWR@subhyperref} \marg{URL} \marg{text}
% \changes{v0.18}{2016/04/14}{Improved \HTML\ output linebreaks.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@subhyperref}{m +m}{%
\LWR@htmltag{a href="{#1}" target="\_{}blank"\LWR@orignewline}#2\LWR@htmltag{/a}%
\LWR@ensuredoingapar%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@subhyperrefclass} \marg{URL} \marg{text} \marg{htmlclass}
% \changes{v0.18}{2016/04/14}{Improved \HTML\ output linebreaks.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@subhyperrefclass}{m +m m}{%
\LWR@htmltag{a href="{#1}"
class="#3"\LWR@orignewline}#2\LWR@htmltag{/a}%
\LWR@ensuredoingapar%
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\href} \oarg{options} \marg{URL} \marg{text}
%
% Create a link with accompanying text:
%
% \changes{v0.43}{2017/10/31}{Made robust.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@hrefb}{O{} m +m}{%
\LWR@subhyperref{#2}{#3}%
\endgroup%
\LWR@ensuredoingapar%
}

\DeclareRobustCommand*{\href}{%
\LWR@ensuredoingapar%
\begingroup%
\catcode`\_=12
\LWR@hrefb%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\nolinkurl} \marg{URL}
%
% Print the name of the link without creating the link:
% \changes{v0.43}{2017/10/31}{Made robust.}
%    \begin{macrocode}
\newcommand*{\LWR@nolinkurlb}[1]{#1\endgroup\LWR@ensuredoingapar}

\DeclareRobustCommand*{\nolinkurl}{%
\LWR@ensuredoingapar%
\begingroup\catcode`\_=12
\LWR@nolinkurlb%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\url} \marg{URL}
%
% Create a link whose text name is the address of the link.
% The \pkg{url} package may redefine \cs{url}, so it is \cs{let} to \cs{LWR@urla}here
% and also redefined by \pkg{lwarp-url}.
%
% \changes{v0.43}{2017/10/31}{Made robust.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@urlb}{m}{%
\LWR@hrefb{#1}{#1}%
}

\DeclareRobustCommand*{\url}{%
\LWR@ensuredoingapar%
\begingroup\catcode`\_=12
\LWR@urlb%
}

% \LetLtxMacro\url\LWR@urla
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@subinlineimage} \oarg{alttag} \marg{class}
%	\marg{filename} \marg{extension} \marg{style}
%
% \changes{v0.18}{2016/05/18}{Surpress extra space.}
%
%    \begin{macrocode}
\newcommand*{\LWR@subinlineimage}[5][]{%
\ifblank{#1}%
{\LWR@htmltag{img src="#3.#4" alt="#3" style="#5" class="#2"{}}}%
{\LWR@htmltag{img src="#3.#4" alt="#1" style="#5" class="#2"{}}}%
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \clearpage

% \section{Floats}
% \label{sec:floats}

% Floats are supported, although partially through emulation.
%
% \Cref{tab:floatdata} shows the data structure associated with each |<type>|
% of float.

% \changes{v0.14}{2016/03/28}{Docs: Table: Float data structures.}
% \begin{table}
% \caption{Float data structures\label{tab:floatdata}}
%
% \bigskip
% For each |<type>| of float (figure, table, etc.) there exists the following:
%
% \hrule
% \begin{description}
% \item [counter <type>:] A counter called |<type>|, such as |figure|, |table|.
% \item [\cs{<type>name}:] Name.  \cs{figurename} prints ``Figure'', etc.%
% \item [\cs{ext@<type>}:] File extension.  \cs{ext@figure} prints ``lof'', etc.
% \item [\cs{fps@<type>}:] Placement.
% \item [\cs{the<type>}:] Number.  \cs{thetable} prints the number of the table, etc.
% \item [\cs{p@<type>}:] Parent's number.
%	Prints the number of the [within] figure, etc.
% \item [\cs{fnum@<type>}:] Prints the figure number for the caption. \\
%	\cs{<type>name}~\cs{the<type>}, ``Figure 123''.
% \item [\cs{<type>}:] Starts the float environment. |\figure| or \cs{begin}|{figure}|
% \item [\cs{end<type>}:] Ends the float environment. |\endfigure| or \cs{end}|{figure}|
% \item [\cs{tf@<ext>}:] The \LaTeX{} file identifier for the output file.
% \item [\texttt{LWR@have<type>}:] A boolean rememebering whether a \cs{listof} was
%	requested for a float of this type.
% \item [File with extension lo<f,t,a-z>:] An output file containing
%	the commands to build the
%	\cs{listof}{<type>}{<name>} ``table-of-contents'' structure.
% \item [Cross-referencing names:] For \pkg{cleveref}'s \cs{cref} and related,
%	\cs{crefname} and \cs{Crefname} assign human-readable names for references to this float type.
% \end{description}
% \hrule
% \end{table}
%
% \cs{@makecaption} is redefined to print the float number and caption text,
% separated by \cs{CaptionSeparator}, which works with the \pkg{babel} package to
% adjust the caption separator according to the language.  French, for example,
% uses an en-dash instead of a colon: ``Figure 123 -- Caption text''.


% \subsection{Float captions}
% \label{sec:floatcaptions}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \begin{macro}{\LWR@floatbegin} \marg{type} \oarg{placement}
%
% Begins a \cs{newfloat} environment.
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@floatbegin}{m o}{%
\ifbool{FormatWP}{\newline}{}%
\LWR@stoppars
%    \end{macrocode}
% There is a new float, so increment the unique float counter:
%    \begin{macrocode}
\addtocounter{LWR@thisautoid}{1}%
\booltrue{LWR@freezethisautoid}%
%    \end{macrocode}
%
%    \begin{macrocode}
\begingroup%
%    \end{macrocode}
% Settings while inside the environment:
%    \begin{macrocode}
\LWR@origraggedright%
%    \end{macrocode}
% Open an \HTML\ |figure| tag:
% \changes{v0.42}{2017/10/26}{If \protect\texttt{FormatWP} add a text frame.}
%    \begin{macrocode}
\LWR@htmltag{figure id="autoid-\arabic{LWR@thisautoid}" class="#1"}%
\ifbool{FormatWP}{%
    \LWR@orignewline%
    \LWR@BlockClassWP{}{}{wp#1}%
}{}%
%    \end{macrocode}
%    \begin{macrocode}
\renewcommand*{\@captype}{#1}%
\caption@settype{#1}%
\LWR@startpars%
\ifboolexpr{bool{FormatWP} and bool{WPMarkFloats}}{%

=== begin #1 ===

}{}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@float}
% \begin{macro}{\@dlbfloat} Support packages which create floats directly.
%    \begin{macrocode}
\let\@float\LWR@floatbegin
\let\@dblfloat\LWR@floatbegin
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\LWR@floatend}
%
% Ends a \cs{newfloat} environment.
%    \begin{macrocode}
\newcommand*{\LWR@floatend}{%
\ifboolexpr{bool{FormatWP} and bool{WPMarkFloats}}{%

=== end ===

}{}%
\LWR@stoppars%
%    \end{macrocode}
% Close an \HTML\ |figure| tag:
% \changes{v0.42}{2017/10/26}{If \protect\texttt{FormatWP} add a text frame.}
%    \begin{macrocode}
\ifbool{FormatWP}{\endLWR@BlockClassWP}{}%
\LWR@htmlelementend{figure}%
\endgroup%
\boolfalse{LWR@freezethisautoid}%
\LWR@startpars%
\ifbool{FormatWP}{\newline}{}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\end@float}
% \begin{macro}{\end@dlbfloat} Support packages which create floats directly.
%    \begin{macrocode}
\let\end@float\LWR@floatend
\let\end@dblfloat\LWR@floatend
%    \end{macrocode}
% \end{macro}
% \end{macro}



% \DescribeCounter{LWR@thisautoid}
% A sequential counter for all floats and theorems.
% This is used to identify the float or theorem
% then reference it from the List of Figures and
% List of Tables.
%    \begin{macrocode}
\newcounter{LWR@thisautoid}
%    \end{macrocode}

% \DescribeBoolean{LWR@freezethisautoid}
% Prevents multiple increments of \cs{LWR@thisautoid} inside a float.
%    \begin{macrocode}
\newbool{LWR@freezethisautoid}
\boolfalse{LWR@freezethisautoid}
%    \end{macrocode}

% \begin{macro}{\LWR@maybeincthisautoid}
% Possibly increments the autoid counter.
%    \begin{macrocode}
\newcommand*{\LWR@maybeincthisautoid}{%
\ifbool{LWR@freezethisautoid}{}{\addtocounter{LWR@thisautoid}{1}}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@newautoidanchor}
% Adds a new \element{autoid} anchor.
%    \begin{macrocode}
\newcommand*{\LWR@newautoidanchor}{%
\LWR@maybeincthisautoid%
\LWR@htmltag{a id="autoid-\arabic{LWR@thisautoid}"{}}\LWR@htmltag{/a}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\@captype}
% Remembers which float type is in use.
%    \begin{macrocode}
\newcommand*{\@captype}{}
%    \end{macrocode}
% \end{macro}


% \subsubsection{Caption inside a float environment}

% \begin{macro}{\CaptionSeparator} How to separate the float number and the caption text.
% \changes{v0.13}{2016/03/23}{Fix for newer babel package.}
%    \begin{macrocode}
\AtBeginDocument{\providecommand*{\CaptionSeparator}{:~}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\@makecaption} \marg{name and num} \marg{text}
%
% Prints the float type and number, the caption separator, and the caption text.
%    \begin{macrocode}
\AtBeginDocument{\renewcommand{\@makecaption}[2]{#1\CaptionSeparator#2}}
%    \end{macrocode}
% \end{macro}


% \subsubsection{Caption and LOF linking and tracking}

% When a new \HTML\ file is marked in the \LaTeX\ \PDF\ file,
% the \LaTeX\ page number at that point is stored in |LWR@latestautopage|,
% (and the associated filename is remembered by the special \LaTeX\ labels).
% This page number is used to generate an |autopage| \HTML\ \element{id}
% in the \HTML\ output at the start of the new \HTML\ file.
% Meanwhile, there is a float counter used to generate an \HTML\ |autoid|
% \element{id} at the start of the float itself in the \HTML\ file.
% The |autopage| and |autoid| values to use for each float are written to the
% |.lof|, etc. files just before each float's entry.  These values are used
% by \cs{l@figure}, etc. to create the \HTML\ links in the List of Figures, etc.
%
% \DescribeCounter{LWR@nextautoid} Tracks autoid for floats.
% \DescribeCounter{LWR@nextautopage} Tracks autopage for floats.
%
% These are updated per float as the |.lof| file is read.
%    \begin{macrocode}
\newcounter{LWR@nextautoid}
\newcounter{LWR@nextautopage}
%    \end{macrocode}
%
%
% \begin{macro}{\LWRsetnextfloat} \marg{autopage} \marg{autoid}
%
% This is written to the |.lof| file just before each float's usual entry.
% The autopage and autoid are remembered for \cs{l@figure} to use when
% creating the \HTML\ links.
%
%    \begin{macrocode}
\newcommand*{\LWRsetnextfloat}[2]{%
\setcounter{LWR@nextautopage}{#1}%
\setcounter{LWR@nextautoid}{#2}%
}
%    \end{macrocode}
% \end{macro}

% \DescribeCounter{LWR@latestautopage}
% Updated each time a new \HTML\ file is begun.
% \cs{LWRsetnextfloat} is written with this and the autoid
% by the modified \cs{addcontentsline} just before each float's entry.
%    \begin{macrocode}
\newcounter{LWR@latestautopage}
\setcounter{LWR@latestautopage}{1}
%    \end{macrocode}


% \begin{environment}{LWR@figcaption}
%   \qquad Encapsulates a caption inside \element{figcaption},
%   and if |FormatWP| then also a \element{div} with an italic style.
% \changes{v0.42}{2017/10/20}{If \protect\texttt{FormatWP} forces italic captions.}
%    \begin{macrocode}
\newenvironment*{LWR@figcaption}
{%
\LWR@htmlblocktag{figcaption}
\ifbool{FormatWP}{%
\begin{BlockClass}[font-style:italic]{italic}
\LWR@origvspace*{\baselineskip}
}{}%
}
{%
\ifbool{FormatWP}{\end{BlockClass}}{}%
\LWR@htmlblocktag{/figcaption}%
}
%    \end{macrocode}
% \end{environment}



%    \begin{macrocode}
\let\LWR@origcaption@begin\caption@begin
\let\LWR@origcaption@end\caption@end
\let\LWR@orig@@par\@@par
%    \end{macrocode}

% \begin{macro}{\LWR@caption@begin}
% Low-level patches to create \HTML\ tags for captions.
%    \begin{macrocode}
\newcommand{\LWR@caption@begin}
{
\LWR@traceinfo{LWR@caption@begin}%
%    \end{macrocode}
% Keep par and minipage changes local:
%    \begin{macrocode}
\begingroup%
%    \end{macrocode}
% The \pkg{caption} code was not allowing the closing |par| tag:
%    \begin{macrocode}
\renewcommand{\@@par}{\LWR@closeparagraph\LWR@orig@@par}%
%    \end{macrocode}
% No need for a |minipage| or \cs{parbox} inside the caption:
%    \begin{macrocode}
\RenewDocumentEnvironment{minipage}{O{t} o O{t} m}{}{}%
\RenewDocumentCommand{\parbox}{O{t} o O{t} m +m}{##5}%
%    \end{macrocode}
% Enclose the original caption code inside an \HTML\ tag:
%    \begin{macrocode}
\LWR@figcaption%
\LWR@origcaption@begin%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@caption@end}
% Low-level patches to create \HTML\ tags for captions.
%    \begin{macrocode}
\newcommand{\LWR@caption@end}
{%
\LWR@origcaption@end%
%    \end{macrocode}
% Subcaptions were being over-written by the closing \HTML\ tag:
%    \begin{macrocode}
\LWR@origvspace*{\baselineskip}%
%    \end{macrocode}
% Closing tag:
%    \begin{macrocode}
\endLWR@figcaption%
\endgroup%
% \leavevmode% avoid bad space factor (0) error
\LWR@traceinfo{LWR@caption@end: done}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\caption@begin}
% \begin{macro}{\caption@end}
% Low-level patches to create \HTML\ tags for captions.
%    \begin{macrocode}
\AtBeginDocument{
\let\caption@begin\LWR@caption@begin
\let\caption@end\LWR@caption@end
}
%    \end{macrocode}
% \end{macro}
% \end{macro}


% \begin{macro}{\captionlistentry}
% Tracks the float number for this caption used outside a float.
% Patched to create an \HTML\ anchor.
%    \begin{macrocode}
\let\LWR@origcaptionlistentry\captionlistentry

\renewcommand*{\captionlistentry}{%
\LWR@ensuredoingapar%
\LWR@origcaptionlistentry%
}

\def\LWR@LTcaptionlistentry{%
\LWR@ensuredoingapar%
\LWR@htmltag{a id="autoid-\arabic{LWR@thisautoid}"{}}\LWR@htmltag{/a}%
  \bgroup
  \@ifstar{\egroup\LWR@LT@captionlistentry}% gobble *
          {\egroup\LWR@LT@captionlistentry}}%
\def\LWR@LT@captionlistentry#1{%
  \caption@listentry\@firstoftwo[\LTcaptype]{#1}}%
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\addcontentsline}
% Patched to write the autopage and autoid before each float's entry.
% No changes if writing |.toc|
% For a theorem, automatically defines \cs{ext@<type>} as needed, to
% mimic and reuse the float mechanism.
%
% \changes{v0.25}{2017/03/16}{Handles theorems.}
% \changes{v0.44}{2017/11/10}{Automatic \cs{LWR@newfloatanchor}.}
%
%    \begin{macrocode}
\let\LWR@origaddcontentsline\addcontentsline

\renewcommand*{\addcontentsline}[3]{%
\ifstrequal{#1}{toc}{}{% not TOC
    \LWR@newautoidanchor%
    \ifthenelse{\equal{#1}{thm}}{\csdef{ext@#2}{thm}}{}%
    \addtocontents{\@nameuse{ext@#2}}{%
        \protect\LWRsetnextfloat%
        {\arabic{LWR@latestautopage}}%
        {\arabic{LWR@thisautoid}}%
    }%
}% not TOC
\LWR@origaddcontentsline{#1}{#2}{#3}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\captionof}
% Patched to track the float number since this is used outside a float,
% and also create an \HTML\ anchor for the virtual float.
%    \begin{macrocode}
\AtBeginDocument{
\let\LWR@origcaptionof\captionof

\renewcommand*{\captionof}{%
\LWR@stoppars
\LWR@origcaptionof%
}
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}





% \section{Table of Contents, LOF, LOT}
%
% This section controls the generation of the \TOC, \LOF, and \LOT.
%
% The |.toc|, |.lof|, and |.lot| files are named by the source code \cs{jobname}.
%
% In \HTML, the printed tables are placed inside a \element{div}
%   of class \attribute{toc}, \attribute{lof}, or \attribute{lot}.
%
% A ``sidetoc'' is provided which prints a subset of the \TOC\ on the side of each page other
% than the homepage.
%
% The regular \LaTeX{} infrastructure is used for \TOC,
% along with some patches to generate \HTML\ output.

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \subsection{Reading and printing the TOC}

% \begin{macro}{\LWR@myshorttoc} \marg{toc/lof/lot}
% \changes{v0.18}{2016/05/19}{Reorganize \cs{HomeHTMLFilename} logic.}
%
% Reads in and prints the \TOC/\LOF/\LOT\ at the current position.
% While doing so, makes the |@| character into a normal letter to allow
% formatting commands in the section names.

% Unlike in regular \LaTeX{}, the file is not reset after being read, since
% the \TOC\ may be referred to again in each \HTML\ page, and is
% used for the side\TOC.
%    \begin{macrocode}
\newcommand*{\LWR@myshorttoc}[1]{
\LWR@ensuredoingapar
%    \end{macrocode}
% Only if the file exists:
%    \begin{macrocode}
\IfFileExists{\jobname.#1}{
%    \end{macrocode}
% Make |@| a regular letter.
% Many of the commands in the file will have |@| characters in them, so |@|
% \watchout
% must be made a regular letter.
%
% For |pdflatex|, also change to |latin1| encoding.
% When reading back a file with accented characters,
% \watchout[disabled]
% the encoding change seems to be required, rather than leaving it |utf8|.
%    \begin{macrocode}
\begingroup
% \ifxetexorluatex%
% \else
% \inputencoding{latin1}% currently disabled
% \fi
\makeatletter
%    \end{macrocode}
% Read in the \TOC\ file:
%    \begin{macrocode}
\@input{\jobname.#1}
% \makeatother
\endgroup
}%
{}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@subtableofcontents} \marg{toc/lof/lot} \marg{sectionstarname}
%
% Places a TOC/LOF/LOT at the current position.
%    \begin{macrocode}
\NewDocumentCommand{\LWR@subtableofcontents}{m m}{%
%    \end{macrocode}
% Closes previous levels:
%    \begin{macrocode}
\@ifundefined{chapter}
{\LWR@closeprevious{\LWR@depthsection}}
{\LWR@closeprevious{\LWR@depthchapter}}
%    \end{macrocode}
% Prints any pending footnotes so that they appear above the potentially
% large TOC:
%    \begin{macrocode}
\LWR@printpendingfootnotes
%    \end{macrocode}
% Place the list into its own chapter (if defined) or section:
%    \begin{macrocode}
\@ifundefined{chapter}{\section*{#2}}{\chapter*{#2}}
%    \end{macrocode}
% Create a new \HTML\ |nav| containing the TOC/LOF/LOT:
%    \begin{macrocode}
\LWR@htmlelementclass{nav}{#1}
%    \end{macrocode}
% Create the actual list:
%    \begin{macrocode}
\LWR@myshorttoc{#1}
%    \end{macrocode}
% Close the |nav|:
%    \begin{macrocode}
\LWR@htmlelementclassend{nav}{#1}
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\@starttoc} \marg{ext}
%
% Patch \cs{@starttoc} to encapsulate the \TOC\ inside \HTML\ tags:
%    \begin{macrocode}
\let\LWR@orig@starttoc\@starttoc

\renewcommand{\@starttoc}[1]{
\LWR@htmlelementclass{nav}{#1}
\LWR@orig@starttoc{#1}
\LWR@htmlelementclassend{nav}{#1}
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\tableofcontents}
% Patch \cs{tableofcontents}, etc. to print footnotes first.
% \pkg{newfloat} uses \cs{listoffigures} for all future float types.
%    \begin{macrocode}
\let\LWR@origtableofcontents\tableofcontents

\renewcommand*{\tableofcontents}{%
%    \end{macrocode}
% Do not print the table of contents if formatting for a word processor,
% which will presumably auto-generate its own updated table of contents:
% \changes{v0.42}{2017/10/18}{Added boolean \protect\texttt{WPMarkTOC}.}
%    \begin{macrocode}
\ifboolexpr{bool{FormatWP} and bool{WPMarkTOC}}{

=== table of contents ===

}
{
%    \end{macrocode}
% Copy the |.toc| file to |.sidetoc| for printing the side\TOC.
% The original |.toc| file is renewed when \cs{tableofcontents} is finished.
%    \begin{macrocode}
    \LWR@copyfile{\jobname.toc}{\jobname.sidetoc}%
    \LWR@printpendingfootnotes
    \LWR@origtableofcontents
}
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\listoffigures}
% \changes{v0.42}{2017/10/18}{Added boolean \protect\texttt{WPMarkLOFT}.}
%    \begin{macrocode}
\let\LWR@origlistoffigures\listoffigures

\renewcommand*{\listoffigures}{
\ifboolexpr{bool{FormatWP} and bool{WPMarkLOFT}}{

=== list of figures ===

}
{
    \LWR@printpendingfootnotes
    \LWR@origlistoffigures
}
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\listoftables}
% \changes{v0.42}{2017/10/18}{Added boolean \protect\texttt{WPMarkLOFT}.}
%    \begin{macrocode}
\let\LWR@origlistoftables\listoftables

\renewcommand*{\listoftables}{
\ifboolexpr{bool{FormatWP} and bool{WPMarkLOFT}}{

=== list of tables ===

}
{
    \LWR@printpendingfootnotes
    \LWR@origlistoftables
}
}
%    \end{macrocode}
% \end{macro}


% \subsection{High-level TOC commands}

% \label{sec:listof}
% \begin{macro}{\listof} \marg{type} \marg{title}
%
% Emulate the \cs{listof} command from the \pkg{float} package (\cref{sec:newfloat}).
% Used to create lists of custom float types.  Also used to redefine
% the standard \LaTeX{} \cs{listoffigures} and \cs{listoftables} commands.
%    \begin{macrocode}
\NewDocumentCommand{\listof}{m +m}{%
\LWR@subtableofcontents{\@nameuse{ext@#1}}{#2}
\expandafter\newwrite\csname tf@\csname ext@#1\endcsname\endcsname
\immediate\openout \csname tf@\csname ext@#1\endcsname\endcsname
    \jobname.\csuse{ext@#1}\relax
}
%    \end{macrocode}
% \end{macro}


% \subsection{Side TOC}
% \label{sec:sidetoc}

% The ``side TOC'' is a table-of-contents positioned to the side.
%
% It may be renamed by redefining \cs{sidetocname}, and may contain paragraphs.
%
% \CSS\ may be used to format the sideTOC:
%
% \begin{docsidebar}[CSS related to sideTOC:]
%	\raggedright
% \begin{description}[parsep=0ex]
% \item [|nav.sidetoc|:] The entire side\TOC.
% \item [|div.sidetoctitle|:] The title.
% \item [|div.sidetoccontents|:] The table of contents.
% \end{description}
% \end{docsidebar}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \DescribeCounter{SideTOCDepth}
% Controls how deep the side-TOC gets.  Use a standard \LaTeX{} section level
% similar to |tocdepth|.
%    \begin{macrocode}
\newcounter{SideTOCDepth}
\setcounter{SideTOCDepth}{1}
%    \end{macrocode}

% \begin{macro}{\sidetocname}
% Holds the default name for the side\TOC.
%
%    \begin{macrocode}
\newcommand{\sidetocname}{Contents}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}


% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{macro}{\LWR@sidetoc}
% Creates the actual side-TOC.
%    \begin{macrocode}
\newcommand*{\LWR@sidetoc}{
\LWR@forcenewpage
\LWR@stoppars

%    \end{macrocode}
% The entire side\TOC\ is placed into a |nav| of class |sidetoc|.
%    \begin{macrocode}
\LWR@htmlelementclass{nav}{sidetoc}

\setcounter{tocdepth}{\value{SideTOCDepth}}

%    \end{macrocode}
% The title is placed into a \element{div} of class \attribute{sidetoctitle}, and may
% contain paragraphs.
%    \begin{macrocode}
\begin{BlockClass}{sidetoctitle}
\sidetocname
\end{BlockClass}
%    \end{macrocode}
% The table of contents is placed into a \element{div} of class \attribute{sidetoccontents}.
%    \begin{macrocode}
\begin{BlockClass}{sidetoccontents}
\LinkHome

\LWR@myshorttoc{sidetoc}
\end{BlockClass}
\LWR@htmlelementclassend{nav}{sidetoc}
}
%    \end{macrocode}
% \end{macro}




% \subsection{Low-level TOC line formatting}

% \begin{macro}{\numberline} \marg{number}
%
% (Called from each line in the |.aux|, |.lof| files.)
%
% Record this section number for further use:
%
% \changes{v0.38}{2017/08/21}{Added trailing \cs{quad}.}
%
%    \begin{macrocode}
\newcommand*{\LWR@numberline}[1]{%
\LWR@sectionnumber{#1}\quad%
}

\LetLtxMacro\numberline\LWR@numberline
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\hypertoc}  \marg{1: depth} \marg{2: type} \marg{3: name} \marg{4: page}
%
% Called by \cs{l@section}, etc. to create a hyperlink to a section.
%
% The autopage label is always created just after the section.
%
% \begin{description}
% \item[\#1] is depth
% \item[\#2] is |section|, |subsection|, etc.
% \item[\#3] the text of the caption
% \item[\#4] page number
% \end{description}
%    \begin{macrocode}
\NewDocumentCommand{\hypertoc}{m m +m m}{%
%    \end{macrocode}
% Respond to tocdepth:
%    \begin{macrocode}
\ifthenelse{\cnttest{#1}{<=}{\value{tocdepth}}}{%
    \LWR@startpars%
%    \end{macrocode}
% Create an \HTML\ link to filename\#autosec-(page), with text of the caption,
% of the given \HTML\ class.
%    \begin{macrocode}
    \LWR@subhyperrefclass{%
    \LWR@htmlrefsectionfilename{autopage-#4}\#autosec-#4}{#3}{toc#2}%
    \LWR@stoppars%
}
{}
}
%    \end{macrocode}
% \end{macro}

% \DescribeCounter{lofdepth} \TOC\ depth for figures.
%    \begin{macrocode}
\newcounter{lofdepth}
\setcounter{lofdepth}{1}
%    \end{macrocode}

% \DescribeCounter{lotdepth} \TOC\ depth for tables.
%    \begin{macrocode}
\newcounter{lotdepth}
\setcounter{lotdepth}{1}
%    \end{macrocode}


% \begin{macro}{\hypertocfloat} \marg{1: depth} \marg{2: type}
%			\marg{3: ext of parent} \marg{4: caption} \marg{5: page}
%
% \begin{description}
% \item[\#1] is depth
% \item[\#2] is |figure|, |table|, etc.
% \item[\#3] is |lof|, |lot|, of the parent.
% \item[\#4] the text of the caption
% \item[\#5] page number
% \end{description}
%
% \changes{v0.24}{2017/03/06}{List of floats responds to \texttt{lofdepth}, \texttt{lotdepth}.}
%
%    \begin{macrocode}
\newcommand{\hypertocfloat}[5]{%
\LWR@startpars
%    \end{macrocode}
% If some float-creation package has not yet defined
% the float type's |lofdepth| counter, etc, define it here:
%    \begin{macrocode}
\@ifundefined{c@#3depth}{%
\newcounter{#3depth}%
\setcounter{#3depth}{1}%
}{}%
%    \end{macrocode}
% Respond to |lofdepth|, etc.:
%    \begin{macrocode}
\LWR@traceinfo{hypertocfloat depth is #1 #3depth is \arabic{#3depth}}%
\ifthenelse{\cnttest{#1}{<=}{\arabic{#3depth}}}{%
    \LWR@startpars%
%    \end{macrocode}
% Create an \HTML\ link to
% filename\#autoid-(float number), with text of the caption,
% of the given \HTML\ class.
%    \begin{macrocode}
    \LWR@subhyperrefclass{%
    \LWR@htmlrefsectionfilename{autopage-\arabic{LWR@nextautopage}}%
    \#autoid-\arabic{LWR@nextautoid}}%
    {#4}{toc#2}%
    \LWR@stoppars%
}{}%
}
%    \end{macrocode}
% \end{macro}

% Automatically called by |\contentsline|:
%    \begin{macrocode}
\renewcommand{\l@part}[2]{\hypertoc{-1}{part}{#1}{#2}}
\DeclareDocumentCommand{\l@chapter}{m m}
    {\hypertoc{0}{chapter}{#1}{#2}}
\renewcommand{\l@section}[2]{\hypertoc{1}{section}{#1}{#2}}
\renewcommand{\l@subsection}[2]{\hypertoc{2}{subsection}{#1}{#2}}
\renewcommand{\l@subsubsection}[2]
    {\hypertoc{3}{subsubsection}{#1}{#2}}
\renewcommand{\l@paragraph}[2]{\hypertoc{4}{paragraph}{#1}{#2}}
\renewcommand{\l@subparagraph}[2]{\hypertoc{5}{subparagraph}{#1}{#2}}
\renewcommand{\l@figure}[2]{\hypertocfloat{1}{figure}{lof}{#1}{#2}}
\renewcommand{\l@table}[2]{\hypertocfloat{1}{table}{lot}{#1}{#2}}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \section{Index and glossary}
% \label{sec:index}

% See:\\
% \href{http://tex.stackexchange.com/questions/187038/how-to-mention-section-number-in-index-created-by-imakeidx}
%   {\texttt{http://tex.stackexchange.com/questions/187038/\\
%		\hspace*{2em}how-to-mention-section-number-in-index-created-by-imakeidx}}

% Index links are tracked by the counter |LWR@autoindex|.
% This counter is used to create a label for each index entry, and
% a reference to this label for each entry in the index listing.
% This method allows each index entry to link directly to its exact position in the document.

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


%    \begin{macrocode}
\newcounter{LWR@autoindex}
\setcounter{LWR@autoindex}{0}

\newcounter{LWR@autoglossary}
\setcounter{LWR@autoglossary}{0}
%    \end{macrocode}



% \begin{macro}{\printindex}
%    \begin{macrocode}
\let\LWR@origprintindex\printindex

\renewcommand*{\printindex}
{
\LWR@startpars
\LWR@origprintindex
}
%    \end{macrocode}
% \end{macro}

% \begin{environment}{theindex}
%    \begin{macrocode}
\@ifundefined{chapter}
{\newcommand*{\LWR@indexsection}[1]{\section*{#1}}}
{\newcommand*{\LWR@indexsection}[1]{\chapter*{#1}}}

\renewenvironment*{theindex}{%
\LWR@indexsection{\indexname}%
\let\item\LWR@indexitem%
\let\subitem\LWR@indexsubitem%
\let\subsubitem\LWR@indexsubsubitem%
}{}
%    \end{macrocode}
% \end{environment}


% \begin{macro}{\LWR@indexitem}
%    \begin{macrocode}
\newcommand{\LWR@indexitem}{

\InlineClass{indexitem}{}
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@indexitem}
%    \begin{macrocode}
\newcommand{\LWR@indexsubitem}{

\InlineClass{indexsubitem}{}
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@indexitem}
%    \begin{macrocode}
\newcommand{\LWR@indexsubsubitem}{

\InlineClass{indexsubsubitem}{}
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\@wrindex} \marg{term} \qquad
% Redefined to write the |LWR@latestautopage| counter instead of |page|
% \changes{v0.28}{2017/04/13}{Improved indexing.}
%    \begin{macrocode}
\def\LWR@wrindex#1{%
\addtocounter{LWR@autoindex}{1}%
\LWR@newlabel{LWRindex-\theLWR@autoindex}%
\protected@write\@indexfile{}%
{\string\indexentry{#1}{\theLWR@autoindex}}%
\endgroup
\@esphack}

\let\@wrindex\LWR@wrindex
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\@wrglossary} \marg{term} \qquad
% Redefined to write the |LWR@latestautopage| counter instead of |page|
%    \begin{macrocode}
\def\@wrglossary#1{%
\addtocounter{LWR@autoglossary}{1}%
\LWR@newlabel{LWRglossary-\theLWR@autoglossary}%
\protected@write\@glossaryfile{}%
{\string\glossaryentry{#1}{\theLWR@autoglossary}}%
\endgroup
\@esphack}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\hyperindexref} \marg{autosecnumber}
%
% |\hyperindexref{web address}| is inserted into |*.ind| by
% the xindy style file |lwarp.xdy|
%
% \changes{v0.20}{2016/12/19}{Print mode provided in case hyperref not used.}
% \changes{v0.28}{2017/04/13}{Improved indexing.}
%    \begin{macrocode}
\newcommand*{\hyperindexref}[1]{\nameref{LWRindex-#1}}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \codeprint
%
% A null command for print mode, in case \pkg{hyperref} was not used:
%    \begin{macrocode}
\begin{warpprint}
\newcommand{\hyperindexref}[1]{#1}
\end{warpprint}
%    \end{macrocode}



% \codeall
%
% For the \pkg{glossaries} package, try to prevent an error where
% \cs{glo@name} was not found:
%
% \changes{v0.32}{2017/06/08}{\pkg{glossaries}: Prevent error with \cs{glo@name} not defined.}
%    \begin{macrocode}
\begin{warpall}
\providecommand{\glo@name}{}
\end{warpall}
%    \end{macrocode}



% \section{Restoring original formatting}
%
%
% \begin{macro}{\LWR@restoreorigformatting}
% Used to temporarily restore
% the print-mode meaing of a number of formatting, graphics, and symbols-related
% macros while generating \SVG\ math or a \env{lateximage}.
% A number of packages will \cs{appto} additional actions to this macro.
%
% Various packages add to this macro using \cs{appto}.
%
% \label{sec:restoreorigformatting}
%
% \changes{v0.34}{2017/08/05}{Improved font control.}
% \changes{v0.34}{2017/08/08}{\pkg{booktabs}: Works inside \env{lateximage}.}
% \changes{v0.36}{2017/08/16}{\pkg{siunitx}: Improved super/subscripts in a \env{lateximage}.}
% \changes{v0.39}{2017/09/01}{Appended with \cs{appto} instead of calling various macros.}
% \changes{v0.40}{2017/09/09}{Improved symbols inside a \env{lateximage}.}
% \changes{v0.40}{2017/09/09}{Improved \protect\LaTeX\ logos inside a \env{lateximage}.}
% \changes{v0.40}{2017/09/09}{Nullified \cs{InlineClass}, etc. inside a \env{lateximage}.}
%
%    \begin{macrocode}
\newcommand*{\LWR@restoreorigformatting}{%
\LWR@traceinfo{LWR@restoreorigformatting}%
\linespread{1}%
%    \end{macrocode}
% \changes{v0.43}{2017/10/31}{Fix: \cs{ref} in math or lateximage.}
%    \begin{macrocode}
\LetLtxMacro\ref\LWR@origref%{} syntax highlighting
\RenewDocumentCommand{\InlineClass}{o m +m}{##3}%
\RenewDocumentEnvironment{BlockClass}{o m}{}{}%
\renewcommand{\BlockClassSingle}[2]{##2}%
\LetLtxMacro{\hspace}{\LWR@orighspace}%
\LetLtxMacro\rule\LWR@origrule%
\let\,\LWR@origcomma% disable HTML short unbreakable space
\let\textellipsis\LWR@origtextellipsis%
\let\textless\LWR@origtextless%
\let\textgreater\LWR@origtextgreater%
\LetLtxMacro{\textrm}{\LWR@origtextrm}%
\LetLtxMacro{\textsf}{\LWR@origtextsf}%
\LetLtxMacro{\texttt}{\LWR@origtexttt}%
\LetLtxMacro{\textbf}{\LWR@origtextbf}%
\LetLtxMacro{\textmd}{\LWR@origtextmd}%
\LetLtxMacro{\textit}{\LWR@origtextit}%
\LetLtxMacro{\textsl}{\LWR@origtextsl}%
\LetLtxMacro{\textsc}{\LWR@origtextsc}%
\LetLtxMacro{\textup}{\LWR@origtextup}%
\LetLtxMacro{\textnormal}{\LWR@origtextnormal}%
\LetLtxMacro{\emph}{\LWR@origemph}%
\LetLtxMacro{\rmfamily}{\LWR@origrmfamily}%
\LetLtxMacro{\sffamily}{\LWR@origsffamily}%
\LetLtxMacro{\ttfamily}{\LWR@origttfamily}%
\LetLtxMacro{\bfseries}{\LWR@origbfseries}%
\LetLtxMacro{\mdseries}{\LWR@origmdseries}%
\LetLtxMacro{\upshape}{\LWR@origupshape}%
\LetLtxMacro{\slshape}{\LWR@origslshape}%
\LetLtxMacro{\scshape}{\LWR@origscshape}%
\LetLtxMacro{\itshape}{\LWR@origitshape}%
\LetLtxMacro{\em}{\LWR@origem}%
\LetLtxMacro{\normalfont}{\LWR@orignormalfont}%
\let\sp\LWR@origsp%
\let\sb\LWR@origsb%
\LetLtxMacro\textsuperscript\LWR@origtextsuperscript%
\LetLtxMacro\@textsuperscript\LWR@orig@textsuperscript%
\LetLtxMacro\textsubscript\LWR@origtextsubscript%
\LetLtxMacro\@textsubscript\LWR@orig@textsubscript%
\LetLtxMacro\underline\LWR@origunderline%
\let~\LWR@origtilde%
\let\enskip\LWR@origenskip%
\let\quad\LWR@origquad%
\let\qquad\LWR@origqquad%
\LetLtxMacro{\tabular}{\LWR@origtabular}%
\LetLtxMacro{\endtabular}{\LWR@origendtabular}%
\LetLtxMacro\toprule\LWR@origtoprule%
\LetLtxMacro\midrule\LWR@origmidrule%
\LetLtxMacro\cmidrule\LWR@origcmidrule%
\LetLtxMacro\bottomrule\LWR@origbottomrule%
\LetLtxMacro\addlinespace\LWR@origaddlinespace%
\LetLtxMacro\morecmidrules\LWR@origmorecmidrules%
\LetLtxMacro\specialrule\LWR@origspecialrule%
\let\newline\LWR@orignewline%
\LetLtxMacro{\raisebox}{\LWR@origraisebox}%
\LetLtxMacro\includegraphics\LWR@origincludegraphics%
\LetLtxMacro{\scalebox}{\LWR@origscalebox}%
\LetLtxMacro{\rotatebox}{\LWR@origrotatebox}%
\let\reflectbox\LWR@origreflectbox%
\LetLtxMacro\resizebox\LWR@origresizebox%
\let\framebox\LWR@origframebox%
\let\makebox\LWR@origmakebox%
\let\fbox\LWRprint@fbox%
\let\fboxBlock\LWRprint@fbox%
\LetLtxMacro{\fminipage}{\LWRprint@fminipage}%
\LetLtxMacro{\endfminipage}{\endLWRprint@fminipage}%
\LetLtxMacro{\minipage}{\LWR@origminipage}%
\let\endminipage\LWR@endminipage%
\LetLtxMacro{\parbox}{\LWR@origparbox}%
\let\TeX\LWR@origTeX%
\let\LaTeX\LWR@origLaTeX%
\let\LaTeXe\LWR@origLaTeXe%
\renewcommand*{\Xe}{X\textsubscript{E}}%
%    \end{macrocode}
% \changes{v0.42}{2017/10/16}{Improved \cs{ensuremath}.}
%    \begin{macrocode}
\LetLtxMacro\@ensuredmath\LWR@origensuredmath%
%    \end{macrocode}
% \changes{v0.43}{2017/10/31}{Fix: Improved math inside lateximages.}
%    \begin{macrocode}
\csletcs{equation*}{LWR@origequationstar}%
\csletcs{endequation*}{LWR@origendequationstar}%
%
\LWR@restoreorigaccents%
\LWR@restoreoriglists%
%
\LWR@FBcancel%
}
%    \end{macrocode}
% \end{macro}



% \section{Math}
% \label{sec:math}
%
%
%
% \subsection{Limitations}
%
% \limitsmath
%
%
%
% \subsection{Inline and display math}
%
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \DescribeMacro{\$}
%	Plain dollar signs appearing in the \HTML\ output may be interpreted
%	by MathJax to be math shifts.
%	For a plain text dollar |\$|, print it inside a span to avoid
%	it being interpreted by MathJax, unless are inside a lateximage,
%	in which case it will not be seen by MathJax.
% \changes{v0.19}{2016/06/08}{Avoids MathJax.}
% \changes{v0.26}{2017/03/30}{Dollar span avoided in a lateximage.}
%    \begin{macrocode}
\let\LWR@origtextdollar\$

\renewcommand*{\$}{%
\ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
{\LWR@origtextdollar}%
{\LWR@htmltagc{span}\LWR@origtextdollar\LWR@htmltagc{/span}}%
}
%    \end{macrocode}



%
% \DescribeCounter{LWR@externalfilecnt}
% Counter for the external files which are generated and then referenced from the \HTML:
%    \begin{macrocode}
\newcounter{LWR@externalfilecnt}
%    \end{macrocode}



%    \begin{macrocode}
\LetLtxMacro\LWR@origdollar$
\LetLtxMacro\LWR@secondorigdollar$% balance for editor syntax highlighting
%    \end{macrocode}

%    \begin{macrocode}
\LetLtxMacro\LWR@origopenparen\(
\LetLtxMacro\LWR@origcloseparen\)
\LetLtxMacro\LWR@origopenbracket\[
\LetLtxMacro\LWR@origclosebracket\]
%    \end{macrocode}

% \DescribeObject{\$}
% \DescribeObject{\$\$}
% Redefine the dollar sign to place math inside a \env{lateximage}, or use MathJax:
%    \begin{macrocode}
\begingroup
\catcode`\$=\active%
\protected\gdef${\@ifnextchar$\LWR@doubledollar\LWR@singledollar}%
%    \end{macrocode}


% \begin{macro}{\LWR@doubledollar}
%
% \changes{v0.19}{2016/05/25}{MathJax support.}
% \changes{v0.42}{2017/10/16}{Improved \cs{ensuremath}.}
% \changes{v0.42}{2017/10/16}{Improved line spacing with mathjax.}
%
% Redefine the double dollar sign to place math inside a \env{lateximage}, or use MathJax:
%    \begin{macrocode}
\protected\gdef\LWR@doubledollar$#1$${
%    \end{macrocode}
% If MathJax or formatting for a word processor, print the \LaTeX\ expression:
% \changes{v0.42}{2017/10/26}{If \protect\texttt{FormatWP} print LaTeX expression.}
%    \begin{macrocode}
\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
%    \end{macrocode}
% For MathJax, print the math between |\[| and |\]|:
%    \begin{macrocode}
{

        \textbackslash[%
        \LWR@HTMLsanitize{#1}%
        \textbackslash]

}% mathjax
%    \end{macrocode}
% For SVG, print the math inside a \env{lateximage},
%   with an \element{alt} tag of the \LaTeX\ code:
%    \begin{macrocode}
{% not mathjax

        \begin{lateximage}%
        [\textbackslash{[} \LWR@HTMLsanitize{#1} \textbackslash{]}]%
        \LWR@origdollar\LWR@origdollar#1\LWR@origdollar\LWR@origdollar%
        \end{lateximage}%

}% not mathjax
}%
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@singledollar}
%
% \changes{v0.19}{2016/05/25}{MathJax support.}
%
% Redefine the single dollar sign to place math inside a \env{lateximage}, or use MathJax:
%
% \changes{v0.42}{2017/10/26}{If \protect\texttt{FormatWP} print LaTeX expression.}
%    \begin{macrocode}
\protected\gdef\LWR@subsingledollar#1{%
\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
%    \end{macrocode}
% For MathJax, print the math between |\(| and |\)|:
%    \begin{macrocode}
{%
        {\textbackslash(\LWR@HTMLsanitize{#1}\textbackslash)}%
}% mathjax
%    \end{macrocode}
% For SVG, print the math inside a \env{lateximage}, with an \element{alt} tag of the \LaTeX\ code:
%    \begin{macrocode}
{% not mathjax
        \begin{lateximage}%
        [\textbackslash( \LWR@HTMLsanitize{#1} \textbackslash)]%
        \LWR@origdollar#1\LWR@origdollar%
        \end{lateximage}%
}%
}

\protected\gdef\LWR@singledollar#1${%
\LWR@subsingledollar{#1}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\(}
% \begin{macro}{\)}
% Redefine to the above dollar macros.
%    \begin{macrocode}
\protected\gdef\(#1\){%
$#1$}
\protected\gdef\[#1\]{$$#1$$}

\endgroup



%    \end{macrocode}
% \end{macro}
% \end{macro}



% \begin{macro}{\@ensuredmath} \marg{expression} Not yet adapted to \pkg{lwarp}.
%
% \changes{v0.42}{2017/10/16}{Improved \cs{ensuremath}.}
%
%    \begin{macrocode}
\LetLtxMacro\LWR@origensuredmath\@ensuredmath

\renewcommand{\@ensuredmath}[1]{%
\ifmmode%
    \LWR@origensuredmath{#1}%
\else%
    \LWR@subsingledollar{\relax#1}%
\fi%
}
%    \end{macrocode}
% \end{macro}


% Remove the old |math| and |displaymath| environments:
%    \begin{macrocode}
\let\math\relax
\let\endmath\relax
\let\displaymath\relax
\let\enddisplaymath\relax
%    \end{macrocode}

% \begin{environment}{math}
% 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{math}{\expandafter\(\BODY\)}
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{displaymath}
% 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}
%    \end{macrocode}
% \end{environment}



% \subsection{MathJax support}
% \changes{v0.19}{2016/05/25}{MathJax support added.}
%
% \DescribeCounter{LWR@nextequation} Used to add one to compute the next equation number.
%    \begin{macrocode}
\newcounter{LWR@nextequation}
%    \end{macrocode}
%
%
%
% \begin{macro}{\LWR@syncmathjax} Sets the MathJax equation format
% and number for the following equations.
%
% These MathJax commands are printed inside ``\cs{(}'' and ``\cs{)}'' characters.
% They are printed to \HTML\ output, not interpreted by \LaTeX.
%    \begin{macrocode}
\newcommand*{\LWR@syncmathjax}{%
%    \end{macrocode}
% If using chapters, place the chapter number in front of the equation.
% Otherwise, use the simple equation number.
%    \begin{macrocode}
\ifcsdef{thechapter}{
\InlineClass{hidden}{
\textbackslash(
\textbackslash{}seteqsection \{\thechapter\}
\textbackslash)
}
}
{}% not using chapters
%    \end{macrocode}
% MathJax doesn't allow setting the equation number to 1:
%    \begin{macrocode}
\ifthenelse{\cnttest{\value{equation}}>0}
{
%    \end{macrocode}
% Tell MathJax that the next set of equations begins with the current \LaTeX{} equation
% number, plus one.
%    \begin{macrocode}
    \setcounter{LWR@nextequation}{\value{equation}}
    \addtocounter{LWR@nextequation}{1}
%    \end{macrocode}
% Place the MathJax command inside ``\cs{(}'' and ``\cs{)}'' characters,
% to be printed to \HTML, not interpreted by \LaTeX.
%    \begin{macrocode}
    \InlineClass{hidden}{
        \textbackslash(
        \textbackslash{}seteqnumber \{\arabic{LWR@nextequation}\}
        \textbackslash)
    }
}{}% not eq > 0
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@hidelatexequation} \marg{environment} \marg{contents}
%
% Creates the \LaTeX{} version of the equation
% inside an \HTML\ comment.
%    \begin{macrocode}
\NewDocumentCommand{\LWR@hidelatexequation}{m +m}{%
%    \end{macrocode}
% Stop \HTML\ paragraph handling and open an \HTML\ comment:
%    \begin{macrocode}
\LWR@stoppars
\LWR@htmlopencomment

%    \end{macrocode}
% Start the \LaTeX\ math environment inside the \HTML\ comment:
%    \begin{macrocode}
\begingroup
\csuse{LWR@orig#1}
%    \end{macrocode}
% While in the math environment,
% restore various commands to their \LaTeX\ meanings.
%    \begin{macrocode}
\LWR@restoreorigformatting
%    \end{macrocode}
% ^^A When a label is encountered, the \HTML\ comment is closed,
% ^^A the label is generated in an HTML-output context,
% ^^A then the \HTML\ comment is opened again.
% See \cs{LWR@htmlmathlabel} in \cref{sec:amsmathsupport}.
%
% Print the contents of the equation:
%    \begin{macrocode}
#2
%    \end{macrocode}
% End the \LaTeX{} math environment inside the \HTML\ comment:
%    \begin{macrocode}
\csuse{LWR@origend#1}
\endgroup

%    \end{macrocode}
% Close the \HTML\ comment and resume \HTML\ paragraph handling:
%    \begin{macrocode}
\LWR@htmlclosecomment
\LWR@startpars
}
%    \end{macrocode}
% \end{macro}


%
% \begin{macro}{\LWR@addmathjax} \marg{environment} \marg{contents}
%
% Given the name of a math environment and its contents,
% create a MathJax instance.
% The contents are printed to \HTML\ output, not interpreted by \LaTeX.
%    \begin{macrocode}
\NewDocumentCommand{\LWR@addmathjax}{m +m}{%
%    \end{macrocode}
% Enclose the MathJax environment inside printed ``\cs{(}'' and ``\cs{)}'' characters.
%    \begin{macrocode}
\LWR@origtilde\LWR@orignewline
\textbackslash{}begin\{#1\}
%    \end{macrocode}
% Print the contents, sanitizing for \HTML\ special characters.
%    \begin{macrocode}
\LWR@HTMLsanitizeexpand{\detokenize\expandafter{#2}}
%    \end{macrocode}
% Close the MathJax environment:
%    \begin{macrocode}
\textbackslash{}end\{#1\}
\LWR@orignewline
}
%    \end{macrocode}
% \end{macro}


% \subsection{Equation environment}
%
% Remember existing \env{equation} environment:
%    \begin{macrocode}
\let\LWR@origequation\equation
\let\LWR@origendequation\endequation
%    \end{macrocode}
%
% Remove existing \env{equation} environment:
%    \begin{macrocode}
\let\equation\relax
\let\endequation\relax
%    \end{macrocode}


% \begin{environment}{equation}
% \changes{v0.19}{2016/05/25}{MathJax support.}
% The new \env{equation} environment is created with
% \cs{NewEnviron} (from the \pkg{environ} package),
% which stores the contents of its environment in a
% macro called \cs{BODY}.
%
% For \SVG\ math output, 
% the contents are typeset using the original \env{equation}
% inside a \env{lateximage}, along with an \element{alt} tag
% containing a detokenized copy of the \LaTeX\ source for
% the math.
%
% For MathJax output, the contents are typeset in an
% original \env{equation} environment placed inside a \HTML\
% comment, with special processing for \cs{label}s.
% The contents are also printed to the \HTML\ output
% for processing by the MathJax script.
%    \begin{macrocode}
\NewEnviron{equation}{%

%    \end{macrocode}
% If |mathjax| or |FormatWP|, print the \LaTeX\ expression:
% \changes{v0.42}{2017/10/26}{If \protect\texttt{FormatWP} print LaTeX expression.}
%    \begin{macrocode}
\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
%    \end{macrocode}
% MathJax output:
%    \begin{macrocode}
{
%    \end{macrocode}
% Print commands to syncronize MathJax's equation number and format
% to the current \LaTeX\ chapter/section and equation number:
%    \begin{macrocode}
    \LWR@syncmathjax
%    \end{macrocode}
% Print the \LaTeX\ math inside an \HTML\ comment:
%    \begin{macrocode}
    \LWR@hidelatexequation{equation}{\BODY}
}
%    \end{macrocode}
% SVG output:
% Create the |lateximage| along with an \HTML\ \element{alt} tag
% having an equation number, the \LaTeX{} equation environment
% commmands, and the contents of the environment's \cs{BODY}.
%    \begin{macrocode}
{% not mathjax
%    \end{macrocode}
% Begin the \env{lateximage} with an \element{alt} tag containing the math source:
%    \begin{macrocode}
    \begin{lateximage}[(\LWR@equationtag) \textbackslash{begin\{equation\}} %
    \LWR@HTMLsanitizeexpand{\detokenize\expandafter{\BODY}} %
    \textbackslash{end\{equation\}}]% alt tag
%    \end{macrocode}
% Create the actual \LaTeX-formatted equation inside
% the |lateximage| using the contents of the environment.
%    \begin{macrocode}
    \LWR@origequation
    \BODY% contents collected by NewEnviron
    \LWR@origendequation
    \end{lateximage}%
}% not mathjax

%    \end{macrocode}
% After the environment, if MathJax, print the math to the \HTML\ output
% for MathJax processing:
%    \begin{macrocode}
}[%
    \ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
    {%
        \LWR@addmathjax{equation}{\BODY}%
    }{}%

]
%    \end{macrocode}
% \end{environment}


% \begin{environment}{equation*}
%    \begin{macrocode}
\csletcs{LWR@origequationstar}{equation*}
\csletcs{LWR@origendequationstar}{endequation*}
\renewenvironment*{equation*}
{\displaymath}
{\enddisplaymath}
%    \end{macrocode}
% \end{environment}




% \subsection{AMS Math environments}
% \changes{v0.19}{2016/05/25}{MathJax support added.}
%
% \subsubsection{Support macros}
% \label{sec:amsmathsupport}
%
% \DescribeBoolean{LWR@amsmultline} True if processing a multline environment.
%
% To compensate for \env{multline}-spefific code,
% |LWR@amsmultline| is used to add extra horizontal space in \cs{LWR@htmlmathlabel} if
% is used in an \pkg{amsmath} environment which is
% not a \env{multline} environment and not an \env{equation}.
%    \begin{macrocode}
\newbool{LWR@amsmultline}
\boolfalse{LWR@amsmultline}
%    \end{macrocode}


% \begin{macro}{\LWR@htmlmathlabel} \marg{label}
% \index{label>math environment}
%
% \pkg{lwarp} points \cs{ltx@label} here.
% This is used by \cs{label} when inside a
% \LaTeX{} AMS math environment's math display environment.
%
% \cs{LWR@origltx@label} points to the \LaTeX\ original,
% modified by \pkg{lwarp}, then by \pkg{amsmath},
% then by \pkg{cleveref}.
%    \begin{macrocode}
\newcommand*{\LWR@htmlmathlabel}[1]{%
\LWR@traceinfo{LWR@htmlmathlabel #1}%
%    \end{macrocode}
% If |mathjax| or |FormatWP|, print the \LaTeX\ expression:
% \changes{v0.42}{2017/10/26}{If \protect\texttt{FormatWP} print LaTeX expression.}
%    \begin{macrocode}
\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{%
%    \end{macrocode}
% The combined \LaTeX\ \& \HTML\ label is printed in a \cs{text} field:
%    \begin{macrocode}
    \text{
%    \end{macrocode}
% Shift the label over to the right side of the environment to avoid
% over-printing the math:
%    \begin{macrocode}
    \ifbool{LWR@amsmultline}{}{\hspace*{\totwidth@}}
%    \end{macrocode}
% Temporarily end the \HTML\ comment,
% insert the \LaTeX{} \& \HTML\ label, then
% resume the \HTML\ comment.
% \cs{@firstofone} is required to remove extra braces
%	introduced by the \pkg{amsmath} package.)
%    \begin{macrocode}
    \LWR@htmlclosecomment%
    \LWR@origltx@label{#1}%
    \LWR@htmlopencomment%
    }% text
}% mathjax
{%
    \LWR@origltx@label{#1}%
}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@beginhideamsmath}
% Starts hiding \LaTeX\ math inside an \HTML\ comment.
%    \begin{macrocode}
\newcommand*{\LWR@beginhideamsmath}{
\LWR@stoppars
\LWR@origtilde\LWR@orignewline
\LWR@htmlopencomment

\begingroup
\LWR@restoreorigformatting
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@endhideamsmath}
% Ends hiding \LaTeX\ math inside an \HTML\ comment.
%    \begin{macrocode}
\newcommand*{\LWR@endhideamsmath}{
\endgroup

\LWR@htmlclosecomment
\LWR@orignewline
\LWR@startpars
}
%    \end{macrocode}
% \end{macro}




% \subsubsection{Environment patches}
%
% \changes{v0.19}{2016/05/25}{MathJax support added.}
% \changes{v0.33}{2017/06/20}{Fix: Incorrectly-inline math environments.}
% \changes{v0.34}{2017/07/29}{Fix: Added the \protect\texttt{eqnarray} environments.}
%
% The following \pkg{amsmath} environments already collect their contents
% in \cs{@envbody} for further processing.  \env{eqnarray} is not an \AmS\ package,
% and thus requires special handling.
%
% For \SVG\ math: Each envrionment is encapsulated inside a \env{lateximage} environment,
% along with a special optional argument of \cs{LWR@amsmathbody}
% or \cs{LWR@amsmathbodynumbered}
% telling \env{lateximage} to use as the \HTML\ \element{alt} tag
% the environment's contents which
% were automatically captured by the \AmS{} environment.
%
% For MathJax: Each environment is syched with \LaTeX's equation numbers,
% typeset with \LaTeX\ inside an \HTML\ comment, then
% printed to \HTML\ output for MathJax to process.
%


% \begin{environment}{eqnarray}
%
% This environmnet is not an \AmS\ environment and thus its body is not
% automatically captured, so the \pkg{environ} package is used to
% capture the environment into \cs{BODY}.
%    \begin{macrocode}
\let\LWR@origeqnarray\eqnarray
\let\LWR@origendeqnarray\endeqnarray
%    \end{macrocode}
%
% To remember whether the starred environment was used, and thus
% whether to number the equations:
%    \begin{macrocode}
\newbool{LWR@numbereqnarray}
\booltrue{LWR@numbereqnarray}
%    \end{macrocode}
%
% Common code used by \env{eqnarray} and \env{Beqnarray} (from \pkg{fancybox}):
%    \begin{macrocode}
\newcommand{\LWR@eqnarrayfactor}{%
%    \end{macrocode}
%
% If |mathjax| or |FormatWP|, print the \LaTeX\ expression:
% \changes{v0.42}{2017/10/26}{If \protect\texttt{FormatWP} print LaTeX expression.}
%    \begin{macrocode}
\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{%
%    \end{macrocode}
%
% If MathJax, the environment contents (the \cs{BODY}) are executed in a
% \HTML\ comment to trigger the correct equation number increment (if not starred),
% then are included verbatim in the output for MathJax to interpret:
%    \begin{macrocode}
    \LWR@syncmathjax
    \boolfalse{LWR@amsmultline}
    \ifbool{LWR@numbereqnarray}
    {
%    \end{macrocode}
%
% If numbering the equations, execute a copy inside an \HTML\ comment block:
%    \begin{macrocode}
        \LWR@beginhideamsmath
        \LWR@origeqnarray
        \BODY
        \LWR@origendeqnarray
        \LWR@endhideamsmath
%    \end{macrocode}
%
% Then print the (sanitized) contents to the output for MathJax to interpret:
%    \begin{macrocode}
        \LWR@addmathjax{eqnarray}{\BODY}
    }%
    {% not LWR@numbereqnarray
%    \end{macrocode}
%
% If not numbering equations, just create the contents for MathJax:
%    \begin{macrocode}
    \LWR@addmathjax{eqnarray*}{\BODY}
    }% LWR@numbereqnarray
}% mathjax
{% not mathjax
    \ifbool{LWR@numbereqnarray}
    {
%    \end{macrocode}
%
% For numbered \SVG\ equations, first create a \env{lateximage} with
%	an \attribute{alt} attribute containing sanitized copy of the source code:
% \changes{v0.42}{2017/10/12}{Fix: Numbering and naming AMS math environments.}
%    \begin{macrocode}
        \begin{lateximage}[(\LWR@startingequationtag--\LWR@equationtag)
            \LWR@addmathjax{eqnarray}{\BODY}]
%    \end{macrocode}
% Then create the image contents using an actual \env{eqnarray}:
%    \begin{macrocode}
        \LWR@origeqnarray
        \BODY
        \LWR@origendeqnarray
        \end{lateximage}
    }%
    {% not LWR@numbereqnarray
%    \end{macrocode}
% If not numbered, do the same, but an extra \cs{nonumber} seems to be required:
%    \begin{macrocode}
        \begin{lateximage}[\LWR@addmathjax{eqnarray*}{\BODY}]
        \LWR@origeqnarray
        \BODY
        \nonumber
        \LWR@origendeqnarray
        \end{lateximage}
    }% LWR@numbereqnarray
}% not mathjax
%    \end{macrocode}
%
% Default to number equations in the future:
%    \begin{macrocode}
\booltrue{LWR@numbereqnarray}
}
%    \end{macrocode}
%
% \env{eqnarray} itself is made with a blank line before and after to
% force it to be on its own line:
%    \begin{macrocode}
\RenewEnviron{eqnarray}
{%

\LWR@eqnarrayfactor

}
%    \end{macrocode}
%
% The starred version is patched to turn off the numbering:
%    \begin{macrocode}
\csgpreto{eqnarray*}{\boolfalse{LWR@numbereqnarray}}
%    \end{macrocode}
% \end{environment}
%
%
% The following \AmS\ environments are more easily patched in-place:
%
% \changes{v0.44}{2017/11/16}{\pkg{AMS environments}: Fix: Groups for lateximages.}
%
% \begin{environment}{multline}
%    \begin{macrocode}
\BeforeBeginEnvironment{multline}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@syncmathjax
    \booltrue{LWR@amsmultline}
    \LWR@beginhideamsmath
}
{
    \begin{lateximage}[\LWR@amsmathbodynumbered{multline}]
}
}

\AfterEndEnvironment{multline}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \boolfalse{LWR@amsmultline}
    \LWR@addmathjax{multline}{\the\@envbody}
}
{\end{lateximage}}

}
%    \end{macrocode}
% \end{environment}


% \begin{environment}{multline*}
%    \begin{macrocode}
\BeforeBeginEnvironment{multline*}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@syncmathjax
    \booltrue{LWR@amsmultline}
    \LWR@beginhideamsmath
}
{
    \begin{lateximage}[\LWR@amsmathbody{multline*}]
}
}

\AfterEndEnvironment{multline*}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \boolfalse{LWR@amsmultline}
    \LWR@addmathjax{multline*}{\the\@envbody}
}
{\end{lateximage}}

}

%    \end{macrocode}
% \end{environment}


% \begin{environment}{gather}
%    \begin{macrocode}
\BeforeBeginEnvironment{gather}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@syncmathjax
    \boolfalse{LWR@amsmultline}
    \LWR@beginhideamsmath
}
{
    \begin{lateximage}[\LWR@amsmathbodynumbered{gather}]
}
}

\AfterEndEnvironment{gather}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \LWR@addmathjax{gather}{\the\@envbody}
}
{\end{lateximage}}

}
%    \end{macrocode}
% \end{environment}

% \begin{environment}{gather*}
%    \begin{macrocode}
\BeforeBeginEnvironment{gather*}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@syncmathjax
    \boolfalse{LWR@amsmultline}
    \LWR@beginhideamsmath
}
{
    \begin{lateximage}[\LWR@amsmathbody{gather*}]
}
}

\AfterEndEnvironment{gather*}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \LWR@addmathjax{gather*}{\the\@envbody}
}
{\end{lateximage}}

}
%    \end{macrocode}
% \end{environment}


% \begin{environment}{align}
%    \begin{macrocode}
\BeforeBeginEnvironment{align}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@syncmathjax
    \boolfalse{LWR@amsmultline}
    \LWR@beginhideamsmath
}
{
    \begin{lateximage}[\LWR@amsmathbodynumbered{align}]
}
}

\AfterEndEnvironment{align}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \LWR@addmathjax{align}{\the\@envbody}
}
{\end{lateximage}}

}
%    \end{macrocode}
% \end{environment}


% \begin{environment}{align*}
%    \begin{macrocode}
\BeforeBeginEnvironment{align*}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@syncmathjax
    \boolfalse{LWR@amsmultline}
    \LWR@beginhideamsmath
}
{
    \begin{lateximage}[\LWR@amsmathbody{align*}]
}
}

\AfterEndEnvironment{align*}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \LWR@addmathjax{align*}{\the\@envbody}
}
{\end{lateximage}}

}
%    \end{macrocode}
% \end{environment}


% \begin{environment}{flalign}
%    \begin{macrocode}
\BeforeBeginEnvironment{flalign}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@syncmathjax
    \boolfalse{LWR@amsmultline}
    \LWR@beginhideamsmath
}
{
    \begin{lateximage}[\LWR@amsmathbodynumbered{flalign}]
}
}

\AfterEndEnvironment{flalign}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \LWR@addmathjax{flalign}{\the\@envbody}
}
{\end{lateximage}}

}
%    \end{macrocode}
% \end{environment}


% \begin{environment}{flalign*}
%    \begin{macrocode}
\BeforeBeginEnvironment{flalign*}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@syncmathjax
    \boolfalse{LWR@amsmultline}
    \LWR@beginhideamsmath
}
{
    \begin{lateximage}[\LWR@amsmathbody{flalign*}]
}
}

\AfterEndEnvironment{flalign*}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \LWR@addmathjax{flalign*}{\the\@envbody}
}
{\end{lateximage}}

}
%    \end{macrocode}
% \end{environment}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}





% \section{Lateximages}
%
% \subsection{Description}
%
% \DescribeEnv{lateximage}
% A \env{lateximage} is a piece of the document which is typeset in
% \LaTeX\ then included in the \HTML\ output as an image.
% This is used for math if \SVG\ math is chosen, and also
% for the \env{picture}, \env{tikzpicture}, and other environments.
%
% Before typesetting the \env{lateximage} a large number of formatting,
% graphics, and symbols-related macros are temporarily restored
% to their print-mode meaning by \cs{LWR@restoreorigformatting}.
% (See \cref{sec:restoreorigformatting}.)
%
% A \env{lateximage} is typeset on its own \PDF\ page inside an \HTML\ comment
% which starts on the preceeding page and ends on following page, and instructions are written to
% |lateximage.txt| for |lwarpmk| to extract the |\lateximage| from the page of the \PDF\ file
% then generate an accompanying |.svg| file image file.  Meanwhile, instructions to
% show this image are placed into the \HTML\ file after the comment.
%
% An \HTML\ \element{span} is created to hold both the \HTML\ comment,
% which will have the |pdftotext| conversion,
% and also the link to the final |.svg| image.
%
% A \LaTeX\ label is used to remember which \PDF\ page has the image.
% A label is used because footnotes, endnotes, and pagenotes may cause the image to appear
% at a later time.  The label is declared along with the image, and so it correctly remembers
% where the image finally ended up.
%
% \limitslateximagefontsize
%
%
% \subsection{Support counters and macros}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
% \DescribeCounter{LWR@lateximagenumber}
% Sequence the images.
%    \begin{macrocode}
\newcounter{LWR@lateximagenumber}
\setcounter{LWR@lateximagenumber}{0}
%    \end{macrocode}
% \DescribeCounter{LWR@lateximagedepth}
% Do not create |\lateximage| inside of |\lateximage|.
%    \begin{macrocode}
\newcounter{LWR@lateximagedepth}
\setcounter{LWR@lateximagedepth}{0}
%    \end{macrocode}

% A few utility macros to write special characters:
%    \begin{macrocode}
\edef\LWR@hashmark{\string#}	% for use in \write
\edef\LWR@percent{\@percentchar}	% for use in \write
%    \end{macrocode}
%
%
% \DescribeCounter{LWR@LIpage}
% Used to reference the \PDF\ page number of a lateximage
% to be written into |lateximages.txt|.
%    \begin{macrocode}
\newcounter{LWR@LIpage}
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \subsection{Font size}

% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \begin{macro}{\LateximageFontSizeName}
% \changes{v0.19}{2016/05/29}{Add: User-adjustable math/lateximage font size.}
% Declares how large to write text in the |\lateximage|.  The |.svg| file text size
% should blend well with the surrounding \HTML\ text size.
%
% \emph{Do not include the leading backslash in the name.}
% \watchout[no backslash]
%
%    \begin{macrocode}
\newcommand*{\LateximageFontSizeName}{large}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}


% \subsection{Sanitizing math expressions for HTML}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{macro}{\LWR@HTMLsanitize} \marg{text}
%
% Math expressions are converted to |lateximage|s, and some math environments may contain
% ``\&'', ``\textless'', or ``\textgreater'', 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.
% There may be a better way\dots
%
% \changes{v0.36}{2017/08/16}{Fix for \protect\pkg{babel-french}.}
%
%    \begin{macrocode}
\newcommand{\LWR@HTMLsanitize}[1]{%
\begingroup%
\LWR@FBcancel%
\protect\StrSubstitute{\detokenize{#1}}%
{\detokenize{&}}%
{\detokenize{&amp;}}[\LWR@strresult]%
\protect\StrSubstitute{\detokenize\expandafter{\LWR@strresult}}%
{\detokenize{<}}%
{\detokenize{&lt;}}%
[\LWR@strresult]%
\protect\StrSubstitute{\detokenize\expandafter{\LWR@strresult}}%
{\detokenize{>}}%
{\detokenize{&gt;}}%
[\LWR@strresult]%
\protect\StrSubstitute{\detokenize\expandafter{\LWR@strresult}}%
{\detokenize{##}}%
{\#}%
[\LWR@strresult]%
\LWR@strresult%
\endgroup%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@HTMLsanitizeexpand} \marg{text}
%
% This version expands the argument before sanitizing it.
%
% \changes{v0.36}{2017/08/16}{Fix for \protect\pkg{babel-french}.}
%
%    \begin{macrocode}
\newcommand{\LWR@HTMLsanitizeexpand}[1]{%
\begingroup%
\LWR@FBcancel%
\protect\StrSubstitute{\detokenize\expandafter{#1}}%
{\detokenize{&}}%
{\detokenize{&amp;}}%
[\LWR@strresult]%
\protect\StrSubstitute{\detokenize\expandafter{\LWR@strresult}}%
{\detokenize{<}}%
{\detokenize{&lt;}}%
[\LWR@strresult]%
\protect\StrSubstitute{\detokenize\expandafter{\LWR@strresult}}%
{\detokenize{>}}%
{\detokenize{&gt;}}%
[\LWR@strresult]%
\LWR@strresult%
\endgroup%
}
%    \end{macrocode}
% \end{macro}


% \subsection{Equation numbers}

% \DescribeCounter{LWR@startingequation}
%   For use with |lateximage| and multi-line numbered equations.
%   Remembers the next equation number so that it may be printed
%   in the alt tag.
%
% \changes{v0.42}{2017/10/12}{Fix: Numbering and naming AMS math environments.}
%
%    \begin{macrocode}
\newcounter{LWR@startingequation}

\@ifundefined{chapter}
{
\renewcommand{\theLWR@startingequation}{%
\arabic{LWR@startingequation}%
}
}
{% chapter defined
\renewcommand{\theLWR@startingequation}{%
\ifnumcomp{\value{chapter}}{>}{0}{\arabic{chapter}.}{}%
\arabic{LWR@startingequation}%
}
}
%    \end{macrocode}

% \DescribeBoolean{LWR@isstartingequation}
% True for the first equation tag, false for later tags in the same environment.
%    \begin{macrocode}
\newbool{LWR@isstartingequation}
%    \end{macrocode}


% \begin{macro}{\LWR@startingequationtag} \quad
%   Prints the starting equation number or tag.
%    \begin{macrocode}
\let\LWR@startingequationtag\theLWR@startingequation
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@equationtag} \quad
%   Prints the ending equation number or tag.
%    \begin{macrocode}
\let\LWR@equationtag\theequation
%    \end{macrocode}
% \end{macro}


% Only if \SVG\ math, patch \cs{tag} after packages have loaded,
% in case someone else modified \cs{tag}.
%    \begin{macrocode}
\AtBeginDocument{

\ifbool{mathjax}{}{% not mathjax
%    \end{macrocode}

% \begin{macro}{\LWR@remembertag} \marg{tag}
%
% For use inside the math environments while using \SVG\ math.
% Sets \cs{theLWR@startingequation} and \cs{theequation}
% to the given tag.
%
% \changes{v0.42}{2017/10/12}{Fix: Numbering and naming AMS math environments.}
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@remembertag}{m}{%
\ifbool{LWR@isstartingequation}%
{%
    \global\boolfalse{LWR@isstartingequation}%
    \xdef\LWR@startingequationtag{#1}%
}%
{}%
\xdef\LWR@equationtag{#1}%
}%
%    \end{macrocode}
% \end{macro}

% Patches for \AmS\ math \cs{tag} macro to remember the first tag:
%    \begin{macrocode}
\LetLtxMacro\LWR@origmake@df@tag@@\make@df@tag@@
\LetLtxMacro\LWR@origmake@df@tag@@@\make@df@tag@@@

\renewcommand*{\make@df@tag@@}[1]{%
\LWR@remembertag{#1}%
\LWR@origmake@df@tag@@{#1}%
}

\renewcommand*{\make@df@tag@@@}[1]{%
\LWR@remembertag{#1}%
\LWR@origmake@df@tag@@@{#1}%
}

}% not mathjax
}% AtBeginDocument
%    \end{macrocode}


% \subsection{HTML \element{alt} tags}

% \begin{macro}{\LWR@amsmathbody} \marg{envname}
%   For use inside the optional argument to a \env{lateximage}
%   to add the contents of a AMS math environment to the \element{alt} tag.
%
% \changes{v0.42}{2017/10/12}{Fix: Numbering and naming AMS math environments.}
%
%    \begin{macrocode}
\newcommand*{\LWR@amsmathbody}[1]
{%
\textbackslash\{begin\}\{#1\} %
\LWR@HTMLsanitizeexpand{\detokenize\expandafter{\the\@envbody}}%
\textbackslash\{end\}\{#1\}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@amsmathbodynumbered} \marg{envname}
%   For use inside the optional argument to a \env{lateximage}
%   to add the contents of a AMS math environment to the \element{alt} tag,
%   prefixed by the equation numbers.
%
% \changes{v0.42}{2017/10/12}{Fix: Numbering and naming AMS math environments.}
%
%    \begin{macrocode}
\newcommand*{\LWR@amsmathbodynumbered}[1]
{%
\ifnumcomp{\value{LWR@startingequation}}{=}{\value{equation}}%
{(\LWR@equationtag)}%
{(\LWR@startingequationtag--\LWR@equationtag)} %
\LWR@amsmathbody{#1} %
}
%    \end{macrocode}
% \end{macro}


% \subsection{\env{lateximage}}

% \begin{environment}{lateximage} \oarg{\element{alt} tag}
%
% \changes{v0.18}{2016/05/18}{Surpress extra space.}
% \changes{v0.18}{2016/05/18}{pdfcrop: -{}-hires added.}
% \changes{v0.18}{2016/05/19}{Reorganize \cs{HomeHTMLFilename} logic.}
% \changes{v0.26}{2017/03/22}{Print mode now uses a \env{minipage} of \cs{linewidth}.}
% \changes{v0.26}{2017/03/29}{Labels track page numbers of lateximages.}
% \changes{v0.34}{2017/07/29}{Fix: \env{lateximage} with
%		\env{minipage}, \cs{parbox}, \cs{makebox}, \cs{fbox}, \cs{framebox},
%		\cs{raisebox}, \cs{scalebox}, \cs{reflectbox}.}
% \changes{v0.36}{2017/08/16}{Footnotes appear in regular text instead of
%       the \protect\env{lateximage} \protect\env{minipage}.}
%
%    \begin{macrocode}
\catcode`\$=\active%


\NewDocumentEnvironment{lateximage}{O{image}}
{%
\LWR@traceinfo{lateximage: starting on page \arabic{page}}%
%    \end{macrocode}
% Nested |lateximage|s remain one large |lateximage|:
%    \begin{macrocode}
\ifthenelse{\cnttest{\value{LWR@lateximagedepth}}{>}{0}}%
%    \end{macrocode}
% If nesting inside an already-existing lateximage, simply record one more level:
%    \begin{macrocode}
{%
    \addtocounter{LWR@lateximagedepth}{1}%
}%
%    \end{macrocode}
% Otherwise, this is the outer-most lateximage:
%    \begin{macrocode}
{% start of outer-most lateximage
%    \end{macrocode}
% Remember the next equation number to be allocated, in case it must be
% printed in a multi-equation environment:
% \changes{v0.42}{2017/10/12}{Fix: Numbering and naming AMS math environments.}
%    \begin{macrocode}
    \setcounter{LWR@startingequation}{\value{equation}}%
    \addtocounter{LWR@startingequation}{1}%
    \booltrue{LWR@isstartingequation}%
    \let\LWR@startingequationtag\theLWR@startingequation%
    \let\LWR@equationtag\theequation%
%    \end{macrocode}
% Starting a new lateximage:
%    \begin{macrocode}
    \addtocounter{LWR@lateximagenumber}{1}%
    \LWR@traceinfo{lateximage: LWR@lateximagenumber is \arabic{LWR@lateximagenumber}}%
%    \end{macrocode}
% While inside a lateximage, locally do not use mathjax:
%    \begin{macrocode}
    \boolfalse{mathjax}%
%    \end{macrocode}
% Be sure that are doing a paragraph:
%    \begin{macrocode}
    \LWR@ensuredoingapar%
%    \end{macrocode}
% Next file:
%    \begin{macrocode}
    \addtocounter{LWR@externalfilecnt}{1}%
    \LWR@traceinfo{lateximage: LWR@externalfilecnt is \arabic{LWR@externalfilecnt}}%
%    \end{macrocode}
% Figure out what the next page number will be:
%    \begin{macrocode}
    \setcounterpageref{LWR@LIpage}{LWRlateximage\arabic{LWR@lateximagenumber}}%
    \LWR@traceinfo{lateximage: LWR@LIpage is \arabic{LWR@LIpage}}%
%    \end{macrocode}
% Create an \HTML\ span which will hold the comment which contains the |pdftotext| translation
% of the image's page, and also will hold the link to the |.svg| file:
%    \begin{macrocode}
    \LWR@htmltag{span id="lateximage\arabic{LWR@lateximagenumber}" %
    class="lateximagesource"{}} \LWR@orignewline
%    \end{macrocode}
% Write instructions to the |lateximages.txt| file:
%    \begin{macrocode}
    \LWR@traceinfo{lateximage: about to write to lateximages.txt}%
    \immediate\write\LWR@lateximagesfile{|\theLWR@LIpage|\theLWR@externalfilecnt|}%
%    \end{macrocode}
% Place an open comment tag at the bottom of page; footnotes will be above this tag.
% This will hide any traces of the lateximage \PDF\ page which were picked up by
% |pdftotext|.
%    \begin{macrocode}
    \LWR@traceinfo{lateximage: about to create open comment}%
    \LWR@htmlopencomment%
%    \end{macrocode}
% One level deeper:
%    \begin{macrocode}
    \addtocounter{LWR@lateximagedepth}{1}%
%    \end{macrocode}
% Start the new \PDF\ page:
%    \begin{macrocode}
    \LWR@traceinfo{lateximage: about to create a new page}%
    \LWR@orignewpage%
%    \end{macrocode}
% Typeset the image in a ``standard'' width page and font size:
%    \begin{macrocode}
    \LWR@traceinfo{lateximage: about to create minipage}%
    \LWR@origminipage{6in}%
    \csuse{LWR@orig\LateximageFontSizeName}%
%    \end{macrocode}
% Temporarily restore formatting to its \PDF\ definitions:
% Do not produce \HTML\ tags for \cs{hspace}, etc. inside a lateximage.
%    \begin{macrocode}
    \LWR@traceinfo{lateximage: about to temporarily restore formatting}%
    \LWR@restoreorigformatting%
%    \end{macrocode}
% Use full-page footnotes instead of minipage footnotes.
% These become \HTML\ footnotes.
%    \begin{macrocode}
    \def\@mpfn{footnote}%
    \def\thempfn{\thefootnote}%
    \let\@footnotetext\LWR@footnotetext%
%    \end{macrocode}
% Create the |LWRlateximage<number>| label:
%    \begin{macrocode}
    \LWR@traceinfo{lateximage: about to create label}%
    \LWR@origlabel{LWRlateximage\arabic{LWR@lateximagenumber}}%
    \LWR@traceinfo{lateximage: finished creating the label}%
%    \end{macrocode}
% Enable print-mode math functions:
%    \begin{macrocode}
    \LetLtxMacro$\LWR@origdollar%
    \catcode`\$=3% math shift
    \LetLtxMacro\(\LWR@origopenparen%
    \LetLtxMacro\)\LWR@origcloseparen%
    \LetLtxMacro\[\LWR@origopenbracket%
    \LetLtxMacro\]\LWR@origclosebracket%
}% end of outer-most lateximage
\LWR@traceinfo{lateximage: finished start of environment}%
}% end of \begin{lateximage}
%    \end{macrocode}
%
% When the environment closes:
% \margintag{\cs{endlateximage}}
%
%    \begin{macrocode}
{% start of \end{lateximage}
\LWR@traceinfo{lateximage: starting end of environment}%
%    \end{macrocode}
% Nested more than one deep?
%    \begin{macrocode}
\ifthenelse{\cnttest{\value{LWR@lateximagedepth}}{>}{1}}%
%    \end{macrocode}
% If nesting inside an already-existing lateximage, simply record one more level:
%    \begin{macrocode}
{\addtocounter{LWR@lateximagedepth}{-1}}%
%    \end{macrocode}
% If this is the outer-most lateximage:
%    \begin{macrocode}
{% end of outer-most lateximage
%    \end{macrocode}
% Finish the lateximage minipage and start a new \PDF\ page:
%    \begin{macrocode}
    \LWR@origendminipage%
    \LWR@orignewpage%
    \LWR@origscriptsize%
%    \end{macrocode}
% Close the \HTML\ comment which encapsulated any traces of the lateximage picked up by |pdftotext|:
%    \begin{macrocode}
    \LWR@htmlclosecomment{}\LWR@orignewline%
    \LWR@traceinfo{lateximage: The page after the image is \arabic{page}}%
%    \end{macrocode}
% Create a link to the lateximage, allowing its natural height:
%    \begin{macrocode}
    \LWR@subinlineimage[#1]{lateximage}%
    {lateximages\OSPathSymbol{}lateximage-\theLWR@externalfilecnt}{svg}{}%
%    \end{macrocode}
% Be sure that are doing a paragraph:
%    \begin{macrocode}
    \LWR@ensuredoingapar%
%    \end{macrocode}
% Close the \HTML\ span which has the |pdftotext| comment and also the link to the |.svg| image:
%    \begin{macrocode}
    \LWR@htmltag{/span}%
    \ifbool{HTMLDebugComments}{%
        \LWR@htmlcomment{End of lateximage}%
    }{}%
% \LWR@orignewline% Removed to prevent extra space.
%    \end{macrocode}
% Undo one lateximage level:
%    \begin{macrocode}
    \addtocounter{LWR@lateximagedepth}{-1}%
}% end of outer-most lateximage
\LWR@traceinfo{lateximage: done}%
}%
\catcode`\$=3% math shift
\end{warpHTML}
%    \end{macrocode}

% \codeprint
%    \begin{macrocode}
\begin{warpprint}
% \newenvironment{lateximage}[1][]{\minipage{\linewidth}}{\endminipage}
\newenvironment{lateximage}[1][]{}{}
\end{warpprint}
%    \end{macrocode}
% \end{environment}




% \section{\env{center}, \env{flushleft}, \env{flushright}}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{environment}{center}
% Replace \env{center} functionality with \CSS\ tags:
% \changes{v0.42}{2017/10/26}{If \protect\texttt{FormatWP} use explicit \attribute{text-align}.}
%    \begin{macrocode}
\renewenvironment*{center}
{
\LWR@forcenewpage
\ifbool{FormatWP}
{\BlockClass[text-align:center]{center}}
{\BlockClass{center}}
}
{\endBlockClass}
%    \end{macrocode}
% \end{environment}


% \begin{environment}{flushright}
%    \begin{macrocode}
\renewenvironment*{flushright}
{
\LWR@forcenewpage
\ifbool{FormatWP}
{\BlockClass[text-align:right]{flushright}}
{\BlockClass{flushright}}
}
{\endBlockClass}
%    \end{macrocode}
% \end{environment}

% \begin{environment}{flushleft}
%    \begin{macrocode}
\renewenvironment*{flushleft}
{
\LWR@forcenewpage
\ifbool{FormatWP}
{\BlockClass[text-align:left]{flushleft}}
{\BlockClass{flushleft}}
}
{\endBlockClass}
%    \end{macrocode}
% \end{environment}


%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}







% \section{Pre-loaded packages}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
% If \pkg{textcomp} was loaded before \pkg{lwarp},
% perhaps as part of the font-related packages,
% explicitly load the lwarp patches now:
%    \begin{macrocode}
\@ifpackageloaded{textcomp}
{
\LWR@origRequirePackage{lwarp-textcomp}
}
{}
%    \end{macrocode}

% If \pkg{graphics} or \pkg{graphicx} were loaded before \pkg{lwarp},
% perhaps by \pkg{xunicode}, explicitly load the lwarp patches now:
%    \begin{macrocode}
\@ifpackageloaded{graphics}
{
\LWR@origRequirePackage{lwarp-graphics}
}
{}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}






% \section{Siunitx}
% \label{sec:siunitx}

% \DescribePackage{siunitx}
% The \pkg{lwarp} core passes a few options to \pkg{siunitx}.

% \limitssiunitx
%
% \changes{v0.36}{2017/08/16}{\pkg{siunitx}: Fix for \pkg{babel-french}.}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% Options for siunitx:
%    \begin{macrocode}
\PassOptionsToPackage{
    detect-mode=true,
    per-mode=symbol,	% fraction is not seen by pdftotext
%     text-celsius = {\protect\LWRsiunitx@degree{}C},
%     text-degree = {\protect\LWRsiunitx@degree},
}{siunitx}

%    \end{macrocode}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}





% \section{Graphics print-mode modifications}
%
% \index{images>graphicx package}
%
% \subsection{General limitations}
% \limitsgraphics
%
% \subsection{Print-mode modifications}
% \label{sec:graphicsprint}
%
% \codeprint
%
% For print output, accept and then discard the new |class| key:
%    \begin{macrocode}
\begin{warpprint}
\define@key{Gin}{class}{}
%    \end{macrocode}
%
% Print-mode additions for the \pkg{overpic} package.
% See \cref{sec:overpic} for the \HTML\ version.
%    \begin{macrocode}
\AtBeginDocument{
\@ifpackageloaded{overpic}{
\newcommand*{\overpicfontsize}{12}
\newcommand*{\overpicfontskip}{14}
}{}
}
\end{warpprint}
%    \end{macrocode}







% \section{Xcolor boxes}
%
% \label{sec:xcolorpatches}
%
% \DescribePackage{xcolor}
% A few new definitions are provided for enhanced \HTML\ colored boxes,
% and \cs{fcolorbox} is slightly modified.
% Print-mode version are also provided.
%
%
% Print-mode versions of new \pkg{xcolor} defintions.
% These are defined inside \env{warpall} because they are also used
% for \HTML\ while inside a \env{lateximage}.
% They are defined \cs{AtBeginDocument} so that the \pkg{xcolor} originals
% may first be loaded and saved for reuse.
%
% The framed versions are modified to allow a background color of |none|, in which
% case only the frame is drawn, allowing the background page color to show.
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}
%
%
% \textcolor{red}{After \pkg{xparse} may have been loaded \dots}
%    \begin{macrocode}
\AtBeginDocument{
%    \end{macrocode}
% \textcolor{red}{\dots\ and \emph{only} if \pkg{xcolor} was loaded:}
%    \begin{macrocode}
\@ifpackageloaded{xcolor}{
\LWR@traceinfo{patching xcolor}
%    \end{macrocode}
%
% \begin{macro}{\colorboxBlock}
% \cs{colorboxBlock} is the same as \cs{colorbox}:
%    \begin{macrocode}
\LetLtxMacro\colorboxBlock\colorbox
%    \end{macrocode}
% \end{macro}
%
%
%
% In \HTML\ mode, the following is done when \pkg{xcolor} is loaded.
% Following is the print-mode action:
%    \begin{macrocode}
\warpprintonly{
\LetLtxMacro\LWRprint@colorboxBlock\colorbox
\LetLtxMacro\LWRorigprint@fcolorbox\fcolorbox
\LetLtxMacro\LWRorigprint@fcolorboxBlock\fcolorbox
}
%    \end{macrocode}

% \begin{macro}{\fcolorbox}
%	\oarg{framemodel} \marg{framecolor} \oarg{boxmodel} \marg{boxcolor} \marg{text}
%
% In print mode, \cs{fcolorbox} is modified to accept a background color of |none|.
%
% (\cs{fcolorbox} is particular about its optional arguments, thus the
% elaborate combinations of \cs{ifthenelse}.)
%    \begin{macrocode}
\newsavebox{\LWR@colorminipagebox}

\DeclareDocumentCommand{\LWRprint@fcolorbox}{o m o m +m}{%
\LWR@traceinfo{LWRprint@fcolorbox #2 #4}%
%    \end{macrocode}
% Pre-load the contents into an LR box so that they can
% be used inside a \cs{fcolorbox}:
%    \begin{macrocode}
\begin{lrbox}{\LWR@colorminipagebox}%
#5%
\end{lrbox}%
%    \end{macrocode}
% Sort out the various optional arguments and the background color of |none|.
% In each case, the LRbox is placed inside a \cs{fcolorbox}.
%    \begin{macrocode}
\ifthenelse{\equal{#4}{none}}%
{% #4 none
    \LWR@traceinfo{background is none}%
    {% scope the \colorlet
        \colorlet{LWR@currentcolor}{.}%
        \color{#2}%
        \fbox{%
            \color{LWR@currentcolor}%
            \usebox{\LWR@colorminipagebox}%
        }% fbox
    }% colorlet
}% #4 none
{% #4 not none
\LWR@traceinfo{background not none}%
\IfValueTF{#1}%
{%
    \IfValueTF{#3}%
    {\LWRorigprint@fcolorbox[#1]{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
    {\LWRorigprint@fcolorbox[#1]{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
}%
{% no value #1
    \IfValueTF{#3}%
    {\LWRorigprint@fcolorbox{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
    {\LWRorigprint@fcolorbox{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
}% no value #1
}% #4 not none
\LWR@traceinfo{LWRprint@fcolorbox done}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\fcolorboxBlock}
%	\oarg{framemodel} \marg{framecolor} \oarg{boxmodel} \marg{boxcolor} \marg{text}
%
% In print mode, \cs{fcolorboxBlock} is the same as \cs{fcolorbox}.
%    \begin{macrocode}
\LetLtxMacro\LWRprint@fcolorboxBlock\LWRprint@fcolorbox
%    \end{macrocode}
% \end{macro}

% \begin{environment}{fcolorminipage}
%	\oarg{1:framemodel} \marg{2:framecolor} \oarg{3:boxmodel} \marg{4:boxcolor} 
%	\oarg{5:align} \oarg{6:height} \oarg{7:inner-align} \marg{8:width}
%
% In print mode, becomes a \cs{fcolorbox} containing a \env{minipage}:
%    \begin{macrocode}
\NewDocumentEnvironment{LWRprint@fcolorminipage}{o m o m O{c} O{} o m}
{%
\LWR@traceinfo{*** fcolorminipage: #2 #4 #8}%
%    \end{macrocode}
% Pre-load the contents into an LR box so that they can
% be used inside a \cs{fcolorbox}:
%    \begin{macrocode}
\begin{lrbox}{\LWR@colorminipagebox}%
%    \end{macrocode}
% If inner alignment is not given, use the outer alignment instead:
%    \begin{macrocode}
\IfValueTF{#7}%
{\begin{minipage}[#5][#6][#7]{#8}}%
{\begin{minipage}[#5][#6][#5]{#8}}%
}%
{%
\end{minipage}%
\end{lrbox}%
\LWR@traceinfo{*** starting end fcolorminipage #1 #2 #3 #4 #8}%
%    \end{macrocode}
% Sort out the various optional arguments and the background color of |none|.
% In each case, the LRbox is placed inside a \cs{fcolorbox}.
%    \begin{macrocode}
\ifthenelse{\equal{#4}{none}}%
{% #4 none
    {% scope the \colorlet
        \colorlet{LWR@currentcolor}{.}%
        \color{#2}%
        \fbox{%
            \color{LWR@currentcolor}%
            \usebox{\LWR@colorminipagebox}%
        }% fbox
    }% colorlet
}% #4 none
{% #4 not none
    \IfValueTF{#1}%
    {%
    \IfValueTF{#3}%
    {\LWRorigprint@fcolorbox[#1]{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
    {\LWRorigprint@fcolorbox[#1]{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
    }%
    {% no value #1
    \IfValueTF{#3}%
    {\LWRorigprint@fcolorbox{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
    {\LWRorigprint@fcolorbox{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
    }% no value #1
}% #4 not none
\LWR@traceinfo{*** finished end fcolorminipage}%
}
%    \end{macrocode}
% \end{environment}

% \begin{macro}{\LWR@restoreorigprintxcolor}
% Used to activate print-mode additions for \pkg{xcolor}.
% In print mode, this is used immediately following.
% In \HTML\ mode, this is used inside a \env{lateximage}.
%    \begin{macrocode}
\newcommand*{\LWR@restoreorigprintxcolor}{%
\LWR@traceinfo{LWR@restoreorigprintxcolor}%
\LetLtxMacro\colorboxBlock\LWRprint@colorboxBlock%
\LetLtxMacro\fcolorbox\LWRprint@fcolorbox%
\LetLtxMacro\fcolorboxBlock\LWRprint@fcolorboxBlock%
\LetLtxMacro\fcolorminipage\LWRprint@fcolorminipage%
\LetLtxMacro\endfcolorminipage\endLWRprint@fcolorminipage%
}

\appto{\LWR@restoreorigformatting}{%
\LWR@restoreorigprintxcolor%
}
%    \end{macrocode}
% \end{macro}
%
% If print mode, immediately activate the print-mode enhancements for \pkg{xcolor}:
%    \begin{macrocode}
\warpprintonly{\LWR@restoreorigprintxcolor}

\LWR@traceinfo{xcolor patches done}
}{}% xcolor loaded
}% AtBeginDocument
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}







% \section{Cleveref}
% \label{sec:cleveref}

% \DescribePackage{cleveref}
% \pkg{cleveref} package is used as-is with minor patches.
%
% \limitscpageref
%
% \pkg{cleveref} and the following associated macro patches are
% \margintag{loading order}
% automatically preloaded at the end of the preamble via \cs{AtEndPreamble}
% and \cs{AfterEndPreamble}.
% This is done because the \HTML\ conversion requires \pkg{cleveref}.
% The user's document may not require \pkg{cleveref}, thus the user
% may never explicitly load it, so during \HTML\ output \pkg{lwarp} loads it last.
% If the user's document preamble uses \pkg{cleveref} options, or functions such as
% \cs{crefname}, then \pkg{cleveref} may be loaded in the user's preamble near the
% end, and \pkg{lwarp}'s additional loading of \pkg{cleveref} will have no effect.
%
% \Cref{tab:crossrefdata} on page \pageref{tab:crossrefdata}
% shows the data structure of the label/reference system
% as revised by \pkg{lwarp} and \pkg{cleveref}.


% A few patches allow \pkg{cleveref} to work as-is:

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
% \cs{AtEndPreable} forces \pkg{cleveref} to be loaded last:
%
% \changes{v0.19}{2016/06/06}{cleveref: Loaded \cs{AtEndPreamble}.}
% \changes{v0.33}{2017/06/18}{cleveref: Fix: Loaded \cs{AtEndPreamble}.}
%
%    \begin{macrocode}
\AtEndPreamble{
\RequirePackage{cleveref}
}
%    \end{macrocode}
%
%
% \changes{v0.20}{2017/01/05}{\pkg{cleveref} and referencing patches: Applied \cs{AfterEndPreamble}.}
%
% \begin{flushleft}
% The following patches are applied after \pkg{cleveref} has loaded,
% and after \cs{AtBeginDocument}:
% \end{flushleft}
%    \begin{macrocode}
\AfterEndPreamble{
\LWR@traceinfo{Patching cleveref.}
%    \end{macrocode}

% \begin{macro}{\@@setcref} \marg{kindofref} \marg{label}

% ^^A |\@templabel| becomes the section number

% ^^A original: \def\@@setcref#1#2{\cref@getlabel{#2}{\@templabel}#1{\@templabel}{}{}}

%    \begin{macrocode}
\renewcommand*{\@@setcref}[2]{#1{\ref{#2}}{}{}}
%    \end{macrocode}
% \end{macro}

% ^^A orig:
% ^^A  \def\@@setcrefrange#1#2#3{%
% ^^A    \cref@getlabel{#2}{\@labela}%
% ^^A    \cref@getlabel{#3}{\@labelb}%
% ^^A    #1{\@labela}{\@labelb}{}{}{}{}}

%\begin{macro}{\@@setcrefrange} \marg{text} \marg{label} \marg{label}
%    \begin{macrocode}
\renewcommand{\@@setcrefrange}[3]{%
#1{\ref{#2}}{\ref{#3}}{}{}{}{}}
%    \end{macrocode}
% \end{macro}

% ^^A  orig:
% ^^A  \def\@@setcpageref#1#2{%
% ^^A    \cref@getpageref{#2}{\@temppage}#1{\@temppage}{}{}}


% \label{sec:cpagereffor}
% \begin{macro}{\cpagerefFor} Redefinable word between ``page(s)'' and the page numbers.
%
% \changes{v0.20}{2017/01/03}{User-redefinable word for page references.}
%
%    \begin{macrocode}
\newcommand*{\cpagerefFor}{for}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\@@setcpageref} \marg{typeofref} \marg{label},
% where typeofref is ``page'' or ``pages''
%
%    \begin{macrocode}
\renewcommand*{\@@setcpageref}[2]{%
#1{\cpagerefFor\ \cref{#2}}{}{}%
}
%    \end{macrocode}
% \end{macro}


% ^^A  orig:
% ^^A  \def\@@setcpagerefrange#1#2#3{%
% ^^A    \cref@getpageref{#2}{\@pagea}%
% ^^A    \cref@getpageref{#3}{\@pageb}%
% ^^A    #1{\@pagea}{\@pageb}{}{}{}{}}

%    \begin{macrocode}
\renewcommand{\@@setcpagerefrange}[3]{%
#1{\cpagerefFor\ \cref{#2}}{\cref{#3}}{}{}{}{}}
}% AfterEndPreamble
%    \end{macrocode}


%
% Remember and patch some label-related defintions.
% These will be further encased and patched by other packages later.
%
%    \begin{macrocode}
\LetLtxMacro\LWR@origlabel\label
% \LetLtxMacro\label\LWR@newlabel
\RenewDocumentCommand{\label}{}{\LWR@newlabel}

\LetLtxMacro\LWR@origref\ref
% \LetLtxMacro\ref\LWR@newref
\RenewDocumentCommand{\ref}{}{\LWR@newref}%

\LetLtxMacro\LWR@origpageref\pageref
% \LetLtxMacro\pageref\LWR@newpageref
\RenewDocumentCommand{\pageref}{}{\LWR@newpageref}

\end{warpHTML}
%    \end{macrocode}





% \section{Picture}
% \label{sec:picture}

% \DescribeEnv{picture} The \env{picture} environment is enclosed
% inside a \cs{lateximage}.
%
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{environment}{picture}
% \changes{v0.24}{2017/03/13}{Fix for inline images.}
% \changes{v0.26}{2017/03/30}{Fix for \cs{makebox} in \env{picture}.}
% \changes{v0.44}{2017/11/16}{\pkg{overpic}: Fix: Groups for lateximages.}
%    \begin{macrocode}
\BeforeBeginEnvironment{picture}{\begin{lateximage}}

\AfterEndEnvironment{picture}{\end{lateximage}}
%    \end{macrocode}
% \end{environment}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}





% \section{Boxes and Minipages}
%
% A \CSS\ flexbox is used for minipages and parboxes,
% allowing external and internal vertical positioning.
%
%
% \limitsminipage
%

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \subsection{Counters and lengths}

% \DescribeCounter{LWR@minipagedepth}
% Used to only reset the line width at the outermost minipage.
%    \begin{macrocode}
\newcounter{LWR@minipagedepth}
\setcounter{LWR@minipagedepth}{0}
%    \end{macrocode}


%
% \DescribeLength{LWR@minipagewidth}
% Used to convert the width into printable units.
%    \begin{macrocode}
\newlength{\LWR@minipagewidth}
%    \end{macrocode}
% \DescribeLength{LWR@minipageheight}
% Used to convert the height into printable units.
%    \begin{macrocode}
\newlength{\LWR@minipageheight}
%    \end{macrocode}
%
%
%
% \subsection{Footnote handling}
%
% Also see \cref{sec:footnotes} for other forms of footnotes.
% Minipage footnotes are gathered in \cref{sec:footnotesminipage},
% and then placed into the document in \cref{sec:footnotesminipageplaced}.
%
% \subsection{Minipage handling}
% \label{sec:footnotesminipageplaced}
%
% \begin{macro}{\LWR@endminipage}
% Used to close a minipage.
%
% Copied the \LaTeX{} definition and modified to create a \element{div} of class  \attribute{mpfootnotes}:
%    \begin{macrocode}
\def\LWR@endminipage{%
    \par
    \unskip
    \ifvoid\@mpfootins\else
      \vskip\skip\@mpfootins
      \normalcolor
        \LWR@htmldivclass{mpfootnotes}
        \LWR@origmedskip
      \unvbox\@mpfootins
        \LWR@htmldivclassend{mpfootnotes}
    \fi
    \@minipagefalse
  \color@endgroup
  \egroup
  \expandafter\@iiiparbox\@mpargs{\unvbox\@tempboxa}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@subminipage}
% Used to create a \PDF\ minipage without creating an \HTML\ minipage.
% This allows footnotes to appear at the bottom of the minipage instead of
% the bottom of the \HTML\ page.
%    \begin{macrocode}
\newcommand*{\LWR@subminipage}{%
\LWR@stoppars
\LWR@origminipage{6in}
%    \end{macrocode}
% |\raggedright| cancels hyphenation, which will be done by \HTML\ instead.
%    \begin{macrocode}
\LWR@origraggedright%
%    \end{macrocode}
% Resume paragraph tag handling for the contents of the minipage:
%    \begin{macrocode}
\LWR@startpars%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@endsubminipage}
% Closes the subminipage.
%    \begin{macrocode}
\newcommand*{\LWR@endsubminipage}{%
\LWR@stoppars%
\LWR@endminipage% The following empty line is required:

}
%    \end{macrocode}
% \end{macro}


% \DescribeBoolean{LWR@minipagefullwidth} Should the next minipage have no \HTML\ |width|?
%    \begin{macrocode}
\newbool{LWR@minipagefullwidth}
\boolfalse{LWR@minipagefullwidth}
%    \end{macrocode}
%
% \begin{macro}{\minipagefullwidth} Requests that the next minipage
% have no |width| tag in \HTML:
% \changes{v0.19}{2016/05/28}{Added: No width tag for the next minipage in HTML.}
%
% \codehtml
%
%    \begin{macrocode}
\newcommand*{\minipagefullwidth}{\booltrue{LWR@minipagefullwidth}}
\end{warpHTML}
%    \end{macrocode}
%
% \codeprint
%
%    \begin{macrocode}
\begin{warpprint}
\newcommand*{\minipagefullwidth}{}
\end{warpprint}
%    \end{macrocode}
%
% \codehtml
%
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
% \end{macro}
%
%
% \DescribeBoolean{LWR@minipagethispar}
% Has a minipage been seen this paragraph?
% If true, prevents paragraph tags around horizontal space
% between minipages.
%    \begin{macrocode}
\newbool{LWR@minipagethispar}
\boolfalse{LWR@minipagethispar}
%    \end{macrocode}
%
%
% \begin{environment}{minipage} \oarg{vert position} \oarg{height} \oarg{inner vert position} \marg{width}
% \changes{v0.18}{2016/05/17}{Fix: \cs{linewidth}, \cs{textwidth}, \cs{textheight} inside a minipage.}
%
% The vertical positions may be 'c', 't', or 'b'.
% The inner position may also be 's'.
%
% When using |\linewidth|, |\textwidth|, or |\textheight|, these are scaled proportionally to a
% 6\texttimes{}9 inch text area.
%
%    \begin{macrocode}
\RenewDocumentEnvironment{minipage}{O{t} o O{t} m}
{%
%    \end{macrocode}
% Units for printing dimensions to \HTML:
%    \begin{macrocode}
\uselengthunit{PT}%
%    \end{macrocode}
% Compute width, adjusted for frames:
%    \begin{macrocode}
\setlength{\LWR@minipagewidth}{#4}%
\ifthenelse{\cnttest{\value{LWR@minipagedepth}}{=}{0}}{%
    \addtolength{\LWR@minipagewidth}{3em}% room for frames
    \setlength{\linewidth}{6in}%
    \setlength{\textwidth}{6in}%
    \setlength{\textheight}{9in}%
}{}%
\LWR@traceinfo{computed width is \rndprintlength{\LWR@minipagewidth}}
%    \end{macrocode}
% Compute height:
%    \begin{macrocode}
\setlength{\LWR@minipageheight}{\textheight}% default unless specified
\IfValueT{#2}{\setlength{\LWR@minipageheight}{#2}}%
%    \end{macrocode}
% Track nesting depth:
%    \begin{macrocode}
\addtocounter{LWR@minipagedepth}{1}%
%    \end{macrocode}
% \LaTeX{} wants to start a paragraph for the new minipage, then start a paragraph again
% for the contents of the minipage, so cancel the  paragraph tag handling
% until the minipage has begun.
%    \begin{macrocode}
\ifbool{FormatWP}{\newline}{}%
\LWR@stoppars%
%    \end{macrocode}
% If |FormatWP|, add a text frame:
% \changes{v0.42}{2017/10/26}{If \protect\texttt{FormatWP} add a text frame.}
%    \begin{macrocode}
\ifbool{FormatWP}{%

\addtocounter{LWR@thisautoid}{1}%
\booltrue{LWR@freezethisautoid}%
\LWR@htmltag{div id="autoid-\arabic{LWR@thisautoid}" class="wpminipage"}%

}{}%
%    \end{macrocode}
% Create the \element{div} tag with optional alignment style:
%    \begin{macrocode}
\LWR@traceinfo{minipage: creating div class}%
\LWR@orignewpage%
\LWR@htmltag{div class="minipage" style="%
\ifthenelse{\equal{#1}{t}}{vertical-align:bottom ; }{}%
\ifthenelse{\equal{#1}{c}}{vertical-align:middle ; }{}%
\ifthenelse{\equal{#1}{b}}{vertical-align:top ; }{}%
\ifthenelse{\equal{#3}{t}}{justify-content:flex-start ; }{}%
\ifthenelse{\equal{#3}{c}}{justify-content:center ; }{}%
\ifthenelse{\equal{#3}{b}}{justify-content:flex-end ; }{}%
\ifthenelse{\equal{#3}{s}}{justify-content:space-between ; }{}%
%    \end{macrocode}
% Print the width and optional height styles:
%    \begin{macrocode}
\LWR@traceinfo{minipage: about to print the width of \rndprintlength{\LWR@minipagewidth}}%
\uselengthunit{PT}%
\ifbool{LWR@minipagefullwidth}%
{\boolfalse{LWR@minipagefullwidth}}%
{%
    \ifthenelse{\lengthtest{#4}=\linewidth}%
    {}%
    {width:\rndprintlength{\LWR@minipagewidth} ; }%
}%
\LWR@traceinfo{minipage: about to print the height}%
\IfValueT{#2}{height:\rndprintlength{\LWR@minipageheight} ; }%
"{}}%
%    \end{macrocode}
% Finish with an empty line to start  \LaTeX{} minipage processing on a new line.
% Use a large minipage area to avoid the unnecessary wrapping of tags.
%    \begin{macrocode}

\LWR@origminipage{6in}% The preceding empty line is required.
%    \end{macrocode}
% Set the user-accessible minipage and text width and height values inside the minipage.
% These do not affect the actual size of the large minipage created by
% \cs{LWR@origminipage} above, but are used by any reference to \cs{linewidth}, etc.
% inside the \PDF\ minipage being created here.
%    \begin{macrocode}
\setlength{\linewidth}{#4}% the original width
\setlength{\textwidth}{6in}%
\setlength{\textheight}{9in}%
%    \end{macrocode}
% |\raggedright| cancels hyphenation, which will be done by \HTML\ instead.
%    \begin{macrocode}
\LWR@origraggedright%
%    \end{macrocode}
% Resume paragraph tag handling for the contents of the minipage:
% \changes{v0.42}{2017/10/18}{Added boolean \protect\texttt{WPMarkMinipages}.}
%    \begin{macrocode}
\LWR@startpars%
\ifboolexpr{bool{FormatWP} and bool{WPMarkMinipages}}{%

=== begin minipage ===

}{}%
\LWR@traceinfo{minipage: finished starting the minipage}%
}
%    \end{macrocode}
% End the environment with \LaTeX{} processing and closing tag:
% \changes{v0.42}{2017/10/18}{Added boolean \protect\texttt{WPMarkMinipages}.}
%    \begin{macrocode}
{%
\ifboolexpr{bool{FormatWP} and bool{WPMarkMinipages}}{%

=== end minipage ===

}{}%
\LWR@stoppars%
\LWR@endminipage% The following empty line is required:

\ifbool{FormatWP}{%

\LWR@htmlelementend{div}%
\boolfalse{LWR@freezethisautoid}%

}{}%
\LWR@htmldivclassend{minipage}%

\LWR@origvspace{1\baselineskip}% required for subcaption
\addtocounter{LWR@minipagedepth}{-1}%
\LWR@startpars%
\ifbool{FormatWP}{\newline}{}%
%    \end{macrocode}
% Prevent paragraph tags around horizontal white space
% until the start of the next paragraph:
%    \begin{macrocode}
\global\booltrue{LWR@minipagethispar}%
}
%    \end{macrocode}
% \end{environment}
%
%
% \subsection{Parbox, makebox, framebox, fbox, raisebox}
%
% \codehtml
%
% \begin{macro}{\parbox} \oarg{pos} \oarg{height} \oarg{inner-pos} \marg{width} \marg{text}
%
% A parbox uses the minipage code:
%    \begin{macrocode}
\RenewDocumentCommand{\parbox}{O{t} o O{t} m +m}
{
\LWR@traceinfo{parbox of width #4}%
\begin{minipage}[#1][#2][#3]{#4}
#5
\end{minipage}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\makebox} \parg(posn) \oarg{width} \oarg{pos} \marg{text}
%
% \changes{v0.34}{2017/07/31}{Fix: Handles paren arg.}
% \changes{v0.36}{2017/08/15}{Fix: Handles width and horiz position.}
%    \begin{macrocode}
\LetLtxMacro\LWR@origmakebox\makebox

\RenewDocumentCommand{\makebox}{d() o o m}{%
%    \end{macrocode}
% Check for the optional width:
%    \begin{macrocode}
\IfValueTF{#2}%
{%
%    \end{macrocode}
% Check for the horizontal text alignment.
% For |s|tretched, the best \HTML\ can do is \attribute{justified} alignment.
%    \begin{macrocode}
    {% scope
    \def\LWR@align{center}%
    \ifstrequal{#3}{l}{\def\LWR@align{left}}{}%
    \ifstrequal{#3}{r}{\def\LWR@align{right}}{}%
    \ifstrequal{#3}{s}{\def\LWR@align{justify}}{}%
%    \end{macrocode}
% To print the \attribute{width} argument:
%    \begin{macrocode}
    \setlength{\LWR@tempwidth}{#2}%
%    \end{macrocode}
% \attribute{inline-block} allows \attribute{width} and
% \attribute{text-alignment} to be used in a \element{span}.
%    \begin{macrocode}
    \uselengthunit{PT}%
    \InlineClass[%
        display:inline-block ; %
        text-align:\LWR@align\ ; %
        width:\rndprintlength{\LWR@tempwidth}%
    ]%
    {makebox}%
%    \end{macrocode}
% Without a width argument, the text is simply used inline:
%    \begin{macrocode}
    {\mbox{#4}}%
    }% scope
}%
{\mbox{#4}}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\framebox} \oarg{width} \oarg{pos} \marg{text}
% \changes{v0.36}{2017/08/15}{Fix: Handles width and horiz position.}
%
%    \begin{macrocode}
\LetLtxMacro\LWR@origframebox\framebox

\RenewDocumentCommand{\framebox}{o o m}{%
\fbox{\makebox[#1][#2]{#3}}%
}
%    \end{macrocode}
% \end{macro}
%
%
%
%
% \begin{macro}{\LWR@forceminwidth} \marg{legth}
%
% Sets \cs{LWR@atleastonept} to be at least 1pt.
%    \begin{macrocode}
\newlength{\LWR@atleastonept}

\newcommand*{\LWR@forceminwidth}[1]{%
\setlength{\LWR@atleastonept}{#1}%
\ifthenelse{%
    \lengthtest{\LWR@atleastonept>0pt}\AND%
    \lengthtest{\LWR@atleastonept<1pt}%
}%
{\setlength{\LWR@atleastonept}{1pt}}%
{}%
}
%    \end{macrocode}
% \end{macro}
%
%

% \begin{macro}{\LWR@blackborderpadding}
% Prints the \HTML\ attributes for a black border and padding.
%
% \cs{LWR@forceminwidth} must be used first in order to set the border width.
%
%    \begin{macrocode}
\newcommand*{\LWR@blackborderpadding}{%
\uselengthunit{PT}%
border:\rndprintlength{\LWR@atleastonept} solid black ; %
padding:\rndprintlength{\fboxsep}%
}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\fbox} \marg{text}
%
% Creates a framed inline span enclosing the text.
%
% \changes{v0.36}{2017/08/10}{Fix: Uses \cs{fboxrule} and \cs{fboxsep}.}
%
% Remember the print-mode version:
%    \begin{macrocode}
\let\LWRprint@fbox\fbox
%    \end{macrocode}
%
% Create a new \HTML\ version, but don't use it until after \pkg{xcolor}
% may have loaded:
%    \begin{macrocode}
\newcommand{\LWRhtml@fbox}[1]{%
\LWR@traceinfo{HTML fbox}
\LWR@forceminwidth{\fboxrule}%
\InlineClass[%
\LWR@blackborderpadding%
]{fbox}{#1}
}
%    \end{macrocode}
% \pkg{xcolor} \cs{let}s things to \cs{fbox} when it is loaded,
% and this must remain even for \HTML\ output while in a \env{lateximage},
% so \cs{fbox} is not modified until \cs{AtBeginDocument}:
%    \begin{macrocode}
\AtBeginDocument{\let\fbox\LWRhtml@fbox}
%    \end{macrocode}
% \end{macro}
%

% \begin{macro}{\fboxBlock} \marg{text}
% Creates a framed \HTML\ \element{div} of the text.
%
% A print-output version is also supplied below.
%
% \changes{v0.34}{2017/07/31}{Added.}
%
%    \begin{macrocode}
\newcommand{\fboxBlock}[1]{%
\LWR@forceminwidth{\fboxrule}%
\begin{BlockClass}[%
\LWR@blackborderpadding%
]{fboxBlock}
#1
\end{BlockClass}
}
%    \end{macrocode}
% \end{macro}

% \begin{environment}{fminipage} \oarg{align} \oarg{height} \oarg{align} \marg{width}
%
% Creates a framed \HTML\ \element{div} around its contents.
%
% A print-output version is also supplied below.
%
% \changes{v0.34}{2017/07/31}{Added.}
%
%    \begin{macrocode}
\NewDocumentEnvironment{fminipage}{O{t} o O{t} m}
{%
\LWR@traceinfo{fminipage #1 #2 #3 #4}%
\LWR@forceminwidth{\fboxrule}%
\setlength{\LWR@tempwidth}{#4}%
\IfValueT{#2}{\setlength{\LWR@tempheight}{#2}}%
\begin{BlockClass}[%
\LWR@blackborderpadding ; %
\uselengthunit{PT}%
\IfValueT{#2}{height:\rndprintlength{\LWR@tempheight} ; }%
width:\rndprintlength{\LWR@tempwidth}%
]{fminipage}%
}
{%
\end{BlockClass}%
\LWR@traceinfo{fminipage done}%
}
%    \end{macrocode}
% \end{environment}
%
%
% \begin{macro}{\raisebox} \marg{raiselen} \oarg{height} \oarg{depth} \marg{text}
%    \begin{macrocode}
\LetLtxMacro{\LWR@origraisebox}{\raisebox}

\RenewDocumentCommand{\raisebox}{m o o m}{%
#4%
}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}
%
%
%
% \env{LWRprint@fminipage} is defined inside \env{warpall}.
% For print output, it is \cs{let} to \env{fminipage}.
% For \HTML\ output, the \HTML\ version of \env{fminipage} is used instead,
% but the print version is still available for use inside a \env{lateximage}.
%
%
% \begin{environment}{LWRprint@fminipage}
%	\oarg{1:align} \oarg{2:height} \oarg{3:inner-align} \marg{4:width}
%
% Creates a frame around its contents.
%    \begin{macrocode}
\newsavebox{\LWR@fminipagebox}

\NewDocumentEnvironment{LWRprint@fminipage}{O{t} o O{t} m}
{%
%    \end{macrocode}
% An outer minipage will be used for vertical alignment.
% An inner minipage will be framed with \cs{fbox}.
%
% If the optional inner alignment is not given, use the outer instead:
%    \begin{macrocode}
\IfValueTF{#3}%
{\def\LWR@thisalign{#3}}
{\def\LWR@thisalign{#1}}%
%    \end{macrocode}
% Form the outer minipage depending on whether a height was given.
% Make the outer minipage larger to compensate for the frame.
%    \begin{macrocode}
\IfValueTF{#2}%
{\minipage[#1][#2+2\fboxsep+2\fboxrule][\LWR@thisalign]{#4+2\fboxsep+2\fboxrule}}%
{\minipage[#1]{#4+2\fboxsep+2\fboxrule}}%
%    \end{macrocode}
% Capture the contents of the environment:
%    \begin{macrocode}
\begin{lrbox}{\LWR@fminipagebox}%
%    \end{macrocode}
% Nest the contents inside an inner minipage of the desired size:
%    \begin{macrocode}
\IfValueTF{#2}%
{\minipage[#1][#2][\LWR@thisalign]{#4}}%
{\minipage[#1]{#4}}%
}
{%
%    \end{macrocode}
% Close the inner minipage and the LR box with the contents:
%    \begin{macrocode}
\endminipage%
\end{lrbox}%
%    \end{macrocode}
% Create a frame around the contents of the environment:
%    \begin{macrocode}
\fbox{\usebox{\LWR@fminipagebox}}%
%    \end{macrocode}
% The entire thing is placed inside the outer minipage:
%    \begin{macrocode}
\endminipage%
}
%    \end{macrocode}
% \end{environment}


%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}



% \codeprint
%    \begin{macrocode}
\begin{warpprint}
%    \end{macrocode}
%
%
% For print output, the following are \cs{let} to become active.
%
%
% \begin{macro}{\fboxBlock} \marg{text}
%
% Creates a framed \HTML\ \element{div} around the text.
%    \begin{macrocode}
\let\fboxBlock\fbox
%    \end{macrocode}
% \end{macro}


% \begin{environment}{fminipage} \oarg{align} \oarg{height} \oarg{align} \marg{width}
%
% Creates a frame around its contents.
%    \begin{macrocode}
\LetLtxMacro{\fminipage}{\LWRprint@fminipage}
\LetLtxMacro{\endfminipage}{\endLWRprint@fminipage}
%    \end{macrocode}
% \end{environment}

%    \begin{macrocode}
\end{warpprint}
%    \end{macrocode}







% \section{Direct formatting}
% \label{sec:directformatting}
%
% \limitstext
%
% For high-level block and inline custom CSS classes,
% see \cref{sec:highlevelclasses}.


% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \changes{v0.34}{2017/08/05}{Improved font control.}
% \changes{v0.35}{2017/08/08}{Fix: \cs{textbf} and related.}
% \changes{v0.42}{2017/10/20}{\cs{textbf} and related: If \protect\texttt{FormatWP}, use explicit styles for
%   \cs{textsc}, etc.}


% \begin{macro}{\LWR@HTMLtextstyle} \marg{FormatWP style} \marg{class} \marg{text}
%
% If |FormatWP|, adds an explicit style to the text span class.
% This is used by LibreOffice to mark its imported text using the given style.
% \changes{v0.42}{2017/10/20}{Added.}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTMLtextstyle}[3]{%
\ifbool{FormatWP}%
{\LWR@htmlspanclass[#1]{#2}{#3}}%
{\LWR@htmlspanclass{#2}{#3}}%
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\emph} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTMLemph}[1]{\LWR@htmlspan{em}{#1}}
\DeclareRobustCommand{\LWR@nullemph}[1]{#1}
\LetLtxMacro{\emph}{\LWR@HTMLemph}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\textmd} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTMLtextmd}[1]{%
\LWR@HTMLtextstyle{font-weight:normal}{textmd}{#1}%
}
\DeclareRobustCommand{\LWR@nulltextmd}[1]{#1}

\LetLtxMacro{\textmd}{\LWR@HTMLtextmd}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\textbf} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTMLtextbf}[1]{\LWR@htmlspan{b}{#1}}
\DeclareRobustCommand{\LWR@nulltextbf}[1]{#1}
\LetLtxMacro{\textbf}{\LWR@HTMLtextbf}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\textrm} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTMLtextrm}[1]{%
\LWR@HTMLtextstyle{font-family:serif}{textrm}{#1}%
}

\DeclareRobustCommand{\LWR@nulltextrm}[1]{#1}

\LetLtxMacro{\textrm}{\LWR@HTMLtextrm}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\textsf} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTMLtextsf}[1]{%
\LWR@HTMLtextstyle{font-family:sans}{textsf}{#1}%
}
\DeclareRobustCommand{\LWR@nulltextsf}[1]{#1}
\LetLtxMacro{\textsf}{\LWR@HTMLtextsf}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\texttt} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTMLtexttt}[1]{\LWR@htmlspan{kbd}{#1}}
\DeclareRobustCommand{\LWR@nulltexttt}[1]{#1}
\LetLtxMacro{\texttt}{\LWR@HTMLtexttt}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\textup} \marg{text}
% \changes{v0.28}{2017/04/13}{Fixed span class.}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTMLtextup}[1]{%
\LWR@HTMLtextstyle{font-variant:normal}{textup}{#1}%
}

\DeclareRobustCommand{\LWR@nulltextup}[1]{#1}

\LetLtxMacro{\textup}{\LWR@HTMLtextup}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\textit} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTMLtextit}[1]{\LWR@htmlspan{i}{#1}}
\DeclareRobustCommand{\LWR@nulltextit}[1]{#1}
\LetLtxMacro{\textit}{\LWR@HTMLtextit}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\textsc} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTMLtextsc}[1]{%
\LWR@HTMLtextstyle{font-variant:small-caps}{textsc}{#1}%
}

\DeclareRobustCommand{\LWR@nulltextsc}[1]{#1}

\LetLtxMacro{\textsc}{\LWR@HTMLtextsc}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\textsl} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTMLtextsl}[1]{%
\LWR@HTMLtextstyle{font-style:oblique}{textsl}{#1}%
}

\DeclareRobustCommand{\LWR@nulltextsl}[1]{#1}

\LetLtxMacro{\textsl}{\LWR@HTMLtextsl}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\textnormal} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTMLtextnormal}[1]{\textmd{\textrm{\textup{#1}}}}
\DeclareRobustCommand{\LWR@nulltextnormal}[1]{#1}
\LetLtxMacro{\textnormal}{\LWR@HTMLtextnormal}
%    \end{macrocode}
% \end{macro}


%    \begin{macrocode}
\DeclareRobustCommand{\LWR@nullrmfamily}{}
\DeclareRobustCommand{\LWR@nullsffamily}{}
\DeclareRobustCommand{\LWR@nullttfamily}{}
\DeclareRobustCommand{\LWR@nullbfseries}{}
\DeclareRobustCommand{\LWR@nullmdseries}{}
\DeclareRobustCommand{\LWR@nullupshape}{}
\DeclareRobustCommand{\LWR@nullslshape}{}
\DeclareRobustCommand{\LWR@nullscshape}{}
\DeclareRobustCommand{\LWR@nullitshape}{}
\DeclareRobustCommand{\LWR@nullem}[1]{}
\DeclareRobustCommand{\LWR@nullnormalfont}{}
%    \end{macrocode}



% \begin{macro}{\LWR@nullfonts} Removes formatting during filename operations.
% \changes{v0.34}{2017/08/05}{Improved font control.}
% \changes{v0.36}{2017/08/15}{Fix: Filenames while using MathJax.}
% \changes{v0.40}{2017/09/21}{Fix: Long arguments for expandable command.}
% \changes{v0.43}{2017/10/31}{Fix: Nullify dollar inside filesnames.}
%    \begin{macrocode}
\newcommand*{\LWR@nullfonts}{%
\LetLtxMacro{\emph}{\LWR@nullemph}%
\LetLtxMacro{\textmd}{\LWR@nulltextmd}%
\LetLtxMacro{\textbf}{\LWR@nulltextbf}%
\LetLtxMacro{\textrm}{\LWR@nulltextrm}%
\LetLtxMacro{\textsf}{\LWR@nulltextsf}%
\LetLtxMacro{\texttt}{\LWR@nulltexttt}%
\LetLtxMacro{\textup}{\LWR@nulltextup}%
\LetLtxMacro{\textit}{\LWR@nulltextit}%
\LetLtxMacro{\textsc}{\LWR@nulltextsc}%
\LetLtxMacro{\textsl}{\LWR@nulltextsl}%
\LetLtxMacro{\textnormal}{\LWR@nulltextnormal}%
\LetLtxMacro{\rmfamily}{\LWR@nullrmfamily}%
\LetLtxMacro{\sffamily}{\LWR@nullsffamily}%
\LetLtxMacro{\ttfamily}{\LWR@nullttfamily}%
\LetLtxMacro{\bfseries}{\LWR@nullbfseries}%
\LetLtxMacro{\mdseries}{\LWR@nullmdseries}%
\LetLtxMacro{\upshape}{\LWR@nullupshape}%
\LetLtxMacro{\slshape}{\LWR@nullslshape}%
\LetLtxMacro{\scshape}{\LWR@nullscshape}%
\LetLtxMacro{\itshape}{\LWR@nullitshape}%
\LetLtxMacro{\em}{\LWR@nullem}%
\LetLtxMacro{\normalfont}{\LWR@nullnormalfont}%
\renewcommand*{\HTMLunicode}[1]{}%
\renewcommand*{\HTMLentity}[1]{}%
%    \end{macrocode}
% Ampersand becomes ``and'', which is a short word and is then removed from the filename.
%    \begin{macrocode}
\renewcommand*{\&}{and}%
\renewcommand{\textsuperscript}[1]{##1}%
\renewcommand{\textsubscript}[1]{##1}%
\LetLtxMacro\underline\LWR@origunderline%
\RenewDocumentCommand{\LWR@htmlspanclass}{o m +m}{##3}%
\DeclareExpandableDocumentCommand{\InlineClass}{+o +m +m}{##3}%
\DeclareRobustCommand{\LWR@HTMLtextstyle}[3]{##3}%
\DeclareRobustCommand{\LWR@subsingledollar}[1]{}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\mdseries}
%    \begin{macrocode}
\renewcommand*{\mdseries}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\bfseries}
%    \begin{macrocode}
\renewcommand*{\bfseries}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\rmfamily}
%    \begin{macrocode}
\renewcommand*{\rmfamily}{}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\sffamily}

%    \begin{macrocode}
\renewcommand*{\sffamily}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\ttfamily}
%    \begin{macrocode}
\renewcommand*{\ttfamily}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\upshape}
%    \begin{macrocode}
\renewcommand*{\upshape}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\itshape}
%    \begin{macrocode}
\renewcommand*{\itshape}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\scshape}
%    \begin{macrocode}
\renewcommand*{\scshape}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\normalfont}
%    \begin{macrocode}
\renewcommand*{\normalfont}{}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\sp} \marg{text}

% For \pkg{siunitx}.  Must work in math mode.
%    \begin{macrocode}
\renewcommand{\sp}[1]{\text{<sup>#1</sup>}{}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\sb} \marg{text}

% For \pkg{siunitx}.  Must work in math mode.
%    \begin{macrocode}
\renewcommand{\sb}[1]{\text{<sub>#1</sub>}{}}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\textsuperscript} \marg{text}
%    \begin{macrocode}
\renewcommand{\textsuperscript}[1]{\LWR@htmlspan{sup}{#1}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\@textsuperscript} \marg{text}
% \changes{v0.42}{2017/10/16}{Added.}
%    \begin{macrocode}
\renewcommand{\@textsuperscript}[1]{\LWR@htmlspan{sup}{#1}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\textsubscript} \marg{text}
%    \begin{macrocode}
\AtBeginDocument{
\renewcommand{\textsubscript}[1]{\LWR@htmlspan{sub}{#1}}
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\@textsubscript} \marg{text}
% \changes{v0.42}{2017/10/16}{Added.}
%    \begin{macrocode}
\AtBeginDocument{
\renewcommand{\@textsubscript}[1]{\LWR@htmlspan{sub}{#1}}
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\up} \marg{text} Prints superscript.
%
% This is \cs{let} at the beginning of the document in case some other package
% has changed the definition.
%    \begin{macrocode}
\AtBeginDocument{\let\up\textsuperscript}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\fup} \marg{text} Prints superscript.
%
% Supports \pkg{fmtcount} package.
%
% This is \cs{let} at the beginning of the document in case some other package
% has changed the definition.
%    \begin{macrocode}
\AtBeginDocument{\let\fup\textsuperscript}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\underline} \marg{text}
% \changes{v0.40}{2017/09/12}{Added.}
% \changes{v0.42}{2017/10/20}{If \protect\texttt{FormatWP}, use explicit styles for
%   \cs{underline}, etc.}
%    \begin{macrocode}
\renewcommand{\underline}[1]{%
\LWR@HTMLtextstyle%
    {text-decoration:underline;text-decoration-skip}%
    {underline}{#1}%
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\hfill}
% \changes{v0.20}{2016/12/12}{Inserts a \cs{qquad}.}
%    \begin{macrocode}
\renewcommand*{\hfill}{\qquad}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\hrulefill}
% \changes{v0.20}{2017/01/19}{Inserts a short rule.}
%    \begin{macrocode}
\renewcommand*{\hrulefill}{\rule{1in}{1pt}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\dotfill}
% \changes{v0.20}{2017/01/19}{Inserts an ellipsis.}
%    \begin{macrocode}
\renewcommand*{\dotfill}{\dots}
%    \end{macrocode}
% \end{macro}



%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}





% \section{Skips, spaces, font sizes}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% |\,| must be redefined after |\RequirePackage{printlen}|
%    \begin{macrocode}
\let\LWR@origcomma\,
\let\LWR@origtilde~
\let\LWR@origenskip\enskip
\let\LWR@origquad\quad
\let\LWR@origqquad\qquad
\let\LWR@orighspace\hspace
\let\LWR@origvspace\vspace
\let\LWR@origrule\rule
\let\LWR@origmedskip\medskip
\let\LWR@origtextellipsis\textellipsis
%    \end{macrocode}

% Direct-formatting space commands become \HTML\ entities:
%    \begin{macrocode}
\renewcommand*{\,}{\HTMLunicode{202f}}	% HTML thin non-breakable space
%    \end{macrocode}
% ^^A \renewcommand*{\,}{\HTMLunicode{2009}}	% HTML thin wrappable space
% ^^A \renewcommand*{\,}{\HTMLentity{nbsp}}	% regular-width non-breakable space
%    \begin{macrocode}

\renewcommand*{~}{\HTMLentity{nbsp}}

\renewcommand*{\textellipsis}{\HTMLunicode{2026}}
%    \end{macrocode}
% Direct-formatting font sizes are ignored:
%    \begin{macrocode}
\let\LWR@orignormalsize\normalsize
\let\LWR@origsmall\small
\let\LWR@origfootnotesize\footnotesize
\let\LWR@origscriptsize\scriptsize
\let\LWR@origtiny\tiny
\let\LWR@origlarge\large
\let\LWR@origLarge\Large
\let\LWR@origLARGE\LARGE
\let\LWR@orighuge\huge
\let\LWR@origHuge\Huge
\renewcommand*{\normalsize}{}
\renewcommand*{\small}{}
\renewcommand*{\footnotesize}{}
\renewcommand*{\scriptsize}{}
\renewcommand*{\tiny}{}
\renewcommand*{\large}{}
\renewcommand*{\Large}{}
\renewcommand*{\LARGE}{}
\renewcommand*{\huge}{}
\renewcommand*{\Huge}{}

\renewcommand*{\onecolumn}{}

\renewcommand{\twocolumn}[1][]{

#1

}
%    \end{macrocode}


% \begin{macro}{\newline}
% Uses the \HTML\ \element{br /} element.
%    \begin{macrocode}
\newcommand*{\LWR@newlinebr}{\unskip\LWR@htmltag{br /}\LWR@orignewline}%
\let\newline\LWR@newlinebr
%    \end{macrocode}
% \end{macro}


% \DescribeMacro{\\} Redefined to \cs{LWR@endofline} or \cs{LWR@tabularendofline}.
%
% \begin{macro}{\LWR@endofline} * \oarg{len}
% \changes{v0.20}{2016/08/20}{Fix: \protect\textbackslash\protect\textbackslash}
%
% |\\| is assigned to \cs{LWR@endofline} at \cs{LWR@LwarpStart}.
%
% Inside |tabular|, |\\| is temporarily changed to \cs{LWR@tabularendofline}.
%    \begin{macrocode}
\LetLtxMacro\LWR@origendofline\\
\NewDocumentCommand{\LWR@endofline}{s o}
{%
\newline%
}
%    \end{macrocode}
% \end{macro}





% \begin{macro}{\LWR@minipagestartpars}
% \changes{v0.19}{2016/05/31}{Surpresses paragraph tags between minipages.}
% \index{minipage>horizontal space between}
% \index{space>horizontal>between minipages}
% \index{horizontal space>between minipages}
% Minipages are often placed side-by-side inside figures, with a bit of
% horizontal space to separate them.  Since \HTML\ does not allow
% a \element{div} to be inside a |p|, paragraphs must be turned off during the
% generation of the minipage, then turned on after the minipage is complete.
% When this occurs between side-by-side minipages, |lwarp| correctly
% surpresses the paragraph tags between the minipages, unless some other
% text is between the minipages.  Such text forms its own paragraph, resulting
% in text after a minipage to be on its own line.  Since people often place
% \DescribeMacro{\hspace}
% \DescribeMacro{\enskip}
% \DescribeMacro{\quad}
% \DescribeMacro{\qquad}
% small horizontal space between minipages, it is desirable to maintain this
% space if possible.  |lwarp| tries to do this by remembering that a minipage
% has been seen, in which case paragraph tags are surpressed around
% \cs{hspace}, \cs{enskip}, \cs{quad}, and \cs{qquad} until the end of the paragraph, when
% the closing |p| tag is created.
%
% When a minipage is seen, the boolean
% |LWR@minipagethispar| is set, telling the following horizontal
% whitespace commands to try to surpress their surrounding paragraph
% tags.  |LWR@minipagethispar| is cleared at the next
% end of paragraph, when the \HTML\ paragraph closing tag is
% generated.
%
% Placed just before \cs{hspace}, \cs{quad}, or \cs{qquad}'s \HTML\ output.
%    \begin{macrocode}
\newcommand*{\LWR@minipagestartpars}{%
\ifbool{LWR@minipagethispar}{\LWR@startpars}{}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@minipagestoppars}
% Placed just after \cs{hspace}, \cs{quad}, or \cs{qquad}'s \HTML\ output.
%    \begin{macrocode}
\newcommand*{\LWR@minipagestoppars}{%
\ifbool{LWR@minipagethispar}{\LWR@stoppars}{}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\quad}
% Handles special minipage \& horizontal space interactions.
%    \begin{macrocode}
\renewcommand*{\quad}{%
\LWR@minipagestoppars%
\HTMLunicode{2001}%
\LWR@minipagestartpars%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\qquad}
% Handles special minipage \& horizontal space interactions.
%    \begin{macrocode}
\renewcommand*{\qquad}{\quad\quad}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\enskip}
% Handles special minipage \& horizontal space interactions.
%    \begin{macrocode}
\renewcommand*{\enskip}{%
\LWR@minipagestoppars%
\HTMLunicode{2000}%
\LWR@minipagestartpars%
}
%    \end{macrocode}
% \end{macro}


% \DescribeLength{LWR@tempwidth}
% \DescribeLength{LWR@tempheight}
% \DescribeLength{LWR@tempraise}
% Used to compute span width, height, raise for \cs{hspace} and \cs{rule}:
%    \begin{macrocode}
\newlength{\LWR@tempwidth}
\newlength{\LWR@tempheight}
\newlength{\LWR@tempraise}
%    \end{macrocode}
%

% \begin{macro}{\LWR@hspace} * \marg{length}
%
% Handles special minipage \& horizontal space interactions.
% \changes{v0.18}{2016/05/13}{\cs{hspace} supported.}
% \changes{v0.19}{2016/05/29}{Fix: \cs{hspace} length computations.}
% \changes{v0.20}{2016/08/22}{Add: Supports \HTML\ thin breakable space.}
% \changes{v0.24}{2017/03/14}{Add: \cs{hspace} \cs{fill} converts to 2em}
%
% Prints a span of a given width.  Ignores the optional star.
%
% |\hspace{\fill}| is converted to |\hspace{2em}|, equal to \cs{qquad}.
%    \begin{macrocode}
\NewDocumentCommand{\LWR@hspace}{s m}{%
\setlength{\LWR@tempwidth}{#2}%
%    \end{macrocode}
% If \cs{fill}, change to \cs{qquad}:
%    \begin{macrocode}
\ifnum\gluestretchorder\LWR@tempwidth>0%
\setlength{\LWR@tempwidth}{2em}%
\fi%
%    \end{macrocode}
% Only if the width is not zero:
%    \begin{macrocode}
\ifdimcomp{\LWR@tempwidth}{=}{0pt}{}{%
%    \end{macrocode}
% If had a minipage this paragraph, try to inline the
% white space without generating paragraph tags:
%    \begin{macrocode}
    \LWR@minipagestoppars%
%    \end{macrocode}
% Support the \HTML\ thin wrappable space:
%    \begin{macrocode}
    \ifdimcomp{\LWR@tempwidth}{=}{.16667em}%
    {%
        \HTMLunicode{2009}% thin breakable space
    }%
%    \end{macrocode}
% Print the span with the converted width.  Not rounded.
%    \begin{macrocode}
    {%
        \uselengthunit{PT}%
        \LWR@htmltagc{%
            span style="width:\printlength{\LWR@tempwidth}; %
                display:inline-block"%
        }%
%    \end{macrocode}
% If formatting for a word processor, approximate with a number of \cs{quad}s,
% in case a span of a given width is not supported:
% \changes{v0.42}{2017/10/27}{If \protect\texttt{FormatWP} add \cs{quad}s.}
%    \begin{macrocode}
        \ifbool{FormatWP}{%
            \setlength{\LWR@templengthone}{\LWR@tempwidth}%
            \whiledo{\lengthtest{\LWR@templengthone>1em}}{%
                \quad%
                \addtolength{\LWR@templengthone}{-1em}%
            }%
        }{}%
%    \end{macrocode}
% Close the span:
%    \begin{macrocode}
        \LWR@htmltagc{/span}%
    }%
%    \end{macrocode}
% If had a minipage this paragraph, try to inline the
% white space without generating paragraph tags:
%    \begin{macrocode}
    \LWR@minipagestartpars%
}% width not 0
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LWR@nohspace} * \marg{length}
%
% Used to disable \cs{hspace} while creating |description| \cs{item}s.
%    \begin{macrocode}
\NewDocumentCommand{\LWR@nohspace}{s m}{}
%    \end{macrocode}
% \end{macro}

%
%
% \begin{macro}{\hspace} * \marg{length}
%
% Handles special minipage \& horizontal space interactions.
%    \begin{macrocode}
\LetLtxMacro{\hspace}{\LWR@hspace}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@vspace} * \marg{length} Nullified vspace.
%
% \changes{v0.33}{2017/06/21}{Add: \cs{vspace} nullified.}
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@vspace}{s m}{}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\vspace} * \marg{length} Nullified.
%    \begin{macrocode}
\let\vspace\LWR@vspace
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\linebreak} \oarg{num} \qquad
% Inserts an \HTML\ |br| tag.
%    \begin{macrocode}
\renewcommand*{\linebreak}[1][]{\newline}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\nolinebreak} \oarg{num}
%    \begin{macrocode}
\renewcommand*{\nolinebreak}[1][]{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\pagebreak} \oarg{num} \qquad
% Starts a new paragraph.
%    \begin{macrocode}
\renewcommand*{\pagebreak}[1][]{

}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\nopagebreak} \oarg{num}
%    \begin{macrocode}
\renewcommand*{\nopagebreak}[1][]{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\enlargethispage} * \marg{len}
%    \begin{macrocode}
\RenewDocumentCommand{\enlargethispage}{s m}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\clearpage}
% \begin{macro}{\cleardoublepage}
%    \begin{macrocode}
\renewcommand*{\clearpage}{}
\renewcommand*{\cleardoublepage}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\LWR@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@currenttextcolor}{black}
%    \end{macrocode}
% \end{macro}
%
%
%
%
% \begin{macro}{\LWR@rule} \oarg{raise} \marg{width} \marg{height}
%
% Handles special minipage \& horizontal space interactions.
%
% Creates a span of a given width and height.  Ignores the optional star.
%
% \cs{fill} is zero-width, so |\hspace{\fill}| is ignored.
%    \begin{macrocode}
\NewDocumentCommand{\LWR@rule}{o m m}{%
%    \end{macrocode}
% The width is copied into a temporary \LaTeX\ length, from which
% comparisons and conversions may be made:
%    \begin{macrocode}
\setlength{\LWR@tempwidth}{#2}%
%    \end{macrocode}
% If it's zero-width then skip the entire rule:
%    \begin{macrocode}
\ifthenelse{\lengthtest{\LWR@tempwidth=0pt}}
{}% zero- width
{% non-zero width
%    \end{macrocode}
% If it's non-zero width, set a minimal thickness so that it
% more reliably shows in the browser:
%    \begin{macrocode}
    \ifthenelse{%
        \lengthtest{\LWR@tempwidth>0pt}\AND%
        \lengthtest{\LWR@tempwidth<1pt}%
    }%
    {\setlength{\LWR@tempwidth}{1pt}}{}%
%    \end{macrocode}
% Likewise with height:
%    \begin{macrocode}
    \setlength{\LWR@tempheight}{#3}%
    \ifthenelse{%
        \lengthtest{\LWR@tempheight>0pt}\AND%
        \lengthtest{\LWR@tempheight<1pt}%
    }%
    {\setlength{\LWR@tempheight}{1pt}}{}%
%    \end{macrocode}
% If had a minipage this paragraph, try to inline the
% rule without generating paragraph tags:
%    \begin{macrocode}
    \LWR@minipagestoppars%
%    \end{macrocode}
% Print the span with the converted width and height.
% The width and height are NOT rounded, since a height of
% less than 1pt is quite common in \LaTeX\ code.
%    \begin{macrocode}
    \uselengthunit{PT}%
    \LWR@htmltagc{%
    span
    style="%
%    \end{macrocode}
% The background color is used to draw the filled rule.
% The color may be changed by \cs{textcolor}.
%    \begin{macrocode}
    \ifbool{FormatWP}{}{background:\LWR@currenttextcolor ; }%
%    \end{macrocode}
% The width and height are printed, converted to PT:
%    \begin{macrocode}
    width:\printlength{\LWR@tempwidth} ; %
    height:\printlength{\LWR@tempheight} ; %
%    \end{macrocode}
% The raise height is converted to a \CSS\ transform.
% The |*2| raise multiplier is to approximately match \HTML\ output's X height.
% Conversion to a \LaTeX\ length allows a typical \LaTeX\ expression to be
% used as an argument for the raise, whereas printing the raise argument
% directly to \HTML\ output without conversion to a \LaTeX\ length
% limits the allowable syntax.  To do:\ A superior method would compute a
% ratio of \LaTeX\ ex height, then print that to \HTML\ with an ex unit.
%    \begin{macrocode}
    \IfValueT{#1}%
    {%
        \setlength{\LWR@tempraise}{0pt-#1}%
        \setlength{\LWR@tempraise}{\LWR@tempraise*2}%
        \LWR@orignewline%
        -ms-transform: translate(0pt,\printlength{\LWR@tempraise}); %
        \LWR@orignewline%
        -webkit-transform: translate(0pt,\printlength{\LWR@tempraise}); %
        \LWR@orignewline%
        transform: translate(0pt,\printlength{\LWR@tempraise}); %
        \LWR@orignewline%
    }%
%    \end{macrocode}
% Display inline-block to place the span inline with the text:
%    \begin{macrocode}
    display:inline-block;"%
    }%
%    \end{macrocode}
% If formatting for a word processor, approximate with a number of underscores,
% in case a span of a given width is not supported:
% \changes{v0.42}{2017/10/27}{If \protect\texttt{FormatWP} add \cs{quad}s.}
%    \begin{macrocode}
        \ifbool{FormatWP}{%
            \setlength{\LWR@templengthone}{\LWR@tempwidth}%
            \whiledo{\lengthtest{\LWR@templengthone>1em}}{%
                \_{}%
                \addtolength{\LWR@templengthone}{-1em}%
            }%
        }{}%
%    \end{macrocode}
% Close the span:
%    \begin{macrocode}
    \LWR@htmltagc{/span}%
%    \end{macrocode}
% If had a minipage this paragraph, try to inline the
% white space without generating paragraph tags:
%    \begin{macrocode}
    \LWR@minipagestartpars%
}% non-zero width
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\rule} \oarg{raise} \marg{width} \marg{height}
% \changes{v0.19}{2016/06/01}{Added}
%
% Handles special minipage \& horizontal space interactions.
%    \begin{macrocode}
\renewcommand{\rule}{\LWR@rule}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}




% \section{\textbackslash{}phantomsection}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{macro}{\phantomsection}
% Emulate the hyperref |\phantomsection| command,
% often used to insert the bibliography into table of contents:
%    \begin{macrocode}
\newcommand*{\phantomsection}{%
\section*{}%
}
%    \end{macrocode}
% \end{macro}


%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}





% \section{\textbackslash{}LaTeX and other logos}

% Logos for \HTML\ and print modes:
%
% Some of these logos may be redefined in a later package,
% so after loading other packages, and at the beginning of the document, their definitions
% are finally |\let| in |\LWR@LwarpStart|.
%
% For \CSS\ conversions, see: \\
% \url{http://edward.oconnor.cx/2007/08/tex-poshlet} \\
% \url{http://nitens.org/taraborelli/texlogo}
%
%
%
% \subsection{HTML logos}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \begin{macro}{\TeX} \TeX
% \nopagebreak
%
% |latexlogo| is a \CSS\ class used to properly typeset the E and A in \LaTeX{} and friends.
%
% |latexlogofont| is a \CSS\ class used to select the font for the rest of the logo in
% \LaTeX, \LuaTeX, \ConTeXt, etc.
% \changes{v0.42}{2017/10/20}{If \protect\texttt{FormatWP} use explicit style.}
%    \begin{macrocode}
\let\LWR@origTeX\TeX

\newcommand*{\LWR@TeX}
{%
    \InlineClass{latexlogofont}%
    {%
        \LWR@HTMLtextstyle%
            {text-transform:uppercase}%
            {latexlogo}%
        {T\textsubscript{e}X}%
    }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LaTeX}
% \changes{v0.42}{2017/10/20}{If \protect\texttt{FormatWP} use explicit style.}
% \begin{macro}{\LaTeXe} \LaTeX, \LaTeXe
%    \begin{macrocode}
\let\LWR@origLaTeX\LaTeX

\newcommand*{\LWR@LaTeX}
{%
    \InlineClass{latexlogofont}%
    {%
        \LWR@HTMLtextstyle%
            {text-transform:uppercase}%
            {latexlogo}%
        {L\textsuperscript{a}T\textsubscript{e}X}%
    }%
}

\let\LWR@origLaTeXe\LaTeXe

\renewcommand*{\LaTeXe}
{\LaTeX\InlineClass{latexlogofont}%
{\,2\textsubscript{\textit{\HTMLunicode{3B5}}}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\LuaTeX}
% \begin{macro}{\LuaLaTeX} \LuaTeX, \LuaLaTeX
%    \begin{macrocode}
\newcommand*{\LWR@LuaTeX}{\InlineClass{latexlogofont}{Lua}\TeX}
\newcommand*{\LWR@LuaLaTeX}{\InlineClass{latexlogofont}{Lua}\LaTeX}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\XeTeX}
% \begin{macro}{\XeLaTeX} \XeTeX, \XeLaTeX
% \nopagebreak
%
% |xetexlogo| is a \CSS\ class which aligns the backwards E in \XeTeX{} and spaces \TeX{}
% appropriately.
%
% |xelatexlogo| is a \CSS\ class which aligns the backwards E in \XeLaTeX{} and spaces
% \LaTeX{} appropriately.
%    \begin{macrocode}
\newcommand*{\Xe}
  {X\textsubscript{\HTMLunicode{18e}}}
\newcommand*{\LWR@XeTeX}{\InlineClass{xetexlogo}{\Xe}\TeX}
\newcommand*{\LWR@XeLaTeX}{\InlineClass{xelatexlogo}{\Xe}\LaTeX}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\ConTeXt} \ConTeXt
%    \begin{macrocode}
\newcommand*{\LWR@ConTeXt}
{\InlineClass{latexlogofont}{Con}\TeX{}%
\InlineClass{latexlogofont}{t}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\BibTeX}
% \begin{macro}{\MakeIndex} \BibTeX, \MakeIndex
%    \begin{macrocode}
\providecommand*{\BibTeX}
{\InlineClass{latexlogofont}{B\textsc{ib}}\TeX}

\newcommand*{\MakeIndex}
{\InlineClass{latexlogofont}{\textit{MakeIndex}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\AmS} \AmS
% \nopagebreak
%
% |amslogo| is a \CSS\ class used for the \AmS logo.
%    \begin{macrocode}
\AtBeginDocument{\DeclareDocumentCommand{\AmS}{}
{\InlineClass{amslogo}{\textit{A\textsubscript{M}S}}}}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\MiKTeX} \MiKTeX
%    \begin{macrocode}
\newcommand*{\MiKTeX}{\InlineClass{latexlogofont}{MiK}\TeX}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\LyX} \LyX
% \nopagebreak
%
% |lyxlogo| is a \CSS\ class used for the \LyX logo.
%    \begin{macrocode}
\newcommand*{\LyX}{\InlineClass{lyxlogo}{LyX}}
%    \end{macrocode}
% \end{macro}
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
% \subsection{Print logos}
%
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\newcommand*{\XeTeXrevE}
  {\hspace{-.1667em}\raisebox{-.5ex}{\reflectbox{E}}\hspace{-.125em}}
\providecommand*{\XeTeX}{\mbox{X\XeTeXrevE\TeX}}
\providecommand*{\XeLaTeX}{\mbox{X\XeTeXrevE\LaTeX}}
\providecommand*{\AmS}{%
\leavevmode\hbox{$\mathcal A\kern-.2em\lower.376ex%
\hbox{$\mathcal M$}\kern-.2em\mathcal S$}}
\newcommand*{\LyX}{\textsf{LyX}}
\providecommand*{\LuaTeX}{\mbox{Lua\TeX}}
\providecommand*{\LuaLaTeX}{\mbox{Lua\LaTeX}}
\providecommand*{\BibTeX}{\mbox{B\textsc{ib}\TeX}}
\providecommand*{\MakeIndex}{\mbox{\textit{MakeIndex}}}
\providecommand*{\ConTeXt}{\mbox{Con\TeX{}t}}
\providecommand*{\MiKTeX}{\mbox{MiK\TeX}}
\end{warpprint}
%    \end{macrocode}


% \section{\textbackslash{}AtBeginDocument, \textbackslash{}AtEndDocument}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{macro}{\LWR@LwarpStart}
% \begin{macro}{\LWR@LwarpEnd}
% Automatically sets up the \HTML-related actions for the start and end of the
% document.
%    \begin{macrocode}
\AfterEndPreamble{\LWR@LwarpStart}
\AtEndDocument{\LWR@LwarpEnd}
%    \end{macrocode}
% \end{macro}
% \end{macro}




%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}







% \clearpage
% \section{Trademarks}
%
% \changes{v0.14}{2016/03/29}{Docs: Trademarks section.}
%
% \begin{itemize}
% \item \TeX\ is a trademark of American Mathematical Society.
% \item Adobe®  and Adobe Framemaker® are either registered trademarks or
%	trademarks of Adobe Systems Incorporated in the United States and/or other countries.
% \item Linux® is the registered trademark of Linus Torvalds in the U.S.\ and other countries.
% \item Mac\,OS® is a trademark of Apple Inc.
% \item MadCap Flare™ is the property of MadCap Software, Inc.
% \item MathJax is copyright 2009 and later.
%	The MathJax Consortium is a joint venture of the American Mathematical Society (AMS)
%	and the Society for Industrial and Applied Mathematics (SIAM)
%	to advance mathematical and scientific content on the web.
% \item Microsoft®, Encarta, MSN, and Windows® are either registered trademarks or
%	trademarks of Microsoft Corporation in the United States and/or other countries.
% \item UNIX® is a registered trademark of The Open Group.
% \end{itemize}

% \iffalse
%</package>
% \fi
%
%
%
%
%
%
%
%
% \changes{v0.20}{2016/12/12}{Code factored into independent \texttt{lwarp\_html} files.}
%
% The following adjustments apply to the lwarp-* package listings:
%
% \titleformat{\part}[hang]
%     {\hrule\nopagebreak[4]\large\ttfamily\bfseries}{}{0pt}{}[\marginpar{\hfill{}File\,\thepart}]
% \titlespacing*{\part}{0pt}{*4}{0ex}
% 
% \titleformat{\section}[hang]
%     {\LARGE\sffamily\bfseries}{}{0pt}{}[\marginpar{\hfill\textsection\,\thesection \qquad Package}]
% \titlespacing*{\section}{0pt}{0ex}{0ex}
%
% \titleformat{\subsection}[hang]
%     {\large\rmfamily\bfseries}{}{0pt}{}[\marginpar{\hfill\textsection\,\thesubsection}]
% \titlespacing*{\subsection}{0pt}{0ex}{0ex}
%
% \titleformat{\subsubsection}[hang]
%     {\normalsize\rmfamily\bfseries}{}{0pt}{}[\marginpar{\hfill\textsection\,\thesubsubsection}]
% \titlespacing*{\subsection}{0pt}{0ex}{0ex}
%
% \renewcommand{\bottomtitlespace}{.2\textheight}
%
%
% \clearpage
%
%
%
%
% \iffalse
%<*patch-komascript>
% \fi
%
% \part{lwarp-patch-komascript.sty}
%
% \section{patch-komascript}
%
% \DescribePackage{lwarp-patch-komascript}
% Patches for \pkg{komascript} classes.
%
% \pkg{lwarp} loads this package when
% \pkg{scrbook}, \pkg{scrartcl}, or \pkg{scrreprt} are detected.
%
% \limitskomascript
%
% \changes{v0.44}{2017/11/19}{\pkg{lwarp-patch-komascript}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\ProvidesPackage{lwarp-patch-komascript}
%    \end{macrocode}
%
% \pkg{typearea} is emulated.
%    \begin{macrocode}
\RequirePackage{lwarp-typearea}
%    \end{macrocode}
%
% \pkg{tocbasic} is emulated.
%    \begin{macrocode}
\RequirePackage{lwarp-tocbasic}
%    \end{macrocode}
%
% \pkg{scrextend} patches most of the new macros.
%    \begin{macrocode}
\RequirePackage{lwarp-scrextend}
%    \end{macrocode}
%
% The \cs{minisec} is placed inside a \element{div} of class \attribute{minisec}.
%    \begin{macrocode}
\renewcommand*{\minisec}[1]{
\begin{BlockClass}{minisec}
#1
\end{BlockClass}
}
%    \end{macrocode}
%
% The part and chapter preambles are placed as plain text just after each heading.
%    \begin{macrocode}
\@ifundefined{setpartpreamble}{}{
\RenewDocumentCommand{\setpartpreamble}{o o +m}{%
\renewcommand{\part@preamble}{#3}%
}
}

\@ifundefined{setchapterpreamble}{}{
\RenewDocumentCommand{\setchapterpreamble}{o o +m}{%
\renewcommand{\chapter@preamble}{#3}%
}
}
%    \end{macrocode}
%
% Simple captions are used in all cases.
%    \begin{macrocode}
\LetLtxMacro\captionbelow\caption
\LetLtxMacro\captionabove\caption

\LetLtxMacro\captionofbelow\captionof
\LetLtxMacro\captionofabove\captionof

\RenewDocumentEnvironment{captionbeside}{o m o o o s}
{}
{%
\IfValueTF{#1}%
{\caption[#1]{#2}}%
{\caption{#2}}%
}

\RenewDocumentEnvironment{captionofbeside}{m o m o o o s}
{}
{%
\IfValueTF{#2}%
{\captionof{#1}[#2]{#3}}%
{\captionof{#1}{#3}}%
}

\RenewDocumentCommand{\setcapindent}{s m}{}
\renewcommand*{\setcaphanging}{}
\renewcommand*{\setcapwidth}[2][]{}
\renewcommand*{\setcapdynwidth}[2][]{}
\RenewDocumentCommand{\setcapmargin}{s o m}{}
%    \end{macrocode}
%
% \iffalse
%</patch-komascript>
% \fi
%
%
%
% \iffalse
%<*a4>
% \fi
%
% \part{lwarp-a4.sty}
%
% \section{a4}
%
% \DescribePackage{a4}
% \pkg{a4} is ignored.
%
% \changes{v0.39}{2017/08/27}{\pkg{a4}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{a4}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\WideMargins}{}
%    \end{macrocode}
%
% \iffalse
%</a4>
% \fi
%
%
%
%
% \iffalse
%<*a4wide>
% \fi
%
% \part{lwarp-a4wide.sty}
%
% \section{a4wide}
%
% \DescribePackage{a4wide}
% \pkg{a4wide} is ignored.
%
% \changes{v0.39}{2017/08/27}{\pkg{a4wide}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{a4wide}
%    \end{macrocode}
%
%
% \iffalse
%</a4wide>
% \fi
%
%
%
% \iffalse
%<*a5comb>
% \fi
%
% \part{lwarp-a5comb.sty}
%
% \section{a5comb}
%
% \DescribePackage{a5comb}
% \pkg{a5comb} is ignored.
%
% \changes{v0.39}{2017/08/27}{\pkg{a5comb}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{a5comb}
%    \end{macrocode}
%
%
% \iffalse
%</a5comb>
% \fi
%
%
%
%
%
% \iffalse
%<*abstract>
% \fi
%
% \part{lwarp-abstract.sty}
%
% \section{abstract}
%
% \credits{Peter Wilson}
%
% \DescribePackage{abstract}
% \pkg{abstract} is supported and patched by \pkg{lwarp}.
%
% \limitsabstract
%
% \changes{v0.22}{2017/03/01}{\pkg{abstract}: Added.}
%
% \codehtml
%
% Accept all options for \pkg{lwarp-abstract}:
%    \begin{macrocode}
\LWR@ProvidesPackagePass{abstract}
%    \end{macrocode}


%    \begin{macrocode}
\AtBeginDocument{
\BeforeBeginEnvironment{abstract}{
\LWR@forcenewpage
\BlockClass{abstract}
}
\AfterEndEnvironment{abstract}{\endBlockClass}
}

\renewcommand{\@bsrunintitle}{%
\hspace*{\abstitleskip}%
{\abstractnamefont%
\InlineClass{abstractrunintitle}{\abstractname}%
\@bslabeldelim}%
}

\if@titlepage
  \renewenvironment{abstract}{%
%     \titlepage
    \null\vfil
    \@beginparpenalty\@lowpenalty
    \if@bsrunin
    \else
      \if@bsstyle
        \abstitlestyle{\BlockClassSingle{abstracttitle}{\abstractname}}
      \else
        \ifnumber@bs
          \num@bs
        \else
          \begin{\absnamepos}%
  \abstractnamefont \BlockClassSingle{abstracttitle}{\abstractname}
            \@endparpenalty\@M
          \end\absnamepos%
%%        \vspace{\abstitleskip}%
        \fi
      \fi
      \vspace{\abstitleskip}%
    \fi
    \put@bsintoc%
    \begin{@bstr@ctlist}\if@bsrunin\@bsrunintitle\fi\abstracttextfont}%
    {\par\end{@bstr@ctlist}\vfil\null%\endtitlepage
    }
\else
  \renewenvironment{abstract}{%
    \if@bsrunin
    \else
      \if@bsstyle
        \abstitlestyle{\BlockClassSingle{abstracttitle}{\abstractname}}
      \else
        \ifnumber@bs
          \num@bs
        \else
\begin{\absnamepos}%
\abstractnamefont\BlockClassSingle{abstracttitle}{\abstractname}%
\end\absnamepos%
%%        \vspace{\abstitleskip}%
        \fi
      \fi
      \vspace{\abstitleskip}%
    \fi
    \put@bsintoc%
    \begin{@bstr@ctlist}\if@bsrunin\@bsrunintitle\fi\abstracttextfont}%
    {\par\end{@bstr@ctlist}}
\fi

%    \end{macrocode}

% \iffalse
%</abstract>
% \fi
%
%
%
%
% \iffalse
%<*adjmulticol>
% \fi
%
% \part{lwarp-adjmulticol.sty}
%
% \section{adjmulticol}
%
% \credits{Boris Veytsman}
%
% \DescribePackage{adjmulticol}
% \pkg{adjmulticol} is emulated.
%
% Emulation similar to \pkg{multicols} is used, with adjusted margins.
% If the number of columns is specified as 1, it is set so, but if
% two or greater are used, \pkg{lwarp} allows a variable number of columns
% up to three.
%
% \changes{v0.40}{2017/09/06}{\pkg{adjmulticol}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{adjmulticol}
%    \end{macrocode}
%
%    \begin{macrocode}
\RequirePackage{multicol}
%    \end{macrocode}


% * \marg{numcols} \marg{left margi} \marg{right margin}
%   \marginpar{\hfill\env{adjmulticols}}
%    \begin{macrocode}
\NewDocumentEnvironment{adjmulticols}{s m m m}
{%
%    \end{macrocode}
% Compute the margins, and limit to positive only:
%    \begin{macrocode}
\setlength{\LWR@templengthone}{#3}%
\ifdimcomp{\LWR@templengthone}{<}{0pt}{\setlength{\LWR@templengthone}{0pt}}{}%
\setlength{\LWR@templengthtwo}{#4}
\ifdimcomp{\LWR@templengthtwo}{<}{0pt}{\setlength{\LWR@templengthtwo}{0pt}}{}%
%    \end{macrocode}
% If one column is specified, use a \element{div} of class \attribute{singlecolumn},
% else use \attribute{multicols}:
%    \begin{macrocode}
\newcommand*{\LWR@mcolstype}{multicols}%
\ifnumcomp{#2}{=}{1}{\renewcommand*{\LWR@mcolstype}{singlecolumn}}{}%
%    \end{macrocode}
% Help avoid page overflow:
%    \begin{macrocode}
\LWR@forcenewpage%
%    \end{macrocode}
% Print margins in points:
%    \begin{macrocode}
\uselengthunit{PT}%
%    \end{macrocode}
% Create the \element{div} with the given margin and class:
%    \begin{macrocode}
\BlockClass[%
margin-left:\rndprintlength{\LWR@templengthone} ; %
margin-right:\rndprintlength{\LWR@templengthtwo}%
]{\LWR@mcolstype}%
}
{\endBlockClass}
%    \end{macrocode}
%
% \iffalse
%</adjmulticol>
% \fi
%
%
%
%
% \iffalse
%<*addlines>
% \fi
%
% \part{lwarp-addlines.sty}
%
% \section{addlines}
%
% \credits{Will Robertson}
%
% \DescribePackage{addlines}
% \pkg{addlines} is emulated.
%
% \changes{v0.39}{2017/08/27}{\pkg{addlines}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{addlines}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*\addlines[1][1]{}
\let\addline\addlines
\newcommand*\removelines[1][1]{}
\let\removeline\removelines
%    \end{macrocode}
%
% \iffalse
%</addlines>
% \fi
%
%
%
%
%
% \iffalse
%<*afterpage>
% \fi
%
% \part{lwarp-afterpage.sty}
%
% \section{afterpage}
%
% \credits{David Carlisle}
%
% \DescribePackage{afterpage} Emulated.
%
% \changes{v0.20}{2017/01/11}{\pkg{afterpage}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-afterpage}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{afterpage}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\afterpage}[1]{#1}
%    \end{macrocode}
%
% \iffalse
%</afterpage>
% \fi
%
%
%
%
% \iffalse
%<*algorithmicx>
% \fi
%
% \part{lwarp-algorithmicx.sty}
%
% \section{algorithmicx}
% \label{sec:algorithmicx}
%
% \credits{Sz\'{a}sz J\'{a}nos}
%
% \DescribePackage{algorithmicx}
% \pkg{algorithmicx} is supported with minor adjustments.
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{algorithmicx}
%    \end{macrocode}
%
%
% Inside the \env{algorithmic} environment, level indenting is converted to a \element{span}
% of the required length, and comments are placed inside a \element{span} which is floated right.
%
% \limitscombiningfloats
%
% \changes{v0.42}{2017/10/27}{\pkg{algorithmicx}: If \protect\texttt{FormatWP} add \cs{quad}s.}
% \changes{v0.44}{2017/11/16}{\pkg{algorithmicx}: Improved comment symbol.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

%    \begin{macrocode}
\AtBeginEnvironment{algorithmic}{%
%
\let\origALG@doentity\ALG@doentity%
%
\renewcommand*{\ALG@doentity}{%
\origALG@doentity%
\uselengthunit{PT}%
\LWR@htmltagc{%
span style="width:\rndprintlength{\ALG@thistlm}; display:inline-block;"%
}%
\ifbool{FormatWP}{%
\setlength{\LWR@templengthone}{\the\ALG@thistlm}%
\whiledo{\lengthtest{\LWR@templengthone>1em}}{%
\quad%
\addtolength{\LWR@templengthone}{-1em}%
}%
}{}%
\LWR@htmltagc{/span}%
}%

\let\LWR@origComment\Comment%

\renewcommand{\Comment}[1]{%
    \InlineClass{floatright}{\LWR@origComment{#1}}%
}%
}

\renewcommand\algorithmiccomment[1]{%
\hfill\HTMLunicode{25B7} #1% white right triangle
}%
%    \end{macrocode}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}

% \iffalse
%</algorithmicx>
% \fi
%
%
%
%
% \iffalse
%<*alltt>
% \fi
%
% \part{lwarp-alltt.sty}

% \section{alltt}
%
% \credits{Johannes Braams}
%
% \DescribePackage{alltt}
% \pkg{alltt} is patched for use by \pkg{lwarp}.
%
% \changes{v0.20}{2017/01/11}{\pkg{alltt}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{alltt}
%    \end{macrocode}

%    \begin{macrocode}
\AfterEndPreamble{
\LWR@traceinfo{Patching alltt.}
\AtBeginEnvironment{alltt}{%
\LWR@forcenewpage
\LWR@atbeginverbatim{alltt}\unskip\LWR@origvspace*{-\baselineskip}%
}
\AfterEndEnvironment{alltt}{\unskip\LWR@origvspace*{-\baselineskip}\LWR@afterendverbatim}
}
%    \end{macrocode}

% \iffalse
%</alltt>
% \fi
%
%
%
%
% \iffalse
%<*amsthm>
% \fi

% \part{lwarp-amsthm.sty}

% \section{amsthm}
%
% \credits{Publications Technical Group --- American Mathematical Society}
%
% \DescribePackage{amsthm}
% \pkg{amsthm} is patched for use by \pkg{lwarp}.
%
% \changes{v0.25}{2017/03/15}{\pkg{amsthm}: Added.}
%
% \begin{table}[ht]
% \hrule\smallskip
% \caption{AMSthm package --- CSS styling of theorems and proofs}
% \begin{description}
% \item [Theorem:] \element{div} of class |amsthmbody<theoremstyle>|
% \item [Theorem Name:] \element{span} of class |amsthmname<theoremtyle>|
% \item [Theorem Number:] \element{span} of class |amsthmnumber<theoremstyle>|
% \item [Theorem Note:] \element{span} of class |amsthmnote<theoremstyle>|
% \item [Proof:] \element{div} of class |amsthmproof|
% \item [Proof Name:] \element{span} of class |amsthmproofname|
% \end{description}
% where |<theoremstyle>| is |plain|, |definition|, etc.
% \smallskip
% \hrule
% \end{table}
% 
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{amsthm}
%    \end{macrocode}

% Storage for the style being used for new theorems:
%    \begin{macrocode}
\newcommand{\LWR@newtheoremstyle}{plain}
%    \end{macrocode}

% Patched to remember the style being used for new theorems:
%    \begin{macrocode}
\renewcommand{\theoremstyle}[1]{%
  \@ifundefined{th@#1}{%
    \PackageWarning{amsthm}{Unknown theoremstyle `#1'}%
    \thm@style{plain}%
    \renewcommand{\LWR@newtheoremstyle}{plain}% new
  }{%
    \thm@style{#1}%
    \renewcommand{\LWR@newtheoremstyle}{#1}% new
  }%
}
%    \end{macrocode}

% Patched to remember the style for this theorem type:
%    \begin{macrocode}
\def\@xnthm#1#2{%
  \csedef{LWR@thmstyle#2}{\LWR@newtheoremstyle}% new
  \let\@tempa\relax
  \@xp\@ifdefinable\csname #2\endcsname{%
    \global\@xp\let\csname end#2\endcsname\@endtheorem
    \ifx *#1% unnumbered, need to get one more mandatory arg
      \edef\@tempa##1{%
        \gdef\@xp\@nx\csname#2\endcsname{%
          \@nx\@thm{\@xp\@nx\csname th@\the\thm@style\endcsname}%
            {}{##1}}}%
    \else % numbered theorem, need to check for optional arg
      \def\@tempa{\@oparg{\@ynthm{#2}}[]}%
    \fi
    \AtBeginEnvironment{#2}{\edef\LWR@thisthmstyle{\csuse{LWR@thmstyle#2}}}% new
  }%
  \@tempa
}
%    \end{macrocode}

% Patched to enclose with \CSS:
%    \begin{macrocode}
\newcommand{\LWR@haveamsthmname}{
\renewcommand{\thmname}[1]{\InlineClass{amsthmname\LWR@thisthmstyle}{##1}}
}

\newcommand{\LWR@haveamsthmnumber}{
\renewcommand{\thmnumber}[1]{\InlineClass{amsthmnumber\LWR@thisthmstyle}{##1}}
}

\newcommand{\LWR@haveamsthmnote}{
\renewcommand{\thmnote}[1]{\InlineClass{amsthmnote\LWR@thisthmstyle}{##1}}
}

\LWR@haveamsthmname
\LWR@haveamsthmnumber
\LWR@haveamsthmnote
%    \end{macrocode}
%
% Patches for \CSS:
%    \begin{macrocode}
\def\@begintheorem#1#2[#3]{%
\LWR@forcenewpage% new
  \BlockClass{amsthmbody\LWR@thisthmstyle}% new
  \deferred@thm@head{
    \the\thm@headfont \thm@indent
    \@ifempty{#1}{\let\thmname\@gobble}{\LWR@haveamsthmname}% new
    \@ifempty{#2}{\let\thmnumber\@gobble}{\LWR@haveamsthmnumber}% new
    \@ifempty{#3}{\let\thmnote\@gobble}{\LWR@haveamsthmnote}% new
    \thm@swap\swappedhead\thmhead{#1}{#2}{#3}%
    \the\thm@headpunct~
    \thmheadnl % possibly a newline.
    \hskip\thm@headsep
  }%
  \ignorespaces}
%    \end{macrocode}
%
% Patched for \CSS:
%    \begin{macrocode}
\def\@endtheorem{\endBlockClass\endtrivlist\@endpefalse }
%    \end{macrocode}
%
%
% Proof QED symbol:
%    \begin{macrocode}
\AtBeginDocument{
\def\openbox{\text{\HTMLunicode{25A1}}}% UTF-8 white box
\def\blacksquare{\text{\HTMLunicode{220E}}}% UTF-8 end-of-proof
\def\Box{\text{\HTMLunicode{25A1}}}% UTF-8 white box
}
%    \end{macrocode}
%
% Patched for \CSS:
%    \begin{macrocode}
\renewenvironment{proof}[1][\proofname]{\par
\LWR@forcenewpage% new
    \BlockClass{amsthmproof}% new
  \pushQED{\qed}%
  \normalfont \topsep6\p@\@plus6\p@\relax
  \trivlist
  \item[\hskip\labelsep
        \InlineClass{amsthmproofname}{#1\@addpunct{.}}]\ignorespaces% changes
}{%
  \InlineClass{theoremendmark}{\popQED}\endtrivlist%
  \endBlockClass% new
  \@endpefalse
}
%    \end{macrocode}


% \iffalse
%</amsthm>
% \fi
%
%
%
%
%
% \iffalse
%<*anonchap>
% \fi
%
% \part{lwarp-anonchap.sty}
%
% \section{anonchap}
%
% \credits{Peter Wilson}
%
% \DescribePackage{anonchap}
% \pkg{anonchap} is emulated.
%
% \limitstocloft
%
% The code is shared by \pkg{tocbibind}.
%
% \changes{v0.40}{2017/09/12}{\pkg{anonchap}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{anonchap}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\simplechapter}[1][\@empty]{%
    \def\@chapcntformat##1{%
        #1~\csname the##1\endcsname\simplechapterdelim\protect\quad%
    }%
}

\newcommand{\restorechapter}{%
\let\@chapcntformat\@seccntformat%
}
%    \end{macrocode}
%
% \iffalse
%</anonchap>
% \fi
%
%
%
%
%
% \iffalse
%<*anysize>
% \fi
%
% \part{lwarp-anysize.sty}
%
% \section{anysize}
%
% \credits{Michael Salzenberg, Thomas Esser}
%
% \DescribePackage{anysize}
% \pkg{anysize} is emulated.
%
% \changes{v0.39}{2017/08/27}{\pkg{anysize}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{anysize}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\papersize#1#2{}
\def\marginsize#1#2#3#4{}
%    \end{macrocode}
%
% \iffalse
%</anysize>
% \fi
%
%
%
%
%
%
% \iffalse
%<*appendix>
% \fi
%
% \part{lwarp-appendix.sty}
%
% \section{appendix}
%
% \credits{Peter Wilson}
%
% \DescribePackage{appendix}
% \pkg{appendix} is patched for use by \pkg{lwarp}.
%
% \limitsappendix
%
% \changes{v0.38}{2017/08/21}{\pkg{appendix}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{appendix}
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand*{\@chap@pppage}{%
\part*{\appendixpagename}
 \if@dotoc@pp
 \addappheadtotoc
 \fi
}

\renewcommand*{\@sec@pppage}{%
\part*{\appendixpagename}
 \if@dotoc@pp
 \addappheadtotoc
 \fi
}
%    \end{macrocode}
%
% \iffalse
%</appendix>
% \fi
%
%
%
%
%
% \iffalse
%<*arabicfront>
% \fi
%
% \part{lwarp-arabicfront.sty}
%
% \section{arabicfront}
%
% \DescribePackage{arabicfront}
% \pkg{arabicfront} is ignored.
%
% \changes{v0.38}{2017/08/25}{\pkg{arabicfront}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{arabicfront}
%    \end{macrocode}
%
%
% \iffalse
%</arabicfront>
% \fi
%
%
%
%
% \iffalse
%<*atbegshi>
% \fi
%
% \part{lwarp-atbegshi.sty}
%
% \section{atbegshi}
%
% \credits{Heiko Oberdiek}
%
% \DescribePackage{atbegshi} Emulated.
%
% \changes{v0.44}{2017/11/10}{\pkg{atbegshi}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-atbegshi}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{atbegshi}[2011/10/05]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\AtBeginShipout}[1]{}
\newbox\AtBeginShipoutBox
\newcommand*{\AtBeginShipoutNext}[1]{}
\newcommand*{\AtBeginShipoutFirst}[1]{}
\newcommand*{\AtBeginShipoutDiscard}{}
\newcommand*{\AtBeginShipoutInit}{}
\newcommand*{\AtBeginShipoutAddToBox}[1]{}
\newcommand*{\AtBeginShipoutAddToBoxForeground}[1]{}
\newcommand*{\AtBeginShipoutUpperLeft}[1]{}
\newcommand*{\AtBeginShipoutUpperLeftForeground}[1]{}
\newcommand*{\AtBeginShipoutOriginalShipout}[1]{}
\def\AtBeginShipoutBoxWidth{0pt}
\def\AtBeginShipoutBoxHeight{0pt}
\def\AtBeginShipoutBoxDepth{0pt}

%    \end{macrocode}
%
% \iffalse
%</atbegshi>
% \fi
%
%
%
%
% \iffalse
%<*authblk>
% \fi
%
% \part{lwarp-authblk.sty}
%
% \section{authblk}
%
% \credits{Patrick W. Daly}
%
% \DescribePackage{authblk}
% \pkg{authblk} is patched for \HTML.
%
% \changes{v0.39}{2017/08/31}{\pkg{authblk}: Added.}
%
% \limitstitlepage
%
% \credits{Patrick W. Daly}
%
% \codehtml
%
% Require that \pkg{authblk} be loaded before \pkg{titling}:
%    \begin{macrocode}
\@ifpackageloaded{titling}{
\PackageError{lwarp-authblk}
{Package authblk must be loaded before titling}
{Titling appends authblk's author macro, so authblk must be loaded first.}
}
{}
%    \end{macrocode}
%
% Load \pkg{authblk}:
%    \begin{macrocode}
\LWR@ProvidesPackagePass{authblk}
%    \end{macrocode}
%
% Patch to add a class for the affiliation:
%    \begin{macrocode}
\LetLtxMacro\LWRAB@affil\affil

\renewcommand{\affil}[2][]{%
\LWRAB@affil[#1]{\protect\InlineClass{affiliation}{#2}}
}
%    \end{macrocode}
% Create an \HTML\ break for an \cs{authorcr}:
%    \begin{macrocode}
\renewcommand*{\authorcr}{\protect\LWR@newlinebr}
%    \end{macrocode}
%
%
%
% \iffalse
%</authblk>
% \fi
%
%
%
%
% \iffalse
%<*balance>
% \fi
%
% \part{lwarp-balance.sty}
%
% \section{balance}
%
% \credits{Patrick W. Daly}
%
% \DescribePackage{balance} Emulated.
%
% \changes{v0.34}{2017/07/27}{\pkg{balance}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-balance}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{balance}
%    \end{macrocode}
%
%
%    \begin{macrocode}
\newcommand*{\balance}{}
\newcommand*{\nobalance}{}
%    \end{macrocode}
%
%
% \iffalse
%</balance>
% \fi
%
%
%
% \iffalse
%<*bigdelim>
% \fi
%
% \part{lwarp-bigdelim.sty}
%
% \section{bigdelim}
% \label{sec:bigdelim}
%
% \credits{Piet van Oostrum, Øystein Bache, Jerry Leichter}
%
% \DescribePackage{bigdelim}
% \pkg{bigdelim} is used as-is for print or \env{lateximage}, and
% patched for \HTML.
%
% The delimiters are displayed in \HTML\
% by printing the delimiter, the text, and a thick border across the side of
% the \cs{multirow} which indicates the actual height of the delimiter.
% The delimiter character is given a \element{span} class of \attribute{ldelim} or
% \attribute{rdelim}, and the default \CSS\ sets this to \attribute{font-size:200\%}
%
% \limitsbigdelim\bigskip
%
% \changes{v0.39}{2017/08/31}{\pkg{bigdelim}: Added.}
% \changes{v0.40}{2017/09/09}{\pkg{bigdelim}: Improved documentation.}
%
% \codehtml
%
% First, remove the temporary definitions of \cs{ldelim} and \cs{rdelim}, which were
% previously defined for tabular scanning in case \pkg{bigdelim} was not loaded:
%    \begin{macrocode}
\let\ldelim\relax
\let\rdelim\relax
%    \end{macrocode}
%
% Next, load the package's new definitions:
%    \begin{macrocode}
\LWR@ProvidesPackagePass{bigdelim}
%    \end{macrocode}
%
% Remember the print-mode versions:
%    \begin{macrocode}
\LetLtxMacro\LWR@origldelim\ldelim
\LetLtxMacro\LWR@origrdelim\rdelim
%    \end{macrocode}
%
% \marg{1:delimiter} \marg{2:\#rows} \marg{3:width} \oarg{4:text}
% \marginpar{\hfill\cs{ldelim}}\marginpar{\hfill\cs{rdelim}}
%    \begin{macrocode}
\RenewDocumentCommand{\ldelim}{m m m O{}}{%
\renewcommand{\LWR@multirowborder}{right}%
\multirow{#2}{#3}{#4 \InlineClass{ldelim}{#1}}%
}

\RenewDocumentCommand{\rdelim}{m m m O{}}{%
\renewcommand{\LWR@multirowborder}{left}%
\multirow{#2}{#3}{\InlineClass{rdelim}{#1} #4}%
}
%    \end{macrocode}
% When entering a \env{lateximage}, restore the print-mode versions:
%    \begin{macrocode}
\appto{\LWR@restoreorigformatting}{%
\LetLtxMacro{\ldelim}{\LWR@origldelim}%
\LetLtxMacro{\rdelim}{\LWR@origrdelim}%
}
%    \end{macrocode}
%
%
% \iffalse
%</bigdelim>
% \fi
%
%
%
%
%
% \iffalse
%<*bigstrut>
% \fi
%
% \part{lwarp-bigstrut.sty}
%
% \section{bigstrut}
%
% \credits{Piet van Oostrum, Øystein Bache, Jerry Leichter}
%
% \DescribePackage{bigstrut}
% \pkg{bigstrut} is used as-is for print or \env{lateximage}, and
% patched for \HTML.
%
% \changes{v0.39}{2017/08/31}{\pkg{bigstrut}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{bigstrut}
%    \end{macrocode}
%
%    \begin{macrocode}
\LetLtxMacro\LWR@origbigstrut\bigstrut

\renewcommand\bigstrut[1][x]{}

\appto{\LWR@restoreorigformatting}{%
\LetLtxMacro{\bigstrut}{\LWR@origbigstrut}%
}
%    \end{macrocode}
%
%
% \iffalse
%</bigstrut>
% \fi
%
%
%
%
% \iffalse
%<*bookmark>
% \fi

% \part{lwarp-bookmark.sty}

% \section{bookmark}
%
% \credits{Heiko Oberdiek}
%
% \DescribePackage{bookmark}
% \pkg{bookmark} is emulated.

% \changes{v0.20}{2017/01/03}{\pkg{bookmark}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-bookmark}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{bookmark}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\bookmarksetup}[1]{}
\newcommand*{\bookmarksetupnext}[1]{}
\newcommand*{\bookmark}[2][]{}
\newcommand*{\bookmarkdefinestyle}[2]{}
\newcommand*{\bookmarkget}[1]{}
\newcommand{\BookmarkAtEnd}[1]{}
%    \end{macrocode}
%
% \iffalse
%</bookmark>
% \fi
%
%
%
%
% \iffalse
%<*booktabs>
% \fi
%
% \part{lwarp-booktabs.sty}
%
% \section{booktabs}
% \label{sec:booktabs}
%
% \credits{Simon Fear}
%
% \DescribePackage{booktabs}
% \pkg{booktabs} is emulated during \HTML\ output, and
% used as-is during print output and inside an \HTML\ \env{lateximage}.
%
% \changes{v0.34}{2017/08/08}{\pkg{booktabs}: Works inside \env{lateximage}.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{booktabs}
%    \end{macrocode}
%
% Booktabs emulation is spread among the tabular code.
% The original definitions are saved here for use in \HTML\ \env{lateximage}s.
% The \HTML\ versions temporarily overwrite these print versions
% when \env{tabular} is started.
%
%    \begin{macrocode}
\LetLtxMacro\LWR@origtoprule\toprule
\LetLtxMacro\LWR@origmidrule\midrule
\LetLtxMacro\LWR@origcmidrule\cmidrule
\LetLtxMacro\LWR@origbottomrule\bottomrule
\LetLtxMacro\LWR@origaddlinespace\addlinespace
\LetLtxMacro\LWR@origmorecmidrules\morecmidrules
\LetLtxMacro\LWR@origspecialrule\specialrule
%    \end{macrocode}
%
% \iffalse
%</booktabs>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*boxedminipage>
% \fi
%
% \part{lwarp-boxedminipage.sty}
%
% \section{boxedminipage}
%
% \DescribePackage{boxedminipage}
% \pkg{boxedminipage} is superceded by \pkg{boxedminipage2e}.
%
% \changes{v0.34}{2017/07/26}{\pkg{boxedminipage}: Prevented.}
%
% \codehtml
%    \begin{macrocode}
\LWR@loadnever{boxedminipage}{boxedminipage2e}
%    \end{macrocode}
%
% \iffalse
%</boxedminipage>
% \fi
%
%
%
%
% \iffalse
%<*boxedminipage2e>
% \fi

% \part{lwarp-boxedminipage2e.sty}

% \section{boxedminipage2e}
%
% \credits{Scott Pakin}
%
% \DescribePackage{boxedminipage2e}
% \pkg{boxedminipage2e} is emulated.
%
% \changes{v0.34}{2017/07/26}{\pkg{boxedminipage2e}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-boxedminipage2e}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{boxedminipage2e}
%    \end{macrocode}

%    \begin{macrocode}
\newenvironment{boxedminipage}{%
\begin{BlockClass}{framebox}%
\minipage%
}
{
\endminipage%
\end{BlockClass}
}
%    \end{macrocode}

% \iffalse
%</boxedminipage2e>
% \fi
%
%
%
%
% \iffalse
%<*breakurl>
% \fi
%
% \part{lwarp-breakurl.sty}
%
% \section{breakurl}
%
% \credits{Vilar Camara Neto}
%
% \DescribePackage{breakurl}
% \pkg{breakurl} is emulated.
%
% \changes{v0.43}{2017/10/31}{\pkg{breakurl}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{breakurl}
%    \end{macrocode}
%
%    \begin{macrocode}
\LetLtxMacro\burl\url

\NewDocumentCommand{\LWR@burlaltb}{O{} +m m}{%
\LWR@subhyperref{#3}{#2}% order reversed from \href
\endgroup%
\LWR@ensuredoingapar%
}

\DeclareRobustCommand*{\burlalt}{%
\LWR@ensuredoingapar%
\begingroup%
\catcode`\_=12
\LWR@burlaltb%
}
\LetLtxMacro\urlalt\burlalt
%    \end{macrocode}
%
% \iffalse
%</breakurl>
% \fi
%
%
%
%
% \iffalse
%<*cancel>
% \fi
%
% \part{lwarp-cancel.sty}
%
% \section{cancel}
%
% \DescribePackage{cancel}
% \pkg{cancel} is used as-is for SVG math, and emulated for HTML text output.
%
% \changes{v0.44}{2017/11/16}{\pkg{cancel}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{cancel}
%    \end{macrocode}
%
%
%
% \cs{cancelto} is math-only, so is used as-is.
%    \begin{macrocode}
\LetLtxMacro\LWR@origcancel\cancel
\LetLtxMacro\LWR@origbcancel\bcancel
\LetLtxMacro\LWR@origxcancel\xcancel

\appto{\LWR@restoreorigformatting}{%
\LetLtxMacro\cancel\LWR@origcancel%
\LetLtxMacro\bcancel\LWR@origbcancel%
\LetLtxMacro\xcancel\LWR@origxcancel%
}
%    \end{macrocode}


% \begin{noindmacro}{\LWR@cancelcolor}
%   \marg{text} \marg{color} \marg{class} \marg{colorstyle} \marg{FormatWPstyle}
%
% Add colors if not empty:
%    \begin{macrocode}
\newcommand{\LWR@cancelcolor}[5]{%
\ifcsempty{#2}%
{\LWR@HTMLtextstyle{#5}{#3}{#1}}%
{\LWR@htmlspanclass[#5;#4:\#\LWR@tempcolor]{#3}{#1}}%
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cancel} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\cancel}[1]{%
\begingroup%
\CancelColor%
\LWR@findcurrenttextcolor%
\color{black}%
\LWR@cancelcolor{#1}{LWR@tempcolor}{sout}{text-decoration-color}%
    {text-decoration:line-through}%
\endgroup%
}

\LetLtxMacro\bcancel\cancel
\LetLtxMacro\xcancel\cancel
%    \end{macrocode}
% \end{noindmacro}
%
% \iffalse
%</cancel>
% \fi
%
%
%
%
% \iffalse
%<*caption2>
% \fi
%
% \part{lwarp-caption2.sty}
%
% \section{caption2}
%
% \DescribePackage{caption2}
% \pkg{caption2} is not used.
% The user is recommended to use \pkg{caption} instead.
%
% \changes{v0.38}{2017/08/22}{\pkg{caption2}: Prevented.}
%
% \codehtml
%    \begin{macrocode}
\LWR@loadnever{caption2}{caption}
%    \end{macrocode}
%
% \iffalse
%</caption2>
% \fi
%
%
%
%
% \iffalse
%<*ccaption>
% \fi

% \part{lwarp-ccaption.sty}

% \section{ccaption}
%
% \DescribePackage{ccaption}
% \pkg{ccaption} is not used.
% The user is recommended to use \pkg{caption} instead.

% \changes{v0.25}{2017/03/16}{\pkg{ccaption}: Prevented.}

% \codehtml
%    \begin{macrocode}
\LWR@loadnever{ccaption}{caption}
%    \end{macrocode}


% \iffalse
%</ccaption>
% \fi
%
%
%
%
%
%
% \iffalse
%<*changepage>
% \fi

% \part{lwarp-changepage.sty}

% \section{changepage}
%
% \credits{Peter Wilson}
%
% \DescribePackage{changepage}
% \pkg{changepage} is emulated.
%
% \changes{v0.22}{2017/03/02}{\pkg{changepage}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-changepage}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{changepage}
%    \end{macrocode}

%    \begin{macrocode}
\newif\ifoddpage
\DeclareRobustCommand{\checkoddpage}{\oddpagetrue}
\DeclareRobustCommand{\changetext}[5]{}
\DeclareRobustCommand{\changepage}[9]{}
\newenvironment{adjustwidth}[2]{}{}
\newenvironment{adjustwidth*}[2]{}{}
%    \end{macrocode}

% \changes{v0.44}{2017/11/13}{\pkg{changepage}: Additional options.}
%    \begin{macrocode}
\newcommand*{\strictpagecheck}{}
\newcommand*{\easypagecheck}{}
%    \end{macrocode}


% \iffalse
%</changepage>
% \fi
%
%
%
%
%
% \iffalse
%<*chngpage>
% \fi
%
% \part{lwarp-chngpage.sty}
%
% \section{chngpage}
%
% \DescribePackage{chngpage}
% \pkg{chngpage} is superceded by \pkg{changepage}.
%
% \changes{v0.39}{2017/08/27}{\pkg{chngpage}: Prevented.}
%
% \codehtml
%    \begin{macrocode}
\LWR@loadnever{chngpage}{changepage}
%    \end{macrocode}
%
% \iffalse
%</chngpage>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*chappg>
% \fi
%
% \part{lwarp-chappg.sty}
%
% \section{chappg}
%
% \credits{Robin Fairbairns}
%
% \DescribePackage{chappg}
% \pkg{chappg} is emulated.
%
% \changes{v0.38}{2017/08/25}{\pkg{chappg}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{chappg}
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand{\pagenumbering}[2][]{}
\providecommand{\chappgsep}{--}
%    \end{macrocode}
%
% \iffalse
%</chappg>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*color>
% \fi
%
% \part{lwarp-color.sty}
%
% \section{color}
%
% \DescribePackage{color}  Allowed but ignored.
% \pkg{xcolor} is then required as well.
%
% \limitscolor
%
% \changes{v0.37}{2017/08/18}{\pkg{color}: Prevented.}
% \changes{v0.38}{2017/08/25}{\pkg{color}: Forces \pkg{xcolor} as well.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{color}
\RequirePackage{xcolor}
%    \end{macrocode}
%
% \iffalse
%</color>
% \fi
%
%
%
%
%
%
% \iffalse
%<*crop>
% \fi
%
% \part{lwarp-crop.sty}
%
% \section{crop}
%
% \credits{Melchior FRANZ}
%
% \DescribePackage{crop} Emulated.
%
% \changes{v0.34}{2017/08/03}{\pkg{crop}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-crop}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{crop}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\crop}[1][]{}
\newcommand*{\cropdef}[6][]{}
%    \end{macrocode}
%
% \iffalse
%</crop>
% \fi
%
%
%
%
%
% \iffalse
%<*cuted>
% \fi
%
% \part{lwarp-cuted.sty}
%
% \section{cuted}
%
% \credits{Sigitas Tolu\v{s}is}
%
% \DescribePackage{cuted}
% \pkg{cuted} is emulated.
%
% \changes{v0.40}{2017/09/07}{\pkg{cuted}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{cuted}
%    \end{macrocode}
%
%    \begin{macrocode}
\newenvironment{strip}{}{}
\newskip\stripsep
\def\oldcolsbreak#1{}
%    \end{macrocode}
%
% \iffalse
%</cuted>
% \fi
%
%
%
%
%
%
% \iffalse
%<*cutwin>
% \fi
%
% \part{lwarp-cutwin.sty}
%
% \section{cutwin}
%
% \credits{Peter Wilson and Alan Hoenig}
%
% \DescribePackage{cutwin} Emulated.
%
% \changes{v0.26}{2017/03/30}{\pkg{cutwin}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-cutwin}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{cutwin}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\opencutleft}{}
\newcommand*{\opencutright}{}
\newcommand*{\opencutcenter}{}
\newcommand*{\cutfuzz}{}

\newenvironment{cutout}[4]
{\marginpar{\windowpagestuff}}
{}

\newcommand*{\windowpagestuff}{}

\newcommand*{\pageinwindow}{%
% \begin{minipage}{.3\linewidth}
\windowpagestuff
% \end{minipage}
}

\newenvironment{shapedcutout}[3]
{\marginpar{\picinwindow}}
{}

\newcommand*{\putstuffinpic}{}

\newcommand*{\picinwindow}{%
\begin{picture}(0,0)
\putstuffinpic
\end{picture}}
%    \end{macrocode}
%
% \iffalse
%</cutwin>
% \fi
%
%
%
%
% \iffalse
%<*dblfnote>
% \fi
%
% \part{lwarp-dblfnote.sty}
%
% \section{dblfnote}
%
% \credits{Hiroshi Nakashima}
%
% \DescribePackage{dblfnote}
% \pkg{dblfnote} is emulated.
%
% \changes{v0.40}{2017/09/06}{\pkg{dblfnote}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{dblfnote}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcounter{DFNsloppiness}
\newdimen\DFNcolumnsep
\newdimen\DFNcolumnwidth
\def\DFNallowcbreak{}
\def\DFNinhibitcbreak{}
\def\DFNtrysingle{}
\def\DFNalwaysdouble{}
\def\DFNruleboth{}
\def\DFNruleleft{}
%    \end{macrocode}
%
% \iffalse
%</dblfnote>
% \fi
%
%
%
%
% \iffalse
%<*dcolumn>
% \fi
%
% \part{lwarp-dcolumn.sty}
%
% \section{dcolumn}
% \label{sec:dcolumn}
%
% \changes{v0.22}{2017/02/24}{\pkg{dcolumn}: Added.}
%
% \DescribePackage{dcolumn}
% \pkg{dcolumn} is emulated by the \pkg{lwarp} core.
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{dcolumn}
%    \end{macrocode}
%
% \iffalse
%</dcolumn>
% \fi
%
%
%
%
%
% \iffalse
%<*draftwatermark>
% \fi

% \part{lwarp-draftwatermark.sty}

% \section{draftwatermark}
% \label{sec:draftwatermark}
%
% \credits{Sergio Callegari}
%
% \changes{v0.20}{2017/01/11}{\pkg{draftwatermark}: Added.}
%
% \DescribePackage{draftwatermark}
% \pkg{draftwatermark} is emulated.

% \codehtml

%    \begin{macrocode}
\LWR@ProvidesPackageDrop{draftwatermark}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand{\SetWatermarkAngle}[1]{}
\newcommand{\SetWatermarkColor}[1]{}
\newcommand{\SetWatermarkLightness}[1]{}
\newcommand{\SetWatermarkFontSize}[1]{}
\newcommand{\SetWatermarkScale}[1]{}
\newcommand{\SetWatermarkHorCenter}[1]{}
\newcommand{\SetWatermarkVertCenter}[1]{}
\newcommand{\SetWatermarkText}[1]{}
%    \end{macrocode}

% \iffalse
%</draftwatermark>
% \fi
%
%
%
%
%
% \iffalse
%<*easy-todo>
% \fi
%
% \part{lwarp-easy-todo.sty}

% \section{easy-todo}
%
% \credits{Juan Rada-Vilela}
%
% \DescribePackage{easy-todo}
% \pkg{easy-todo} is patched for use by \pkg{lwarp}.
%
% \changes{v0.44}{2017/11/10}{\pkg{easy-todo}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{easy-todo}
%    \end{macrocode}

% \begin{noindmacro}{\listoftodos}
% Modified to correct buggy use of \cs{flushright}.
%    \begin{macrocode}
\let\LWR@origlistoftodos\listoftodos

\renewcommand{\listoftodos}{%
\begingroup
\renewcommand{\flushright}{}
\LWR@origlistoftodos
\endgroup
}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\todoii}
% Modified to use \cs{textcolor} instead of \cs{color}.
%    \begin{macrocode}
\renewcommand{\todoii}[2]{%
\ifthenelse{\equal{\@todoobeyfinal}{true}}{%
    \ifoptionfinal{\todoenable{false}}{\todoenable{true}}%
}{}%
\ifthenelse{\equal{\@todoenable}{true}}{%
\refstepcounter{todos}%
\noindent{%
    \todocolor%
    \LWR@textcurrentcolor{%
        \normalfont\scriptsize{\bfseries{\thetodos.#1}}%
    }%
}%
\addcontentsline{lod}{todos}{\protect{\thetodos. }#2}%
}{}%
}
%    \end{macrocode}
% \end{noindmacro}


% \iffalse
%</easy-todo>
% \fi
%
%
%
%
%
% \iffalse
%<*ebook>
% \fi
%
% \part{lwarp-ebook.sty}
%
% \section{ebook}
%
% \credits{Jørgen Steensgaard}
%
% \DescribePackage{ebook}
% \pkg{ebook} is emulated.
%
% \changes{v0.39}{2017/08/27}{\pkg{ebook}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{ebook}
%    \end{macrocode}
%
%    \begin{macrocode}
\setcounter{secnumdepth}{0}
\setcounter{tocdepth}{2}

\providecommand{\pagefill}[1][0.001mm]{\noindent}

\providecommand{\ebook}{
\setcounter{secnumdepth}{0}
\setcounter{tocdepth}{2}
}
%    \end{macrocode}
%
% \iffalse
%</ebook>
% \fi
%
%
%
%
% \iffalse
%<*ellipsis>
% \fi

% \part{lwarp-ellipsis.sty}

% \section{ellipsis}
% \label{sec:ellipsis}
%
% \credits{Peter J. Heslin}
%
% \changes{v0.25}{2017/03/16}{\pkg{ellipsis}: Added.}
%
% \DescribePackage{ellipsis}
% \pkg{ellipsis} is emulated.

%    \begin{macrocode}
\LWR@ProvidesPackageDrop{ellipsis}

\newcommand{\ellipsisgap}{0.1em}
%    \end{macrocode}

% \iffalse
%</ellipsis>
% \fi
%
%
%
%
%
%
% \iffalse
%<*emptypage>
% \fi

% \part{lwarp-emptypage.sty}

% \section{emptypage}
%
% \DescribePackage{emptypage}
% \pkg{emptypage} is ignored.
%
% \changes{v0.25}{2017/03/22}{\pkg{emptypage}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-emptypage}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{emptypage}
%    \end{macrocode}

% \iffalse
%</emptypage>
% \fi
%
%
%
%
%
%
% \iffalse
%<*endnotes>
% \fi

% \part{lwarp-endnotes.sty}
%
% \section{endnotes}
%
% \credits{John Lavagnino}
%
% \DescribePackage{endnotes} Used as-is.
%
% \limitsendnotes
%
% \bigskip
%
% \changes{v0.26}{2017/03/27}{\pkg{endnotes}: Added.}
%
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{endnotes}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\enoteformat{%
% \rightskip\z@ \leftskip\z@ \parindent=1.8em
\leavevmode
% \llap{
\makeenmark
% }
}

\def\@makeenmark{\hbox{\LWR@htmlspan{sup}{\normalfont\theenmark}}}
\def\makeenmark{\@makeenmark}
%    \end{macrocode}
%
% \iffalse
%</endnotes>
% \fi
%
%
%
%
%
%
% \iffalse
%<*enumerate>
% \fi
%
% \part{lwarp-enumerate.sty}
%
% \section{enumerate}
% \label{sec:enumerate}
%
% \DescribePackage{enumerate}
% \pkg{enumerate} is supported with no changes.

% This package is only required because it was used in the past to drop
% and then emulate the package.
% It cannot be removed because an older version which dropped the
% package may still remain, for example in a local vs. distribution directory,
% but it is now supported directly by \pkg{lwarp} and thus must no longer be dropped.
%
% \changes{v0.34}{2017/07/27}{\pkg{enumerate}: Added.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{enumerate}
%    \end{macrocode}
%
%
% \iffalse
%</enumerate>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*enumitem>
% \fi
%
% \part{lwarp-enumitem.sty}
%
% \section{enumitem}
% \label{sec:enumitem}
%
% \credits{Javier Bezos}
%
% \DescribePackage{enumitem}
% \pkg{enumitem} is supported with minor adjustments.
%
% \changes{v0.34}{2017/07/27}{\pkg{enumitem}: Added, no longer required.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{enumitem}
%    \end{macrocode}
%
%
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \cs{newlist} \marg{name} \marg{type} \marg{maxdepth} \\
% \cs{renewlist} \marg{name} \marg{type} \marg{maxdepth}
%
% For \pkg{enumitem} lists, new lists must have the start and end actions assigned to
% the new environment.  Renewed lists already have their actions assigned, and
% thus need no changes.
%    \begin{macrocode}
\let\LWR@orignewlist\newlist

\renewcommand*{\newlist}[3]{%
\LWR@orignewlist{#1}{#2}{#3}%
\AtBeginEnvironment{#1}{\csuse{LWR@#2start}}%
\AtEndEnvironment{#1}{\csuse{LWR@#2end}}%
}
%    \end{macrocode}


%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}

% \iffalse
%</enumitem>
% \fi
%
%
%
%
%
%
%
%
% \iffalse
%<*epigraph>
% \fi

% \part{lwarp-epigraph.sty}

% \section{epigraph}
% \label{sec:epigraph}
%
% \credits{Peter Wilson}
%
% \DescribePackage{epigraph}
% \pkg{epigraph} is emulated.
%
% \changes{v0.42}{2017/10/27}{\pkg{epigraph}: If \protect\texttt{FormatWP} add HTML styles.}
%
% \codehtml

%    \begin{macrocode}
\LWR@ProvidesPackageDrop{epigraph}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand{\qitem}[2]
{
\begin{BlockClass}{qitem}
#1
\ifbool{FormatWP}
{\begin{BlockClass}[border-top:1px solid gray]{epigraphsource}}
{\begin{BlockClass}{epigraphsource}}
#2
\end{BlockClass}
\end{BlockClass}
}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand{\epigraph}[2]
{
\begin{LWR@BlockClassWP}{text-align:right}{}{epigraph}
\qitem{#1}{#2}
\end{LWR@BlockClassWP}
}

\newenvironment*{epigraphs}
{\LWR@BlockClassWP{text-align:right}{}{epigraph}}
{\endLWR@BlockClassWP}
%    \end{macrocode}
%
% Use \CSS\ to format epigraphs.
%
% The following are null commands for source compatibility:
%    \begin{macrocode}
\newlength{\epigraphwidth}
\setlength{\epigraphwidth}{.5\linewidth}
\newenvironment*{flushepinormal}{}{}
\newcommand{\textflush}[1]{flushepinormal}
\newcommand{\epigraphflush}[1]{flushright}
\newcommand{\sourceflush}[1]{flushright}
\newcommand*{\epigraphsize}{\small}
\newlength{\epigraphrule}
\newlength{\beforeepigraphskip}
\newlength{\afterepigraphskip}
\newcommand{\epigraphhead}[2][0]{#2}
\newcommand{\dropchapter}[1]{}
\newcommand*{\undodrop}{}
\newcommand{\cleartoevenpage}[1][]{}
%    \end{macrocode}
%
% \iffalse
%</epigraph>
% \fi
%
%
%
%
%
%
% \iffalse
%<*eso-pic>
% \fi
%
% \part{lwarp-eso-pic.sty}

% \section{eso-pic}
% \label{sec:eso-pic}
%
% \credits{Rolf Niepraschk}
%
% \changes{v0.20}{2017/01/11}{\pkg{eso-pic}: Added.}
%
% \DescribePackage{eso-pic}
% \pkg{eso-pic} is emulated.

% \codehtml

%    \begin{macrocode}
\LWR@ProvidesPackageDrop{eso-pic}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\LenToUnit}{}
\newcommand{\AtPageUpperLeft}[1]{}
\newcommand{\AtPageLowerLeft}[1]{}
\newcommand{\AtPageCenter}[1]{}
\newcommand{\AtStockLowerLeft}[1]{}
\newcommand{\AtStockUpperLeft}[1]{}
\newcommand{\AtStockCenter}[1]{}
\newcommand{\AtTextUpperLeft}[1]{}
\newcommand{\AtTextLowerLeft}[1]{}
\newcommand{\AtTextCenter}[1]{}
\NewDocumentCommand{\AddToShipoutPictureBG}{s +m}{}
\renewcommand{\AddToShipoutPicture}{\AddToShipoutPictureBG}
\NewDocumentCommand{\AddToShipoutPictureFG}{s +m}{}
\newcommand*{\ClearShipoutPictureBG}{}
\newcommand*{\ClearShipoutPicture}{}
\newcommand*{\ClearShipoutPictureFG}{}
\newcommand{\gridSetup}[6][]{}
%    \end{macrocode}

% \iffalse
%</eso-pic>
% \fi
%
%
%
%
% \iffalse
%<*everypage>
% \fi

% \part{lwarp-everypage.sty}

% \section{everypage}
% \label{sec:everypage}
%
% \credits{Sergio Callegari}
%
% \changes{v0.20}{2017/01/11}{\pkg{everypage}: Added.}
%
% \DescribePackage{everypage}
% \pkg{everypage} is emulated.

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{everypage}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\AddEverypageHook}[1]{}
\newcommand*{\AddThispageHook}[1]{}
%    \end{macrocode}

% \iffalse
%</everypage>
% \fi
%
%
%
%
%
%
% \iffalse
%<*everyshi>
% \fi
%
% \part{lwarp-everyshi.sty}
%
% \section{everyshi}
%
% \credits{Martin Schr\"{o}der}
%
% \DescribePackage{everyshi} Emulated.
%
% \changes{v0.34}{2017/08/03}{\pkg{everyshi}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-everyshi}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{everyshi}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\EveryShipout}[1]{}
\newcommand*{\AtNextShipout}[1]{}
%    \end{macrocode}
%
% \iffalse
%</everyshi>
% \fi
%
%
%
%
%
%
% \iffalse
%<*extramarks>
% \fi

% \part{lwarp-extramarks.sty}

% \section{extramarks}
%
% \credits{Piet van Oostrum}
%
% \DescribePackage{extramarks}
% \pkg{extramarks} is emulated.
%
% \changes{v0.20}{2017/01/11}{\pkg{extramarks}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-extramarks}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{extramarks}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\extramarks}[2]{}
\newcommand*{\firstleftxmark}{}
\newcommand*{\lastleftxmark}{}
\newcommand*{\firstrightxmark}{}
\newcommand*{\lastrightxmark}{}
\newcommand*{\firstxmark}{}
\newcommand*{\lastxmark}{}
\newcommand*{\topxmark}{}
\newcommand*{\topleftxmark}{}
\newcommand*{\firstleftmark}{}
\newcommand*{\lastrightmark}{}
%    \end{macrocode}

% \iffalse
%</extramarks>
% \fi
%
%
%
%
%
%
% \iffalse
%<*fancybox>
% \fi
%
% \part{lwarp-fancybox.sty}
%
% \section{fancybox}
% \label{sec:fancybox}
%
% \credits{Timothy Van Zandt}
%
% \DescribePackage{fancybox}
% \pkg{fancybox} is supported with some patches.
%
% \limitsfancybox
%
%
% \changes{v0.34}{2017/07/27}{\pkg{fancybox}: Added.}
% \changes{v0.42}{2017/10/27}{\pkg{fancybox}: If \protect\texttt{FormatWP} add HTML styles.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{fancybox}
%    \end{macrocode}
%
%
%
%    \begin{macrocode}
\renewcommand*{\@shadowbox}[1]{%
\ifbool{FormatWP}%
{\InlineClass[border:1px solid black]{shadowbox}{#1}}%
{\InlineClass{shadowbox}{#1}}%
}

\renewcommand*{\@doublebox}[1]{%
\ifbool{FormatWP}%
{\InlineClass[border:1px double black]{doublebox}{#1}}%
{\InlineClass{doublebox}{#1}}%
}

\renewcommand*{\@ovalbox}[2]{%
\ifbool{FormatWP}%
{\InlineClass[border:1px solid black; border-radius:1ex]{ovalbox}{#2}}%
{%
    \ifthenelse{\isequivalentto{#1}{\thinlines}}%
    {\InlineClass{ovalbox}{#2}}%
    {\InlineClass{Ovalbox}{#2}}%
}%
}
%    \end{macrocode}
%
%
% Convert minipages, parboxes, and lists into linear text
% using the |LWR@nestspan| environment:
%    \begin{macrocode}
\let\LWR@origSbox\Sbox

\def\Sbox{\LWR@origSbox\LWR@nestspan}


\let\LWR@origendSbox\endSbox

\def\endSbox{\endLWR@nestspan\LWR@origendSbox}
%    \end{macrocode}
%
% \env{Beqnarray} is adapted for MathJax or enclosed inside a \env{lateximage}:
%
%    \begin{macrocode}
\RenewEnviron{Beqnarray}
{\LWR@eqnarrayfactor}

\csgpreto{Beqnarray*}{\boolfalse{LWR@numbereqnarray}}
%    \end{macrocode}
%
% \cs{GenericCaption} is enclosed in an \HTML\ block:
%
%    \begin{macrocode}
\renewcommand{\GenericCaption}[1]{%
\LWR@figcaption%
#1%
\endLWR@figcaption%
}
%    \end{macrocode}
%
% \env{Btrivlist} is enclosed in an \HTML\ block:
%
%    \begin{macrocode}
\RenewDocumentEnvironment{Btrivlist}{m o}
{\begin{BlockClass}{Btrivlist}\tabular{#1}}
{\endtabular\end{BlockClass}}
%    \end{macrocode}
%
% \env{Btrivlist} is also neutralized when used inside a span:
%
%    \begin{macrocode}
\AtBeginEnvironment{LWR@nestspan}{%
\RenewDocumentEnvironment{Btrivlist}{m o}{}{}%
\RenewDocumentCommand{\LWR@origitem}{d()}{\LWRFB@origitem}%
}
%    \end{macrocode}
%
% \pkg{lwarp}'s handling of \cs{item} is patched to accept
% \pkg{fancybox}'s optional arguments:
%
%    \begin{macrocode}
\let\LWRFB@origitemizeitem\LWR@itemizeitem
\let\LWRFB@origdescitem\LWR@descitem
\LetLtxMacro{\LWRFB@origitem}{\LWR@origitem}

\RenewDocumentCommand{\LWR@itemizeitem}{d()}{\LWRFB@origitemizeitem}
\RenewDocumentCommand{\LWR@descitem}{d()}{\LWRFB@origdescitem}
%    \end{macrocode}
%
% The various boxed lists become regular lists:
%
%    \begin{macrocode}
\renewenvironment{Bitemize}[1][]{\begin{itemize}}{\end{itemize}}
\renewenvironment{Benumerate}[1][]{\begin{enumerate}}{\end{enumerate}}
\renewenvironment{Bdescription}[1][]{\begin{description}}{\end{description}}
%    \end{macrocode}
%
% \cs{boxput} simply prints one then the other argument,
% side-by-side instead of above and behind:
%
%    \begin{macrocode}
\RenewDocumentCommand{\boxput}{s d() m m}{%
\IfBooleanTF{#1}{#3\quad#4}{#4\quad#3}%
}
%    \end{macrocode}
%
% Neutralized commands:
%
%    \begin{macrocode}
\RenewDocumentCommand{\fancyput}{s d() m}{}
\RenewDocumentCommand{\thisfancyput}{s d() m}{}

\RenewDocumentCommand{\fancypage}{m m}{}
\RenewDocumentCommand{\thisfancypage}{m m}{}

\def\LandScape#1{}
\def\endLandScape{}
\def\@Landscape#1#2#3{}
\def\endLandscape{}
%    \end{macrocode}
%
% Low-level patches for \env{Verbatim}, \env{VerbatimInput}, \env{UseVerbatim}:
%
%    \begin{macrocode}
\let\LWRFB@UseVerbatim\UseVerbatim
\renewcommand*{\UseVerbatim}[1]{%
\LWR@atbeginverbatim{Verbatim}\unskip\LWR@origvspace*{-.5\baselineskip}%%
\LWRFB@UseVerbatim{#1}%
\LWR@afterendverbatim%
}

\let\LWRFB@LUseVerbatim\LUseVerbatim

\renewcommand*{\LUseVerbatim}[1]{%
\LWR@atbeginverbatim{LVerbatim}%\unskip\LWR@origvspace*{-\baselineskip}%%
\noindent%
\LWRFB@LUseVerbatim{#1}%
\LWR@afterendverbatim%
}

\def\@BUseVerbatim[#1]#2{%
\LWR@atbeginverbatim{BVerbatim}\unskip\LWR@origvspace*{-.5\baselineskip}%%
\LWRFB@UseVerbatim{#2}%
\LWR@afterendverbatim%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
% \iffalse
%</fancybox>
% \fi
%
%
%
%
%
% \iffalse
%<*fancyhdr>
% \fi

% \part{lwarp-fancyhdr.sty}

% \section{fancyhdr}
%
% \credits{Piet van Oostrum}
%
% \DescribePackage{fancyhdr}
% \pkg{fancyhdr} is nullified.
%
% \changes{v0.20}{2017/01/11}{\pkg{fancyhdr}: Added.}
% \changes{v0.33}{2017/06/18}{\pkg{fancyhdr}: Fix: Optional args for \cs{lhead}, etc.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-fancyhdr}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fancyhdr}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\fancyhead}[2][]{}
\newcommand*{\fancyfoot}[2][]{}
\newcommand*{\fancyhf}[2][]{}
\newcommand*{\fancypagestyle}[2]{}
\newcommand*{\lhead}[2][]{}
\newcommand*{\chead}[2][]{}
\newcommand*{\rhead}[2][]{}
\newcommand*{\lfoot}[2][]{}
\newcommand*{\cfoot}[2][]{}
\newcommand*{\rfoot}[2][]{}
\newcommand*{\headrulewidth}{}
\newcommand*{\footrulewidth}{}
\newcommand*{\fancyheadoffset}[2][]{}
\newcommand*{\fancyfootoffset}[2][]{}
\newcommand*{\fancyhfoffset}[2][]{}
\newcommand*{\iffloatpage}[2]{#2}
\newcommand*{\ifftopfloat}[2]{#2}
\newcommand*{\iffbotfloat}[2]{#2}
%    \end{macrocode}

% \iffalse
%</fancyhdr>
% \fi
%
%
%
%
% \iffalse
%<*fancyref>
% \fi
%
% \part{lwarp-fancyref.sty}
%
% \section{fancyref}
%
% \DescribePackage{fancyref}
% \pkg{fancyref} is emulated.
%
% \changes{v0.44}{2017/11/22}{\pkg{fancyref}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fancyref}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\fancyrefhook}[1]{#1}
\newcommand*{\fref}[2][]{\cref{#2}}
\newcommand*{\Fref}[2][]{\Cref{#2}}
\newcommand*{\fancyrefchaplabelprefix}{chap}
\newcommand*{\fancyrefenumlabelprefix}{enum}
\newcommand*{\fancyrefeqlabelprefix}{eq}
\newcommand*{\fancyreffiglabelprefix}{fig}
\newcommand*{\fancyreffnlabelprefix}{fn}
\newcommand*{\fancyrefseclabelprefix}{sec}
\newcommand*{\fancyreftablabelprefix}{tab}
\newcommand*{\fancyrefchangeprefix}[2]{}
\newcommand*{\fancyrefargdelim}{:}
\newcommand*{\fancyrefloosespacing}{~}
\newcommand*{\fancyreftightspacing}{\,}
\newcommand*{\fancyrefdefaultspacing}{\fancyrefloosespacing}
\providecommand*{\chaptername}{Chapter}
\providecommand*{\figurename}{Figure}
\providecommand*{\pagename}{Page}
\providecommand*{\tablename}{Table}
\renewcommand*{\Frefchapname}{\chaptername}
\renewcommand*{\Frefenumname}{Item}
\renewcommand*{\Frefeqname}{Equation}
\renewcommand*{\Freffigname}{\figurename}
\renewcommand*{\Freffnname}{Footnote}
\renewcommand*{\Frefonname}{On}
\renewcommand*{\Frefpgname}{\pagename}
\renewcommand*{\Frefsecname}{Section}
\renewcommand*{\Frefseename}{See}
\renewcommand*{\Freftabname}{\tablename}
\renewcommand*{\Freffigshortname}{Fig.}
\renewcommand*{\Frefpgshortname}{P.}
\renewcommand*{\Freftabshortname}{Tab.}
\renewcommand*{\frefchapname}{\MakeLowercase{\Frefchapname}}
\renewcommand*{\frefenumname}{\MakeLowercase{\Frefenumname}}
\renewcommand*{\frefeqname}{\MakeLowercase{\Frefeqname}}
\renewcommand*{\freffigname}{\MakeLowercase{\Freffigname}}
\renewcommand*{\freffnname}{\MakeLowercase{\Freffnname}}
\renewcommand*{\frefonname}{\MakeLowercase{\Frefonname}}
\renewcommand*{\frefpgname}{\MakeLowercase{\Frefpgname}}
\renewcommand*{\frefsecname}{\MakeLowercase{\Frefsecname}}
\renewcommand*{\frefseename}{\MakeLowercase{\Frefseename}}
\renewcommand*{\freftabname}{\MakeLowercase{\Freftabname}}
\renewcommand*{\freffigshortname}{\MakeLowercase{\Freffigshortname}}
\renewcommand*{\frefpgshortname}{\MakeLowercase{\Frefpgshortname}}
\renewcommand*{\freftabshortname}{\MakeLowercase{\Freftabshortname}}
\newcommand*{\fancyrefaddcaptions}[2]{}
\newcommand*{\fancyrefdefaultformat}{\@empty}
\newcommand{\frefformat}[3]{}
\newcommand{\Frefformat}[3]{}
%    \end{macrocode}
%
% \iffalse
%</fancyref>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*fancyvrb>
% \fi
%
% \part{lwarp-fancyvrb.sty}
%
% \section{fancyvrb}
% \label{sec:fancyvrb}
%
% \credits{Timothy Van Zandt}
%
% \DescribePackage{fancyvrb}
% \pkg{fancyvrb} is supported with some patches.
%
%
% \changes{v0.34}{2017/07/27}{\pkg{fancyvrb}: Added, no longer required.}
%
% \codehtml
%    \begin{macrocode}
\RequirePackage{xcolor}% for \convertcolorspec
\LWR@ProvidesPackagePass{fancyvrb}
%    \end{macrocode}
%

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%

% Initial default patch for fancyvrb:
%    \begin{macrocode}
\fvset{frame=none}%
%    \end{macrocode}

% For \cs{VerbatimFootnotes}:
%    \begin{macrocode}
\renewcommand{\VerbatimFootnotes}{
\PackageError{lwarp}
{Verbatim footnotes are not yet supported by lwarp.}
{This may be improved some day.}
}
%    \end{macrocode}


% After the preamble is loaded, after any patches to \env{Verbatim}:
%    \begin{macrocode}
\AfterEndPreamble{
\LWR@traceinfo{Patching Verbatim.}
%    \end{macrocode}
%
% Remember the original defintion of \env{Verbatim}:
%    \begin{macrocode}
\let\LWRFV@origVerbatim\Verbatim
%    \end{macrocode}
%
%
% \begin{environment}{Verbatim}
%
% Patched to place the environment in a |fancyvrb| div,
% and the label in a |fancyvrblabel| div.
% Also corrects the left margin for line numbers.
% Also uses |VerbatimHTMLWidth| to control placement of line numbers on the right.
% Aligning the right margin requires knowing the width.
%
% \changes{v0.20}{2016/12/24}{Added.}
%
%    \begin{macrocode}
\renewcommand*{\Verbatim}{%
\LWR@forcenewpage
\LWRFV@origVerbatim%
}
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\LWR@FVstyle} Holds the style of the verbatim.
%    \begin{macrocode}
\newcommand*{\LWR@FVstyle}{}
%    \end{macrocode}
% \end{macro}
%
% The following patches to \env{Verbatim} are executed at the
% start and end of the environment, depending on the choice of |frame|.
% Original code is from the \pkg{fancyvrb} package.
%    \begin{macrocode}
\newcommand*{\LWR@fvstartnone}{%
\LWR@traceinfo{fvstartnone}%
\hbox to\z@{\LWR@atbeginverbatim[\LWR@FVstyle]{verbatim}}%
}

\newcommand*{\LWR@fvendnone}{%
\LWR@traceinfo{fvendnone}%
\hbox to\z@{\LWR@afterendverbatim}%
}

\newcommand*{\LWR@fvstartsingle}{%
\LWR@traceinfo{fvstartsingle}%
\LWR@fvstartnone%
\FV@BeginListFrame@Single%
}

\newcommand*{\LWR@fvendsingle}{%
\LWR@traceinfo{fvendsingle}%
\FV@EndListFrame@Single%
\LWR@fvendnone%
}

\newcommand*{\LWR@fvstartline}{%
\LWR@traceinfo{fvstartline}%
\LWR@fvstartnone%
\FV@BeginListFrame@Lines%
}

\newcommand*{\LWR@fvendline}{%
\LWR@traceinfo{fvendline}%
\FV@EndListFrame@Lines%
\LWR@fvendnone%
}
%    \end{macrocode}
%
% The following patches select the start/left/right/end
% behaviors depending on |frame|.
% Original code is from the \pkg{fancyvrb} package.
%    \begin{macrocode}
\newcommand*{\LWR@FVfindbordercolor}{%
\FancyVerbRuleColor%
\LWR@findcurrenttextcolor%
\color{black}%
}

% border width of \FV@FrameRule
\newcommand*{\LWR@FVborderstyle}[1]{%
padding#1: \strip@pt\dimexpr \FV@FrameSep\relax\relax pt ; %
\LWR@FVfindbordercolor %
border#1: \strip@pt\dimexpr \FV@FrameRule\relax\relax pt solid \#\LWR@tempcolor ; %
}

\def\FV@Frame@none{%
\renewcommand*{\LWR@FVstyle}{\LWR@currenttextcolorstyle}%
\let\FV@BeginListFrame\LWR@fvstartnone%
\let\FV@LeftListFrame\relax%
\let\FV@RightListFrame\relax%
\let\FV@EndListFrame\LWR@fvendnone}

\FV@Frame@none% default values

\def\FV@Frame@single{%
\renewcommand*{\LWR@FVstyle}{\LWR@currenttextcolorstyle\LWR@FVborderstyle{}}%
\let\FV@BeginListFrame\LWR@fvstartsingle%
\let\FV@LeftListFrame\FV@LeftListFrame@Single%
\let\FV@RightListFrame\FV@RightListFrame@Single%
\let\FV@EndListFrame\LWR@fvendsingle}

\def\FV@Frame@lines{%
\renewcommand*{\LWR@FVstyle}{%
    \LWR@currenttextcolorstyle\LWR@FVborderstyle{-top}\LWR@FVborderstyle{-bottom}%
}%
\let\FV@BeginListFrame\LWR@fvstartline%
\let\FV@LeftListFrame\relax%
\let\FV@RightListFrame\relax%
\let\FV@EndListFrame\LWR@fvendline}

\def\FV@Frame@topline{%
\renewcommand*{\LWR@FVstyle}{\LWR@currenttextcolorstyle\LWR@FVborderstyle{-top}}%
\let\FV@BeginListFrame\LWR@fvstartline%
\let\FV@LeftListFrame\relax%
\let\FV@RightListFrame\relax%
\let\FV@EndListFrame\LWR@fvendnone}

\def\FV@Frame@bottomline{%
\renewcommand*{\LWR@FVstyle}{\LWR@currenttextcolorstyle\LWR@FVborderstyle{-bottom}}%
\let\FV@BeginListFrame\LWR@fvstartnone%
\let\FV@LeftListFrame\relax%
\let\FV@RightListFrame\relax%
\let\FV@EndListFrame\LWR@fvendline}

\def\FV@Frame@leftline{%
\renewcommand*{\LWR@FVstyle}{\LWR@currenttextcolorstyle\LWR@FVborderstyle{-left}}%
% To define the \FV@FrameFillLine macro (from \FV@BeginListFrame)
\ifx\FancyVerbFillColor\relax%
\let\FV@FrameFillLine\relax%
\else%
\@tempdima\FV@FrameRule\relax%
\multiply\@tempdima-\tw@%
\edef\FV@FrameFillLine{%
{\noexpand\FancyVerbFillColor{\vrule\@width\number\@tempdima sp}%
\kern-\number\@tempdima sp}}%
\fi%
\let\FV@BeginListFrame\LWR@fvstartnone%
\let\FV@LeftListFrame\FV@LeftListFrame@Single%
\let\FV@RightListFrame\relax%
\let\FV@EndListFrame\LWR@fvendnone}
%    \end{macrocode}
%
% Adds the optional label to the top and bottom edges.
% Original code is from the \pkg{fancyvrb} package.
%    \begin{macrocode}
\def\FV@SingleFrameLine#1{%
  \hbox to\z@{%
%     \kern\leftmargin
    \ifnum#1=\z@\relax
      \let\FV@Label\FV@LabelBegin
    \else
      \let\FV@Label\FV@LabelEnd
    \fi
    \ifx\FV@Label\relax
%       \FancyVerbRuleColor{\vrule \@width\linewidth \@height\FV@FrameRule}%
    \else
      \ifnum#1=\z@
%         \setbox\z@\hbox{\strut\enspace\FV@LabelBegin\enspace\strut}%
        \ifx\FV@LabelPositionTopLine\relax
        \else
        \LWR@FVfindbordercolor
        \LWR@htmltagc{div class="fancyvrblabel" style="color: \#\LWR@tempcolor"}
        \LWR@origtextrm{\FV@LabelBegin}% \textrm preserves emdash
        \LWR@htmltagc{/div}
        \fi
      \else
%         \setbox\z@\hbox{\strut\enspace\FV@LabelEnd\enspace\strut}%
        \ifx\FV@LabelPositionBottomLine\relax
        \else
        \LWR@FVfindbordercolor
        \LWR@htmltagc{div class="fancyvrblabel" style="color: \#\LWR@tempcolor"}
        \LWR@origtextrm{\FV@LabelEnd}
        \LWR@htmltagc{/div}
        \fi
      \fi

    \fi
    \hss
    }
}
%    \end{macrocode}
%
% Processes each line, adding optional line numbers.
% Original code is from the \pkg{fancyvrb} package.
%    \begin{macrocode}
\def\FV@ListProcessLine#1{%
   \hbox to \hsize{%
%      \kern\leftmargin
      \hbox to \VerbatimHTMLWidth {%
       \ifcsvoid{FV@LeftListNumber}{}{\kern 2.5em}%
        \FV@LeftListNumber%
%       \FV@LeftListFrame
      \FancyVerbFormatLine{#1}%
      \hss%
%       \FV@RightListFrame
      \FV@RightListNumber%
    }%
      \hss% required to avoid underfull hboxes
}
}
%    \end{macrocode}

% \begin{environment}{BVerbatim}
%    \begin{macrocode}
\AtBeginEnvironment{BVerbatim}
{
\LWR@forcenewpage
\LWR@atbeginverbatim{bverbatim}

}

\AfterEndEnvironment{BVerbatim}
{
\leavevmode\par\LWR@origvspace{-\baselineskip}
\LWR@afterendverbatim
}
%    \end{macrocode}
% \end{environment}

% End of the modifications to make at the end of the preamble:
%    \begin{macrocode}
} % \AfterEndPreamble
%    \end{macrocode}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
% \iffalse
%</fancyvrb>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*figcaps>
% \fi
%
% \part{lwarp-figcaps.sty}
%
% \section{figcaps}
%
% \credits{Patrick W. Daly}
%
% \DescribePackage{figcaps} Emulated.
%
% \changes{v0.34}{2017/07/27}{\pkg{figcaps}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-figcaps}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{figcaps}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\figcapson}{}
\newcommand*{\figcapsoff}{}
\newcommand*{\printfigures}{}
\newcommand*{\figmarkon}{}
\newcommand*{\figmarkoff}{}
\def\figurecapname{Figure Captions}
\def\tablepagename{Tables}
\def\figurepagename{Figures}
%    \end{macrocode}
%
% \iffalse
%</figcaps>
% \fi
%
%
%
%
% \iffalse
%<*fix2col>
% \fi
%
% \part{lwarp-fix2col.sty}
%
% \section{fix2col}
%
% \DescribePackage{fix2col}
% \pkg{fix2col} is ignored.
%
% \changes{v0.38}{2017/08/25}{\pkg{fix2col}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fix2col}
%    \end{macrocode}
%
%
% \iffalse
%</fix2col>
% \fi
%
%
%
%
%
% \iffalse
%<*fixme>
% \fi
%
% \part{lwarp-fixme.sty}

% \section{fixme}
%
% \credits{Didier Verna}
%
% \DescribePackage{fixme}
% \pkg{fixme} is patched for use by \pkg{lwarp}.
%
% \limitsfixme
%
% \changes{v0.44}{2017/11/13}{\pkg{fixme}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{fixme}
%    \end{macrocode}
%
% Restore \pkg{lwarp}'s version of \cs{@wrindex},
% ignoring the \pkg{fixme} package's |target| option:
%    \begin{macrocode}
\let\@wrindex\LWR@wrindex
%    \end{macrocode}
%
% Float-related macros required by \pkg{lwarp}:
%    \begin{macrocode}
\newcommand{\ext@fixme}{lox}

\renewcommand{\l@fixme}[2]{\hypertocfloat{1}{fixme}{lox}{#1}{#2}}
%    \end{macrocode}
%
% Other modifications:
%    \begin{macrocode}
\def\FXFaceInlineHTMLStyle{font-weight:bold}

\renewcommand*\FXLayoutInline[3]{ %
\InlineClass[\FXFaceInlineHTMLStyle]{fixmeinline}%
    {\@fxtextstd{#1}{#2}{#3}}%
}

\def\FXFaceEnvHTMLStyle{font-weight:bold}

\renewcommand*\FXEnvLayoutPlainBegin[2]{%
\BlockClass[\FXFaceEnvHTMLStyle]{fixmebold}
\ignorespaces#2 \fxnotename{#1}: \ignorespaces}

\renewcommand*\FXEnvLayoutPlainEnd[2]{\endBlockClass}

\renewcommand*\FXEnvLayoutSignatureBegin[2]{%
\BlockClass[\FXFaceEnvHTMLStyle]{fixmebold}
\fxnotename{#1}: \ignorespaces}

\renewcommand*\FXEnvLayoutSignatureEnd[2]{\@fxsignature{#2}\endBlockClass}

\def\FXFaceSignatureHTMLStyle{font-style:italic}

\DeclareRobustCommand*\@fxsignature[1]{%
\ifthenelse{\equal{#1}{}}%
{}%
{ -- {\InlineClass[\FXFaceSignatureHTMLStyle]{fixmesignature}{#1}}}%
}


\def\FXFaceTargetHTMLStyle{font-style:italic}

\renewcommand\FXTargetLayoutPlain[2]{%
    \InlineClass[\FXFaceTargetHTMLStyle]{fixmetarget}{#2}%
}
%    \end{macrocode}

% \iffalse
%</fixme>
% \fi
%
%
%
%
% \iffalse
%<*fixmetodonotes>
% \fi
%
% \part{lwarp-fixmetodonotes.sty}

% \section{fixmetodonotes}
%
% \credits{Gioele Barabucci}
%
% \DescribePackage{fixmetodonotes}
% \pkg{fixmetodonotes} is patched for use by \pkg{lwarp}.
%
% \changes{v0.44}{2017/11/10}{\pkg{fixmetodonotes}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{fixmetodonotes}
%    \end{macrocode}

%    \begin{macrocode}
\renewcommand{\NOTES@addtolist}[2]{%
    \refstepcounter{NOTES@note}%
%   \phantomsection% REMOVED
    \addcontentsline{notes}{NOTES@note}{%
        \protect\numberline{\theNOTES@note}{{#1}: {#2}}%
    }%
}

\renewcommand{\NOTES@marker}[2]{\fbox{%
    \textcolor{#2}{% WAS \color
        \textbf{#1}}%
    }}

\renewcommand{\NOTES@colorline}[2]{%
  \bgroup%
    \ULon{\LWR@backgroundcolor{#1}{#2}}%
}
%    \end{macrocode}

% \iffalse
%</fixmetodonotes>
% \fi
%
%
%
%
%
% \iffalse
%<*float>
% \fi

% \part{lwarp-float.sty}

% \section{float and \cs{newfloat}}
% \label{sec:newfloat}
% \label{sec:float}
%
% \credits{Anselm Lingnau}
%
% \DescribePackage{float}
% \pkg{float} is emulated.
%
% \changes{v0.20}{2017/01/22}{Improved float caption type handling.}
%
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{float}[2016/03/04]
%    \end{macrocode}

%
% See \cref{sec:listof} for the \cs{listof} command.


% \begin{macro}{\newfloat} \marg{1: type} \marg{2: placement}
%							\marg{3: ext} \oarg{4: within}
%
% Emulates the \cs{newfloat} command from the \pkg{float} package.
%
% ``placement'' is ignored.
%
%    \begin{macrocode}
\NewDocumentCommand{\newfloat}{m m m o}{%
\IfValueTF{#4}
{\DeclareFloatingEnvironment[fileext=#3,within=#4]{#1}}
{\DeclareFloatingEnvironment[fileext=#3]{#1}}
%    \end{macrocode}
% \pkg{newfloat} package automatically creates the \cs{listof} command
% for new floats, but \pkg{float} does not,
% so remove \cs{listof} here in case it is manually created later.
%    \begin{macrocode}
\cslet{listof#1s}\relax
\cslet{listof#1es}\relax
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\floatname} \marg{type} \marg{name}
%
% Sets the text name of the float, such as ``Figure''.
%    \begin{macrocode}
\NewDocumentCommand{\floatname}{m +m}{%
\SetupFloatingEnvironment{#1}{name=#2}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\floatplacement} \marg{type} \marg{placement}
%
% Float placement is ignored.
%    \begin{macrocode}
\newcommand*{\floatplacement}[2]{%
\SetupFloatingEnvironment{#1}{placement=#2}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\floatstyle} \marg{style}
%
% Float styles are ignored.
%    \begin{macrocode}
\newcommand{\floatstyle}[1]{%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\restylefloat} * \marg{style}
%
% Float styles are ignored.
%    \begin{macrocode}
\NewDocumentCommand{\restylefloat}{s m}{%
}
%    \end{macrocode}
% \end{macro}

% \iffalse
%</float>
% \fi
%
%
%
%
%
%
%
%
% \iffalse
%<*floatflt>
% \fi
%
% \part{lwarp-floatflt.sty}
%
% \section{floatflt}
%
% \credits{Mats Dahlgren}
%
% \DescribePackage{floatflt} Emulated.
%
% \changes{v0.26}{2017/03/30}{\pkg{floatflt}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-floatflt}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{floatflt}
%    \end{macrocode}
%
%
%
% \begin{noindenvironment} \oarg{offset} \marg{type} \marg{width}
% Borrowed from the \pkg{lwarp} version of \pkg{keyfloat}:
% \changes{v0.42}{2017/10/26}{\pkg{floatflt}: Added width.}
%    \begin{macrocode}
\NewDocumentEnvironment{KFLTfloatflt@marginfloat}{O{-1.2ex} m m}
{%
\setlength{\LWR@templengthone}{#3}%
\uselengthunit{PT}%
\LWR@BlockClassWP{%
    float:right; %
    width:\rndprintlength{\LWR@templengthone}; %
    margin:10pt%
}{%
    width:\rndprintlength{\LWR@templengthone}%
}%
{marginblock}%
\captionsetup{type=#2}%
}
{%
\endLWR@BlockClassWP%
}
%    \end{macrocode}
% \end{noindenvironment}
%
% \begin{noindenvironment}{floatingfigure} \oarg{placement} \marg{width}
%    \begin{macrocode}
\DeclareDocumentEnvironment{floatingfigure}{o m}
  {\begin{KFLTfloatflt@marginfloat}{figure}{#2}}
  {\end{KFLTfloatflt@marginfloat}}
%    \end{macrocode}
% \end{noindenvironment}
%
% \begin{noindenvironment}{floatingtable} \oarg{placement}
%    \begin{macrocode}
\DeclareDocumentEnvironment{floatingtable}{o}
  {\begin{KFLTfloatflt@marginfloat}{table}{1.5in}}
  {\end{KFLTfloatflt@marginfloat}}
%    \end{macrocode}
% \end{noindenvironment}
%
% \iffalse
%</floatflt>
% \fi
%
%
%
%
%
%
% \iffalse
%<*floatpag>
% \fi
%
% \part{lwarp-floatpag.sty}
%
% \section{floatpag}
%
% \credits{Vytas Statulevi\v{c}ius and Sigitas Tolu\v{s}is}
%
% \DescribePackage{floatpag} Emulated.
%
% \changes{v0.34}{2017/08/03}{\pkg{floatpag}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-floatpag}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{floatpag}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\floatpagestyle}[1]{}
\newcommand*{\rotfloatpagestyle}[1]{}
\newcommand*{\thisfloatpagestyle}[1]{}
%    \end{macrocode}
%
% \iffalse
%</floatpag>
% \fi
%
%
%
%
%
% \iffalse
%<*floatrow>
% \fi

% \part{lwarp-floatrow.sty}

% \section{floatrow}
% \label{sec:floatrow}
%
% \credits{Olga Lapko}
%
% \DescribePackage{floatrow}
% \pkg{floatrow} is emulated.

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{floatrow}
%    \end{macrocode}

% \changes{v0.14}{2016/03/31}{\pkg{floatrow}: Added.}
% \changes{v0.24}{2017/03/15}{\pkg{floatrow}: Support for \pkg{subfig}.}

% \limitsfloatrow

% After everything has loaded, remember whether \pkg{subcaption} was loaded.
% If not, it is assumed that \pkg{subfig} is used instead:
%    \begin{macrocode}
\newbool{LWR@subcaptionloaded}

\AtBeginDocument{
\@ifpackageloaded{subcaption}
{\booltrue{LWR@subcaptionloaded}}
{\boolfalse{LWR@subcaptionloaded}}
}
%    \end{macrocode}

% \begin{noindmacro}{\floatbox}
% \oarg{1 preamble} \marg{2 captype}
% \oarg{3 width} \oarg{4 height} \oarg{5 vert pos}
% \marg{6 caption} \marg{7 object}
%
% Only parameters for captype, width, caption, and object are used.
%
% |LWR@insubfloatrow| is true if inside a \env{subfloatrow} environment.
%
% There are two actions, depending on the use of \pkg{subcaption} or \pkg{subfig}.
%    \begin{macrocode}
\NewDocumentCommand{\floatbox}{o m o o o +m +m}{%
\ifbool{LWR@subcaptionloaded}%
{% subcaption
%    \end{macrocode}
% For \pkg{subcaption}:
%    \begin{macrocode}
    \ifbool{LWR@insubfloatrow}%
    {% subcaption in a subfloatrow
%    \end{macrocode}
% \env{subfigure} and \env{subtable} environments take width as an argument.
%    \begin{macrocode}
        \IfValueTF{#3}%
        {\@nameuse{sub#2}{#3}}%
        {\@nameuse{sub#2}{\linewidth}}%
    }% subcaption in a subfloatrow
    {% subcaption not in subfloatrow
%    \end{macrocode}
% \env{figure} and \env{table} environments do not take a width argument.
%    \begin{macrocode}
        \@nameuse{#2}%
    }% subcaption not in subfloatrow
    #6

    #7
%    \end{macrocode}
% End the environments:
%    \begin{macrocode}
    \ifbool{LWR@insubfloatrow}%
    {\@nameuse{endsub#2}}%
    {\@nameuse{end#2}}%
}% subcaption
{% assume subfig
%    \end{macrocode}
% For \pkg{subfig}:
%    \begin{macrocode}
\ifbool{LWR@insubfloatrow}%
{% subfig in a subfloatrow
%    \end{macrocode}
% \cs{subfloat} is a macro, not an environment.
%
% Package \pkg{subfig}'s \cs{subfloat} command takes an optional argument which is the
% caption, but \cs{floatbox} argument \#6 contains commands to create
% the caption and label, not the caption itself.  Thus, \cs{caption}
% is temporarily disabled to return its own argument without braces.
%    \begin{macrocode}
    \begingroup
    \let\caption\@firstofone
    \subfloat[#6]{#7}
    \endgroup
}% subfig in a subfloatrow
{% subfig package, but not a subfig
%    \end{macrocode}
% \env{figure} and \env{table} are environments:
%    \begin{macrocode}
\@nameuse{#2}
#6

#7
\@nameuse{end#2}
}% subfig package, but not a subfig
}% assume subfig
}
%    \end{macrocode}
% \end{noindmacro}


% Not used:
%    \begin{macrocode}
\newcommand*{\nocapbeside}{}
\newcommand*{\capbeside}{}
\newcommand*{\captop}{}
\newlength{\FBwidth}
\setlength{\FBwidth}{.3\linewidth}
\newlength{\FBheight}
\setlength{\FBheight}{2in}
\newcommand*{\useFCwidth}{}
\newcommand{\floatsetup}[2][]{}
\newcommand{\thisfloatsetup}[1]{}
\newcommand{\clearfloatsetup}[1]{}
\newcommand*{\killfloatstyle}{}
%    \end{macrocode}


% \begin{noindmacro}{\newfloatcommand} \marg{1 command} \marg{2 captype}
%	\oarg{3 preamble} \oarg{4 default width}
%
% Preamble and default width are ignored.
%    \begin{macrocode}
\NewDocumentCommand{\newfloatcommand}{m m o o}{%
\@namedef{#1}{
\floatbox{#2}
}
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\renewfloatcommand} \marg{1 command} \marg{2 captype}
%	\oarg{3 preamble} \oarg{4 default width}
%
% Preamble and default width are ignored.
%    \begin{macrocode}
\NewDocumentCommand{\renewfloatcommand}{m m o o}{%
\@namedef{#1}{%
\floatbox{#2}
}
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\ffigbox} \oarg{width} \oarg{height} \oarg{vposn}
%	\marg{caption commands} \marg{contents}
%    \begin{macrocode}
\newfloatcommand{ffigbox}{figure}[\nocapbeside][]
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\ttabbox} \oarg{width} \oarg{height} \oarg{vposn}
%	\marg{caption commands} \marg{contents}
% \changes{v0.15}{2016/03/31}{Fixed \& handling.}
%    \begin{macrocode}
\newfloatcommand{ttabbox}{table}[\captop][\FBwidth]
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\fcapside} \oarg{width} \oarg{height} \oarg{vposn}
%	\marg{caption commands} \marg{contents}
%    \begin{macrocode}
\newfloatcommand{fcapside}{figure}[\capbeside][]
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindenvironment}{floatrow} \oarg{numfloats}
% \changes{v0.20}{2016/08/20}{Fix: \cs{linewidth} in a floatrow.}
%
% The row of floats is placed into a \element{div} of class |floatrow|.
%    \begin{macrocode}
\newenvironment*{floatrow}[1][2]
{
\LWR@forcenewpage
\BlockClass{floatrow}
%    \end{macrocode}
% While inside the floatrow, divide the \cs{linewidth} by the number of floats.
%    \begin{macrocode}
\booltrue{LWR@infloatrow}
\setlength{\linewidth}{6in/#1}
}
{
\boolfalse{LWR@infloatrow}
\endBlockClass
}
%    \end{macrocode}
% \end{noindenvironment}
%
% Keys for \cs{DeclareNewFloatType}:
%    \begin{macrocode}
\newcommand*{\LWR@frowkeyplacement}{}
\newcommand*{\LWR@frowkeyname}{}
\newcommand*{\LWR@frowkeyfileext}{}
\newcommand*{\LWR@frowkeywithin}{}
\newcommand*{\LWR@frowkeycapstyle}{}

\define@key{frowkeys}{placement}{}%
\define@key{frowkeys}{name}{\renewcommand{\LWR@frowkeyname}{#1}}%
\define@key{frowkeys}{fileext}{\renewcommand{\LWR@frowkeyfileext}{#1}}%
\define@key{frowkeys}{within}{\renewcommand{\LWR@frowkeywithin}{#1}}%
\define@key{frowkeys}{relatedcapstyle}{}%
%    \end{macrocode}

% \begin{noindmacro}{\DeclareNewFloatType} \marg{type} \marg{options}
%
% Use |\listof{type}{Title}| to print a list of the floats.
%    \begin{macrocode}
\newcommand*{\DeclareNewFloatType}[2]{%
%    \end{macrocode}
% Reset key values:
%    \begin{macrocode}
\renewcommand*{\LWR@frowkeyplacement}{}
\renewcommand*{\LWR@frowkeyname}{}
\renewcommand*{\LWR@frowkeyfileext}{}
\renewcommand*{\LWR@frowkeywithin}{}
\renewcommand*{\LWR@frowkeycapstyle}{}
%    \end{macrocode}
% Read new key values:
%    \begin{macrocode}
\LWR@traceinfo{about to setkeys frowkeys}%
\setkeys{frowkeys}{#2}%
\LWR@traceinfo{finished setkeys frowkeys}%
%    \end{macrocode}
% Create a new float with optional [within]:
%    \begin{macrocode}
\ifthenelse{\equal{\LWR@frowkeywithin}{}}
{
    \LWR@traceinfo{about to newfloat #1 \LWR@frowkeyplacement\ 
        \LWR@frowkeyfileext}%
    \newfloat{#1}{\LWR@frowkeyplacement}{\LWR@frowkeyfileext}
}%
{%
    \LWR@traceinfo{about to newfloat #1\ \LWR@frowkeyplacement\ 
        \LWR@frowkeyfileext\ \LWR@frowkeywithin}%
    \newfloat{#1}{\LWR@frowkeyplacement}%
    {\LWR@frowkeyfileext}[\LWR@frowkeywithin]%
    \LWR@traceinfo{finished newfloat #1}
}%
%    \end{macrocode}
% Rename the float if a name was given:
%    \begin{macrocode}
\ifthenelse{\equal{\LWR@frowkeyname}{}}
{}
{\floatname{#1}{\LWR@frowkeyname}}%
}
%    \end{macrocode}
% \end{noindmacro}

% Not used:
%    \begin{macrocode}
\newcommand{\buildFBBOX}[2]{}
\newcommand*{\CenterFloatBoxes}{}
\newcommand*{\TopFloatBoxes}{}
\newcommand*{\BottomFloatBoxes}{}
\newcommand*{\PlainFloatBoxes}{}

\newcommand{\capsubrowsettings}{}

\NewDocumentCommand{\RawFloats}{o o}{}
%    \end{macrocode}

% \begin{noindmacro}{\RawCaption} \marg{text}
%
% \changes{v0.15}{2016/03/31}{Fix: steps counter}
%
% To be used inside a minipage or parbox.
%    \begin{macrocode}
\newcommand{\RawCaption}[1]{#1}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\floatfoot} \marg{text}
%
% Places additional text inside a float,
% inside a \CSS\ \element{div} of class |floatfoot|.
%    \begin{macrocode}
\NewDocumentCommand{\floatfoot}{s +m}{%
\begin{BlockClass}{floatfoot}
#2
\end{BlockClass}
}
%    \end{macrocode}
% \end{noindmacro}


% ^^A \DescribeBoolean{LWR@insubfloatrow}
% Used to compute \cs{linewidth}.
%    \begin{macrocode}
\newbool{LWR@insubfloatrow}
\boolfalse{LWR@insubfloatrow}
%    \end{macrocode}

% \begin{noindenvironment}{subfloatrow} \oarg{num\_floats}
% \changes{v0.15}{2016/04/01}{Added}
%    \begin{macrocode}
\newenvironment*{subfloatrow}[1][2]
{
%    \end{macrocode}
% The row of floats is placed into a \element{div} of class |floatrow|:
%    \begin{macrocode}
\LWR@forcenewpage
\BlockClass{floatrow}
%    \end{macrocode}
% While inside the floatrow, |LWR@insubfloatrow| is set true,
% which tells \cs{floatbox} to use \cs{subfigure} or \cs{subtable}.
%    \begin{macrocode}
\begingroup
\booltrue{LWR@insubfloatrow}
}
{
\endgroup
\endBlockClass
\boolfalse{LWR@insubfloatrow}
}
%    \end{macrocode}
% \end{noindenvironment}

% \iffalse
%</floatrow>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*flushend>
% \fi
%
% \part{lwarp-flushend.sty}
%
% \section{flushend}
%
% \credits{Sigitas Tolu\v{s}is}
%
% \DescribePackage{flushend} Emulated.
%
% \changes{v0.34}{2017/07/27}{\pkg{flushend}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-flushend}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{flushend}
%    \end{ma-crocode}
%
%    \begin{macrocode}
\newcommand*{\flushend}{}
\newcommand*{\raggedend}{}
\newcommand*{\flushcolsend}{}
\newcommand*{\raggedcolsend}{}
\newcommand*{\atColsBreak}[1]{}
\newcommand*{\atColsEnd}[1]{}
\newcommand*{\showcolsendrule}{}
%    \end{macrocode}
%
% \iffalse
%</flushend>
% \fi
%
%
%
%
%
% \iffalse
%<*fncychap>
% \fi

% \part{lwarp-fncychap.sty}

% \section{fncychap}
%
% \credits{Ulf A. Lindgren}
%
% \DescribePackage{fncychap}
% \pkg{fncychap} is emulated.
%
% \changes{v0.38}{2017/08/24}{\pkg{fncychap}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-fncychap}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fncychap}
%    \end{macrocode}

%    \begin{macrocode}
\def\mghrulefill#1{}
\def\ChNameLowerCase{}
\def\ChNameUpperCase{}
\def\ChNameAsIs{}
\def\ChTitleLowerCase{}
\def\ChTitleUpperCase{}
\def\ChTitleAsIs{}
\newcommand{\ChRuleWidth}[1]{}
\newcommand{\ChNameVar}[1]{}
\newcommand{\ChNumVar}[1]{}
\newcommand{\ChTitleVar}[1]{}
\newcommand{\TheAlphaChapter}{}
\newcommand{\DOCH}{}
\newcommand{\DOTI}[1]{}
\newcommand{\DOTIS}[1]{}
\newlength{\mylen}
\newlength{\myhi}
\newlength{\px}
\newlength{\py}
\newlength{\pyy}
\newlength{\pxx}
\newlength{\RW}
\newcommand{\FmN}[1]{#1}
\newcommand{\FmTi}[1]{#1}
%    \end{macrocode}

% \iffalse
%</fncychap>
% \fi
%
%
%
%
%
% \iffalse
%<*fnpos>
% \fi
%
% \part{lwarp-fnpos.sty}
%
% \section{fnpos}
%
% \credits{Hiroshi Nakashima}
%
% \DescribePackage{fnpos}
% \pkg{fnpos} is emulated.
%
% \changes{v0.40}{2017/09/06}{\pkg{fnpos}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fnpos}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\makeFNbottom}{}
\newcommand*{\makeFNmid}{}
\newcommand*{\makeFNbelow}{}
\newcommand*{\makeFNabove}{}
%    \end{macrocode}
%
% \iffalse
%</fnpos>
% \fi
%
%
%
%
% \iffalse
%<*fontenc>
% \fi
%
% \part{lwarp-fontenc.sty}
%
% \section{fontenc}
%
% \DescribePackage{fontenc}
% If using pdf\LaTeX, \pkg{lwarp} used to require \pkg{fontspec} be loaded
% before \pkg{lwarp},
% but now \pkg{lwarp} itself loads \cs{fontspec} with T1 encoding, which
% \pkg{lwarp} requires.  \pkg{fontspec} is now allowed to be loaded with another
% encoding after \pkg{lwarp}.
%
% \pkg{lwarp-fontenc} is no longer necessary, but is still provided to overwrite
% older versions.
%
% \changes{v0.21}{2017/02/22}{\pkg{fontenc}: Added.}
% \changes{v0.44}{2017/11/16}{\pkg{fontenc}: Allowed after \pkg{lwarp}.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{fontenc}
%    \end{macrocode}
%
% \iffalse
%</fontenc>
% \fi
%
%
%
%
% \iffalse
%<*fontspec>
% \fi
%
% \part{lwarp-fontspec.sty}
%
% \section{fontspec}
%
% \DescribePackage{fontspec}
% Error if \pkg{fontspec} is loaded after \pkg{lwarp}.
%
% \changes{v0.21}{2017/02/22}{\pkg{fontspec}: Added.}
%

% Discard all options for \pkg{lwarp-fontspec}:
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fontspec}
%    \end{macrocode}

%    \begin{macrocode}
\LWR@loadbefore{fontspec}
%    \end{macrocode}

% \iffalse
%</fontspec>
% \fi
%
%
%
%
%
%
% \iffalse
%<*footmisc>
% \fi
%
% \part{lwarp-footmisc.sty}
%
% \section{footmisc}
% \label{sec:footmisc}
%
% \credits{Robin Fairbairns}
%
% \changes{v0.26}{2017/03/27}{\pkg{footmisc}: Added.}
%
% \DescribePackage{footmisc}
% \pkg{footmisc} is emulated.
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{footmisc}
%    \end{macrocode}
%
% Some nullified commands:
%    \begin{macrocode}
\newcommand{\footnotelayout}{}
\newcommand{\setfnsymbol}[1]{}
\NewDocumentCommand{\DefineFNsymbols}{s m o m}{}

\newdimen\footnotemargin
\footnotemargin1.8em\relax

\newcommand*\hangfootparskip{0.5\baselineskip}
\newcommand*\hangfootparindent{0em}%

\let\pagefootnoterule\footnoterule
\let\mpfootnoterule\footnoterule
\def\splitfootnoterule{\kern-3\p@ \hrule \kern2.6\p@}

\providecommand*{\multiplefootnotemarker}{3sp}
\providecommand*{\multfootsep}{,}
%    \end{macrocode}
%
% Using \pkg{cleveref}:
%    \begin{macrocode}
\providecommand*{\footref}[1]{\labelcref{#1}}
%    \end{macrocode}
%
% The following work as-is:
%    \begin{macrocode}
\newcommand\mpfootnotemark{%
  \@ifnextchar[%
    \@xmpfootnotemark
    {%
      \stepcounter\@mpfn
      \protected@xdef\@thefnmark{\thempfn}%
      \@footnotemark
    }%
}
\def\@xmpfootnotemark[#1]{%
  \begingroup
    \csname c@\@mpfn\endcsname #1\relax
    \unrestored@protected@xdef\@thefnmark{\thempfn}%
  \endgroup
  \@footnotemark
}
%    \end{macrocode}
%
% \iffalse
%</footmisc>
% \fi
%
%
%
%
%
% \iffalse
%<*footnote>
% \fi
%
% \part{lwarp-footnote.sty}
%
% \section{footnote}
%
% \credits{Mark Wooding}
%
% \DescribePackage{footnote}
% \pkg{footnote} is used with minor patches.
%
% \changes{v0.26}{2017/03/26}{\pkg{footnote}: Added.}
% \changes{v0.36}{2017/08/15}{\pkg{footnote}: Extra \protect\HTML\ source space after paragraphs.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{footnote}
%    \end{macrocode}
%
% Removed print-version formatting:
%    \begin{macrocode}
\def\fn@startnote{%
%   \@parboxrestore%
  \protected@edef\@currentlabel{\csname p@\@mpfn\endcsname\@thefnmark}%
%   \color@begingroup% *** conflicts with lwarp
}

% \let\fn@endnote\color@endgroup% *** conflicts with lwarp
\newcommand*{\fn@endnote}{%
\LWR@htmltagc{/\LWR@tagregularparagraph}%
\LWR@orignewline%
}
%    \end{macrocode}
%
% Removed print-version formatting:
%    \begin{macrocode}
\def\fn@startfntext{%
  \setbox\z@\vbox\bgroup%
    \fn@startnote%
    \fn@prefntext%
    \ignorespaces%
}
%    \end{macrocode}
%
% Removed print-version formatting, added closing paragraph tag:
%    \begin{macrocode}
\def\fn@endfntext{%
    \LWR@htmltagc{/\LWR@tagregularparagraph}%
    \LWR@orignewline%
    \fn@postfntext%
  \egroup%
  \begingroup%
    \let\@makefntext\@empty%
    \let\@finalstrut\@gobble%
    \LetLtxMacro\rule\@gobbletwo% *8* also the optional argument?
    \@footnotetext{\unvbox\z@}%
  \endgroup%
}
%    \end{macrocode}
%
% These have been redefined, so re-\cs{let} them again:
%    \begin{macrocode}
\let\endfootnote\fn@endfntext
\let\endfootnotetext\endfootnote
%    \end{macrocode}
%
%
% \iffalse
%</footnote>
% \fi
%
%
%
%
%
% \iffalse
%<*footnotehyper>
% \fi

% \part{lwarp-footnotehyper.sty}

% \section{footnotehyper}
%
% \DescribePackage{footnotehyper}
% \pkg{footnotehyper} is a \pkg{hyperref}-safe version of \pkg{footnote}.
% For \pkg{lwarp}, \pkg{footnotehyper} is emulated.
%
% \changes{v0.26}{2017/03/23}{\pkg{footnotehyper}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-footnotehyper}:
%    \begin{macrocode}
\RequirePackage{footnote}
\LWR@ProvidesPackageDrop{footnotehyper}
%    \end{macrocode}
%
%
% \iffalse
%</footnotehyper>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*framed>
% \fi

% \part{lwarp-framed.sty}
%
% \section{framed}
%
% \credits{Donald Arseneau}
%
% \DescribePackage{framed}
% \pkg{framed} is supported and patched by \pkg{lwarp}.
%
% \changes{v0.25}{2017/03/19}{\pkg{framed}: Added.}
%
% \codehtml
%
% Accept all options for \pkg{lwarp-framed}:
%    \begin{macrocode}
\LWR@ProvidesPackagePass{framed}
\RequirePackage{xcolor}% for \convertcolorspec
%    \end{macrocode}


%    \begin{macrocode}

\renewenvironment{framed}{%
\LWR@forcenewpage
\BlockClass{framed}%
}
{\endBlockClass}

\renewenvironment{oframed}{%
\LWR@forcenewpage
\BlockClass{framed}%
}
{\endBlockClass}


\renewenvironment{shaded}{%
\convertcolorspec{named}{shadecolor}{HTML}\LWR@tempcolor%
\LWR@forcenewpage
\BlockClass[background: \#\LWR@tempcolor]{framed}%
}
{\endBlockClass}

\renewenvironment{shaded*}{%
\convertcolorspec{named}{shadecolor}{HTML}\LWR@tempcolor%
\LWR@forcenewpage
\BlockClass[background: \#\LWR@tempcolor]{framed}%
}
{\endBlockClass}


\renewenvironment{leftbar}{%
\LWR@forcenewpage
    \BlockClass{framedleftbar}
  \def\FrameCommand{}%
  \MakeFramed {}
}%
 {\endMakeFramed\endBlockClass}


\renewenvironment{snugshade}{%
\convertcolorspec{named}{shadecolor}{HTML}\LWR@tempcolor%
\LWR@forcenewpage
\BlockClass[background: \#\LWR@tempcolor]{snugframed}%
}
{\endBlockClass}

\renewenvironment{snugshade*}{%
\convertcolorspec{named}{shadecolor}{HTML}\LWR@tempcolor%
\LWR@forcenewpage
\BlockClass[background: \#\LWR@tempcolor]{snugframed}%
}
{\endBlockClass}

\let\oframed\framed
\let\endoframed\endframed


\RenewEnviron{titled-frame}[1]{%
\CustomFBox{#1}{}{0pt}{0pt}{0pt}{0pt}{\BODY}
}
%    \end{macrocode}



% \cs{CustomFBox} \marg{toptitle} \marg{bottitle}
%	\marg{thicknesstop} \marg{bottom} \marg{left} \marg{right}
%	\marg{text contents}
%    \begin{macrocode}
\renewcommand{\CustomFBox}[7]{%
\convertcolorspec{named}{TFFrameColor}{HTML}\LWR@tempcolor%
\LWR@forcenewpage
\begin{BlockClass}[border: 3px solid \#\LWR@tempcolor]{framed}%
\ifthenelse{\isempty{#1}}{}{% not empty
    \begin{BlockClass}[background: \#\LWR@tempcolor]{framedtitle}%
    \textcolor{TFTitleColor}{\textbf{#1}}%
    \end{BlockClass}
}% not empty

#7

\ifthenelse{\isempty{#2}}{}{% not empty
    \convertcolorspec{named}{TFFrameColor}{HTML}\LWR@tempcolor%
    \begin{BlockClass}[background: \#\LWR@tempcolor]{framedtitle}%
    \textcolor{TFTitleColor}{\textbf{#2}}%
    \end{BlockClass}
}% not empty
\end{BlockClass}
}
%    \end{macrocode}

% \cs{TitleBarFrame} \oarg{marker} \marg{title} \marg{contents}
%    \begin{macrocode}
\renewcommand\TitleBarFrame[3][]{
\CustomFBox
    {#2}{}%
    \fboxrule\fboxrule\fboxrule\fboxrule
    {#3}%
}
%    \end{macrocode}


%    \begin{macrocode}
\renewcommand{\TF@Title}[1]{#1}
%    \end{macrocode}


% \env{MakeFramed} \marg{settings}
%    \begin{macrocode}
\let\MakeFramed\relax
\let\endMakeFramed\relax

\NewEnviron{MakeFramed}[1]{%
\FrameCommand{\begin{minipage}{\linewidth}\BODY\end{minipage}}%
}
%    \end{macrocode}


% \cs{fb@put@frame} \marg{frame cmd no split} \marg{frame cmd split}
%    \begin{macrocode}
\renewcommand*{\fb@put@frame}[2]{%
\relax%
\@tempboxa%
}
%    \end{macrocode}

% \iffalse
%</framed>
% \fi
%
%
%
%
%
%
% \iffalse
%<*ftnright>
% \fi

% \part{lwarp-ftnright.sty}

% \section{ftnright}
%
% \DescribePackage{ftnright}
% \pkg{ftnright} is ignored.
%
% \changes{v0.22}{2017/03/01}{\pkg{ftnright}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-ftnright}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{ftnright}
%    \end{macrocode}

% \iffalse
%</ftnright>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*fullpage>
% \fi
%
% \part{lwarp-fullpage.sty}
%
% \section{fullpage}
%
% \DescribePackage{fullpage} \pkg{fullpage} is ignored.
%
% \changes{v0.34}{2017/07/27}{\pkg{fullpage}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-fullpage}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fullpage}
%    \end{macrocode}
%
%
% \iffalse
%</fullpage>
% \fi
%
%
%
%
%
% \iffalse
%<*fullwidth>
% \fi
%
% \part{lwarp-fullwidth.sty}
%
% \section{fullwidth}
%
% \credits{Marco Daniel}
%
% \DescribePackage{fullwidth}
% \pkg{fullwidth} is emulated.
%
% A minipage is used, of no \HTML\ width.
%
% \changes{v0.39}{2017/08/27}{\pkg{fullwidth}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fullwidth}
%    \end{macrocode}
%
%    \begin{macrocode}
\newenvironment*{fullwidth}[1][]{%
\minipagefullwidth%
\minipage{\linewidth}%
}
{%
\endminipage%
}
%    \end{macrocode}
%
% \iffalse
%</fullwidth>
% \fi
%
%
%
%
%
%
% \iffalse
%<*geometry>
% \fi

% \part{lwarp-geometry.sty}

% \section{geometry}
%
% \credits{Hideo Umeki}
%
% \DescribePackage{geometry}
% \pkg{geometry} is preloaded by \pkg{lwarp}, but must be nullified
% as seen by the user's source code.
%
% \changes{v0.22}{2017/03/01}{\pkg{geometry}: Nullified commands.}
%
% \codehtml

% Discard all options for \pkg{lwarp-geometry}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{geometry}
%    \end{macrocode}

%    \begin{macrocode}
\renewcommand*{\geometry}[1]{}
\renewcommand*{\newgeometry}[1]{}
\renewcommand*{\restoregeometry}{}
\renewcommand*{\savegeometry}[1]{}
\renewcommand*{\loadgeometry}[1]{}
%    \end{macrocode}

% \iffalse
%</geometry>
% \fi
%
%
%
%
%
%
% \iffalse
%<*glossaries>
% \fi
%
% \part{lwarp-glossaries.sty}

% \section{glossaries}
%
% \credits{Nicola L.C. Talbot}
%
% \DescribePackage{glossaries}
% \limitsglossaries
%
% \changes{v0.28}{2017/04/14}{\pkg{glossaries}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\PassOptionsToPackage{xindy}{glossaries}
\LWR@ProvidesPackagePass{glossaries}
\setupglossaries{nonumberlist}
\setglossarystyle{index}
%    \end{macrocode}
% Patched to fix \acro{TOC} pointing to the previous page:
%    \begin{macrocode}
\renewcommand*{\@p@glossarysection}[2]{%
  \glsclearpage
  \phantomsection
  \ifdefempty\@@glossarysecstar
  {%
    \csname\@@glossarysec\endcsname{#2}%
  }%
  {%
%    \end{macrocode}
% In the original, the \acro{TOC} entry was made before the section,
% thus linking to the phantomsection in the printed version, but for
% \HTML\, this caused the link to point to the page before the glossaries.
% Here, the \acro{TOC} entry is made after the section is created:
%    \begin{macrocode}
      \csname\@@glossarysec\endcsname*{#2}%
    \@gls@toc{#1}{\@@glossarysec}% Moved after the previous line.
  }%
  \@@glossaryseclabel
}
%    \end{macrocode}
%
% \iffalse
%</glossaries>
% \fi
%
%
%
%
%
%
% \iffalse
%<*graphics>
% \fi

% \part{lwarp-graphics.sty}

% \section{graphics}
%
% \credits{D. P. Carlisle}
%
% \DescribePackage{graphics}
% \pkg{graphics} is emulated.
%
% \changes{v0.28}{2017/04/12}{\pkg{graphics}: Added.}
% \changes{v0.40}{2017/09/07}{\pkg{graphics}: Moved out of the \pkg{lwarp} core.}
% \changes{v0.40}{2017/09/07}{\pkg{graphics}: Restores \cs{includegraphics}
%       and \cs{DeclareGraphicsExtensions} in a \env{lateximage}.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{graphics}
%    \end{macrocode}


% \subsection{Graphics extensions}

% \begin{macro}{\DeclareGraphicsExtensions} \marg{list}
%
% \cs{AtBeginDocument} allow \SVG\ files instead of \PDF:
%    \begin{macrocode}
\AtBeginDocument{
\DeclareGraphicsExtensions{.svg,.SVG,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG}
\DeclareGraphicsRule{.svg}{svg}{.svg}{}
\DeclareGraphicsRule{.SVG}{svg}{.SVG}{}
}
%    \end{macrocode}
% Inside a \env{lateximage}, allow \PDF\ instead of \SVG:
%    \begin{macrocode}
\appto\LWR@restoreorigformatting{%
\DeclareGraphicsExtensions{.pdf,.PDF,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG}%
}
%    \end{macrocode}
% \end{macro}


% \subsection{Length conversions and graphics options}
%
% A scaled image in \LaTeX{} by default takes only as much space
% on the page as it
% requires, but \HTML\ browsers use as much space as the
% \watchout[whitespace]
% original unscaled image would have taken,
% with the scaled image over- or under-flowing the area.

%    \begin{macrocode}
\AtBeginDocument{
\renewcommand*{\unitspace}{}
}
%    \end{macrocode}

% Used to store the user's selected dimensions and \HTML\ class.
%
% The class defaults to ``inlineimage'' unless changed by a |class=xyx| option.
%    \begin{macrocode}
\newlength{\LWR@igwidth}
\newlength{\LWR@igheight}
\newcommand*{\LWR@igwidthstyle}{}
\newcommand*{\LWR@igheightstyle}{}
\newcommand*{\LWR@igorigin}{}
\newcommand*{\LWR@igangle}{}
\newcommand*{\LWR@igxscale}{1}
\newcommand*{\LWR@igyscale}{1}
\newcommand*{\LWR@igclass}{inlineimage}
%    \end{macrocode}

% Set the actions of each of the key/value combinations for
% \cs{includegraphics}.  Many are ignored.
%
% If an optional width was given, set an \HTML\ style:
%    \begin{macrocode}
\define@key{igraph}{width}{%
\setlength{\LWR@igwidth}{#1}%
\ifthenelse{\lengthtest{\LWR@igwidth > 0pt}}%
{%
%    \end{macrocode}
% Default to use the converted fixed length given:
%    \begin{macrocode}
    \uselengthunit{PT}%
    \renewcommand*{\LWR@igwidthstyle}{width:\rndprintlength{\LWR@igwidth}}%
%    \end{macrocode}
% If ex or em dimensions were given, use those instead:
%    \begin{macrocode}
    \IfEndWith{#1}{ex}%
    {\renewcommand*{\LWR@igwidthstyle}{width:#1}}% yes ex
    {}% not ex
    \IfEndWith{#1}{em}%
    {\renewcommand*{\LWR@igwidthstyle}{width:#1}}% yes em
    {}% not em
    \IfEndWith{#1}{\%}%
    {\renewcommand*{\LWR@igwidthstyle}{width:#1}}% yes percent
    {}% not percent
    \IfEndWith{#1}{px}%
    {\renewcommand*{\LWR@igwidthstyle}{width:#1}}% yes px
    {}% not px
}{}% end of length > 0pt
}
%    \end{macrocode}
%
% If an optional height was given, set an \HTML\ style:
%    \begin{macrocode}
\define@key{igraph}{height}{%
\setlength{\LWR@igheight}{#1}%
\ifthenelse{\lengthtest{\LWR@igheight > 0pt}}%
{%
%    \end{macrocode}
% Default to use the converted fixed length given:
%    \begin{macrocode}
    \uselengthunit{PT}%
    \renewcommand*{\LWR@igheightstyle}{%
    height:\rndprintlength{\LWR@igheight} %
    }%
%    \end{macrocode}
% If ex or em dimensions were given, use those instead:
%    \begin{macrocode}
    \IfEndWith{#1}{ex}%
    {\renewcommand*{\LWR@igheightstyle}{height:#1}}% yes ex
    {}% not ex
    \IfEndWith{#1}{em}%
    {\renewcommand*{\LWR@igheightstyle}{height:#1}}% yes em
    {}% not em
    \IfEndWith{#1}{\%}%
    {\renewcommand*{\LWR@igheightstyle}{height:#1}}% yes percent
    {}% not percent
    \IfEndWith{#1}{px}%
    {\renewcommand*{\LWR@igheightstyle}{height:#1}}% yes px
    {}% not px
}{}% end of length > 0pt
}
%    \end{macrocode}
%
%
% Handle origin key:
%    \begin{macrocode}
\define@key{igraph}{origin}{%
\renewcommand*{\LWR@igorigin}{#1}%
}
%    \end{macrocode}
%
%
% Handle angle key:
%    \begin{macrocode}
\define@key{igraph}{angle}{\renewcommand*{\LWR@igangle}{#1}}
%    \end{macrocode}
%
%
% Handle class key:
%    \begin{macrocode}
\define@key{igraph}{class}{\renewcommand*{\LWR@igclass}{#1}}

%    \end{macrocode}
% ^^A \define@key{igraph}{xscale}{\renewcommand*{\LWR@igxscale}{#1}}
% ^^A \define@key{igraph}{yscale}{\renewcommand*{\LWR@igyscale}{#1}}
% It appears that \pkg{graphicx} does not have separate keys for
% |xscale| and |yscale|.  |scale| adjusts both at the same time.
%    \begin{macrocode}
\define@key{igraph}{scale}{%
\renewcommand*{\LWR@igxscale}{#1}%
\renewcommand*{\LWR@igyscale}{#1}}
%    \end{macrocode}
%
% Numerous ignored keys:
%    \begin{macrocode}
\define@key{igraph}{bb}{}
\define@key{igraph}{bbllx}{}
\define@key{igraph}{bblly}{}
\define@key{igraph}{bburx}{}
\define@key{igraph}{bbury}{}
\define@key{igraph}{natwidth}{}
\define@key{igraph}{natheight}{}
\define@key{igraph}{hiresbb}{}
\define@key{igraph}{viewport}{}
\define@key{igraph}{trim}{}
\define@key{igraph}{totalheight}{}
\define@key{igraph}{keepaspectratio}{}
\define@key{igraph}{clip}{}
\define@key{igraph}{draft}{}
\define@key{igraph}{type}{}
\define@key{igraph}{ext}{}
\define@key{igraph}{read}{}
\define@key{igraph}{command}{}
%    \end{macrocode}


% \subsection{Printing HTML styles}

% \begin{macro}{\LWR@rotstyle} \marg{prefix} \marg{degrees}
%
% Prints the rotate style with the given prefix.
%
% |prefix| is |-ms-| or |-webkit-| or nothing, and is used to generate
% three versions of the |transform:rotate| style.
%    \begin{macrocode}
\newcommand*{\LWR@rotstyle}[2]{%
 #1transform:rotate(-#2deg);
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@scalestyle} \marg{prefix} \marg{xscale} \marg{yscale}
%
% Prints the scale style with the given prefix.
%
% |prefix| is |-ms-| or |-webkit-| or nothing, and is used to generate
% three versions of the |transform:scale| style.
%    \begin{macrocode}
\newcommand*{\LWR@scalestyle}[3]{%
 #1transform:scale(#2,#3);
}
%    \end{macrocode}
% \end{macro}




% \subsection{\cs{includegraphics}}

% \DescribeBoolean{LWR@infloatrow}
% Used to compute \cs{linewidth}.
%    \begin{macrocode}
\newbool{LWR@infloatrow}
\boolfalse{LWR@infloatrow}
%    \end{macrocode}

% \cs{LWR@opacity} may be set by the \pkg{transparent} package.
% For \HTML\ it is only used for \cs{includegraphics}.
%    \begin{macrocode}
\def\LWR@opacity{1}
%    \end{macrocode}


% Used to determine the actual image size if needed:
%    \begin{macrocode}
\newsavebox{\LWR@imagesizebox}
%    \end{macrocode}


%    \begin{macrocode}
\let\LWR@origGin@setfile\Gin@setfile
%    \end{macrocode}


% Define the new class key for the print-mode version of \cs{includegraphics},
% which is enabled inside a \env{lateximage}.
% \changes{v0.42}{2017/10/24}{\pkg{includegraphics}: Fix: Class key.}
%    \begin{macrocode}
\AtBeginDocument{
\define@key{Gin}{class}{}
}
%    \end{macrocode}


% \begin{macro}{\LWR@includegraphicsb} * \oarg{2: options} \oarg{3: options} \marg{4: filename}
%
% \pkg{graphics} syntax is \cs{includegraphics} * \oarg{llx,lly} \oarg{urx,ury} \marg{file}
%
% \pkg{graphicx} syntax is \cs{includegraphics} \oarg{key values} \marg{file}
%
% If |#3| is empty, only one optional argument was given, thus \pkg{graphicx} syntax.
%
% \changes{v0.18}{2016/04/14}{Improved \HTML\ output linebreaks.}
% \changes{v0.18}{2016/05/17}{Fix: \cs{linewidth}, \cs{textwidth}, \cs{textheight}
%   inside a minipage.}
% \changes{v0.18}{2016/05/17}{em, ex, \%, px dimensions preserved.}
% \changes{v0.18}{2016/05/17}{Add: svgz file extension.}
% \changes{v0.20}{2016/08/20}{Fix: \cs{linewidth} in a floatrow.}
% \changes{v0.20}{2017/01/12}{Fix: Expands filename.}
% \changes{v0.28}{2017/04/12}{Adapts to \pkg{graphics} syntax.}
% \changes{v0.29}{2017/04/15}{Fix: Error when no optional arguments.}
% \changes{v0.40}{2017/09/08}{Add: Full \cs{graphicspath} support.}
% \changes{v0.42}{2017/10/26}{Fix: Filename expansion.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@includegraphicsb}{s o o m}
{%
\LWR@traceinfo{LWR@includegraphicsb #4}%
%    \end{macrocode}
% Start the image tag on a new line, allow \PDF\ output word wrap:
%    \begin{macrocode}
\LWR@origtilde \LWR@orignewline%
%    \end{macrocode}
% Temporarily compute |\linewidth|, |\textwidth|, |\textheight| arguments with a 6x9 inch size
% until the next |\endgroup|.
%    \begin{macrocode}
\ifthenelse{\cnttest{\value{LWR@minipagedepth}}{=}{0}}%
{%
    \ifbool{LWR@infloatrow}%
    {}
    {% not in a minipage or a floatrow:
        \setlength{\linewidth}{6in}%
        \setlength{\textwidth}{6in}%
        \setlength{\textheight}{9in}%
    }%
}{}%
%    \end{macrocode}
%    \begin{macrocode}
\begingroup%
\renewcommand*{\Gin@setfile}[3]{%
\LWR@traceinfo{Gin@setfile ##3}%
\xdef\LWR@parsedfilename{##3}%
}%
\Ginclude@graphics{\detokenize\expandafter{#4}}%
\endgroup%
\filename@parse{\LWR@parsedfilename}%
%    \end{macrocode}
%
% For correct em sizing during the width and height conversions:
%    \begin{macrocode}
\large%
%    \end{macrocode}
% Reset some defaults, possibly will be changed below if options were given:
%    \begin{macrocode}
\setlength{\LWR@igwidth}{0pt}%
\setlength{\LWR@igheight}{0pt}%
\renewcommand*{\LWR@igwidthstyle}{}%
\renewcommand*{\LWR@igheightstyle}{}%
\renewcommand*{\LWR@igorigin}{}%
\renewcommand*{\LWR@igangle}{}%
\renewcommand*{\LWR@igxscale}{1}%
\renewcommand*{\LWR@igyscale}{1}%
\renewcommand*{\LWR@igclass}{inlineimage}%
%    \end{macrocode}
% 
% If |#3| is empty, only one optional argument was given, thus \pkg{graphicx} syntax:
%    \begin{macrocode}
\IfValueF{#3}{%
\IfValueTF{#2}%
{\setkeys{igraph}{#2}}%
{\setkeys{igraph}{}}%
}%
%    \end{macrocode}
%
% If formatting for a word processor, find and set the actual image size,
% without rotation, using \PDF\ instead of \SVG\ to find the original bounding box:
% \changes{v0.42}{2017/10/24}{If \protect\texttt{FormatWP}, use explicit size.}
%    \begin{macrocode}
\ifbool{FormatWP}{%
    \begingroup%
    \DeclareGraphicsExtensions{.pdf,.PDF,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG}%
    \define@key{Gin}{angle}{}%
    \IfBooleanTF{#1}%
    {% starred
        \IfValueTF{#3}%
        {%
            \global\sbox{\LWR@imagesizebox}{\LWR@origincludegraphics*[#2][#3]{#4}}%
        }%
        {%
            \IfValueTF{#2}%
            {%
                \global\sbox{\LWR@imagesizebox}{\LWR@origincludegraphics*[#2]{#4}}%
            }{%
                \global\sbox{\LWR@imagesizebox}{\LWR@origincludegraphics*{#4}}%
            }%
        }%
    }% starred
    {% not starred
        \IfValueTF{#3}%
        {%
            \global\sbox{\LWR@imagesizebox}{\LWR@origincludegraphics[#2][#3]{#4}}%
        }%
        {%
            \IfValueTF{#2}%
            {%
                \global\sbox{\LWR@imagesizebox}{\LWR@origincludegraphics[#2]{#4}}%
            }{%
                \global\sbox{\LWR@imagesizebox}{\LWR@origincludegraphics{#4}}%
            }%
        }%
    }% not starred
    \endgroup%
    \uselengthunit{PT}%
    \settowidth{\LWR@igwidth}{\usebox{\LWR@imagesizebox}}%
    \global\renewcommand*{\LWR@igwidthstyle}{width:\rndprintlength{\LWR@igwidth}}%
    \settoheight{\LWR@igheight}{\usebox{\LWR@imagesizebox}}%
    \global\renewcommand*{\LWR@igheightstyle}{height:\rndprintlength{\LWR@igheight}}%
}{}%
%    \end{macrocode}
%
% Create the \HTML\ reference with the graphicspath, filename, extension,
% alt tag, style, and class.
%
% The \cs{LWR@origtilde} adds space between tags in case this
% is being done inside a \cs{savebox} where \cs{newline} has no effect.
%    \begin{macrocode}
\LWR@traceinfo{LWR@includegraphicsb: about to create href}%
\href{\LWR@parsedfilename}%
{% start of href
\LWR@traceinfo{LWR@includegraphicsb: about to LWR@htmltag}%
\LWR@htmltag{% start of image tags
img src="\LWR@parsedfilename" \LWR@orignewline%
\LWR@origtilde{} alt="[\filename@base]" \LWR@orignewline%
%    \end{macrocode}
% Only include a style tag if a width, height, angle, or scale was given:
%    \begin{macrocode}
\ifthenelse{
    \NOT\equal{\LWR@igwidthstyle}{} \OR
    \NOT\equal{\LWR@igheightstyle}{} \OR
    \NOT\equal{\LWR@igorigin}{} \OR
    \NOT\equal{\LWR@igangle}{} \OR
    \NOT\equal{\LWR@igxscale}{1} \OR
    \NOT\equal{\LWR@igyscale}{1}
}%
{\LWR@origtilde{} style="%
\ifthenelse{\NOT\equal{\LWR@igwidthstyle}{}}%
{\LWR@igwidthstyle;}{}%
\ifthenelse{\NOT\equal{\LWR@igheightstyle}{}}%
{\LWR@igheightstyle;}{}%
\ifthenelse{\NOT\equal{\LWR@igorigin}{}}%
{\LWR@origtilde{} transform-origin: \LWR@originnames{\LWR@igorigin}; \LWR@orignewline}{}%
\ifthenelse{\NOT\equal{\LWR@igangle}{}}%
{%
\LWR@rotstyle{-ms-}{\LWR@igangle}%
\LWR@rotstyle{-webkit-}{\LWR@igangle}%
\LWR@rotstyle{}{\LWR@igangle%
}}{}%
\ifthenelse{\NOT\equal{\LWR@igxscale}{1}\OR%
\NOT\equal{\LWR@igyscale}{1}}%
{\LWR@scalestyle{-ms-}{\LWR@igxscale}{\LWR@igyscale}%
\LWR@scalestyle{-webkit-}{\LWR@igxscale}{\LWR@igyscale}%
\LWR@scalestyle{}{\LWR@igxscale}{\LWR@igyscale}}{}%
%
\ifthenelse{\NOT\equal{\LWR@opacity}{1}}%
{opacity:\LWR@opacity;}%
{}%
%
" \LWR@orignewline}{}%
%    \end{macrocode}
% Set the class:
%    \begin{macrocode}
\LWR@origtilde{} class="\LWR@igclass" \LWR@orignewline%
}% end of image tags
}% end of href
\endgroup
%    \end{macrocode}
% Return to small-sized output:
%    \begin{macrocode}
\LWR@origscriptsize
\LWR@traceinfo{LWR@includegraphicsb done}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\includegraphics} \oarg{key=val} \marg{filename}

% Handles width and height, converted to fixed width and heights.

% Converts any |.pdf| references to |.svg| for \HTML\

% The user should always refer to |.pdf| in the document source.

%    \begin{macrocode}
\AtBeginDocument{

\LWR@traceinfo{Patching includegraphics.}

\LetLtxMacro\LWR@origincludegraphics\includegraphics

\renewcommand*{\includegraphics}
{%
%    \end{macrocode}
% This graphic should trigger an \HTML\ paragraph even if alone,
% so ensure that are doing paragraph handling:
%    \begin{macrocode}
\LWR@traceinfo{includegraphics}
\LWR@ensuredoingapar%
\begingroup%
\catcode`\_=12
\LWR@includegraphicsb%
}% includegraphics
}% AtBeginDocument
%    \end{macrocode}
% \end{macro}


% \subsection{Boxes}

% \begin{macro}{\LWR@rotboxorigin} Holds the origin key letters.
%    \begin{macrocode}
\newcommand*{\LWR@rotboxorigin}{}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@originname} \marg{letter}
%
% Given one \LaTeX{} origin key value,
% translate into an \HTML\ origin word:
%    \begin{macrocode}
\newcommand*{\LWR@originname}[1]{%
\ifthenelse{\equal{#1}{t}}{top}{}%
\ifthenelse{\equal{#1}{b}}{bottom}{}%
\ifthenelse{\equal{#1}{c}}{center}{}%
\ifthenelse{\equal{#1}{l}}{left}{}%
\ifthenelse{\equal{#1}{r}}{right}{}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@originnames} \marg{letters}
%
% Given one- or two-letter \LaTeX{} origin key values,
% translate into \HTML\ origin words:
%    \begin{macrocode}
\newcommand*{\LWR@originnames}[1]{%
\StrChar{#1}{1}[\LWR@strresult]%
\LWR@originname{\LWR@strresult}
\StrChar{#1}{2}[\LWR@strresult]%
\LWR@originname{\LWR@strresult}
}
%    \end{macrocode}
% \end{macro}
%
%
% Handle the origin key for \cs{rotatebox}:
%    \begin{macrocode}
\define@key{krotbox}{origin}{%
\renewcommand*{\LWR@rotboxorigin}{#1}%
}
%    \end{macrocode}
% These keys are ignored:
%    \begin{macrocode}
\define@key{krotbox}{x}{}
\define@key{krotbox}{y}{}
\define@key{krotbox}{units}{}
%    \end{macrocode}
%
%
% \begin{macro}{\rotatebox} \oarg{keyval list} \marg{angle} \marg{text}
%    \begin{macrocode}
\LetLtxMacro\LWR@origrotatebox\rotatebox

\AtBeginDocument{
\RenewDocumentCommand{\rotatebox}{O{} m +m}{%
%    \end{macrocode}
% Reset the origin to ``none-given'':
%    \begin{macrocode}
\renewcommand*{\LWR@rotboxorigin}{}
%    \end{macrocode}
% Process the optional keys, which may set \cs{LWR@rotateboxorigin}:
%    \begin{macrocode}
\setkeys{krotbox}{#1}%
%    \end{macrocode}
% Select |inline-block| so that \HTML\ will transform this span:
%    \begin{macrocode}
\LWR@htmltagc{span style="display: inline-block; %
%    \end{macrocode}
% If an origin was given, translate and print the origin information:
%    \begin{macrocode}
\ifthenelse{\NOT\equal{\LWR@rotboxorigin}{}}%
{transform-origin: \LWR@originnames{\LWR@rotboxorigin};\LWR@origtilde}{}%
%    \end{macrocode}
% Print the rotation information:
%    \begin{macrocode}
\LWR@rotstyle{-ms-}{#2} %
\LWR@rotstyle{-webkit-}{#2} %
\LWR@rotstyle{}{#2} %
"{}}\LWR@orignewline%
%    \end{macrocode}
% Print the text to be rotated:
%    \begin{macrocode}
\begin{LWR@nestspan}%
#3%
%    \end{macrocode}
% Close the span:
%    \begin{macrocode}
\LWR@htmltagc{/span}%
\end{LWR@nestspan}%
}
}% AtBeginDocument
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\scalebox} \marg{h-scale} \oarg{v-scale} \marg{text}
%    \begin{macrocode}
\LetLtxMacro\LWR@origscalebox\scalebox

\AtBeginDocument{
\RenewDocumentCommand{\scalebox}{m o m}{%
%    \end{macrocode}
% Select |inline-block| so that \HTML\ will transform this span:
%    \begin{macrocode}
\LWR@htmltagc{span style="display: inline-block; %
%    \end{macrocode}
% Print the scaling information:
%    \begin{macrocode}
\LWR@scalestyle{-ms-}{#1}{\IfNoValueTF{#2}{#1}{#2}} %
\LWR@scalestyle{-webkit-}{#1}{\IfNoValueTF{#2}{#1}{#2}} %
\LWR@scalestyle{}{#1}{\IfNoValueTF{#2}{#1}{#2}} %
"{}}%
%    \end{macrocode}
% Print the text to be scaled:
%    \begin{macrocode}
\begin{LWR@nestspan}%
#3%
%    \end{macrocode}
% Close the span:
%    \begin{macrocode}
\LWR@htmltagc{/span}%
\end{LWR@nestspan}%
}
}% AtBeginDocument
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\reflectbox} \marg{text}
%    \begin{macrocode}
\let\LWR@origreflectbox\reflectbox

\AtBeginDocument{
\renewcommand{\reflectbox}[1]{\scalebox{-1}[1]{#1}}
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\resizebox} \marg{h-length} \marg{v-length} \marg{text}
%
% Simply prints its text argument.
%    \begin{macrocode}
\LetLtxMacro\LWR@origresizebox\resizebox

\AtBeginDocument{
\renewcommand{\resizebox}[3]{#3}
}
%    \end{macrocode}
% \end{macro}
%
% \iffalse
%</graphics>
% \fi
%
%
%
%
%
% \iffalse
%<*graphicx>
% \fi

% \part{lwarp-graphicx.sty}

% \section{graphicx}
%
% \DescribePackage{graphicx}
% \pkg{graphicx} is emulated.
%
% \pkg{graphicx} loads \pkg{graphics}, which also loads \pkg{lwarp-graphics},
% which remembers the original graphics definitions for use inside a \env{lateximage},
% and then patches them \cs{AtBeginDocument} for \HTML\ output.
%
% \pkg{lwarp-graphics} handles the syntax of either \pkg{graphics} or \pkg{graphicx}.
%
% \changes{v0.40}{2017/09/07}{\pkg{graphicx}: Moved out of the \pkg{lwarp} core.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{graphicx}
%    \end{macrocode}

% \iffalse
%</graphicx>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*grffile>
% \fi
%
% \part{lwarp-grffile.sty}
%
% \section{grffile}
%
% \DescribePackage{grffile}
% \limitsgrffile
%
% \pkg{lwarp-grffile} now exists as a placeholder since \pkg{grffile}
% used to be emulated by \pkg{lwarp}, and thus older versions of \pkg{lwarp-grffile}
% may exist and should be overwritten by this newer version.
%
% \changes{v0.38}{2017/08/25}{\pkg{grffile}: Added.}
% \changes{v0.40}{2017/09/25}{\pkg{grffile}: Directly supported.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{grffile}
%    \end{macrocode}
%
% \iffalse
%</grffile>
% \fi
%
%
%
% \iffalse
%<*hang>
% \fi
%
% \part{lwarp-hang.sty}
%
% \section{hang}
%
% \DescribePackage{hang}
% \pkg{hang} is emulated.
%
% \changes{v0.44}{2017/11/15}{\pkg{hang}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{hang}
%    \end{macrocode}
%
%    \begin{macrocode}
\newlength{\hangingindent}
\setlength{\hangingindent}{1em}
\newlength{\hangingleftmargin}
\setlength{\hangingleftmargin}{0em}

\newcommand*{\LWR@findhangingleftmargin}{%
\setlength{\LWR@templengthone}{\hangingleftmargin}%
\addtolength{\LWR@templengthone}{\hangingindent}%
}

\newenvironment{hangingpar}
{
    \LWR@findhangingleftmargin%
    \uselengthunit{PT}%
    \BlockClass[%
        margin-left:\rndprintlength{\LWR@templengthone}; %
        text-indent:-\rndprintlength{\hangingindent}%
    ]%
    {hangingpar}%
}
{\endBlockClass}

\newenvironment{hanginglist}
{%
    \renewcommand*{\LWR@printcloselist}{\LWR@printcloseitemize}%
    \renewcommand*{\LWR@printopenlist}{%
        \LWR@findhangingleftmargin%
        \uselengthunit{PT}%
        ul style="list-style-type:none; %
        margin-left:\rndprintlength{\LWR@templengthone}; %
        text-indent:-\rndprintlength{\hangingindent}"%
    }%
    \let\item\LWR@itemizeitem%
    \list{}{}%
}
{\endlist}

\newenvironment{compacthang}
{\hanginglist}
{\endhanginglist}

\newlength{\labeledleftmargin}
\setlength{\labeledleftmargin}{0em}

\newenvironment{labeledpar}[2]
{%
    \BlockClass[%
        \LWR@findhangingleftmargin%
        \uselengthunit{PT}%
        margin-left:\rndprintlength{\LWR@templengthone}; %
        text-indent:-\rndprintlength{\hangingindent}%
    ]{labeledpar}#2%
}
{\endBlockClass}

\newenvironment{labeledlist}[1]
{\hanginglist}
{\endhanginglist}

\newenvironment{compactlabel}[1]
{\hanginglist}
{\endhanginglist}
%    \end{macrocode}
%
% \iffalse
%</hang>
% \fi
%
%
%
%
%
% \iffalse
%<*hyperref>
% \fi

% \part{lwarp-hyperref.sty}

% \section{hyperref}
%
% \credits{Sebastian Rahtz, Heiko Oberdiek}
%
% \DescribePackage{hyperref}
% \pkg{hyperref} is emulated.

% \changes{v0.20}{2017/01/03}{\pkg{hyperref}: Additional user macros.}
%
% \codehtml
%    \begin{macrocode}
% \LWR@ProvidesPackageDrop{hyperref}
\typeout{Using the lwarp html version of package `hyperref' — discarding options.}
\typeout{    Are not using ProvidesPackage, so that other packages}
\typeout{    do not attempt to patch lwarp's version of `hyperref'.}
% \ProvidesPackage{lwarp-#1-#2}
\DeclareOption*{}
\ProcessOptions\relax
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\hypersetup}[1]{}
\newcommand*{\hyperbaseurl}[1]{}
%    \end{macrocode}



% \begin{noindmacro}{\hyperimage} \marg{url} \marg{alt text}
%
% Insert an image with alt text:
%
% \changes{v0.43}{2017/10/31}{\pkg{hyperref}: Made robust.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@hyperimageb}{m +m}{%
\LWR@htmltag{img src="#1" alt="#2" class="hyperimage"{}}%
\endgroup%
\LWR@ensuredoingapar%
}

\DeclareRobustCommand*{\hyperimage}{%
\LWR@ensuredoingapar%
\begingroup\catcode`\_=12
\LWR@hyperimageb%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\hyperdef}
% \marg{1: category} \marg{2: name} \marg{3: text}
%
% Creates an \HTML\ anchor to |category.name| with the given text.
%
%    \begin{macrocode}
\NewDocumentCommand{\hyperdef}{m m +m}{%
\LWR@ensuredoingapar%
\LWR@subsublabel{#1.#2}%
#3%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\LWR@hyperrefb} \marg{1: URL} \marg{2: category}
%							\marg{3: name} \marg{4: text}
%
% Creates an \HTML\ link to |URL#category.name| with the given text.
%    \begin{macrocode}
\NewDocumentCommand{\LWR@hyperrefb}{m m m +m}{%
\LWR@htmltag{a href="#1\LWR@hashmark#2.#3"}%
#4%
\LWR@htmltag{/a}%
\endgroup%
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\LWR@hyperrefc} \oarg{label} \marg{text}
%
% Creates text as an \HTML\ link to the \LaTeX\ label.
%    \begin{macrocode}
\NewDocumentCommand{\LWR@hyperrefc}{O{label} +m}{
\LWR@startref{#1}%
#2%
\LWR@htmltag{/a}%
\endgroup%
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\hyperref}
% \marg{1: URL} \marg{2: category} \marg{3: name} \marg{4: text} \quad ---\,or\,--- \\
% \oarg{1: label} \marg{2: text}
%
% \changes{v0.43}{2017/10/31}{\pkg{hyperref}: Made robust.}
%    \begin{macrocode}
\DeclareRobustCommand*{\hyperref}{%
\LWR@ensuredoingapar%
\begingroup\catcode`\_=12
\@ifnextchar[\LWR@hyperrefc\LWR@hyperrefb%
}
%    \end{macrocode}
% \end{noindmacro}



% \begin{noindmacro}{\hypertarget} \marg{name} \marg{text}
%
% Creates an anchor to |name| with the given text.
%
%    \begin{macrocode}
\NewDocumentCommand{\hypertarget}{m +m}{%
\label{#1}%
#2%
}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\hyperlink} \marg{name} \marg{text}
%
% Creates a link to the anchor created by hypertarget,
% with the given link text.
%
%    \begin{macrocode}
\NewDocumentCommand{\hyperlink}{m +m}{%
\hyperref[#1]{#2}%
}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\autoref} * \marg{label}
%
% For \HTML, \cs{cleveref} is used instead.
%
%    \begin{macrocode}
\NewDocumentCommand{\autoref}{s m}{%
\IfBooleanTF{#1}{\ref{#2}}{\cref{#2}}%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\autopageref} \marg{label}
%
% For \HTML, \cs{cleveref} is used instead.
%
%    \begin{macrocode}
\NewDocumentCommand{\autopageref}{s m}{%
\IfBooleanTF{#1}{\cpageref{#2}}{\cref{#2}}%
}
%    \end{macrocode}
% \end{noindmacro}



% \begin{noindmacro}{\pdfstringdef} \marg{macroname} \marg{\TeX{}string}
%
%    \begin{macrocode}
\newcommand{\pdfstringdef}[2]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\pdfbookmark} \oarg{level} \marg{text} \marg{name}
%
%    \begin{macrocode}
\newcommand{\pdfbookmark}[3][]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\currentpdfbookmark} \marg{text} \marg{name}
%
%    \begin{macrocode}
\newcommand{\currentpdfbookmark}[2]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\subpdfbookmark} \marg{text} \marg{name}
%
%    \begin{macrocode}
\newcommand{\subpdfbookmark}[2]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\belowpdfbookmark} \marg{text} \marg{name}
%
%    \begin{macrocode}
\newcommand{\belowpdfbookmark}[2]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\texorpdfstring} \marg{\TeX{}string} \marg{PDFstring}
%
%    \begin{macrocode}
\newcommand{\texorpdfstring}[2]{#2}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\hypercalcbp} \marg{dimen} \quad
% From \pkg{hyperref}.
%
%    \begin{macrocode}
\def\hypercalcbp#1{%
\strip@pt\dimexpr 0.99626401\dimexpr(#1)\relax\relax
}%
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\Acrobatmenu} \marg{menuoption} \marg{text}
%
%    \begin{macrocode}
\newcommand{\Acrobatmenu}[2]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\TextField} \oarg{parameters} \marg{label}
% \changes{v0.43}{2017/10/31}{\pkg{hyperref}: Made robust.}
%
%    \begin{macrocode}
\DeclareRobustCommand{\TextField}[2][]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\CheckBox} \oarg{parameters} \marg{label}
%
%    \begin{macrocode}
\DeclareRobustCommand{\CheckBox}[2][]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\ChoiceMenu} \oarg{parameters} \marg{label} \marg{choices}
%
%    \begin{macrocode}
\DeclareRobustCommand{\ChoiceMenu}[3][]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\PushButton} \oarg{parameters} \marg{label}
%
%    \begin{macrocode}
\DeclareRobustCommand{\PushButton}[2][]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\Submit} \oarg{parameters} \marg{label}
%
%    \begin{macrocode}
\DeclareRobustCommand{\Submit}[2][]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\Reset} \oarg{parameters} \marg{label}
%
%    \begin{macrocode}
\DeclareRobustCommand{\Reset}[2][]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\Gauge} \oarg{parameters} \marg{label}
%
% \changes{v0.43}{2017/10/31}{\pkg{hyperref}: \cs{Gauge} added.}
%    \begin{macrocode}
\DeclareRobustCommand{\Gauge}[2][]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\LayoutTextField} \marg{label} \marg{field}
%
%    \begin{macrocode}
\newcommand*{\LayoutTextField}[2]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\LayoutChoiceField} \marg{label} \marg{field}
%
%    \begin{macrocode}
\newcommand*{\LayoutChoiceField}[2]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\LayoutCheckField} \marg{label} \marg{field}
%
%    \begin{macrocode}
\newcommand*{\LayoutCheckField}[2]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\MakeRadioField} \marg{width} \marg{height}
%
%    \begin{macrocode}
\newcommand*{\MakeRadioField}[2]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\MakeCheckField} \marg{width} \marg{height}
%
%    \begin{macrocode}
\newcommand*{\MakeCheckField}[2]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\MakeTextField} \marg{width} \marg{height}
%
%    \begin{macrocode}
\newcommand*{\MakeTextField}[2]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\MakeChoiceField} \marg{width} \marg{height}
%
%    \begin{macrocode}
\newcommand*{\MakeChoiceField}[2]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\MakeFieldButton} \marg{text}
%
%    \begin{macrocode}
\newcommand{\MakeFieldButton}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \iffalse
%</hyperref>
% \fi
%
%
%
%
%
%
% \iffalse
%<*hyperxmp>
% \fi
%
% \part{lwarp-hyperxmp.sty}
%
% \section{hyperxmp}
%
% \DescribePackage{hyperxmp} Emulated.
%
% \changes{v0.34}{2017/08/03}{\pkg{hyperxmp}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-hyperxmp}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{hyperxmp}
%    \end{macrocode}
%
%
% \iffalse
%</hyperxmp>
% \fi
%
%
%
%
%
%
% \iffalse
%<*idxlayout>
% \fi
%
% \part{lwarp-idxlayout.sty}
%
% \section{idxlayout}
%
% \credits{Thomas Titz}
%
% \DescribePackage{idxlayout} Emulated.
%
% \changes{v0.34}{2017/07/27}{\pkg{idxlayout}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-idxlayout}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{idxlayout}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\LWR@indexprenote}{}

\renewcommand*{\printindex}
{
\LWR@startpars

\LWR@indexprenote

\LWR@origprintindex
}

\newcommand{\setindexprenote}[1]{\renewcommand{\LWR@indexprenote}{#1}}
\newcommand*{\noindexprenote}{\renewcommand{\LWR@indexprenote}{}}

\newcommand{\idxlayout}[1]{}
\newcommand*{\indexfont}{}
\newcommand*{\indexjustific}{}
\newcommand*{\indexsubsdelim}{}
\newcommand*{\indexstheadcase}{}
%    \end{macrocode}
%
% \iffalse
%</idxlayout>
% \fi
%
%
%
%
% \iffalse
%<*ifoddpage>
% \fi

% \part{lwarp-ifoddpage.sty}

% \section{ifoddpage}
%
% \credits{Martin Scharrer}
%
% \DescribePackage{ifoddpage}
% \pkg{ifoddpage} is emulated.
%
% \changes{v0.44}{2017/11/13}{\pkg{ifoddpage}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-ifoddpage}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{ifoddpage}
%    \end{macrocode}

%    \begin{macrocode}
\newif\ifoddpage

\newif\ifoddpageoroneside

\DeclareRobustCommand{\checkoddpage}{\oddpagetrue\oddpageoronesidetrue}

\def\oddpage@page{1}

\def\@ifoddpage{%
        \expandafter\@firstoftwo
}

\def\@ifoddpageoroneside{%
        \expandafter\@firstoftwo
}
%    \end{macrocode}

% \iffalse
%</ifoddpage>
% \fi
%
%
%
%
%
% \iffalse
%<*indentfirst>
% \fi

% \part{lwarp-indentfirst.sty}

% \section{indentfirst}
%
% \DescribePackage{indentfirst}
% \pkg{indentfirst} is ignored.
%
% \changes{v0.22}{2017/03/01}{\pkg{indentfirst}: Added.}
%
% Discard all options for \pkg{lwarp-indentfirst}:

% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{indentfirst}
%    \end{macrocode}

% \iffalse
%</indentfirst>
% \fi
%
%
%
%
% \iffalse
%<*inputenc>
% \fi
%
% \part{lwarp-inputenc.sty}
%
% \section{inputenc}
%
% \DescribePackage{inputenc}
% Error if \pkg{inputenc} is loaded after \pkg{lwarp}.
%
% \changes{v0.21}{2017/02/22}{\pkg{inputenc}: Added.}
%

% Discard all options for \pkg{lwarp-inputenc}:

% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{inputenc}
%    \end{macrocode}

%    \begin{macrocode}
\LWR@loadbefore{inputenc}
%    \end{macrocode}

% \iffalse
%</inputenc>
% \fi
%
%
%
%
%
% \iffalse
%<*keyfloat>
% \fi

% \part{lwarp-keyfloat.sty}

% \section{keyfloat}
% \label{sec:keyfloat}
%
% \credits{Brian Dunn}
%
% \DescribePackage{keyfloat}
% \pkg{keyfloat} is supported with minor adjustments.
%
% \limitskeyfloat
%
% \changes{v0.20}{2017/01/16}{\pkg{keyfloat}: Added.}
% \changes{v0.31}{2017/05/12}{\pkg{keyfloat}: Improved compatibility.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{keyfloat}
%    \end{macrocode}

% After \pkg{keyfloat} has loaded:
%    \begin{macrocode}
\AtBeginDocument{
%    \end{macrocode}
%
% ^^A *8* use a virtual line width instead of \linewidth
% ^^A% Modified to use \cs{LWR@minipagewidth} instead of \cs{linewidth}:
% ^^A%    \begin{macrocode}
% ^^A\renewcommand*{\KFLT@findwidths}{%
% ^^A\typeout{*** KFLT@findwidths start}% *8*
% ^^A%    \end{macrocode}
% ^^A% Default to a box of full \cs{linewidth} minus the potential frame:
% ^^A%    \begin{macrocode}
% ^^A\ifthenelse{\boolean{KFLT@ft}}% tight frame?
% ^^A{\setlength{\KFLT@boxwidth}{\linewidth - 2\KFLTtightframewidth}}%
% ^^A{% not tight frame
% ^^A\ifthenelse{\boolean{KFLT@f}}% loose frame?
% ^^A{\setlength{\KFLT@boxwidth}{\linewidth - 2\KFLTlooseframewidth}}%
% ^^A{\setlength{\KFLT@boxwidth}{\linewidth}}% no frame
% ^^A}% not tight frame
% ^^A%    \end{macrocode}
% ^^A% Several width options exist.  First see if width was given:
% ^^A%    \begin{macrocode}
% ^^A\ifthenelse{\dimtest{\KFLT@w}{>}{0pt}}%
% ^^A%    \end{macrocode}
% ^^A%  Width was given:
% ^^A%    \begin{macrocode}
% ^^A{\setlength{\KFLT@imagewidth}{\KFLT@w}}%
% ^^A{% width not given
% ^^A%    \end{macrocode}
% ^^A% Use full \cs{linewidth} or only a fraction:
% ^^A%    \begin{macrocode}
% ^^A\ifcsempty{\KFLT@lw}%
% ^^A{\setlength{\KFLT@imagewidth}{\KFLT@boxwidth}}%
% ^^A{\setlength{\KFLT@imagewidth}{\KFLT@lw\KFLT@boxwidth}}%
% ^^A}% width not given
% ^^A\typeout{*** KFLT@findwidths end}% *8*
% ^^A}
% ^^A%    \end{macrocode}


%    \begin{macrocode}
\let\KFLT@boxinner\relax
\let\endKFLT@boxinner\relax

\NewEnviron{KFLT@boxinner}
{%
\LWR@traceinfo{KFLT@boxinner}%
\LWR@stoppars%
\KFLT@frame{\BODY}%
\LWR@startpars%
\LWR@traceinfo{KFLT@boxinner: done}%
}
%    \end{macrocode}


% \changes{v0.42}{2017/10/26}{\pkg{keyfloat}: If \texttt{FormatWP} add explicit HTML style.}
%    \begin{macrocode}
\DeclareDocumentEnvironment{KFLT@marginfloat}{O{-1.2ex} m}
{%
\LWR@BlockClassWP{float:right; width:2in; margin:10pt}{}{marginblock}%
\captionsetup{type=#2}%
}
{%
\endLWR@BlockClassWP%
}
%    \end{macrocode}


%    \begin{macrocode}
\DeclareDocumentEnvironment{marginfigure}{o}
  {\begin{KFLT@marginfloat}{figure}}
  {\end{KFLT@marginfloat}}

\DeclareDocumentEnvironment{margintable}{o}
  {\begin{KFLT@marginfloat}{table}}
  {\end{KFLT@marginfloat}}
%    \end{macrocode}


% ^^A % Modified to vertically align minipage for \HTML\ output:
%    \begin{macrocode}
\DeclareDocumentEnvironment{keywrap}{m +m}
{%
\LWR@ensuredoingapar%
\setlength{\LWR@templengthone}{#1}%
\uselengthunit{PT}%
\begin{LWR@BlockClassWP}{%
    float:right; width:\rndprintlength{\LWR@templengthone}; %
    margin:10pt%
}%
{%
    width:\rndprintlength{\LWR@templengthone}%
}%
{marginblock}%
\setlength{\linewidth}{.95\LWR@templengthone}%
#2%
\end{LWR@BlockClassWP}%
}
{%
}
%    \end{macrocode}
% ^^A \par%
% ^^A \setlength{\KFLT@keywrapwidth}{\linewidth}%
% ^^A \addtolength{\KFLT@keywrapwidth}{-#1}%
% ^^A \addtolength{\KFLT@keywrapwidth}{-2em}%
% ^^A \minipage[b]{\KFLT@keywrapwidth}%
% ^^A %
% ^^A \setlength{\parskip}{\KFLT@keywrapparskip}%
% ^^A \setlength{\parindent}{\KFLT@keywrapparindent}%
% ^^A \booltrue{KFLT@keywrap}%
% ^^A }
% ^^A {%
% ^^A \par
% ^^A \endminipage%
% ^^A \hfill%
% ^^A \begin{minipage}[b]{#1}%
% ^^A \booltrue{KFLT@keywrap}%
% ^^A #2%
% ^^A \par
% ^^A \unskip\vspace{\smallskipamount}
% ^^A \end{minipage}%
% ^^A \par
% ^^A }

% ^^A \BeforeBeginEnvironment{keywrap}{
% ^^A \setlength{\KFLT@keywrapparskip}{\parskip}
% ^^A \setlength{\KFLT@keywrapparindent}{\parindent}
% ^^A }
% ^^A %    \end{macrocode}


%    \begin{macrocode}
}% AtBeginDocument
%    \end{macrocode}


% \iffalse
%</keyfloat>
% \fi
%
%
%
%
%
% \iffalse
%<*layout>
% \fi

% \part{lwarp-layout.sty}

% \section{layout}
%
% \credits{Kent McPherson, Johannes Braams,  Hideo Umeki}
%
% \DescribePackage{layout}
% \pkg{layout} is emulated.
%
% \changes{v0.22}{2017/03/01}{\pkg{layout}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-layout}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{layout}
%    \end{macrocode}

%    \begin{macrocode}
\NewDocumentCommand{\layout}{s}{}
%    \end{macrocode}

% \iffalse
%</layout>
% \fi
%
%
%
%
% \iffalse
%<*letterspace>
% \fi

% \part{lwarp-letterspace.sty}

% \section{letterspace}
%
% \credits{R Schlicht}
%
% \DescribePackage{letterspace}
% \pkg{letterspace} is a subset of microtype, which is pre-loaded by \pkg{lwarp}.
% All user options and macros are ignored and disabled.

% \changes{v0.20}{2017/01/03}{\pkg{letterspace}: User-interface emulated.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-letterspace}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{letterspace}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*\lsstyle{}
\newcommand\textls[2][]{}
\def\textls#1#{}
\newcommand*\lslig[1]{#1}
%    \end{macrocode}

% \iffalse
%</letterspace>
% \fi
%
%
%
%
%
%
% \iffalse
%<*lettrine>
% \fi
%
% \part{lwarp-lettrine.sty}
%
% \section{lettrine}
%
% \credits{Daniel Flipo}
%
% \DescribePackage{lettrine} Emulated.
%
% \changes{v0.27}{2017/04/02}{\pkg{lettrine}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-lettrine}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{lettrine}
%    \end{macrocode}
%
% The initial letter is in a \element{span} of class |lettrine|, and the following
% text is in a \element{span} of class |lettrinetext|.
% \cs{lettrine} \oarg{keys} \marg{letter} \marg{additional text}
%    \begin{macrocode}
\DeclareDocumentCommand{\lettrine}{o m m}{%
\InlineClass{lettrine}{#2}\InlineClass{lettrinetext}{#3} %
}

\newcounter{DefaultLines}
\setcounter{DefaultLines}{2}
\newcounter{DefaultDepth}
\newcommand*{\DefaultOptionsFile}{\relax}
\newcommand*{\DefaultLoversize}{0}
\newcommand*{\DefaultLraise}{0}
\newcommand*{\DefaultLhang}{0}
\newdimen\DefaultFindent
\setlength{\DefaultFindent}{\z@}
\newdimen\DefaultNindent
\setlength{\DefaultNindent}{0.5em}
\newdimen\DefaultSlope
\setlength{\DefaultSlope}{\z@}
\newdimen\DiscardVskip
\setlength{\DiscardVskip}{0.2\p@}
\newif\ifLettrineImage
\newif\ifLettrineOnGrid
\newif\ifLettrineRealHeight

\newcommand*{\LettrineTextFont}{\scshape}
\newcommand*{\LettrineFontHook}{}
\newcommand*{\LettrineFont}[1]{\InlineClass{lettrine}{#1}}
\newcommand*{\LettrineFontEPS}[1]{\includegraphics[height=1.5ex]{#1}}
%    \end{macrocode}
%
% \iffalse
%</lettrine>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*lips>
% \fi

% \part{lwarp-lips.sty}

% \section{lips}
% \label{sec:lips}
%
% \credits{Matt Swift}
%
% \changes{v0.25}{2017/03/16}{\pkg{lips}: Added.}
%
% \DescribePackage{lips}
% \pkg{lips} is emulated.

%    \begin{macrocode}
% \LWR@ProvidesPackageDrop{lips}
\PackageInfo{lwarp}{Using the lwarp version of package `lips'.}%
\ProvidesPackage{lwarp-lips}

\NewDocumentCommand{\Lips}{}{\textellipsis}

\NewDocumentCommand{\BracketedLips}{}{[\textellipsis]}

\let\lips\Lips
\let\olips\lips

\DeclareOption*{}
\DeclareOption{mla}{
\let\lips\BracketedLips
}
\ProcessOptions\relax

\newcommand \LPNobreakList {}
%    \end{macrocode}

% \iffalse
%</lips>
% \fi
%
%
%
%
%
% \iffalse
%<*listings>
% \fi

% \part{lwarp-listings.sty}

% \section{listings}
% \label{sec:listings}
%
% \credits{Carsten Heinz, Brooks Moses, Jobst Hoffmann}
%
%
% \DescribePackage{listings}
% \pkg{listings} is supported with some limitations.
% Text formatting is not yet supported.
%
% \changes{v0.20}{2017/01/01}{\pkg{listings}: Added.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{listings}
%    \end{macrocode}

% ^^A For passing optional arguments to an environment, see:
% ^^A \href
% ^^A {http://tex.stackexchange.com/questions/9035/how-to-pass-an-optional-argument-to-an-environment-with-verbatim-content}
% ^^A {\texttt{http://tex.stackexchange.com/questions/9035/ \\
% ^^A 	\hspace*{3em}how-to-pass-an-optional-argument-to-\\
% ^^A 	\hspace*{3em}an-environment-with-verbatim-content}}
%
%
%
% Patches to embed listings inside |pre| tags:
%
%    \begin{macrocode}
\let\LWR@origlst@Init\lst@Init
\let\LWR@origlst@DeInit\lst@DeInit

\let\LWR@origlsthkEveryPar\lsthk@EveryPar

\renewcommand{\l@lstlisting}[2]{\hypertocfloat{1}{lstlisting}{lol}{#1}{#2}}
%    \end{macrocode}
%
%
% \begin{noindmacro}{\lst@Init} \marg{backslash-processing} \quad
% Done at the start of a listing.
%    \begin{macrocode}
\renewcommand{\lst@Init}[1]{%
%    \end{macrocode}
% First, perform the \pkg{listings} initialization:
%    \begin{macrocode}
\LWR@traceinfo{lst@Init}%
\renewcommand*{\@captype}{lstlisting}%
\LWR@origlst@Init{#1}%
\LWR@traceinfo{finished origlst@Init}%
\lst@ifdisplaystyle%
%    \end{macrocode}
% Creating a display.
%
% Disable line numbers,
% produce the \element{pre}, then
% reenable line numbers.
%    \begin{macrocode}
\LWR@traceinfo{About to create verbatim.}%
\let\lsthk@EveryPar\relax%
\LWR@forcenewpage
\LWR@atbeginverbatim{programlisting}%

\let\lsthk@EveryPar\LWR@origlsthkEveryPar%
\else%
%    \end{macrocode}
% Inline, so open a \element{span}:
%    \begin{macrocode}
\ifbool{LWR@verbtags}{\LWR@htmltag{span class="inlineprogramlisting"}}{}%
\fi%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\lst@DeInit} \quad Done at the end of a listing.
%    \begin{macrocode}
\renewcommand*{\lst@DeInit}{%
\lst@ifdisplaystyle%
%    \end{macrocode}
% Creating a display.
%
% Disable line numbers,
% produce the \element{/pre}, then
% reenable line numbers:
%    \begin{macrocode}
\let\lsthk@EveryPar\relax%

\LWR@afterendverbatim%
\let\lsthk@EveryPar\LWR@origlsthkEveryPar%
\else%
%    \end{macrocode}
% Inline, so create the closing \element{/span}:
%    \begin{macrocode}
\ifbool{LWR@verbtags}{\noindent\LWR@htmltag{/span}}{}%
\fi%
%    \end{macrocode}
% Final \pkg{listings} deinit:
%    \begin{macrocode}
\LWR@origlst@DeInit%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
%
% \begin{noindmacro}{\lst@MakeCaption} \marg{t/b}
%
% This is called BOTH at the top and at the bottom of each listing.
%
% Patched for \pkg{lwarp}.
%    \begin{macrocode}
\def\lst@MakeCaption#1{%
\LWR@traceinfo{MAKING CAPTION at #1}%
  \lst@ifdisplaystyle
\LWR@traceinfo{making a listings display caption}%
    \ifx #1t%
         \ifx\lst@@caption\@empty\expandafter\lst@HRefStepCounter \else
                                 \expandafter\refstepcounter
         \fi {lstlisting}%
\LWR@traceinfo{About to assign label: !\lst@label!}%
%         \ifx\lst@label\@empty\else
% \label{\lst@label}\fi
\LWR@traceinfo{Finished assigning the label.}%
        \let\lst@arg\lst@intname \lst@ReplaceIn\lst@arg\lst@filenamerpl
        \global\let\lst@name\lst@arg \global\let\lstname\lst@name
        \lst@ifnolol\else
            \ifx\lst@@caption\@empty
                \ifx\lst@caption\@empty
                    \ifx\lst@intname\@empty \else \def\lst@temp{ }%
                    \ifx\lst@intname\lst@temp \else
%    \end{macrocode}
% This code places a contents entry for a non-float.
% This would have to be modified for \pkg{lwarp}:
%    \begin{macrocode}
\LWR@traceinfo{addcontents lst@name: -\lst@name-}%
%                            \addcontentsline{lol}{lstlisting}{\lst@name}
                    \fi\fi
                \fi
            \else
%    \end{macrocode}
% This would have to be modified for \pkg{lwarp}:
%    \begin{macrocode}
\LWR@traceinfo{addcontents lst@@caption: -\lst@@caption-}%
                 \addcontentsline{lol}{lstlisting}%
{\protect\numberline{\thelstlisting}%
{\protect\ignorespaces \lst@@caption \protect\relax}}%
            \fi
         \fi
     \fi
    \ifx\lst@caption\@empty\else
\LWR@traceinfo{lst@caption not empty-}%
        \lst@IfSubstring #1\lst@captionpos
            {\begingroup
\LWR@traceinfo{at the selected position}%
%    \end{macrocode}
% These space and box commands are not needed for \HTML\ output:
%    \begin{macrocode}
%              \let\@@vskip\vskip
%              \def\vskip{\afterassignment\lst@vskip \@tempskipa}%
%              \def\lst@vskip{\nobreak\@@vskip\@tempskipa\nobreak}%
%              \par\@parboxrestore\normalsize\normalfont % \noindent (AS)
%              \ifx #1t\allowbreak \fi
             \ifx\lst@title\@empty
%    \end{macrocode}
% New \pkg{lwarp} code to create a caption:
%    \begin{macrocode}
                  \lst@makecaption\fnum@lstlisting{\ignorespaces \lst@caption}
             \else
%    \end{macrocode}
% New \pkg{lwarp} code to create a title:
%    \begin{macrocode}
%                  \lst@maketitle\lst@title % (AS)
\LWR@traceinfo{Making title: \lst@title}%
\begin{BlockClass}{lstlistingtitle}% lwarp
\lst@maketitle\lst@title% lwarp
\end{BlockClass}% lwarp
             \fi
\LWR@traceinfo{About to assign label: !\lst@label!}%
        \ifx\lst@label\@empty\else
\leavevmode% gets rid of bad space factor error
\GetTitleStringExpand{\lst@caption}%
\edef\LWR@lntemp{\GetTitleStringResult}%
\edef\@currentlabelname{\detokenize\expandafter{\LWR@lntemp}}%
\label{\lst@label}\fi
\LWR@traceinfo{Finished assigning the label.}%
%    \end{macrocode}
% Not needed for \pkg{lwarp}:
%    \begin{macrocode}
%              \ifx #1b\allowbreak \fi
             \endgroup}{}%
    \fi
\LWR@traceinfo{end of making a listings display caption}%
  \else
\LWR@traceinfo{INLINE}%
  \fi
\LWR@traceinfo{DONE WITH CAPTION at #1}%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% Patched to keep left line numbers outside of the left margin, and
% place right line numbers in a field \cs{VerbatimHTMLWidth} wide.
%
% ^^A \DescribeKey[listings]{numbers} Activates line numbers.
%    \begin{macrocode}
\lst@Key{numbers}{none}{%
    \let\lst@PlaceNumber\@empty
    \lstKV@SwitchCases{#1}%
    {none&\\%
     left&\def\lst@PlaceNumber{%
% \llap{
\LWR@orignormalfont%
\lst@numberstyle{\thelstnumber}\kern\lst@numbersep%
% }
}
\\%
     right&\def\lst@PlaceNumber{\rlap{\LWR@orignormalfont
                \kern\VerbatimHTMLWidth \kern\lst@numbersep
                \lst@numberstyle{\thelstnumber}}}%
    }{\PackageError{Listings}{Numbers #1 unknown}\@ehc}}
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}

% \iffalse
%</listings>
% \fi
%
%
%
%
%
%
% \iffalse
%<*longtable>
% \fi

% \part{lwarp-longtable.sty}

% \section{longtable}
% \label{sec:longtable}
%
% \credits{David Carlisle}
%
% \DescribePackage{longtable}
% \pkg{longtable} is emulated.

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{longtable}
%    \end{macrocode}
%
% \limitslongtable
%
% See: \\
% \href{http://tex.stackexchange.com/questions/43006/why-is-input-not-expandable}
%	{\texttt{http://tex.stackexchange.com/questions/43006/\\why-is-input-not-expandable}}
%
%
% \begin{environment}{longtable} * \oarg{horizalignment} \marg{colspec}
% Emulates the \env{longtable} environment.
%
% Per the \pkg{caption} package, the starred version steps the counter per caption.
% The unstarred version steps the counter once at the beginning, but
% not at each caption.
%
% Options [c], [l], and [r] are thrown away.
%    \begin{macrocode}
\newenvironment{longtable*}[2][]{%
\LWR@floatbegin{table}%
\setcaptiontype{\LTcaptype}%
\caption@setoptions{longtable}%
\caption@setoptions{@longtable}%
\caption@LT@setup%
\booltrue{LWR@starredlongtable}%
\let\captionlistentry\LWR@LTcaptionlistentry%
\LWR@tabular{#2}
}
{\endLWR@tabular\LWR@floatend}

\newenvironment{longtable}[2][]{%
\LWR@floatbegin{table}%
\setcaptiontype{\LTcaptype}%
\caption@setoptions{longtable}%
\caption@setoptions{@longtable}%
\caption@LT@setup%
\refstepcounter{\LTcaptype}%
\let\captionlistentry\LWR@LTcaptionlistentry%
\LWR@tabular{#2}
}
{\endLWR@tabular\LWR@floatend}

%    \end{macrocode}
% \end{environment}

% Provided for compatibility, but ignored:
%    \begin{macrocode}
\newcounter{LTchunksize}
\def\endhead{\LWR@tabularendofline}% throws away options //[dim] and //*
\def\endfirsthead{\LWR@tabularendofline}
\def\endfoot{\LWR@tabularendofline}
\def\endlastfoot{\LWR@tabularendofline}
\newcommand\tabularnewline{\LWR@tabularendofline}
\newcommand{\setlongtables}{}% Obsolete command, does nothing.
\newlength{\LTleft}
\newlength{\LTright}
\newlength{\LTpre}
\newlength{\LTpost}
\newlength{\LTcapwidth}
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand*{\kill}{\LWR@tabularendofline}
%    \end{macrocode}

% \iffalse
%</longtable>
% \fi
%
%
%
%
%
%
%
%
%
% \iffalse
%<*lscape>
% \fi

% \part{lwarp-lscape.sty}

% \section{lscape}
%
% \credits{D. P. Carlisle}
%
% \DescribePackage{lscape}
% \pkg{lscape} is emulated.
%
% \changes{v0.22}{2017/03/01}{\pkg{lscape}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-lscape}.
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{lscape}
%    \end{macrocode}

%    \begin{macrocode}
\newenvironment*{landscape}{}{}
%    \end{macrocode}

% \iffalse
%</lscape>
% \fi
%
%
%
% \iffalse
%<*ltcaption>
% \fi

% \part{lwarp-ltcaption.sty}

% \section{ltcaption}
% \label{sec:ltcaption}
%
% \credits{Axel Sommerfeldt}
%
% \DescribePackage{ltcaption}
% \pkg{ltcaption} is emulated.

% \changes{v0.20}{2017/01/29}{\pkg{ltcaption}: Added.}

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{ltcaption}
%    \end{macrocode}

%
% \cs{LTcaptype} is already defined by \pkg{lwarp}.
%
% \env{longtable*} is already defined by \pkg{lwarp-longtable}.
%
%    \begin{macrocode}
\newlength{\LTcapskip}
\newlength{\LTcapleft}
\newlength{\LTcapright}
\newcommand*{\LTcapmarginsfalse}{}
%    \end{macrocode}
%
%
% \iffalse
%</ltcaption>
% \fi
%
%
%
% \iffalse
%<*ltxtable>
% \fi
%
% \part{lwarp-ltxtable.sty}
%
% \section{ltxtable}
%
% \DescribePackage{ltxtable}
% \pkg{ltxtable} is emulated.
%
% \changes{v0.44}{2017/11/15}{\pkg{ltxtable}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{ltxtable}
%    \end{macrocode}
%
% \begin{noindmacro}{\LTXtable} \marg{width} \marg{file}
%    \begin{macrocode}
\newcommand*{\LTXtable}[2]{%
\input{#2}%
}
%    \end{macrocode}
% \end{noindmacro}
%
% \iffalse
%</ltxtable>
% \fi
%
%
%
%
%
%
% \iffalse
%<*luatodonotes>
% \fi
%
% \part{lwarp-luatodonotes.sty}
%
% \section{luatodonotes}
%
% \credits{Fabian Lipp}
%
% \DescribePackage{luatodonotes}
% \pkg{luatodonotes} is emulated.
%
% \limitstodonotes
%
% \changes{v0.43}{2017/11/07}{\pkg{luatodonotes}: Added.}
% \changes{v0.44}{2017/11/10}{\pkg{luatodonotes}: Improved.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{luatodonotes}
%    \end{macrocode}
%
%
% Nullify options:
%    \begin{macrocode}
\@todonotes@additionalMarginEnabledfalse
%    \end{macrocode}
%
%
%    \begin{macrocode}
\if@todonotes@disabled
\else

\newcommand{\ext@todo}{tdo}

\renewcommand{\l@todo}[2]{\hypertocfloat{1}{todo}{ldo}{#1}{#2}}


\renewcommand{\@todonotes@drawMarginNoteWithLine}{%
\fcolorbox
    {\@todonotes@currentbordercolor}
    {\@todonotes@currentbackgroundcolor}
    {\arabic{@todonotes@numberoftodonotes}}
\marginpar{\@todonotes@drawMarginNote}
}

\renewcommand{\@todonotes@drawInlineNote}{%
\fcolorboxBlock%
    {\@todonotes@currentbordercolor}%
    {\@todonotes@currentbackgroundcolor}%
    {%
        \if@todonotes@authorgiven%
        {\@todonotes@author:\,}%
        \fi%
        \@todonotes@text%
    }%
}

\newcommand{\@todonotes@drawMarginNote}{%
    \if@todonotes@authorgiven%
        \@todonotes@author\par%
    \fi%
    \arabic{@todonotes@numberoftodonotes}: %
    \fcolorbox%
    {\@todonotes@currentbordercolor}%
    {\@todonotes@currentbackgroundcolor}%
    {%
        \@todonotes@sizecommand%
        \@todonotes@text %
    }%
}%

\renewcommand{\missingfigure}[2][]{%
\setkeys{todonotes}{#1}%
\addcontentsline{tdo}{todo}{\@todonotes@MissingFigureText: #2}%
\fcolorboxBlock%
    {\@todonotes@currentbordercolor}%
    {\@todonotes@currentfigcolor}%
    {%
        \setlength{\fboxrule}{4pt}%
        \fcolorbox{red}{white}{Missing figure} \quad #2%
    }
}

\LetLtxMacro\LWRTODONOTES@orig@todocommon\@todocommon

\RenewDocumentCommand{\@todocommon}{m m}{%
\begingroup%
\renewcommand*{\phantomsection}{}%
\LWRTODONOTES@orig@todocommon{#1}{#2}%
\endgroup%
}

\renewcommand{\@todoarea}[3][]{%
    \@todonotes@areaselectedtrue%
    \@todocommon{#1}{#2}%
    \todonotes@textmark@highlight{#3}%
    \zref@label{@todonotes@\arabic{@todonotes@numberoftodonotes}@end}%
}%


\DeclareDocumentCommand{\todonotes@textmark@highlight}{m}{%
\InlineClass[background:\#B3FFB3]{highlight}{#1}%
}

\fi% \if@todonotes@disabled
%    \end{macrocode}
%
% \iffalse
%</luatodonotes>
% \fi
%
%
%
%
%
%
% \iffalse
%<*marginfit>
% \fi
%
% \part{lwarp-marginfit.sty}
%
% \section{marginfit}
%
% \DescribePackage{marginfit} \pkg{marginfit} is ignored.
%
% \changes{v0.34}{2017/07/25}{\pkg{marginfit}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-marginfit}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{marginfit}
%    \end{macrocode}
%
% \iffalse
%</marginfit>
% \fi
%
%
%
%
%
% \iffalse
%<*marginfix>
% \fi
%
% \part{lwarp-marginfix.sty}
%
% \section{marginfix}
%
% \credits{Stephen Hicks}
%
% \DescribePackage{marginfix} Emulated.
%
% \changes{v0.26}{2017/03/29}{\pkg{marginfix}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-marginfix}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{marginfix}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\marginskip}[1]{}
\newcommand*{\clearmargin}{}
\newcommand*{\softclearmargin}{}
\newcommand*{\extendmargin}[1]{}
\newcommand*{\mparshift}[1]{}
\newdimen\marginheightadjustment
\newdimen\marginposadjustment
\newcommand*{\blockmargin}[1][]{}
\newcommand*{\unblockmargin}[1][]{}
\newcommand*{\marginphantom}[2][]{}
%    \end{macrocode}
%
% \iffalse
%</marginfix>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*marginnote>
% \fi
%
% \part{lwarp-marginnote.sty}
%
% \section{marginnote}
%
% \credits{Markus Kohm}
%
% \DescribePackage{marginnote} Emulated.
%
% \changes{v0.26}{2017/03/30}{\pkg{marginnote}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-marginnote}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{marginnote}
%    \end{macrocode}
%
%    \begin{macrocode}
\NewDocumentCommand{\marginnote}{o +m o}{\marginpar{#2}}
\newcommand*{\marginnoteleftadjust}{}
\newcommand*{\marginnoterightadjust}{}
\newcommand*{\marginnotetextwidth}{}
\let\marginnotetextwidth\textwidth
\newcommand*{\marginnotevadjust}{}
\newcommand*{\marginfont}{}
\newcommand*{\raggedleftmarginnote}{}
\newcommand*{\raggedrightmarginnote}{}
%    \end{macrocode}
%
% \iffalse
%</marginnote>
% \fi
%
%
%
%
% \iffalse
%<*mcaption>
% \fi

% \part{lwarp-mcaption.sty}

% \section{mcaption}
%
% \credits{Stephan Hennig}
%
% \DescribePackage{mcaption}
% \pkg{mcaption} is nullified.
%
% \changes{v0.22}{2017/03/01}{\pkg{mcaption}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-mcaption}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{mcaption}
%    \end{macrocode}

%    \begin{macrocode}
\newenvironment{margincap}{}{}
\newcommand*{\margincapalign}{}
\newlength{\margincapsep}
%    \end{macrocode}

% \iffalse
%</mcaption>
% \fi
%
%
%
%
%
%
% \iffalse
%<*mdframed>
% \fi

% \part{lwarp-mdframed.sty}

% \section{mdframed}
% \label{sec:mdframed}
%
% \credits{Marco Daniel, Elke Schubert}
%
% \DescribePackage{mdframed}
% \pkg{mdframed} is loaded with options forced to
% |framemethod=none|.
%
% \changes{v0.17}{2016/04/14}{\pkg{mdframed}: Added.}
%
% \subsection{Package loading}
%
% \codehtml
%    \begin{macrocode}
\RequirePackage{xcolor}% for \convertcolorspec
\LWR@ProvidesPackageDrop{mdframed}
%    \end{macrocode}
%
%
% \pkg{amsthm} must be loaded before \pkg{mdframed}
%    \begin{macrocode}
\LWR@origRequirePackage{amsthm}
%    \end{macrocode}
%
% Do not require \tikz{} or pstricks:
%    \begin{macrocode}
\LWR@origRequirePackage[framemethod=none]{mdframed}
%    \end{macrocode}
%
%
% \subsection{Limitations}
%
% \limitsmdframed
%
% Environments created or encapsulated by \pkg{mdframed} are enclosed in a
% \margintag{CSS classes}
% \element{div} of class |md<environmentname>|, or |mdframed| otherwise.
%
% Frame titles are placed into a \element{span} of class |mdframedtitle|.
% Subtitles are in a \element{span} of class |mdframedsubtitle|,
% and likewise for subsubtitles.
%
% Pre-existing hooks are used to patch extra functions before and after the frames.
%
%
%
% ^^A \DescribeMacro{\mdfsetup}
% To handle CSS and paragraphs,
% patch code at start and end of environment and contents.
% \cs{LWR@origraggedright} helps avoid hyphenation.
%
% \changes{v0.25}{2017/03/16}{\pkg{mdframed}: Help avoid hyphenation.}
%
%    \begin{macrocode}
\mdfsetup{
startcode={\LWR@mdframedstart\LWR@origraggedright},
endcode={\LWR@mdframedend},
startinnercode={\LWR@startpars\LWR@origraggedright},
endinnercode={\LWR@stoppars},
}
%    \end{macrocode}
%
%
% \subsection{Color and length HTML conversion}
%
% \begin{noindmacro}{\LWR@mdfprintcolor} \marg{mdfcolorkey}
%
% Given the \pkg{mdframed} key, print the color.
%    \begin{macrocode}
\newcommand*{\LWR@mdfprintcolor}[1]{%
\convertcolorspec{named}{\csuse{mdf@#1}}{HTML}\LWR@tempcolor%
\#\LWR@tempcolor
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\LWR@mdfprintlength} \marg{mdflengthkey}
%
% Given the \pkg{mdframed} key, print the length.
%    \begin{macrocode}
\newcommand*{\LWR@mdfprintlength}[1]{%
\rndprintlength{\csuse{mdf@#1@length}}
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \subsection{Environment encapsulation}
%
% \begin{noindmacro}{\LWR@mdframedstart}
% Actions before an mdframe starts.
%
% Encapsulate a frame inside a \element{div} of the desired |class|.
%    \begin{macrocode}
\newcommand*{\LWR@mdframedstart}{%
%    \end{macrocode}
% Turn off paragraph handling during the generation of
% the encapsulating tags:
%    \begin{macrocode}
\LWR@stoppars%
%    \end{macrocode}
% Below, print \HTML\ pt units:
%    \begin{macrocode}
\uselengthunit{PT}%
%    \end{macrocode}
% Open a \element{div} and with custom |class| and custom |style|:
%    \begin{macrocode}
\LWR@htmltagc{div class="\LWR@mdthisenv" \LWR@orignewline
style=" \LWR@orignewline
%    \end{macrocode}
% Convert and print the background color:
%    \begin{macrocode}
background: \LWR@mdfprintcolor{backgroundcolor} ; \LWR@orignewline
%    \end{macrocode}
% Convert and print the border color and width:
%    \begin{macrocode}
border: \LWR@mdfprintlength{linewidth} solid
\LWR@mdfprintcolor{linecolor} ; \LWR@orignewline
%    \end{macrocode}
% Convert and print the border radius:
%    \begin{macrocode}
border-radius: \LWR@mdfprintlength{roundcorner} ; \LWR@orignewline
%    \end{macrocode}
% Convert and print the shadow:
%    \begin{macrocode}
\ifbool{mdf@shadow}{%
    box-shadow:
    \LWR@mdfprintlength{shadowsize}
    \LWR@mdfprintlength{shadowsize}
    \LWR@mdfprintlength{shadowsize}
    \LWR@mdfprintcolor{shadowcolor} ;
}
{box-shadow: none ;}
\LWR@orignewline
%    \end{macrocode}
%    \begin{macrocode}
"}
% \LWR@htmldivclass{\LWR@mdthisenv}
%    \end{macrocode}
% \env{mdframed} environment may not work with the \HTML\ versions of the following,
% so restore them to their originals while inside \env{mdframed}:
%    \begin{macrocode}
\LetLtxMacro{\hspace}{\LWR@orighspace}%
\LetLtxMacro\rule\LWR@origrule%
\LetLtxMacro\makebox\LWR@origmakebox%
}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\LWR@mdframedend}
% Actions after an mdframe ends.
%
% After closing the \element{div}, globally restore to the default environment type:
%    \begin{macrocode}
\newcommand*{\LWR@mdframedend}{
%    \end{macrocode}
% Close the custom \element{div}:
%    \begin{macrocode}
\LWR@htmldivclassend{\LWR@mdthisenv}
%    \end{macrocode}
% Reset future custom class to the default:
%    \begin{macrocode}
\gdef\LWR@mdthisenv{mdframed}
%    \end{macrocode}
% Resume paragraph handling:
%    \begin{macrocode}
\LWR@startpars%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \subsection{Titles and subtitles}
%
% \begin{noindmacro}{\mdfframedtitleenv} \marg{title}
%
% Encapsulation of the original which places the title
% inside a \element{span} of class |mdframedtitle|:
%    \begin{macrocode}
\LetLtxMacro\LWR@origmdfframedtitleenv\mdfframedtitleenv

\newlength{\LWR@titleroundcorner}

\renewrobustcmd\mdfframedtitleenv[1]{%
\LWR@origmdfframedtitleenv{%
%    \end{macrocode}
% Below, print \HTML\ pt lengths:
%    \begin{macrocode}
\uselengthunit{PT}%
%    \end{macrocode}
% Open a \element{span} with a custom |class| and custom |style|:
%    \begin{macrocode}
\LWR@htmltagc{span class="mdframedtitle" \LWR@orignewline
style=" \LWR@orignewline
%    \end{macrocode}
% Convert and print the title background color:
%    \begin{macrocode}
background:
\LWR@mdfprintcolor{frametitlebackgroundcolor}
; \LWR@orignewline
%    \end{macrocode}
% Convert and print the title rule:
%    \begin{macrocode}
\ifbool{mdf@frametitlerule}{%
    border-bottom:
    \LWR@mdfprintlength{frametitlerulewidth}
    solid
    \LWR@mdfprintcolor{frametitlerulecolor}
    ; \LWR@orignewline
}{}%
%    \end{macrocode}
% The title's top border radius is adjusted for the line width:
%    \begin{macrocode}
border-radius:
\setlength{\LWR@titleroundcorner}
    {\maxof{\mdf@roundcorner@length-\mdf@linewidth@length}{0pt}}
    \rndprintlength{\LWR@titleroundcorner}
    \rndprintlength{\LWR@titleroundcorner}
    0pt 0pt
    \LWR@orignewline
%    \end{macrocode}
% Finish the custom style and the opening span tag:
%    \begin{macrocode}
" \LWR@orignewline
}% span
%    \end{macrocode}
% Restrict paragraph tags inside a span:
%    \begin{macrocode}
\begin{LWR@nestspan}%
%    \end{macrocode}
% Print the title inside the span:
%    \begin{macrocode}
#1%
%    \end{macrocode}
% Closee the span and unnest the paragraph tag restriction:
%    \begin{macrocode}
\LWR@htmltagc{/span}%
\end{LWR@nestspan}%
}
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\LWR@mdfsubtitlecommon}
% \marg{sub -or- subsub} \oarg{options} \marg{title}
%
% Common code for \cs{LWR@mdfsubtitle} and \cs{LWR@mdfsubsubtitle}.
%
% Encapsulate the subtitle inside a \element{span} of class |mdframedsubtitle|:
%    \begin{macrocode}
\NewDocumentCommand{\LWR@mdfsubtitlecommon}{m o m}
{% the following empty line is required

%    \end{macrocode}
% Special handling for mdframed:
% Subtitles have \cs{par}s around them,
% so temporarily disable them here.
%    \begin{macrocode}
\let\par\LWR@origpar%
%    \end{macrocode}
% Open a \element{span} with a custom |class| and custom |style|:
%    \begin{macrocode}
\LWR@htmltagc{span class="mdframed#1title"
style=" \LWR@orignewline
%    \end{macrocode}
% Convert and print the background color:
%    \begin{macrocode}
background:
\LWR@mdfprintcolor{#1titlebackgroundcolor}
; \LWR@orignewline
%    \end{macrocode}
% Convert and print the above line:
%    \begin{macrocode}
\ifbool{mdf@#1titleaboveline}{%
    border-top:
    \LWR@mdfprintlength{#1titleabovelinewidth}
    solid
    \LWR@mdfprintcolor{#1titleabovelinecolor}
    ; \LWR@orignewline
}{}%
%    \end{macrocode}
% Convert and print the below line:
%    \begin{macrocode}
\ifbool{mdf@#1titlebelowline}{%
    border-bottom:
    \LWR@mdfprintlength{#1titlebelowlinewidth}
    solid
    \LWR@mdfprintcolor{#1titlebelowlinecolor}
    ; \LWR@orignewline
}{}%
%    \end{macrocode}
% Finish the custom style and the opening span tag:
%    \begin{macrocode}
"}% span
%    \end{macrocode}
% Restrict paragraph tags inside a span:
%    \begin{macrocode}
\begin{LWR@nestspan}%
%    \end{macrocode}
% Perform the original subtitle action:
%    \begin{macrocode}
\IfNoValueTF{#2}
{\csuse{LWR@origmdf#1title}{#3}}%
{\csuse{LWR@origmdf#1title}[#2]{#3}}%
%    \end{macrocode}
% Close the span and unnest the paragraph tag restriction:
%    \begin{macrocode}
\LWR@htmltagc{/span}% the following empty line is required
\end{LWR@nestspan}% must follow the /span or an extra <p> appears

}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\LWR@mdfsubtitle} \oarg{options} \marg{title}
%    \begin{macrocode}
\let\LWR@origmdfsubtitle\mdfsubtitle

\newcommand*{\LWR@mdfsubtitle}{%
\LWR@mdfsubtitlecommon{sub}%
}
\let\mdfsubtitle\LWR@mdfsubtitle
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\LWR@mdfsubsubtitle} \oarg{options} \marg{title}
%    \begin{macrocode}
\let\LWR@origmdfsubsubtitle\mdfsubsubtitle

\newcommand*{\LWR@mdfsubsubtitle}{%
\LWR@mdfsubtitlecommon{subsub}%
}
\let\mdfsubsubtitle\LWR@mdfsubsubtitle
%    \end{macrocode}
% \end{noindmacro}
%
%
% \subsection{New environments}
%
% \begin{noindmacro}{\LWR@mdthisenv}
% Stores the environment of the frame about to be created:
%    \begin{macrocode}
\newcommand*{\LWR@mdthisenv}{mdframed}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\newmdenv} \oarg{options} \marg{env-name}
%
% Modified from the original to remember the environment.
%    \begin{macrocode}
\renewrobustcmd*\newmdenv[2][]{%
\newenvironment{#2}%
{%
\mdfsetup{#1}%
\renewcommand*{\LWR@mdthisenv}{md#2}%
\begin{mdframed}%
}
{\end{mdframed}}%
}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\surroundwithmdframed} \oarg{options} \marg{environment}
%
% Modified from the original to remember the environment.
%    \begin{macrocode}
\renewrobustcmd*{\surroundwithmdframed}[2][]{%
\BeforeBeginEnvironment{#2}{%
\renewcommand*{\LWR@mdthisenv}{md#2}%
\begin{mdframed}[#1]}%
\AfterEndEnvironment{#2}{\end{mdframed}}%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\mdtheorem} \oarg{mdframed-options}{envname}
%        \oarg{numberedlike} \marg{caption} \oarg{within}
%
% Modified from the original to remember the environment.
%
% \changes{v0.34}{2017/08/05}{\pkg{mdframed}: Improved \env{mdtheorem} patch.}
%
%    \begin{macrocode}
\DeclareDocumentCommand{\mdtheorem}{ O{} m o m o }%
 {\ifcsdef{#2}%
   {\mdf@PackageWarning{Environment #2 already exits\MessageBreak}}%
   {%
    \IfNoValueTF {#3}%
     {%#3 not given -- number relationship
      \IfNoValueTF {#5}%
        {%#3+#5 not given
        \@definecounter{#2}%
        \expandafter\xdef\csname the#2\endcsname{\@thmcounter{#2}}%
        \newenvironment{#2}[1][]{%
          \refstepcounter{#2}%
          \ifstrempty{##1}%
            {\let\@temptitle\relax}%
            {%
             \def\@temptitle{\mdf@theoremseparator%
                             \mdf@theoremspace%
                             \mdf@theoremtitlefont%
                             ##1}%
             \mdf@thm@caption{#2}{{#4}{\csname the#2\endcsname}{##1}}%
             }%
          \begin{mdframed}[#1,frametitle={\strut#4\ \csname the#2\endcsname%
                                          \@temptitle}]}%
          {\end{mdframed}}%
        \newenvironment{#2*}[1][]{%
          \ifstrempty{##1}{\let\@temptitle\relax}{\def\@temptitle{:\ ##1}}%
          \begin{mdframed}[#1,frametitle={\strut#4\@temptitle}]}%
          {\end{mdframed}}%
        }%
        {%#5 given -- reset counter
        \@definecounter{#2}\@newctr{#2}[#5]%
        \expandafter\xdef\csname the#2\endcsname{\@thmcounter{#2}}%
        \expandafter\xdef\csname the#2\endcsname{%
               \expandafter\noexpand\csname the#5\endcsname \@thmcountersep%
                  \@thmcounter{#2}}%
        \newenvironment{#2}[1][]{%
          \refstepcounter{#2}%
          \ifstrempty{##1}%
            {\let\@temptitle\relax}%
            {%
             \def\@temptitle{\mdf@theoremseparator%
                             \mdf@theoremspace%
                             \mdf@theoremtitlefont%
                             ##1}%
             \mdf@thm@caption{#2}{{#4}{\csname the#2\endcsname}{##1}}%
             }
          \begin{mdframed}[#1,frametitle={\strut#4\ \csname the#2\endcsname%
                                          \@temptitle}]}%
          {\end{mdframed}}%
        \newenvironment{#2*}[1][]{%
          \ifstrempty{##1}%
            {\let\@temptitle\relax}%
            {%
             \def\@temptitle{\mdf@theoremseparator%
                             \mdf@theoremspace%
                             \mdf@theoremtitlefont%
                             ##1}%
             \mdf@thm@caption{#2}{{#4}{\csname the#2\endcsname}{##1}}%
             }%
          \begin{mdframed}[#1,frametitle={\strut#4\@temptitle}]}%
          {\end{mdframed}}%
        }%
     }%
     {%#3 given -- number relationship
        \global\@namedef{the#2}{\@nameuse{the#3}}%
        \newenvironment{#2}[1][]{%
          \refstepcounter{#3}%
          \ifstrempty{##1}%
            {\let\@temptitle\relax}%
            {%
             \def\@temptitle{\mdf@theoremseparator%
                             \mdf@theoremspace%
                             \mdf@theoremtitlefont%
                             ##1}%
             \mdf@thm@caption{#2}{{#4}{\csname the#2\endcsname}{##1}}%
             }
          \begin{mdframed}[#1,frametitle={\strut#4\ \csname the#2\endcsname%
                                          \@temptitle}]}%
          {\end{mdframed}}%
        \newenvironment{#2*}[1][]{%
          \ifstrempty{##1}{\let\@temptitle\relax}{\def\@temptitle{:\ ##1}}%
          \begin{mdframed}[#1,frametitle={\strut#4\@temptitle}]}%
          {\end{mdframed}}%
     }%
    \BeforeBeginEnvironment{#2}{\renewcommand*{\LWR@mdthisenv}{md#2}}% new
    \BeforeBeginEnvironment{#2*}{\renewcommand*{\LWR@mdthisenv}{md#2}}% new
   }%
 }
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\newmdtheoremenv} \oarg{mdframed-options}{envname}
%        \oarg{numberedlike} \marg{caption} \oarg{within}
%
% Modified from the original to remember the environment.
%    \begin{macrocode}
\DeclareDocumentCommand\newmdtheoremenv{O{} m o m o }{%
 \ifboolexpr{ test {\IfNoValueTF {#3}} and test {\IfNoValueTF {#5}} }%
    {\newtheorem{#2}{#4}}%
    {%
     \IfValueT{#3}{\newtheorem{#2}[#3]{#4}}%
     \IfValueT{#5}{\newtheorem{#2}{#4}[#5]}%
    }%
\BeforeBeginEnvironment{#2}{%
\renewcommand*{\LWR@mdthisenv}{md#2}%
\begin{mdframed}[#1]}%
\AfterEndEnvironment{#2}{%
\end{mdframed}}%
}
%    \end{macrocode}
% \end{noindmacro}

% \iffalse
%</mdframed>
% \fi
%
%
%
%
%
% \iffalse
%<*metalogo>
% \fi
%
% \part{lwarp-metalogo.sty}
%
% \section{metalogo}
%
% \credits{Andrew Gilbert Moschou}
%
% \DescribePackage{metalogo}
% \pkg{metalogo} is emulated.
%
% \changes{v0.38}{2017/08/25}{\pkg{metalogo}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{metalogo}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand\setlogokern[2]{}
\newcommand\setlogodrop[2][XeTeX]{}
\newcommand\setLaTeXa[1]{}
\newcommand\setLaTeXee[1]{}
\newcommand\seteverylogo[1]{}
\newcommand\everylogo[1]{}
%    \end{macrocode}
%
% \iffalse
%</metalogo>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*microtype>
% \fi

% \part{lwarp-microtype.sty}

% \section{microtype}
%
% \credits{R Schlicht}
%
% \DescribePackage{microtype}
% \pkg{microtype} is pre-loaded by \pkg{lwarp}.
% All user options and macros are ignored and disabled.

% \changes{v0.20}{2017/01/03}{\pkg{microtype}: User-interface emulated.}
% \changes{v0.27}{2017/04/01}{\pkg{microtype}: Fix with Xe\LaTeX, \LuaLaTeX.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-microtype}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{microtype}
%    \end{macrocode}

%    \begin{macrocode}
\DeclareDocumentCommand{\DeclareMicrotypeSet}{o m m}{}
\DeclareDocumentCommand{\UseMicrotypeSet}{o m}{}
\DeclareDocumentCommand{\DeclareMicrotypeSetDefault}{o m}{}
\DeclareDocumentCommand{\SetProtrusion}{o m m}{}
\DeclareDocumentCommand{\SetExpansion}{o m m}{}
\DeclareDocumentCommand{\SetTracking}{o m m}{}
\DeclareDocumentCommand{\SetExtraKerning}{o m m}{}
\DeclareDocumentCommand{\SetExtraSpacing}{o m m}{}
\DeclareDocumentCommand{\DisableLigatures}{o m}{}
\DeclareDocumentCommand{\DeclareCharacterInheritance}{o m m}{}
\DeclareDocumentCommand{\DeclareMicrotypeVariants}{m}{}
\DeclareDocumentCommand{\DeclareMicrotypeAlias}{m m}{}
\DeclareDocumentCommand{\LoadMicrotypeFile}{m}{}
\DeclareDocumentCommand{\DeclareMicrotypeBabelHook}{m m}{}
\DeclareDocumentCommand{\microtypesetup}{m}{}
\DeclareDocumentCommand{\microtypecontext}{m}{}
\DeclareDocumentCommand{\textmicrotypecontext}{m m}{#2}
\@ifpackageloaded{letterspace}{\let\MT@textls\relax}{%
\DeclareDocumentCommand{\lsstyle}{}{}
\DeclareDocumentCommand{\textls}{o +m}{}
\DeclareDocumentCommand{\lslig}{m}{#1}
}
\def\DeclareMicrotypeSet#1#{\@gobbletwo}
\def\DeclareMicrotypeVariants#1#{\@gobble}
\@onlypreamble\DeclareMicrotypeSet
\@onlypreamble\UseMicrotypeSet
\@onlypreamble\DeclareMicrotypeSetDefault
\@onlypreamble\DisableLigatures
\@onlypreamble\DeclareMicrotypeVariants
\@onlypreamble\DeclareMicrotypeBabelHook
%    \end{macrocode}

% \iffalse
%</microtype>
% \fi
%
%
%
%
% \iffalse
%<*midfloat>
% \fi
%
% \part{lwarp-midfloat.sty}
%
% \section{midfloat}
%
% \credits{Sigitas Tolu\v{s}is}

% \DescribePackage{midfloat}
% \pkg{midfloat} is emulated.
%
% \changes{v0.40}{2017/09/07}{\pkg{midfloat}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{midfloat}
%    \end{macrocode}
%
%    \begin{macrocode}
\newenvironment{strip}[1][]{}{}
\newskip\stripsep
%    \end{macrocode}
%
% \iffalse
%</midfloat>
% \fi
%
%
%
%
%
% \iffalse
%<*moreverb>
% \fi
%
% \part{lwarp-moreverb.sty}
%
% \section{moreverb}
% \label{sec:moreverb}
%
% \credits{Robin Fairbairns}
%
% \DescribePackage{moreverb}
% \pkg{moreverb} is supported with some patches.
%
% \changes{v0.34}{2017/08/02}{\pkg{moreverb}: Added.}
% \changes{v0.42}{2017/10/27}{\pkg{moreverb}: Simplified formatting of listings.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{moreverb}
%    \end{macrocode}
%
%
%
%    \begin{macrocode}
\BeforeBeginEnvironment{verbatimtab}{%
\LWR@forcenewpage
\LWR@atbeginverbatim{Verbatim}\unskip\LWR@origvspace*{-\baselineskip}%
}
\AfterEndEnvironment{verbatimtab}{%
\LWR@afterendverbatim%
}


\LetLtxMacro\LWRMV@orig@verbatimtabinput\@verbatimtabinput

\renewcommand{\@verbatimtabinput}[2][]{%
\LWR@forcenewpage
\LWR@atbeginverbatim{Verbatim}\unskip\LWR@origvspace*{-\baselineskip}%
\LWRMV@orig@verbatimtabinput[#1]{#2}%
\LWR@afterendverbatim%
}

\BeforeBeginEnvironment{listing}{%
\LWR@forcenewpage
\LWR@atbeginverbatim{programlisting}\unskip\LWR@origvspace*{-\baselineskip}%
}

\AfterEndEnvironment{listing}{%
% \unskip\LWR@origvspace*{-\baselineskip}%
\LWR@afterendverbatim%
}

\BeforeBeginEnvironment{listingcont}{%
\LWR@forcenewpage
\LWR@atbeginverbatim{programlisting}\unskip\LWR@origvspace*{-\baselineskip}%
}

\AfterEndEnvironment{listingcont}{%
% \unskip\LWR@origvspace*{-\baselineskip}%
\LWR@afterendverbatim%
}
%    \end{macrocode}

% ^^A UNNECESSARY, AND CAUSED PROBLEMS WITH FORMATTING FOR A WORD PROCESSOR:
% ^^A \renewcommand{\listinglabel}[1]{%
% ^^A \ifbool{FormatWP}
% ^^A {\InlineClass{listinglabel}{\qquad\the#1\quad}}%
% ^^A {\InlineClass{listinglabel}{\the#1}}%
% ^^A }
% 
% ^^A \def\thelisting@line{%
% ^^A \@tempcnta=\listing@line%
% ^^A \divide\@tempcnta\listing@step \multiply\@tempcnta\listing@step%
% ^^A \ifnum\listing@line=\@ne%
% ^^A \listinglabel\listing@line%
% ^^A \else%
% ^^A \ifnum\@tempcnta=\listing@line%
% ^^A \listinglabel\listing@line%
% ^^A \else%
% ^^A \InlineClass{listinglabel}{\ifbool{FormatWP}{\qquad\quad}{}}%
% ^^A \fi%
% ^^A \fi}

%    \begin{macrocode}
\LetLtxMacro\LWRMV@@listinginput\@listinginput

\renewcommand{\@listinginput}[3][]{
\LWR@forcenewpage
\LWR@atbeginverbatim{programlisting}\unskip\LWR@origvspace*{-\baselineskip}%
\LWRMV@@listinginput[#1]{#2}{#3}
\LWR@afterendverbatim%
}


\renewenvironment*{boxedverbatim}
{
\LWR@forcenewpage
\LWR@atbeginverbatim{boxedverbatim}\unskip\LWR@origvspace*{-\baselineskip}%
\verbatim%
}
{
\endverbatim%
\LWR@afterendverbatim%
}


%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
% \iffalse
%</moreverb>
% \fi
%
%
%
%
%
% \iffalse
%<*morewrites>
% \fi
%
% \part{lwarp-morewrites.sty}
%
% \section{morewrites}
%
% \DescribePackage{morewrites}
% Error if \pkg{morewrites} is loaded after \pkg{lwarp}.
%
% \changes{v0.42}{2017/10/19}{\pkg{morewrites}: Added.}
%

% Discard all options for \pkg{lwarp-morewrites}:

% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{morewrites}
%    \end{macrocode}

%    \begin{macrocode}
\LWR@loadbefore{morewrites}
%    \end{macrocode}

% \iffalse
%</morewrites>
% \fi
%
%
%
%
%
%
% \iffalse
%<*mparhack>
% \fi
%
% \part{lwarp-mparhack.sty}
%
% \section{mparhack}
%
% \DescribePackage{mparhack} Ignored.
%
% \changes{v0.26}{2017/03/29}{\pkg{mparhack}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-mparhack}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{mparhack}
%    \end{macrocode}
%
% \iffalse
%</mparhack>
% \fi
%
%
%
%
%
%
% \iffalse
%<*multicol>
% \fi

% \part{lwarp-multicol.sty}

% \section{multicol}
% \label{sec:multicol}
%
% \credits{Frank Mittelbach}
%
% \DescribePackage{multicol}
% \pkg{multicol} is emulated.

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{multicol}[2015/09/13]
%    \end{macrocode}

% Multicols are converted into a 1--3 column display, browser-supported.
%
% The optional multicols heading is placed inside a \element{div} of class |multicolsheading|.
%
% The content is placed inside a \element{div} of class |multicols|.

%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

% \begin{noindenvironment}{multicols} * \marg{numcols} \oarg{heading}
%    \begin{macrocode}
\NewDocumentEnvironment{multicols}{s m o}
%    \end{macrocode}
% \HTML\ \element{div} class to contain everything:
%    \begin{macrocode}
{
\LWR@forcenewpage
\BlockClass{multicols}
%    \end{macrocode}
% Optional \HTML\ \element{div} class for the heading:
%    \begin{macrocode}
\IfValueT{#3}{\begin{BlockClass}{multicolsheading}#3\end{BlockClass}}}
%    \end{macrocode}
% When done with the environment, close the \element{div}:
%    \begin{macrocode}
{\endBlockClass}
%    \end{macrocode}
% \end{noindenvironment}

% Emulated null functions which are not used in \HTML:
%    \begin{macrocode}
\newcommand*{\columnbreak}{}
\newcommand*{\RLmulticolcolumns}{}
\newcommand*{\LRmulticolcolumns}{}

\newlength{\premulticols}
\newlength{\postmulticols}
\newlength{\multicolsep}
\newlength{\multicolbaselineskip}
\newlength{\multicoltolerance}
\newlength{\multicolpretolerance}
\newcommand*{\columnseprulecolor}{\normalcolor}
\newcounter{columnbadness}
\newcounter{finalcolumnbadness}
\newcounter{collectmore}
\newcounter{unbalance}
\newlength{\multicolovershoot}
\newlength{\multicolundershoot}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}

% \iffalse
%</multicol>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*multirow>
% \fi

% \part{lwarp-multirow.sty}

% \section{multirow}
% \label{sec:multirow}
%
% \credits{Piet van Oostrum, Øystein Bache, Jerry Leichter}
%
% \DescribePackage{multirow}
% \pkg{multirow} is emulated during \HTML\ output, and
% used as-is while inside a \env{lateximage}.
%
% In a \env{lateximage}, the original print-mode versions are temporarily restored
% by \cs{LWR@restoreorigformatting}.
%
% See \cref{sec:printmultirow} for the print-mode versions.
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{multirow}
%    \end{macrocode}
%
% Remember the print-mode version:
%    \begin{macrocode}
\LetLtxMacro\LWR@origmultirow\multirow
%    \end{macrocode}
%
% \begin{macro}{\LWR@multirowborder}
% Set to |left| or |right| to create a thick border for the cell,
% for use by \pkg{bigdelim}:
%    \begin{macrocode}
\newcommand{\LWR@multirowborder}{}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Multirow}
%
% \DescribeMacro{\multirow}
%   \oarg{vpos} \marg{numrows} \oarg{bigstruts} \marg{width} \oarg{fixup} \marg{text}
% \changes{v0.19}{2015/05/28}{Added optional args.}
% \changes{v0.39}{2017/08/30}{Add: New optional \protect\texttt{vpos} argument.}
% \changes{v0.39}{2017/08/30}{Add: Supports left/right border for \pkg{bigdelim}.}
% \changes{v0.39}{2017/08/30}{Fix: Long text argument.}
% \changes{v0.40}{2017/09/22}{Improved \pkg{bigdelim} borders.}
% \changes{v0.41}{2017/09/28}{Add: \cs{cmidrule} trims.}
%    \begin{macrocode}
\RenewDocumentCommand{\multirow}{O{c} m o m o +m}%
{%
\LWR@traceinfo{*** multirow #1 #2 #4}
\LWR@maybenewtablerow%
\LWR@tabularleftedge%
%    \end{macrocode}
% Print the start of a new table data cell:
%    \begin{macrocode}
\LWR@htmltag{td rowspan="#2" %
%    \end{macrocode}
% The vertical alignment, if given:
%    \begin{macrocode}
\IfValueT{#1}{%
\ifstrequal{#1}{b}{style="vertical-align:bottom" }{}%
\ifstrequal{#1}{t}{style="vertical-align:top" }{}%
}%
%    \end{macrocode}
% The left/right border, if given:
%    \begin{macrocode}
\ifdefvoid{\LWR@multirowborder}{}{%
style="border-\LWR@multirowborder: 2px dotted black ; %
padding-\LWR@multirowborder: 2px" %
}%
%    \end{macrocode}
% A class adds the column spec and the rule:
%    \begin{macrocode}
class="td%
%    \end{macrocode}
% Append this column's spec:
%    \begin{macrocode}
\StrChar{\LWR@tablecolspec}{\arabic{LWR@tablecolindex}}%
%    \end{macrocode}
% If this column has a cmidrule, add ``rule'' to the end of the \HTML\ class tag.
% Also add the vertical bar class.
% \changes{v0.41}{2017/10/07}{Added vertical rules.}
%    \begin{macrocode}
\LWR@addcmidruletrim%
\LWR@addleftmostbartag%
\LWR@printbartag{\arabic{LWR@tablecolindex}}%
"%
%    \end{macrocode}
% \changes{v0.42}{2017/10/26}{\pkg{multirow}: If \protect\texttt{FormatWP} add cell alignment.}
%    \begin{macrocode}
\LWR@tdstartstyles%
\LWR@addcmidrulewidth%
\LWR@tdendstyles%
}%
%    \end{macrocode}
% \changes{v0.41}{2017/10/05}{Fix: \protect\textless\ spec.}
% The column's |<| spec:
%    \begin{macrocode}
\LWR@getexparray{LWR@colbeforespec}{\arabic{LWR@tablecolindex}}%
%    \end{macrocode}
% While printing the text, redefine |\\| to generate a new line
%    \begin{macrocode}
\begingroup\LetLtxMacro{\\}{\LWR@endofline}#6\endgroup%
\LWR@stoppars%
\global\boolfalse{LWR@intabularmetadata}%
\renewcommand{\LWR@multirowborder}{}%
\LWR@traceinfo{*** multirow done}%
}%
%    \end{macrocode}
%
%
% \subsection{Combined multicolumn and multirow}
% \label{sec:multicolumnmultirow}
%
% \limitsmulticolumnrow
% \index{multicolumn>with multirow}
% \index{multirow>with multicolumn}
% \index{tabular>multicolumn with multirow}
%
%
% \begin{macro}{\multicolumnrow}
%   \marg{1:cols} \marg{2:halign}
%   \oarg{3:vpos} \marg{4:numrows} \oarg{5:bigstruts}
%       \marg{6:width} \oarg{7:fixup} \marg{8:text}
%
% \changes{v0.39}{2017/08/30}{Added.}
%
%    \begin{macrocode}
\NewDocumentCommand{\multicolumnrow}{m m O{} m O{} m O{} +m}{%
%    \end{macrocode}
% Figure out how many extra \HTML\ columns to add for |@| and |!| columns:
%    \begin{macrocode}
\LWR@tabularhtmlcolumns{\arabic{LWR@tablecolindex}}{#1}
%    \end{macrocode}
% Create the multicolumn/multirow tag:
%    \begin{macrocode}
\begingroup%
\LetLtxMacro{\\}{\LWR@endofline}%
\LWR@domulticolumn[#3][#4]{#1}{\arabic{LWR@tabhtmlcoltotal}}{#2}{#8}%
\endgroup%
%    \end{macrocode}
% Move to the next \LaTeX\ column:
%    \begin{macrocode}
\addtocounter{LWR@tablecolindex}{#1}%
\addtocounter{LWR@tablecolindex}{-1}%
%    \end{macrocode}
% Skip any trailing |@| or |!| columns for this cell:
%    \begin{macrocode}
\booltrue{LWR@skipatbang}%
}
%    \end{macrocode}
% \end{macro}
%
%
%    \begin{macrocode}
\appto{\LWR@restoreorigformatting}{%
\LetLtxMacro\multirow\LWR@origmultirow%
\renewcommand{\multicolumnrow}{\LWR@origmulticolumnrow}%
}
%    \end{macrocode}
%
%
% \iffalse
%</multirow>
% \fi
%
%
%
%
%
% \iffalse
%<*nameref>
% \fi

% \part{lwarp-nameref.sty}

% \section{nameref}
%
% \DescribePackage{nameref}
% \pkg{nameref} is emulated by \pkg{lwarp}.
%
% \changes{v0.22}{2017/03/01}{\pkg{nameref}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-nameref}:
%    \begin{macrocode}
\typeout{Using the lwarp html version of package `nameref' — discarding options.}
\typeout{    Are not using ProvidesPackage, so that other packages}
\typeout{    do not attempt to patch lwarp's version of `nameref'.}
\DeclareOption*{}
\ProcessOptions\relax
%    \end{macrocode}

% \iffalse
%</nameref>
% \fi
%
%
%
%
%
%
% \iffalse
%<*needspace>
% \fi

% \part{lwarp-needspace.sty}

% \section{needspace}
%
% \credits{Peter Wilson}
%
% \DescribePackage{needspace}
% \pkg{needspace} is not used during \HTML\ conversion.
%
% \changes{v0.20}{2016/12/22}{\pkg{needspace}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-needspace}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{needspace}

\newcommand*{\needspace}[1]{}
\DeclareDocumentCommand{\Needspace}{s m}{}
%    \end{macrocode}

% \iffalse
%</needspace>
% \fi
%
%
%
%
% \iffalse
%<*newclude>
% \fi
%
% \part{lwarp-newclude.sty}
%
% \section{newclude}
%
% \DescribePackage{newclude}
% Error if \pkg{newclude} is loaded after \pkg{lwarp}.
%
% \changes{v0.21}{2017/02/22}{\pkg{newclude}: Added.}
%

% Discard all options for \pkg{lwarp-newclude}:

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{newclude}
%    \end{macrocode}

%    \begin{macrocode}
\LWR@loadbefore{newclude}
%    \end{macrocode}

% \iffalse
%</newclude>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*newunicodechar>
% \fi
%
% \part{lwarp-newunicodechar.sty}
%
% \section{newunicodechar}
%
% \DescribePackage{newunicodechar}
% Error if \pkg{newunicodechar} is loaded after \pkg{lwarp}.
%
% \changes{v0.21}{2017/02/22}{\pkg{newunicodechar}: Added.}
%

% Discard all options for \pkg{lwarp-newunicodechar}:

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{newunicodechar}
%    \end{macrocode}

%    \begin{macrocode}
\LWR@loadbefore{newunicodechar}
%    \end{macrocode}

% \iffalse
%</newunicodechar>
% \fi
%
%
%
%
% \iffalse
%<*nextpage>
% \fi

% \part{lwarp-nextpage.sty}

% \section{nextpage}
%
% \credits{Peter Wilson}
%
% \DescribePackage{nextpage}
% \pkg{nextpage} is nullified.
%
% \changes{v0.22}{2017/03/01}{\pkg{nextpage}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-nextpage}.
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{nextpage}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand{\cleartoevenpage}[1][]{}
\newcommand{\movetoevenpage}[1][]{}
\newcommand{\cleartooddpage}[1][]{}
\newcommand{\movetooddpage}[1][]{}
%    \end{macrocode}

% \iffalse
%</nextpage>
% \fi
%
%
%
%
%
% \iffalse
%<*nonumonpart>
% \fi
%
% \part{lwarp-nonumonpart.sty}
%
% \section{nonumonpart}
%
% \DescribePackage{nonumonpart}
% \pkg{nonumonpart} is ignored.
%
% \changes{v0.38}{2017/08/25}{\pkg{nonumonpart}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{nonumonpart}
%    \end{macrocode}
%
%
% \iffalse
%</nonumonpart>
% \fi
%
%
%
% \iffalse
%<*nopageno>
% \fi
%
% \part{lwarp-nopageno.sty}
%
% \section{nopageno}
%
% \DescribePackage{nopageno}
% \pkg{nopageno} is ignored.
%
% \changes{v0.38}{2017/08/25}{\pkg{nopageno}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{nopageno}
%    \end{macrocode}
%
%
% \iffalse
%</nopageno>
% \fi
%
%
%
%
%
%
%
%
% \iffalse
%<*nowidow>
% \fi

% \part{lwarp-nowidow.sty}

% \section{nowidow}
%
% \credits{Rapha\"{e}l Pinson}
%
% \DescribePackage{nowidow}
% \pkg{nowidow} is not used during \HTML\ conversion.
%
% \changes{v0.20}{2017/01/03}{\pkg{nowidow}: Added.}
%
%
% Discard all options for \pkg{lwarp-nowidow}:

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{nowidow}
%    \end{macrocode}

% \begin{noindmacro}{\nowidow} \oarg{lines}
% \begin{noindmacro}{\setnowidow} \oarg{lines}
%    \begin{macrocode}
\newcommand*{\nowidow}[1][]{}
\newcommand*{\setnowidow}[1][]{}
%    \end{macrocode}
% \end{noindmacro}
% \end{noindmacro}
%
% \begin{noindmacro}{\noclub} \oarg{lines}
% \begin{noindmacro}{\setnoclub} \oarg{lines}
%    \begin{macrocode}
\newcommand*{\noclub}[1][]{}
\newcommand*{\setnoclub}[1][]{}
%    \end{macrocode}
% \end{noindmacro}
% \end{noindmacro}
%
% \iffalse
%</nowidow>
% \fi
%
%
%
%
%
%
% \iffalse
%<*ntheorem>
% \fi

% \part{lwarp-ntheorem.sty}
%
% \section{ntheorem}
%
% \label{sec:ntheorem}
%
% \credits{Wolfgang May, Andreas Schedler}
%
% \DescribePackage{ntheorem}
% \pkg{ntheorem} is patched for use by \pkg{lwarp}.
%
% \changes{v0.25}{2017/03/22}{\pkg{ntheorem}: Added.}
%
% \begin{table}[ht]
% \hrule
% \smallskip
% \caption{Ntheorem package --- CSS styling of theorems and proofs}\unskip
% \begin{description}
% \item [Theorem:] \element{div} of class |theorembody<theoremstyle>|
% \item [Theorem Header:] \element{span} of class |theoremheader<style>|
% \end{description}
% where |<theoremstyle>| is |plain|, |break|, etc.
% \smallskip
% \hrule
% \end{table}
%
%
% \subsection{Limitations}
%
% \limitsntheorem
%
% \subsection{Options}
%
% Options |amsthm| or |standard| choose which set of theorems and proofs
% to initialize.
%
% The options |thmmarks| and |amsmath| are disabled, since they
% \watchout[Disabled options]
% heavily modify the underlying math code.  Theorem marks are emulated.
% The AMS-math modifications are not done.
%
% Option |thref| is disabled because \pkg{cleveref} functions are used instead.
% \cs{thref} is emulated.
%
% Option |hyperref| is disabled because \pkg{lwarp} emulated \pkg{hyperref}.
%
% \codehtml
%
% Some disabled options:
%    \begin{macrocode}
\DeclareOption{thref}{}


\newbool{LWR@ntheoremmarks}
\boolfalse{LWR@ntheoremmarks}

\DeclareOption{thmmarks}{
\booltrue{LWR@ntheoremmarks}
\newif\ifsetendmark\setendmarktrue
}


\newbool{LWR@ntheoremamsthm}
\boolfalse{LWR@ntheoremamsthm}

\DeclareOption{amsthm}{\booltrue{LWR@ntheoremamsthm}}


\DeclareOption{amsmath}{}
\DeclareOption{hyperref}{}


\LWR@ProvidesPackagePass{ntheorem}
%    \end{macrocode}
%
%
% \subsection{Remembering the theorem style}
%
% Storage for the style being used for new theorems.
%    \begin{macrocode}
\newcommand{\LWR@newtheoremstyle}{plain}
%    \end{macrocode}
%
% Patched to remember the style being used for new theorems:
%    \begin{macrocode}
\gdef\theoremstyle#1{%
   \@ifundefined{th@#1}{\@warning
          {Unknown theoremstyle `#1'. Using `plain'}%
          \theorem@style{plain}
            \renewcommand{\LWR@newtheoremstyle}{plain}% new
            }%
      {
        \theorem@style{#1}
        \renewcommand{\LWR@newtheoremstyle}{#1}% new
        }
}
%    \end{macrocode}
%
%
% Patched to remember the style for this theorem type,
% and set it later when the environment is started.
%    \begin{macrocode}

\gdef\@xnthm#1#2[#3]{%
  \ifthm@tempif
     \csedef{LWR@thmstyle#1}{\LWR@newtheoremstyle}% new
     \expandafter\@ifundefined{c@#1}%
        {\@definecounter{#1}}{}%
     \@newctr{#1}[#3]%
     \expandafter\xdef\csname the#1\endcsname{%
       \expandafter\noexpand\csname the#3\endcsname \@thmcountersep
          {\noexpand\csname\the\theoremnumbering\endcsname{#1}}}%
     \expandafter\gdef\csname mkheader@#1\endcsname
       {\csname setparms@#1\endcsname
        \@thm{#1}{#1}{#2}
        }%
     \global\@namedef{end#1}{\@endtheorem}
     \AtBeginEnvironment{#1}{\edef\LWR@thisthmstyle{\csuse{LWR@thmstyle#1}}}% new
  \fi
}

\gdef\@ynthm#1#2{%
  \ifthm@tempif
     \csedef{LWR@thmstyle#1}{\LWR@newtheoremstyle}% new
     \expandafter\@ifundefined{c@#1}%
        {\@definecounter{#1}}{}%
     \expandafter\xdef\csname the#1\endcsname
        {\noexpand\csname\the\theoremnumbering\endcsname{#1}}%
     \expandafter\gdef\csname mkheader@#1\endcsname
       {\csname setparms@#1\endcsname
        \@thm{#1}{#1}{#2}
        }%
     \global\@namedef{end#1}{\@endtheorem}
     \AtBeginEnvironment{#1}{\edef\LWR@thisthmstyle{\csuse{LWR@thmstyle#1}}}% new
  \fi
}

\gdef\@othm#1[#2]#3{%
  \@ifundefined{c@#2}{\@nocounterr{#2}}%
   {\ifthm@tempif
     \csedef{LWR@thmstyle#1}{\LWR@newtheoremstyle}% new
     \global\@namedef{the#1}{\@nameuse{the#2}}%
     \expandafter\protected@xdef\csname num@addtheoremline#1\endcsname{%
              \noexpand\@num@addtheoremline{#1}{#3}}%
     \expandafter\protected@xdef\csname nonum@addtheoremline#1\endcsname{%
              \noexpand\@nonum@addtheoremline{#1}{#3}}%
    \theoremkeyword{#3}%
    \expandafter\protected@xdef\csname #1Keyword\endcsname
             {\the\theoremkeyword}%
     \expandafter\gdef\csname mkheader@#1\endcsname
       {\csname setparms@#1\endcsname
                \@thm{#1}{#2}{#3}
        }%
     \global\@namedef{end#1}{\@endtheorem}
     \AtBeginEnvironment{#1}{\edef\LWR@thisthmstyle{\csuse{LWR@thmstyle#1}}}% new
  \fi}
}
%    \end{macrocode}
%
%
% \subsection{HTML cross-referencing}
%
% Mimics a float by incrementing the float counter and generating
% an \HTML\ anchor.  These are used for list-of-theorem cross-references.
%    \begin{macrocode}
\newcommand{\LWR@inctheorem}{%
\addtocounter{LWR@thisautoid}{1}%
\LWR@stoppars%
\LWR@htmltag{a id="autoid-\arabic{LWR@thisautoid}"{}}\LWR@htmltag{/a}%
\LWR@startpars%
}
%    \end{macrocode}
%
%
% \subsection{\cs{newtheoremstyle}}
%
% The following are patched for \CSS.
%
% These were in individual files |thp.sty| for plain,
% |thmb.sty| for margin break, etc.
% They are gathered together here.
%
% Each theorem is encased in a \env{BlockClass} environment
% of class |theorembody<style>|.
%
% Each header is encased in an \cs{InlineClass} of class |theoremheader<style>|.
%    \begin{macrocode}
\gdef\newtheoremstyle#1#2#3{%
  \expandafter\@ifundefined{th@#1}%
   {\expandafter\gdef\csname th@#1\endcsname{%
    \def\@begintheorem####1####2{%
\LWR@forcenewpage% new
\BlockClass{theorembody#1}%\LWR@thisthmstyle% new
\LWR@inctheorem% new
#2}%
    \def\@opargbegintheorem####1####2####3{%
\LWR@forcenewpage% new
\BlockClass{theorembody#1}%\LWR@thisthmstyle% new
\LWR@inctheorem% new
#3}%
}%
}%
{\PackageError{\basename}{Theorem style #1 already defined}\@eha}
}
%    \end{macrocode}
%
% \subsection{Standard styles}
%
%    \begin{macrocode}
\renewtheoremstyle{plain}%
  {\item[\hskip\labelsep \theorem@headerfont
    \InlineClass{theoremheaderplain}{##1\ ##2\theorem@separator}]}%
  {\item[\hskip\labelsep \theorem@headerfont
    \InlineClass{theoremheaderplain}{##1\ ##2\ (##3)\theorem@separator}]}

\renewtheoremstyle{break}%
  {\item[
% 		\rlap{\vbox{\hbox{
    \hskip\labelsep \theorem@headerfont
    \InlineClass{theoremheaderbreak}{##1\ ##2\theorem@separator}\newline
% 		}\hbox{\strut}}}
    ]}%
  {\item[
% 		\rlap{\vbox{\hbox{
    \hskip\labelsep \theorem@headerfont
    \InlineClass{theoremheaderbreak}%
        {##1\ ##2\ (##3)\theorem@separator}\newline
% 		}\hbox{\strut}}}
    ]}

\renewtheoremstyle{change}%
  {\item[\hskip\labelsep
    \theorem@headerfont
    \InlineClass{theoremheaderchange}{##2\ ##1\theorem@separator}]}%
  {\item[\hskip\labelsep
    \theorem@headerfont
    \InlineClass{theoremheaderchange}{##2\ ##1\ (##3)\theorem@separator}]}

\renewtheoremstyle{changebreak}%
  {\item[
% 		\rlap{\vbox{\hbox{
        \hskip\labelsep \theorem@headerfont
        \InlineClass{theoremheaderchangebreak}%
            {##2\ ##1\theorem@separator}\newline
% 		}\hbox{\strut}}}
    ]}%
  {\item[
% 		\rlap{\vbox{\hbox{
        \hskip\labelsep \theorem@headerfont
        \InlineClass{theoremheaderchangebreak}%
            {##2\ ##1\ (##3)\theorem@separator}\newline
% 		}\hbox{\strut}}}
    ]}

\renewtheoremstyle{margin}%
  {\item[\hskip\labelsep\theorem@headerfont
        \InlineClass{theoremheadermargin}{##2 \qquad ##1\theorem@separator}
    ]}%
  {\item[\hskip\labelsep\theorem@headerfont
        \InlineClass{theoremheadermargin}{##2 \qquad ##1\ (##3)\theorem@separator}
    ]}

\renewtheoremstyle{marginbreak}%
  {\item[\hskip\labelsep\theorem@headerfont
    \InlineClass{theoremheadermarginbreak}%
        {##2 \qquad ##1\theorem@separator}\newline
    ]}%
  {\item[\hskip\labelsep\theorem@headerfont
    \InlineClass{theoremheadermarginbreak}%
        {##2 \qquad ##1\ (##3)\theorem@separator}\newline
    ]}

\renewtheoremstyle{nonumberplain}%
  {\item[\theorem@headerfont\hskip\labelsep
    \InlineClass{theoremheaderplain}{##1\theorem@separator}]}%
  {\item[\theorem@headerfont\hskip \labelsep
    \InlineClass{theoremheaderplain}{##1\ (##3)\theorem@separator}]}

\renewtheoremstyle{nonumberbreak}%
  {\item[
% 		\rlap{\vbox{\hbox{
    \hskip\labelsep \theorem@headerfont
    \InlineClass{theoremheaderbreak}{##1\theorem@separator}\newline
% 		}\hbox{\strut}}}
    ]}%
  {\item[
% 		\rlap{\vbox{\hbox{
    \hskip\labelsep \theorem@headerfont
    \InlineClass{theoremheaderbreak}{##1\ (##3)\theorem@separator}\newline
% 		}\hbox{\strut}}}
    ]}

\renewtheoremstyle{empty}%
  {\item[]}%
  {\item[\theorem@headerfont \hskip\labelsep\relax
    \InlineClass{theoremheaderplain}{##3}]}

\renewtheoremstyle{emptybreak}%
  {\item[]}%
  {\item[\theorem@headerfont \hskip\labelsep\relax
    \InlineClass{theoremheaderplain}{##3}] \ \newline}
%    \end{macrocode}
%
%
% \subsection{Additional objects}
%
% The following manually adjust the \CSS\ for the standard configuration
% objects which are not a purely plain style:
%    \begin{macrocode}
\ifbool{LWR@ntheoremamsthm}{}{%
% upright text via CSS
    \newtheoremstyle{plainupright}%
    {\item[\hskip\labelsep \theorem@headerfont
        \InlineClass{theoremheaderplain}{##1\ ##2\theorem@separator}]}%
    {\item[\hskip\labelsep \theorem@headerfont
        \InlineClass{theoremheaderplain}{##1\ ##2\ (##3)\theorem@separator}]}

% upright text and small caps header via CSS
    \newtheoremstyle{nonumberplainuprightsc}%
    {\item[\theorem@headerfont\hskip\labelsep
        \InlineClass{theoremheadersc}{##1\theorem@separator}]}%
    {\item[\theorem@headerfont\hskip \labelsep
        \InlineClass{theoremheadersc}{##1\ (##3)\theorem@separator}]}
}% not amsthm
%    \end{macrocode}
%
%
% \subsection{Renewed standard configuration}
%
% The following standard configuration is renewed using the new \CSS:
%    \begin{macrocode}
\ifbool{LWR@ntheoremamsthm}{}{%
    \theoremstyle{plainupright}
    \theorembodyfont{\upshape}
    \theoremsymbol{\HTMLunicode{25A1}}% UTF-8 white box
    \renewtheorem{Example}{Example}
    \renewtheorem{example}{Example}
    \renewtheorem{Beispiel}{Beispiel}
    \renewtheorem{beispiel}{Beispiel}
    \renewtheorem{Bemerkung}{Bemerkung}
    \renewtheorem{bemerkung}{Bemerkung}
    \renewtheorem{Anmerkung}{Anmerkung}
    \renewtheorem{anmerkung}{Anmerkung}
    \renewtheorem{Remark}{Remark}
    \renewtheorem{remark}{Remark}
    \renewtheorem{Definition}{Definition}
    \renewtheorem{definition}{Definition}

    \theoremstyle{nonumberplainuprightsc}
    \theoremsymbol{\HTMLunicode{220E}}% UTF-8 end-of-proof
    \renewtheorem{Proof}{Proof}
    \renewtheorem{proof}{Proof}
    \renewtheorem{Beweis}{Beweis}
    \renewtheorem{beweis}{Beweis}
    \qedsymbol{\HTMLunicode{220E}}% UTF-8 end-of-proof

    \theoremsymbol{}
}% not amsthm
%    \end{macrocode}
%
%
% \subsection{\protect\texttt{amsthm} option}
%
% Only if the |amsthm| option was given:
%    \begin{macrocode}
\ifbool{LWR@ntheoremamsthm}{

\gdef\th@plain{%
  \def\theorem@headerfont{\normalfont\bfseries}\itshape%
  \def\@begintheorem##1##2{%
\LWR@forcenewpage% new
        \BlockClass{theorembodyplain}% new
        \LWR@inctheorem% new
      \item[\hskip\labelsep
% 			\theorem@headerfont
 			\InlineClass{theoremheaderplain}{##1\ ##2.}
        ]}%
  \def\@opargbegintheorem##1##2##3{%
\LWR@forcenewpage% new
        \BlockClass{theorembodyplain}% new
        \LWR@inctheorem% new
     \item[\hskip\labelsep
% 			\theorem@headerfont
 		\InlineClass{theoremheaderplain}{##1\ ##2\ (##3).}
        ]}}

\gdef\th@nonumberplain{%
  \def\theorem@headerfont{\normalfont\bfseries}\itshape%
  \def\@begintheorem##1##2{%
\LWR@forcenewpage% new
        \BlockClass{theorembodyplain}% new
        \LWR@inctheorem% new
      \item[\hskip\labelsep
% 			\theorem@headerfont
 			\InlineClass{theoremheaderplain}{##1.}
        ]}%
  \def\@opargbegintheorem##1##2##3{%
\LWR@forcenewpage% new
        \BlockClass{theorembodyplain}% new
        \LWR@inctheorem% new
     \item[\hskip\labelsep
% 			\theorem@headerfont
 		\InlineClass{theoremheaderplain}{##1\ (##3).}
        ]}}

\gdef\th@definition{%
  \def\theorem@headerfont{\normalfont\bfseries}\normalfont%
  \def\@begintheorem##1##2{%
\LWR@forcenewpage% new
        \BlockClass{theorembodydefinition}% new
        \LWR@inctheorem% new
      \item[\hskip\labelsep
% 			\theorem@headerfont
 			\InlineClass{theoremheaderdefinition}{##1\ ##2.}
        ]}%
  \def\@opargbegintheorem##1##2##3{%
\LWR@forcenewpage% new
        \BlockClass{theorembodydefinition}% new
        \LWR@inctheorem% new
     \item[\hskip\labelsep
% 			\theorem@headerfont
 		\InlineClass{theoremheaderdefinition}{##1\ ##2\ (##3).}
        ]}}

\gdef\th@nonumberdefinition{%
  \def\theorem@headerfont{\normalfont\bfseries}\normalfont%
  \def\@begintheorem##1##2{%
\LWR@forcenewpage% new
        \BlockClass{theorembodydefinition}% new
        \LWR@inctheorem% new
      \item[\hskip\labelsep
% 			\theorem@headerfont
 			\InlineClass{theoremheaderdefinition}{##1.}
        ]}%
  \def\@opargbegintheorem##1##2##3{%
\LWR@forcenewpage% new
        \BlockClass{theorembodydefinition}% new
        \LWR@inctheorem% new
     \item[\hskip\labelsep
% 			\theorem@headerfont
 		\InlineClass{theoremheaderdefinition}{##1\ (##3).}
        ]}}

\gdef\th@remark{%
  \def\theorem@headerfont{\itshape}\normalfont%
  \def\@begintheorem##1##2{%
\LWR@forcenewpage% new
        \BlockClass{theorembodyremark}% new
        \LWR@inctheorem% new
      \item[\hskip\labelsep
% 			\theorem@headerfont
 			\InlineClass{theoremheaderremark}{##1\ ##2.}
        ]}%
  \def\@opargbegintheorem##1##2##3{%
\LWR@forcenewpage% new
        \BlockClass{theorembodyremark}% new
        \LWR@inctheorem% new
     \item[\hskip\labelsep
% 			\theorem@headerfont
 		\InlineClass{theoremheaderremark}{##1\ ##2\ (##3).}
        ]}}

\gdef\th@nonumberremark{%
  \def\theorem@headerfont{\itshape}\normalfont%
  \def\@begintheorem##1##2{%
\LWR@forcenewpage% new
        \BlockClass{theorembodyremark}% new
        \LWR@inctheorem% new
      \item[\hskip\labelsep
% 			\theorem@headerfont
 			\InlineClass{theoremheaderremark}{##1.}
        ]}%
  \def\@opargbegintheorem##1##2##3{%
\LWR@forcenewpage% new
        \BlockClass{theorembodyremark}% new
        \LWR@inctheorem% new
     \item[\hskip\labelsep
% 			\theorem@headerfont
 		\InlineClass{theoremheaderremark}{##1\ (##3).}
        ]}}

\gdef\th@proof{%
  \def\theorem@headerfont{\normalfont\bfseries}\itshape%
  \def\@begintheorem##1##2{%
\LWR@forcenewpage% new
        \BlockClass{theorembodyproof}% new
        \LWR@inctheorem% new
      \item[\hskip\labelsep
% 			\theorem@headerfont
 			\InlineClass{theoremheaderproof}{##1.}
        ]}%
  \def\@opargbegintheorem##1##2##3{%
\LWR@forcenewpage% new
        \BlockClass{theorembodyroof}% new
        \LWR@inctheorem% new
     \item[\hskip\labelsep
% 			\theorem@headerfont
 		\InlineClass{theoremheaderproof}{##1\ (##3).}
        ]}}



\newcounter{proof}%
\if@thmmarks
    \newcounter{currproofctr}%
    \newcounter{endproofctr}%
\fi

\gdef\proofSymbol{\openbox}

\newcommand{\proofname}{Proof}

\newenvironment{proof}[1][\proofname]{
    \th@proof
    \def\theorem@headerfont{\itshape}%
    \normalfont
    \theoremsymbol{\HTMLunicode{220E}}% UTF-8 end-of-proof
    \@thm{proof}{proof}{#1}
}%
{\@endtheorem}

}{}% amsthm option
%    \end{macrocode}
%
%
% \subsection{Ending a theorem}
%
% Patched for \CSS:
%    \begin{macrocode}
\let\LWR@origendtheorem\@endtheorem
\renewcommand{\@endtheorem}{%
\ifbool{LWR@ntheoremmarks}{%
    \ifsetendmark%
    \InlineClass{theoremendmark}{\csname\InTheoType Symbol\endcsname}%
    \setendmarkfalse%
    \fi%
}{}%
\LWR@origendtheorem%
\ifbool{LWR@ntheoremmarks}{\global\setendmarktrue}{}%
\endBlockClass%
}
%    \end{macrocode}
%
%
% \subsection{\cs{NoEndMark}}
%
%    \begin{macrocode}
\gdef\NoEndMark{\global\setendmarkfalse}
%    \end{macrocode}
%
%
% \subsection{List-of}
%
% Redefined to reuse the float mechanism to add list-of-theorem links:
%
% \cs{thm@thmline} \marg{1: printed type} \marg{2: \#} \marg{3: optional} \marg{4: page}
%    \begin{macrocode}
\renewcommand{\thm@@thmline@noname}[4]{%
\hypertocfloat{1}{theorem}{thm}{#2 #3}{}%
}

\renewcommand{\thm@@thmline@name}[4]{%
\hypertocfloat{1}{theorem}{thm}{#1 #2 #3}{}%
}
%    \end{macrocode}
%
% This was redefined by \pkg{ntheorem} when loaded,
% so it is now redefined for \pkg{lwarp}:
%    \begin{macrocode}
\def\thm@@thmline{\thm@@thmline@name}
%    \end{macrocode}
%
%
% Patch for \CSS:
%    \begin{macrocode}
\def\listtheorems#1{
\LWR@htmlelementclass{nav}{lothm}%
\begingroup
\c@tocdepth=-2%
\def\thm@list{#1}\thm@processlist
\endgroup
\LWR@htmlelementclassend{nav}{lothm}%
}
%    \end{macrocode}
%
%
% \subsection{Symbols}
%
% Proof QED symbol:
%    \begin{macrocode}
\newcommand{\qed}{\qquad\the\qedsymbol}

\AtBeginDocument{
\def\openbox{\text{\HTMLunicode{25A1}}}% UTF-8 white box
\def\blacksquare{\text{\HTMLunicode{220E}}}% UTF-8 end-of-proof
\def\Box{\text{\HTMLunicode{25A1}}}% UTF-8 white box
}
%    \end{macrocode}
%
% \subsection{Cross-referencing}
%
% \cs{thref} \marg{label}
%    \begin{macrocode}
\newcommand*{\thref}[1]{\cref{#1}}
%    \end{macrocode}
%
% \iffalse
%</ntheorem>
% \fi
%
%
%
%
%
% \iffalse
%<*overpic>
% \fi
%
% \part{lwarp-overpic.sty}

% \section{overpic}
% \label{sec:overpic}
%
% \credits{Rolf Niepraschk}
%
% \DescribePackage{overpic}
% \pkg{overpic} is patched for use by \pkg{lwarp}.
%
% \changes{v0.42}{2017/10/16}{\pkg{overpic}: Added.}
% \changes{v0.44}{2017/11/16}{\pkg{overpic}: Fix: Groups for lateximages.}
%
% \limitsoverpic
%
% See \cref{sec:graphicsprint} for the print-mode version of
% \cs{overpicfontsize} and \cs{overpicfontskip}.
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{overpic}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\overpicfontsize}{12}
\newcommand*{\overpicfontskip}{14}

\BeforeBeginEnvironment{overpic}{%
    \begin{lateximage}%
    \fontsize{\overpicfontsize}{\overpicfontskip}%
    \selectfont%
}

\AfterEndEnvironment{overpic}{\end{lateximage}}

\BeforeBeginEnvironment{Overpic}{%
    \begin{lateximage}%
    \fontsize{\overpicfontsize}{\overpicfontskip}%
    \selectfont%
}

\AfterEndEnvironment{Overpic}{\end{lateximage}}
%    \end{macrocode}

% \iffalse
%</overpic>
% \fi
%
%
%
%
% \iffalse
%<*pagenote>
% \fi

% \part{lwarp-pagenote.sty}

% \section{pagenote}
%
% \DescribePackage{pagenote}
% \limitspagenote
%
% \changes{v0.26}{2017/03/29}{\pkg{pagenote}: Supported as-is.}
% \changes{v0.38}{2017/08/24}{\pkg{pagenote}: Option \protect\texttt{page} disabled.}
%
% \codehtml
%    \begin{macrocode}
\DeclareOption{page}{}
\LWR@ProvidesPackagePass{pagenote}
%    \end{macrocode}
%
% \iffalse
%</pagenote>
% \fi
%
%
%
%
%
%
% \iffalse
%<*paralist>
% \fi
%
% \part{lwarp-paralist.sty}
%
% \section{paralist}
% \label{sec:paralist}
%
% \credits{Bernd Schandl}
%
% \DescribePackage{paralist}
% \pkg{paralist} is supported with minor changes.

% \changes{v0.34}{2017/07/27}{\pkg{paralist}: Added.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{paralist}
%    \end{macrocode}
%
% The compact environments are identical to the regular ones:
%    \begin{macrocode}
\AtBeginEnvironment{compactitem}{\LWR@itemizestart}
\AtBeginEnvironment{compactenum}{\LWR@enumeratestart}
\AtBeginEnvironment{compactdesc}{\LWR@descriptionstart}
\AtEndEnvironment{compactitem}{\LWR@listend}
\AtEndEnvironment{compactenum}{\LWR@listend}
\AtEndEnvironment{compactdesc}{\LWR@listend}
%    \end{macrocode}
%
% For the inline environments, revert \cs{item} to its original print-mode version:
%    \begin{macrocode}
\AtBeginEnvironment{inparaitem}{\LetLtxMacro\item\LWR@origitem}
\AtBeginEnvironment{inparaenum}{\LetLtxMacro\item\LWR@origitem}
\AtBeginEnvironment{inparadesc}{\LetLtxMacro\item\LWR@origitem}
%    \end{macrocode}
%
% Manual formatting of the description labels:
%    \begin{macrocode}
\def\paradescriptionlabel#1{{\normalfont\textbf{#1}}}
%    \end{macrocode}
%
% \iffalse
%</paralist>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*parskip>
% \fi

% \part{lwarp-parskip.sty}

% \section{parskip}
%
% \DescribePackage{parskip}
% \pkg{parskip} is ignored.
%
% \changes{v0.22}{2017/03/01}{\pkg{parskip}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-parskip}.
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{parskip}
%    \end{macrocode}

% \iffalse
%</parskip>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*pdflscape>
% \fi
%
% \part{lwarp-pdflscape.sty}
%
% \section{pdflscape}
%
% \DescribePackage{pdflscape} Emulated.
%
% \changes{v0.34}{2017/08/03}{\pkg{pdflscape}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-pdflscape}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pdflscape}
%    \end{macrocode}
%
%    \begin{macrocode}
%    \end{macrocode}
%
% \iffalse
%</pdflscape>
% \fi
%
%
%
%
%
% \iffalse
%<*pdfsync>
% \fi
%
% \part{lwarp-pdfsync.sty}
%
% \section{pdfsync}
%
% \credits{J. Laurens}
%
% \DescribePackage{pdfsync} Emulated.
%
% \changes{v0.34}{2017/08/03}{\pkg{pdfsync}: Added.}
% \changes{v0.44}{2017/11/19}{\pkg{pdfsync}: Fixes.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-pdfsync}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pdfsync}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\pdfsync}{}
\newcommand*{\pdfsyncstart}{}
\newcommand*{\pdfsyncstop}{}
%    \end{macrocode}
%
% \iffalse
%</pdfsync>
% \fi
%
%
%
%
%
% \iffalse
%<*pfnote>
% \fi
%
% \part{lwarp-pfnote.sty}
%
% \section{pfnote}
%
% \DescribePackage{pfnote}
% \pkg{pfnote} is emulated.
%
% \limitspfnote
%
% \changes{v0.40}{2017/09/06}{\pkg{pfnote}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pfnote}
%    \end{macrocode}
%
% \iffalse
%</pfnote>
% \fi
%
%
%
%
%
% \iffalse
%<*placeins>
% \fi
%
% \part{lwarp-placeins.sty}
%
% \section{placeins}
%
% \credits{Donald Arseneau}
%
% \DescribePackage{placeins}
% \pkg{placeins} is not used during \HTML\ conversion.
%
% \changes{v0.20}{2017/01/19}{\pkg{placeins}: Added.}
%

% Discard all options for \pkg{lwarp-placeins}:

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{placeins}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\FloatBarrier}{}
%    \end{macrocode}

% \iffalse
%</placeins>
% \fi
%
%
%
%
%
%
% \iffalse
%<*prelim2e>
% \fi
%
% \part{lwarp-prelim2e.sty}
%
% \section{prelim2e}
%
% \credits{Martin Schröder}
%
% \DescribePackage{prelim2e} Emulated.
%
% \changes{v0.34}{2017/08/03}{\pkg{prelim2e}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-prelim2e}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{prelim2e}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\PrelimText}{}
\newcommand{\PrelimTextStyle}{}
\newcommand{\PrelimWords}{}
%    \end{macrocode}
%
% \iffalse
%</prelim2e>
% \fi
%
%
%
% \iffalse
%<*preview>
% \fi
%
% \part{lwarp-preview.sty}
%
% \section{preview}
%
% \DescribePackage{preview}
% \pkg{preview} is ignored.
%
% \changes{v0.44}{2017/11/22}{\pkg{preview}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{preview}
%    \end{macrocode}
%
%    \begin{macrocode}
\newenvironment{preview}{}{}
\newenvironment{nopreview}{}{}
\NewDocumentCommand{\PreviewMacro}{s o o +m}{}
\NewDocumentCommand{\PreviewEnvironment}{s o o +m}{}
\newcommand{\PreviewSnarfEnvironment}[2][]{}
\NewDocumentCommand{\PreviewOpen}{s o}{}
\NewDocumentCommand{\PreviewClose}{s o}{}
\let\ifPreview\iffalse% \fi for syntax highlighting
%    \end{macrocode}
%
% \iffalse
%</preview>
% \fi
%
%
%
%
%
% \iffalse
%<*quotchap>
% \fi
%
% \part{lwarp-quotchap.sty}
%
% \section{quotchap}
%
% \credits{Karsten Tinnefeld, Jan Klever}
%
% \DescribePackage{quotchap}
% \pkg{quotchap} is emulated.
%
% \changes{v0.40}{2017/09/22}{\pkg{quotchap}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{quotchap}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\@quotchap}{}
\newlength{\LWR@quotchapwidth}

\let\@printcites\relax

\newcommand*{\@iprintcites}{%
%    \end{macrocode}
% Place the quotes inside a \element{div}
% of class \attribute{quotchap},
% of the maximum selected width:
%    \begin{macrocode}
\uselengthunit{PT}%
\begin{BlockClass}[max-width: \rndprintlength{\LWR@quotchapwidth}]{quotchap}
%\begin{minipage}{\LWR@quotchapwidth}
\@quotchap
%\end{minipage}
\end{BlockClass}
%    \end{macrocode}
% Deactivate the quote printing:
%    \begin{macrocode}
\global\let\@printcites\relax
}

\NewEnviron{savequote}[1][\linewidth]{%
%    \end{macrocode}
% Remember the width, adjusted for \HTML,
% and make the length assignment global, per: \\ 
%\href{https://tex.stackexchange.com/questions/300823/why-is-setlength-ineffective-inside-a-tabular-environment}
%{\ttfamily https://tex.stackexchange.com/questions/300823/ \\
%	\hspace*{2em} why-is-setlength-ineffective-inside-a-tabular-environment}
%    \begin{macrocode}
\setlength{\LWR@quotchapwidth}{#1*2}%
\global\LWR@quotchapwidth=\LWR@quotchapwidth%
%    \end{macrocode}
% Remember the body, and activate the quote printing:
%    \begin{macrocode}
\global\let\@quotchap\BODY
\global\let\@printcites\@iprintcites%
}
%    \end{macrocode}
% The quotation author is placed inside a \element{div}
% of class \attribute{qauthor}:
%    \begin{macrocode}
\newcommand{\qauthor}[1]{\begin{BlockClass}{qauthor}{#1}\end{BlockClass}}
%    \end{macrocode}
% \cs{qsetcnfont} is ignored:
%    \begin{macrocode}
\newcommand{\qsetcnfont}[1]{}
%    \end{macrocode}
%
% \iffalse
%</quotchap>
% \fi
%
%
%
%
%
% \iffalse
%<*ragged2e>
% \fi
%
% \part{lwarp-ragged2e.sty}
%
% \section{ragged2e}
%
% \credits{Martin Schröder}
%
% \DescribePackage{ragged2e}
% \pkg{ragged2e} is not used during \HTML\ conversion.
%
% \changes{v0.20}{2017/01/19}{\pkg{ragged2e}: Added.}
%

% Discard all options for \pkg{lwarp-ragged2e}:

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{ragged2e}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\Centering}{\centering}
\newcommand*{\RaggedLeft}{\raggedleft}
\newcommand*{\RaggedRight}{\raggedright}
\newcommand*{\justifying}{}
\newlength{\CenteringLeftskip}
\newlength{\RaggedLeftLeftskip}
\newlength{\RaggedRightLeftskip}
\newlength{\CenteringRightskip}
\newlength{\RaggedLeftRightskip}
\newlength{\RaggedRightRightskip}
\newlength{\CenteringParfillskip}
\newlength{\RaggedLeftParfillskip}
\newlength{\RaggedRightParfillskip}
\newlength{\JustifyingParfillskip}
\newlength{\CenteringParindent}
\newlength{\RaggedLeftParindent}
\newlength{\RaggedRightParindent}
\newlength{\JustifyingParindent}
\newenvironment*{Center}{\center}{\endcenter}
\newenvironment*{FlushLeft}{\flushleft}{\endflushleft}
\newenvironment*{FlushRight}{\flushright}{\endflushright}
\newenvironment*{justify}{\justifying}{\endjustifying}
%    \end{macrocode}


% \iffalse
%</ragged2e>
% \fi
%
%
%
%
%
% \iffalse
%<*realscripts>
% \fi
%
% \part{lwarp-realscripts.sty}
%
% \section{realscripts}
%
% \credits{Will Robertson}
%
% \DescribePackage{realscripts}
% \pkg{realscripts} is emulated.
% See |lwarp.css| for the \element{span} of class \attribute{supsubscript}.
%
% \changes{v0.38}{2017/08/26}{\pkg{realscripts}: Added.}
% \changes{v0.42}{2017/10/16}{\pkg{realscripts}: Fix for subscripts in a \env{lateximage}.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{realscripts}
%    \end{macrocode}
%
%    \begin{macrocode}
\let\realsuperscript\textsuperscript
\let\realsubscript\textsubscript

\let\fakesuperscript\textsuperscript
\let\fakesubscript\textsubscript

\newlength{\subsupersep}

\newcommand*{\LWR@realscriptsalign}{}

\newcommand*{\LWR@setrealscriptsalign}[1]{%
\renewcommand*{\LWR@realscriptsalign}{}%
\ifthenelse{\equal{#1}{c}}{\renewcommand{\LWR@realscriptsalign}{text-align:center;}}{}%
\ifthenelse{\equal{#1}{r}}{\renewcommand{\LWR@realscriptsalign}{text-align:right;}}{}%
}

\DeclareDocumentCommand \textsubsuperscript {s O{l} mm} {%
\LWR@setrealscriptsalign{#2}%
\InlineClass[\LWR@realscriptsalign]{supsubscript}{%
\textsuperscript{#4}\textsubscript{#3}%
}%
}

\DeclareDocumentCommand \textsupersubscript {s O{l} mm} {%
\LWR@setrealscriptsalign{#2}%
\InlineClass[\LWR@realscriptsalign]{supsubscript}{%
\textsubscript{#4}\textsuperscript{#3}%
}%
}
%    \end{macrocode}
%
% \iffalse
%</realscripts>
% \fi
%
%
%
%
%
%
% \iffalse
%<*relsize>
% \fi
%
% \part{lwarp-relsize.sty}

% \section{relsize}
%
% \credits{Donald Arseneau, Bernie Cosell, Matt Swift}
%
% \DescribePackage{relsize}
% \pkg{relsize} is patched for use by \pkg{lwarp}.
%
% \limitsrelsize
%
% \changes{v0.38}{2017/08/25}{\pkg{relsize}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{relsize}
%    \end{macrocode}
%
%    \begin{macrocode}
\let\LWR@origrelsize\relsize
\LetLtxMacro\LWR@origlarger\larger
\LetLtxMacro\LWR@origsmaller\smaller
\let\LWR@relscale\relscale
\LetLtxMacro\LWR@origtextlarger\textlarger
\LetLtxMacro\LWR@origtextsmaller\textsmaller
\let\LWR@textscale\textscale

\appto{\LWR@restoreorigformatting}{%
\let\relsize\LWR@origrelsize%
\LetLtxMacro\larger\LWR@origlarger%
\LetLtxMacro\smaller\LWR@origsmaller%
\let\relscale\LWR@relscale%
\LetLtxMacro\textlarger\LWR@origtextlarger%
\LetLtxMacro\textsmaller\LWR@origtextsmaller%
\let\textscale\LWR@textscale%
}

\newcounter{LWR@relsizetemp}

\renewcommand*{\relsize}[1]{}
\renewcommand*{\larger}[1][]{}
\renewcommand*{\smaller}[1][]{}
\renewcommand*{\relscale}[1]{}

\renewcommand*{\textlarger}[2][1]{%
\setcounter{LWR@relsizetemp}{100+(#1*20)}%
\InlineClass[font-size:\arabic{LWR@relsizetemp}\%]{textlarger}{#2}%
}

\renewcommand*{\textsmaller}[2][1]{%
\setcounter{LWR@relsizetemp}{100-(#1*20)}%
\InlineClass[font-size:\arabic{LWR@relsizetemp}\%]{textsmaller}{#2}%
}

\renewcommand*{\textscale}[2]{%
\setcounter{LWR@relsizetemp}{100*\real{#1}}%
\InlineClass[font-size:\arabic{LWR@relsizetemp}\%]{textscale}{#2}%
}
%    \end{macrocode}
%
% \iffalse
%</relsize>
% \fi
%
%
%
%
%
%
% \iffalse
%<*romanbar>
% \fi
%
% \part{lwarp-romanbar.sty}

% \section{romanbar}
%
% \credits{H.-Martin M\"{u}nch}

%
% \DescribePackage{romanbar}
% \pkg{romanbar} is patched for use by \pkg{lwarp}.
%
% An inline class with an overline and underline is used.
%
% \changes{v0.38}{2017/08/21}{\pkg{romanbar}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{romanbar}
%    \end{macrocode}

%    \begin{macrocode}
\DeclareRobustCommand{\Roman@bar}[1]{% #1 is in Roman, i.e. MMXII
\InlineClass[%
    text-decoration: overline underline ;
]{romanbar}{#1}%
}
%    \end{macrocode}

% \iffalse
%</romanbar>
% \fi
%
%
%
% \iffalse
%<*romanbarpagenumber>
% \fi
%
% \part{lwarp-romanbarpagenumber.sty}
%
% \section{romanbarpagenumber}
%
% \DescribePackage{romanbarpagenumber}
% \pkg{romanbarpagenumber} is ignored.
%
% \changes{v0.38}{2017/08/25}{\pkg{romanbarpagenumber}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{romanbarpagenumber}
%    \end{macrocode}
%
%
% \iffalse
%</romanbarpagenumber>
% \fi
%
%
%
%
%
% \iffalse
%<*rotating>
% \fi

% \part{lwarp-rotating.sty}

% \section{rotating}
%
% \credits{Robin Fairbairns, Sebastian Rahtz, Leonor Barroca}
%
% \DescribePackage{rotating}
% \pkg{rotating} is emulated.
%
% All rotations are ignored in \HTML\ output.
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{rotating}
%    \end{macrocode}

%    \begin{macrocode}
\LetLtxMacro\sidewaystable\table
\let\endsidewaystable\endtable

\LetLtxMacro\sidewaysfigure\figure
\let\endsidewaysfigure\endfigure

\newenvironment*{sideways}{}{}
\newenvironment*{turn}[1]{}{}
\newenvironment*{rotate}[1]{}{}
\NewDocumentCommand{\turnbox}{m +m}{#2}
\let\rotcaption\caption
\let\@makerotcaption\@makecaption
%    \end{macrocode}


% \iffalse
%</rotating>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*rotfloat>
% \fi

% \part{lwarp-rotfloat.sty}

% \section{rotfloat}
%
% \credits{Axel Sommerfeldt}
%
% \DescribePackage{rotfloat}
% \pkg{rotfloat} is emulated.
%
% \changes{v0.34}{2017/07/25}{\pkg{rotfloat}: Added.}
%
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{rotfloat}

\RequirePackage{float}
%    \end{macrocode}
%
%
% \begin{macro}{\newfloat} \marg{1: type} \marg{2: placement}
%							\marg{3: ext} \oarg{4: within}
%
% Emulates the \cs{newfloat} command from the \pkg{float} package.
% Sideways floats are \cs{let} to the same as regular floats.
%
% ``placement'' is ignored.
%
%    \begin{macrocode}
\RenewDocumentCommand{\newfloat}{m m m o}{%
\IfValueTF{#4}
{
    \DeclareFloatingEnvironment[fileext=#3,within=#4]{#1}
}
{
    \DeclareFloatingEnvironment[fileext=#3]{#1}
    \DeclareFloatingEnvironment[fileext=#3]{sideways#1}
}
\csletcs{sideways#1}{#1}
\csletcs{endsideways#1}{end#1}
%    \end{macrocode}
% \pkg{newfloat} package automatically creates the \cs{listof} command
% for new floats, but \pkg{float} does not,
% so remove \cs{listof} here in case it is manually created later.
%    \begin{macrocode}
\cslet{listof#1s}\relax
\cslet{listof#1es}\relax
}
%    \end{macrocode}
% \end{macro}
%
% \iffalse
%</rotfloat>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*savetrees>
% \fi
%
% \part{lwarp-savetrees.sty}
%
% \section{savetrees}
%
% \DescribePackage{savetrees} Emulated.
%
% \changes{v0.34}{2017/07/27}{\pkg{savetrees}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-savetrees}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{savetrees}
%    \end{macrocode}
%
%
% \iffalse
%</savetrees>
% \fi
%
%
%
%
%
% \iffalse
%<*scalefnt>
% \fi
%
% \part{lwarp-scalefnt.sty}

% \section{scalefnt}
%
% \credits{D. Carlisle}
%
% \DescribePackage{scalefnt}
% \pkg{scalefnt} is ignored.
%
% \changes{v0.38}{2017/08/25}{\pkg{scalefnt}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{scalefnt}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareRobustCommand\scalefont[1]{}
%    \end{macrocode}
%
% \iffalse
%</scalefnt>
% \fi
%
%
%
%
% \iffalse
%<*scrextend>
% \fi
%
% \part{lwarp-scrextend.sty}
%
% \section{scrextend}
%
% \DescribePackage{scrextend}
% \pkg{scrextend} is emulated.
%
% \usedbykomascript
%
% \changes{v0.44}{2017/11/20}{\pkg{scrextend}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{scrextend}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareDocumentCommand{\setkomafont}{m m}{}
\DeclareDocumentCommand{\addkomafont}{m m}{}
\DeclareDocumentCommand{\usekomafont}{m}{}

\DeclareDocumentCommand{\usefontofkomafont}{m}{}
\DeclareDocumentCommand{\useencodingofkomafont}{m}{}
\DeclareDocumentCommand{\usesizeofkomafont}{m}{}
\DeclareDocumentCommand{\usefamilyofkomafont}{m}{}
\DeclareDocumentCommand{\useseriesofkomafont}{m}{}
\DeclareDocumentCommand{\useshapeofkomafont}{m}{}

\AtBeginDocument{
\let\LWR@maketitle\maketitle
\DeclareDocumentCommand{\maketitle}{o}{\LWR@maketitle}
}

\DeclareDocumentCommand{\extratitle}{m}{}
\DeclareDocumentCommand{\titlehead}{m}{}
\DeclareDocumentCommand{\subject}{m}{}
\DeclareDocumentCommand{\publishers}{m}{\published{#1}}
\DeclareDocumentCommand{\uppertitleback}{m}{}
\DeclareDocumentCommand{\lowertitleback}{m}{}
\DeclareDocumentCommand{\dedication}{m}{}

\DeclareDocumentCommand{\ifthispageodd}{m m}{#1}

\DeclareDocumentCommand{\titlepagestyle}{}{}

\DeclareDocumentCommand{\cleardoublepageusingstyle}{m}{}
\DeclareDocumentCommand{\cleardoubleemptypage}{}{}
\DeclareDocumentCommand{\cleardoubleplainpage}{}{}
\DeclareDocumentCommand{\cleardoublestandardpage}{}{}
\DeclareDocumentCommand{\cleardoubleoddpage}{}{}
\DeclareDocumentCommand{\cleardoubleoddpageusingstyle}{m}{}
\DeclareDocumentCommand{\cleardoubleoddemptypage}{}{}
\DeclareDocumentCommand{\cleardoubleoddplainpage}{}{}
\DeclareDocumentCommand{\cleardoubleoddstandardpage}{}{}
\DeclareDocumentCommand{\cleardoubleevenpage}{}{}
\DeclareDocumentCommand{\cleardoubleevenpageusingstyle}{m}{}
\DeclareDocumentCommand{\cleardoubleevenemptypage}{}{}
\DeclareDocumentCommand{\cleardoubleevenplainpage}{}{}
\DeclareDocumentCommand{\cleardoubleevenstandardpage}{}{}

\DeclareDocumentCommand{\multiplefootnoteseparator}{}{%
  \begingroup\let\thefootnotemark\multfootsep\@makefnmark\endgroup
}

\DeclareDocumentCommand{\multfootsep}{}{,}

\DeclareDocumentCommand{\footref}{m}{%
  \begingroup
    \unrestored@protected@xdef\@thefnmark{\ref{#1}}%
  \endgroup
  \@footnotemark
}

\DeclareDocumentCommand{\deffootnote}{o m m m}{}
\DeclareDocumentCommand{\deffootnotemark}{m}{}
\DeclareDocumentCommand{\setfootnoterule}{o m}{}
\DeclareDocumentCommand{\raggedfootnote}{}{}

\DeclareDocumentCommand{\dictum}{o m}{
\begin{LWR@BlockClassWP}{text-align:right}{}{dictum}
    #2
    \IfValueT{#1}
    {
        \ifbool{FormatWP}
        {\begin{BlockClass}[border-top:1px solid gray]{dictumauthor}}
        {\begin{BlockClass}{dictumauthor}}
        \dictumauthorformat{#1}
        \end{BlockClass}
    }
\end{LWR@BlockClassWP}
}

\DeclareDocumentCommand{\dictumwidth}{}{}
\DeclareDocumentCommand{\dictumauthorformat}{m}{(#1)}
\DeclareDocumentCommand{\dictumrule}{}{}
\DeclareDocumentCommand{\raggeddictum}{}{}
\DeclareDocumentCommand{\raggeddictumtext}{}{}
\DeclareDocumentCommand{\raggeddictumauthor}{}{}

\DeclareDocumentEnvironment{labeling}{o m}
{%
\def\sc@septext{#1}%
\list{}{}%
\let\makelabel\labelinglabel%
}
{
\endlist
}

\DeclareDocumentCommand{\labelinglabel}{m}{%
#1 \qquad \sc@septext%
}

\let\addmargin\relax
\let\endaddmargin\relax
\cslet{addmargin*}{\relax}
\cslet{endaddmargin*}{\relax}

\NewDocumentEnvironment{addmargin}{s O{} m}
{
\uselengthunit{PT}%
\setlength{\LWR@templengthtwo}{#3}
\ifblank{#2}
{
    \begin{BlockClass}[
        margin-left:\rndprintlength{\LWR@templengthtwo} ;
        margin-right:\rndprintlength{\LWR@templengthtwo}
    ]{addmargin}
}
{
    \setlength{\LWR@templengthone}{#2}
    \begin{BlockClass}[
        margin-left:\rndprintlength{\LWR@templengthone} ;
        margin-right:\rndprintlength{\LWR@templengthtwo}
    ]{addmargin}
}
}
{\end{BlockClass}}
%    \end{macrocode}
% Ref to create a starred environment: \\
%   \href
%   {https://tex.stackexchange.com/questions/45401/use-the-s-star-argument-with-newdocumentenvironment}
%   {\ttfamily https://tex.stackexchange.com/questions/45401/ \\
%       \hspace*{2em} use-the-s-star-argument-with-newdocumentenvironment}
%    \begin{macrocode}

\ExplSyntaxOn
\cs_new:cpn {addmargin*} {\addmargin*}
\cs_new_eq:cN {endaddmargin*} \endaddmargin
\ExplSyntaxOff

\DeclareDocumentCommand{\marginline}{m}{\marginpar{#1}}
%    \end{macrocode}
%
% \iffalse
%</scrextend>
% \fi
%
%
%
% \iffalse
%<*scrhack>
% \fi
%
% \part{lwarp-scrhack.sty}
%
% \section{scrhack}
%
% \DescribePackage{scrhack}
% \pkg{scrhack} is ignored.
%
% \changes{v0.44}{2017/11/22}{\pkg{scrhack}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{scrhack}
%    \end{macrocode}
%
%
% \iffalse
%</scrhack>
% \fi
%
%
%
%
% \iffalse
%<*scrlayer>
% \fi
%
% \part{lwarp-scrlayer.sty}
%
% \section{scrlayer}
%
% \credits{Markus Kohm}
%
% \DescribePackage{scrlayer}
% \pkg{scrlayer} is emulated.
%
% \testthis
%
% \changes{v0.44}{2017/11/22}{\pkg{scrlayer}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{scrlayer}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\DeclareSectionNumberDepth}[2]{}
\newcommand*{\DeclareLayer}[2][]{}
\newcommand*{\DeclareNewLayer}[2][]{}
\newcommand*{\ProvideLayer}[2][]{}
\newcommand*{\RedeclareLayer}[2][]{}
\newcommand*{\ModifyLayer}[2][]{}
\newcommand*{\layerhalign}{}
\newcommand*{\layervalign}{}
\newcommand*{\layerxoffset}{}
\newcommand*{\layeryoffset}{}
\newcommand*{\layerwidth}{}
\newcommand*{\layerheight}{}
\providecommand*{\LenToUnit}[1]{\strip@pt\dimexpr#1*\p@/\unitlength}
\newcommand*{\putUL}[1]{}
\newcommand*{\putUR}[1]{}
\newcommand*{\putLL}[1]{}
\newcommand*{\putLR}[1]{}
\newcommand*{\putC}[1]{}
\newcommand*{\GetLayerContents}[1]{}
\newcommand{\IfLayerExists}[3]{#3}
\newcommand*{\DestroyLayer}[1]{}
\newcommand*{\layercontentsmeasure}{}
\newcommand*{\currentpagestyle}{}
\newcommand*{\BeforeSelectAnyPageStyle}[1]{}
\newcommand*{\AfterSelectAnyPageStyle}[1]{}
\newcommand*{\DeclarePageStyleAlias}[2]{}
\newcommand*{\DeclareNewPageStyleAlias}[2]{}
\newcommand*{\ProvidePageStyleAlias}[2]{}
\newcommand*{\RedeclarePageStyleAlias}[2]{}
\newcommand*{\DestroyPageStyleAlias}[1]{}
\newcommand*{\GetRealPageStyle}[1]{}
\newcommand*{\DeclarePageStyleByLayers}[3][]{}
\newcommand*{\DeclareNewPageStyleByLayers}[3][]{}
\newcommand*{\ProvidePageStyleByLayers}[3][]{}
\newcommand*{\RedeclarePageStyleByLayers}[3][]{}
\NewDocumentCommand{\ForEachLayerOfPageStyle}{s m m}{}
\newcommand*{\AddLayersToPageStyle}[2]{}
\newcommand*{\AddLayersAtBeginOfPageStyle}[2]{}
\newcommand*{\AddLayersAtEndOfPageStyle}[2]{}
\newcommand*{\RemoveLayersFromPageStyle}[2]{}
\newcommand*{\AddLayersToPageStyleBeforeLayer}[3]{}
\newcommand*{\AddLayersToPageStyleAfterLayer}[3]{}
\newcommand*{\UnifyLayersAtPageStyle}[1]{}
\newcommand*{\ModifyLayerPageStyleOptions}[2]{}
\newcommand*{\AddToLayerPageStyleOptions}[2]{}
\newcommand{\IfLayerPageStyleExists}[3]{#3}
\newcommand{\IfRealLayerPageStyleExists}[3]{#3}
\newcommand{\IfLayerAtPageStyle}[4]{#4}
\newcommand{\IfSomeLayerAtPageStyle}[4]{#4}
\newcommand{\IfLayersAtPageStyle}[4]{#4}
\newcommand*{\DestroyRealLayerPageStyle}[1]{}
\@ifundefined{footheight}{\newlength\footheight}{}
\DeclareDocumentCommand{\automark}{s o m}{}
\DeclareDocumentCommand{\manualmark}{}{}
\DeclareDocumentCommand{\MakeMarkcase}{m}{#1}
\DeclareDocumentCommand{\GenericMarkFormat}{}{}
\newcommand*{\@mkleft}[1]{}
\newcommand*{\@mkright}[1]{}
\newcommand*{\@mkdouble}[1]{}
\newcommand*{\@mkboth}[2]{}
\newcommand*{\scrlayerInitInterface}[1][]{}
\newcommand{\scrlayerAddToInterface}[3][]{}
\newcommand{\scrlayerAddCsToInterface}[3][]{}
\newcommand{\scrlayerOnAutoRemoveInterface}[2][]{}
%    \end{macrocode}
%
% \iffalse
%</scrlayer>
% \fi
%
%
%
% \iffalse
%<*scrlayer-notecolumn>
% \fi
%
% \part{lwarp-scrlayer-notecolumn.sty}
%
% \section{scrlayer-notecolumn}
%
% \credits{Markus Kohm}
%
% \DescribePackage{scrlayer-notecolumn}
% \pkg{scrlayer-notecolumn} is emulated.
%
% \testthis
%
% \changes{v0.44}{2017/11/22}{\pkg{scrlayer-notecolumn}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{scrlayer-notecolumn}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\DeclareNoteColumn}[2][]{}
\newcommand*{\DeclareNewNoteColumn}[2][]{}
\newcommand*{\ProvideNoteColumn}[2][]{}
\newcommand*{\RedeclareNoteColumn}[2][]{}
\NewDocumentCommand{\makenote}{s o m}{\marginpar{#3}}
\newcommand*{\syncwithnotecolumn}[1][]{}
\newcommand*{\syncwithnotecolumns}[1][]{}
\newcommand*{\clearnotecolumn}[1][]{}
\newcommand*{\clearnotecolumns}[1][]{}
%    \end{macrocode}
%
% \iffalse
%</scrlayer-notecolumn>
% \fi
%
%
%
%
% \iffalse
%<*scrlayer-scrpage>
% \fi
%
% \part{lwarp-scrlayer-scrpage.sty}
%
% \section{scrlayer-scrpage}
%
% \credits{Markus Kohm}
%
% \DescribePackage{scrlayer-scrpage}
% \pkg{scrlayer-scrpage} is emulated.
%
% \testthis
%
% \changes{v0.44}{2017/11/22}{\pkg{scrlayer-scrpage}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{scrlayer-scrpage}
%    \end{macrocode}
%
%    \begin{macrocode}
\@ifundefined{footheight}{\newlength\footheight}{}
\NewDocumentCommand{\lehead}{s o m}{}
\NewDocumentCommand{\cehead}{s o m}{}
\NewDocumentCommand{\rehead}{s o m}{}
\NewDocumentCommand{\lohead}{s o m}{}
\NewDocumentCommand{\cohead}{s o m}{}
\NewDocumentCommand{\rohead}{s o m}{}
\NewDocumentCommand{\lefoot}{s o m}{}
\NewDocumentCommand{\cefoot}{s o m}{}
\NewDocumentCommand{\refoot}{s o m}{}
\NewDocumentCommand{\lofoot}{s o m}{}
\NewDocumentCommand{\cofoot}{s o m}{}
\NewDocumentCommand{\rofoot}{s o m}{}
\NewDocumentCommand{\ohead}{s o m}{}
\NewDocumentCommand{\chead}{s o m}{}
\NewDocumentCommand{\ihead}{s o m}{}
\NewDocumentCommand{\ofoot}{s o m}{}
\NewDocumentCommand{\cfoot}{s o m}{}
\NewDocumentCommand{\ifoot}{s o m}{}
\DeclareDocumentCommand{\automark}{s o m}{}
\DeclareDocumentCommand{\manualmark}{}{}
\DeclareDocumentCommand{\MakeMarkcase}{m}{#1}
\DeclareDocumentCommand{\GenericMarkFormat}{}{}
\newcommand*{\defpairofpagestyles}[3][]{}
\newcommand*{\newpairofpagestyles}[3][]{}
\newcommand*{\renewpairofpagestyles}[3][]{}
\newcommand*{\providepairofpagestyles}[3][]{}
\newcommand*{\clearmainofpairofpagestyles}
\newcommand*{\clearplainofpairofpagestyles}
\newcommand*{\clearpairofpagestyles}
\NewDocumentCommand{\deftriplepagestyle}{m o o m m m m m m}{}
\NewDocumentCommand{\newtriplepagestyle}{m o o m m m m m m}{}
\NewDocumentCommand{\renewtriplepagestyle}{m o o m m m m m m}{}
\NewDocumentCommand{\providetriplepagestyle}{m o o m m m m m m}{}
\newcommand*{\defpagestyle}[3]{}
\newcommand*{\newpagestyle}[3]{}
\newcommand*{\providepagestyle}[3]{}
\newcommand*{\renewpagestyle}[3]{}
%    \end{macrocode}
%
% \iffalse
%</scrlayer-scrpage>
% \fi
%
%
%
%
% \iffalse
%<*section>
% \fi
%
% \part{lwarp-section.sty}
%
% \section{section}
%
% \DescribePackage{section}
% \pkg{section} is ignored.
%
% \credits{Oliver Pretzel}
%
% \changes{v0.44}{2017/11/22}{\pkg{section}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{section}
%    \end{macrocode}
%
%    \begin{macrocode}
\ifx\chapter\undefined
 \def\chsize{\Large}\def\hdsize{\huge}\else
 \def\chsize{\huge}\def\hdsize{\Huge}
\fi
\let\ttsize\LARGE
\let\ausize\large
\let\dasize\large
\let\secsize\Large
\let\subsize\large
\let\hdpos\raggedright
\newcounter{hddepth}
\let\fpind\relax
\def\ttfnt{}
\def\hdfnt{}
\def\fefnt{}
\def\thfnt{}
\def\pgfnt{}
\def\hmkfnt{}
\let\mkcse\uppercase
\def\hddot{}
\def\cpdot{:}
\def\nmdot{}
\ifx\secindent\undefined
 \newdimen\secindent
 \newskip\secpreskp
 \newskip\secpstskp
 \newdimen\subindent
 \newskip\subpreskp
 \newskip\subpstskp
 \newskip\parpstskp
 \newcount\c@hddepth
\fi
%    \end{macrocode}
%
% \iffalse
%</section>
% \fi
%
%
%
% \iffalse
%<*sectsty>
% \fi
%
% \part{lwarp-sectsty.sty}
%
% \section{sectsty}
%
% \credits{Rowland McDonnell}
%
% \DescribePackage{sectsty}
% \pkg{sectsty} is emulated.
%
% \changes{v0.40}{2017/09/12}{\pkg{sectsty}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{sectsty}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\partfont}          [1] {}
\newcommand*{\partnumberfont}    [1] {}
\newcommand*{\parttitlefont}     [1] {}
\newcommand*{\chapterfont}       [1] {}
\newcommand*{\chapternumberfont} [1] {}
\newcommand*{\chaptertitlefont}  [1] {}
\newcommand*{\sectionfont}       [1] {}
\newcommand*{\subsectionfont}    [1] {}
\newcommand*{\subsubsectionfont} [1] {}
\newcommand*{\paragraphfont}     [1] {}
\newcommand*{\subparagraphfont}  [1] {}
\newcommand*{\minisecfont}  [1] {}
\newcommand*{\allsectionsfont}[1] {}
\newcommand{\nohang}{}
%    \end{macrocode}
% \cs{sectionrule} is only to be used in |*font| commands, thus it is ignored.
%    \begin{macrocode}
\newcommand*{\sectionrule}[5]{}

\def\ulemheading#1#2{}
%    \end{macrocode}
%
% \iffalse
%</sectsty>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*setspace>
% \fi

% \part{lwarp-setspace.sty}

% \section{setspace}
%
% \credits{Robin Fairbairns}
%
% \DescribePackage{setspace}
% \pkg{setspace} is not used during \HTML\ conversion.
%
% \changes{v0.20}{2016/12/22}{\pkg{setspace}: Improved support.}
%

% Discard all options for \pkg{lwarp-setspace}:

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{setspace}

\newcommand*{\setstretch}[1]{}
\newcommand*{\SetSinglespace}[1]{}
\newcommand*{\singlespacing}{}
\newcommand*{\onehalfspacing}{}
\newcommand*{\doublespacing}{}

\newenvironment*{singlespace}
{
\LWR@forcenewpage
\BlockClass{singlespace}
}
{\endBlockClass}

\newenvironment*{singlespace*}
{
\LWR@forcenewpage
\BlockClass{singlespace}
}
{\endBlockClass}

\newenvironment*{spacing}[1]{

}{

}

\newenvironment*{onehalfspace}
{
\LWR@forcenewpage
\BlockClass{onehalfspace}
}
{\endBlockClass}

\newenvironment*{doublespace}
{
\LWR@forcenewpage
\BlockClass{doublespace}
}
{\endBlockClass}
%    \end{macrocode}

% \iffalse
%</setspace>
% \fi
%
%
%
% \iffalse
%<*shadow>
% \fi

% \part{lwarp-shadow.sty}

% \section{shadow}
%
% \credits{Mauro Orlandini}
%
% \DescribePackage{shadow}
% \pkg{shadow} is emulated.
%
% \changes{v0.34}{2017/07/26}{\pkg{shadow}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-shadow}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{shadow}
%    \end{macrocode}

%    \begin{macrocode}
\newdimen\sboxsep
\newdimen\sboxrule
\newdimen\sdim

\newcommand{\shabox}[1]{%
\InlineClass{shabox}{#1}%
}
%    \end{macrocode}

% \iffalse
%</shadow>
% \fi
%
%
%
%
%
%
%
%
% \iffalse
%<*showidx>
% \fi

% \part{lwarp-showidx.sty}

% \section{showidx}
%
% \DescribePackage{showidx}
% \pkg{showidx} is ignored.
%
% \changes{v0.25}{2017/03/22}{\pkg{showidx}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-showidx}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{showidx}
%    \end{macrocode}

% \iffalse
%</showidx>
% \fi
%
%
%
%
%
% \iffalse
%<*showkeys>
% \fi

% \part{lwarp-showkeys.sty}

% \section{showkeys}
%
% \credits{David Carlisle, Morten Høgholm}
%
% \DescribePackage{showkeys}
% \pkg{showkeys} is ignored.
%
% \changes{v0.22}{2017/03/01}{\pkg{showkeys}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-showkeys}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{showkeys}
%    \end{macrocode}

%    \begin{macrocode}
\NewDocumentCommand{\showkeys}{s}{}
%    \end{macrocode}

% \iffalse
%</showkeys>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*sidecap>
% \fi

% \part{lwarp-sidecap.sty}

% \section{sidecap}
%
% \credits{Rolf Niepraschk, Hubert Gäßlein}
%
% \DescribePackage{sidecap}
% \pkg{sidecap} is emulated.
%
% \changes{v0.22}{2017/03/01}{\pkg{sidecap}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-sidecap}.
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{sidecap}
%    \end{macrocode}

% See: \\
% \href
% {http://tex.stackexchange.com/questions/45401/use-the-s-star-argument-with-newdocumentenvironment}
% {\texttt{http://tex.stackexchange.com/questions/45401/ \\
%	use-the-s-star-argument-with-newdocumentenvironment}} \\
% regarding the creation of starred environments with \pkg{xparse}.
%    \begin{macrocode}
\NewDocumentEnvironment{SCtable}{soo}
{\IfValueTF{#3}{\table[#3]}{\table}}
{\endtable}

\ExplSyntaxOn
\cs_new:cpn {SCtable*} {\SCtable*}
\cs_new_eq:cN {endSCtable*} \endSCtable
\ExplSyntaxOff


\NewDocumentEnvironment{SCfigure}{soo}
{\IfValueTF{#3}{\figure[#3]}{\figure}}
{\endfigure}

\ExplSyntaxOn
\cs_new:cpn {SCfigure*} {\SCfigure*}
\cs_new_eq:cN {endSCfigure*} \endSCfigure
\ExplSyntaxOff


\newenvironment*{wide}{}{}
%    \end{macrocode}

% \iffalse
%</sidecap>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*sidenotes>
% \fi
%
% \part{lwarp-sidenotes.sty}
%
% \section{sidenotes}
%
% \credits{Andy Thomas, Oliver Schebaum}
%
% \DescribePackage{sidenotes} Patched for \pkg{lwarp}.
%
% \changes{v0.26}{2017/03/30}{\pkg{sidenotes}: Added.}
%
% \codehtml
%
%
% Load the original package:
%    \begin{macrocode}
\LWR@ProvidesPackagePass{sidenotes}
%    \end{macrocode}
%
%
% The following patch \pkg{sidenotes} for use with \pkg{lwarp}:
%
% Stop paragraph handling while creating the caption:
%    \begin{macrocode}
\RenewDocumentCommand \sidecaption {s o o m}
{
    \LWR@stoppars
  \captionsetup{style=sidecaption}
  \IfBooleanTF{#1}
  { % starred
    \IfNoValueOrEmptyTF{#2}
    {\marginnote{\caption*{#4}}}
    {\marginnote{\caption*{#4}}[#2]}
  }
  { % unstarred
  \IfNoValueOrEmptyTF{#2}
    {\def\@sidenotes@sidecaption@tof{#4}}
    {\def\@sidenotes@sidecaption@tof{#2}}
  \IfNoValueOrEmptyTF{#3}
    {\marginnote{\caption[\@sidenotes@sidecaption@tof]{#4}}}
    {\marginnote{\caption[\@sidenotes@sidecaption@tof]{#4}}[#3]}
  }
    \LWR@startpars
}
%    \end{macrocode}
%
%
%
% Borrowed from the \pkg{lwarp} version of \pkg{keyfloat}:
% \changes{v0.42}{2017/10/26}{\pkg{sidenotes}: If \texttt{FormatWP} add explicit HTML style.}
%    \begin{macrocode}
\NewDocumentEnvironment{KFLTsidenotes@marginfloat}{O{-1.2ex} m}
{% start
\LWR@BlockClassWP{float:right; width:2in; margin:10pt}{}{marginblock}%
\captionsetup{type=#2}%
}
{%
\endLWR@BlockClassWP%
}

\RenewDocumentEnvironment{marginfigure}{o}
  {\begin{KFLTsidenotes@marginfloat}{figure}}
  {\end{KFLTsidenotes@marginfloat}}

\RenewDocumentEnvironment{margintable}{o}
  {\begin{KFLTsidenotes@marginfloat}{table}}
  {\end{KFLTsidenotes@marginfloat}}
%    \end{macrocode}
%
% The following were changed by \pkg{sidenotes}, and now are
% reset back to their \pkg{lwarp}-supported originals:
%
% Restoring the definition from the \LaTeXe\ |article.cls| source:
%    \begin{macrocode}
\renewenvironment{figure*}
               {\@dblfloat{figure}}
               {\end@dblfloat}

\renewenvironment{table*}
               {\@dblfloat{table}}
               {\end@dblfloat}
%    \end{macrocode}
%
% \iffalse
%</sidenotes>
% \fi
%
%
%
%
%
%
% \iffalse
%<*siunitx>
% \fi
%
% \part{lwarp-siunitx.sty}

% \section{siunitx}
%
% \credits{Joseph Wright}
%
% \DescribePackage{siunitx}
% \pkg{siunitx} is patched for use by \pkg{lwarp}.
%
% \limitssiunitx
%
% \changes{v0.36}{2017/08/17}{\pkg{siunitx}: Improved symbol support.}
% \changes{v0.37}{2017/08/17}{\pkg{siunitx}: Improved symbol support.}
% \changes{v0.38}{2017/08/26}{\pkg{siunitx}: Removed from \pkg{lwarp} core.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{siunitx}
%    \end{macrocode}

%    \begin{macrocode}
\AtBeginDocument{% in case textcomp was not loaded
\DeclareSIUnit\bohr{\textit{a}\textsubscript{0}}
\DeclareSIUnit\clight{\textit{c}\textsubscript{0}}
\DeclareSIUnit\elementarycharge{\textit{e}}
\DeclareSIUnit\electronmass{\textit{m}\textsubscript{e}}
\DeclareSIUnit\hartree{\textit{E}\textsubscript{h}}
}% AtBeginDocument
%    \end{macrocode}

% \changes{v0.42}{2017/10/16}{\pkg{siunitx}: Improved \cs{ensuremath}.}
% The following is executed by \pkg{siunitx} at the end of \cs{document}.
% \cs{@ensuredmath} is not supported inside an \cs{hbox}, so it must
% temporarily be restored to its original.
%    \begin{macrocode}
\ExplSyntaxOn
\cs_undefine:N \__siunitx_set_math_fam:n
\cs_new_protected:Npn \__siunitx_set_math_fam:n #1 {
    \LWR@traceinfo{sunitx set math fam}
  \int_new:c { c__siunitx_math #1 _int }
  \group_begin:
    \LetLtxMacro\@ensuredmath\LWR@origensuredmath
    \hbox_set:Nn \l__siunitx_tmp_box
      {
        \ensuremath
          {
            \use:c { math #1 }
              {
                \int_gset:cn { c__siunitx_math #1 _int } { \fam }
              }
          }
      }
  \group_end:
    \LWR@traceinfo{sunitx set math fam: done}
}

\cs_undefine:N \__siunitx_combined_output:n
\cs_new_protected:Npn \__siunitx_combined_output:n #1 {
    \group_begin:
    \LetLtxMacro\@ensuredmath\LWR@origensuredmath
  \bool_if:NTF \l__siunitx_number_parse_bool
    {
      \tl_clear:N \l__siunitx_number_out_tl
      \bool_set_false:N \l__siunitx_number_compound_bool
      \__siunitx_number_output_parse:n {#1}
    }
    {
      \__siunitx_unit_output_pre_print:
      \__siunitx_print:nn { number } { \ensuremath {#1} }
      \__siunitx_unit_output_print:
    }
    \group_end:
}

\ExplSyntaxOff
%    \end{macrocode}

% \iffalse
%</siunitx>
% \fi
%
%
%
%
%
%
% \iffalse
%<*soul>
% \fi
%
% \part{lwarp-soul.sty}
%
% \section{soul}
%
% \credits{Melchior FRANZ}
%
% \DescribePackage{soul} Emulated.
%
% \changes{v0.27}{2017/04/02}{\pkg{soul}: Added.}
% \changes{v0.42}{2017/10/20}{\pkg{soul}: If \protect\texttt{FormatWP}, add explicit styles.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{soul}[2003/11/17]
\RequirePackage{xcolor}% for \convertcolorspec
%    \end{macrocode}
%
% Storage for the colors to use:
%    \begin{macrocode}
\newcommand*{\LWR@soululcolor}{}

\newcommand*{\LWR@soulstcolor}{}

% \definecolor{LWR@soulhlcolordefault}{HTML}{F8E800}
% \newcommand*{\LWR@soulhlcolor}{LWR@soulhlcolordefault}
\newcommand*{\LWR@soulhlcolor}{}
%    \end{macrocode}
%
% \begin{noindmacro}{\so} \marg{text}
%
% Basic markup with \CSS:
%    \begin{macrocode}
\newcommand{\so}[1]{%
\LWR@HTMLtextstyle{letter-spacing:.2ex}{letterspacing}{#1}%
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\caps} \marg{text}
%    \begin{macrocode}
\newcommand{\caps}[1]{%
\LWR@HTMLtextstyle%
    {font-variant:small-caps;letter-spacing:.1ex}%
    {capsspacing}{#1}%
}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\LWR@soulcolor}
%   \marg{text} \marg{color} \marg{class} \marg{colorstyle} \marg{FormatWPstyle}
%
% Add colors if not empty:
%    \begin{macrocode}
\newcommand{\LWR@soulcolor}[5]{%
\ifcsempty{#2}%
{\LWR@HTMLtextstyle{#5}{#3}{#1}}%
{%
    \convertcolorspec{named}{\csuse{#2}}{HTML}\LWR@tempcolor%
    \LWR@htmlspanclass[#5;#4:\#\LWR@tempcolor]{#3}{#1}%
}%
}
%    \end{macrocode}
% \end{noindmacro}

%    \begin{macrocode}
\newcommand{\ul}[1]{%
\LWR@soulcolor{#1}{LWR@soululcolor}{uline}{text-decoration-color}%
    {text-decoration:underline;text-decoration-skip;}%
}

\newcommand{\st}[1]{
\LWR@soulcolor{#1}{LWR@soulstcolor}{sout}{text-decoration-color}%
    {text-decoration:line-through}%
}

\newcommand{\hl}[1]{
\LWR@soulcolor{#1}{LWR@soulhlcolor}{highlight}{background-color}%
    {background:\#F8E800}
}
%    \end{macrocode}
%
% Nullified:
%    \begin{macrocode}
\newcommand*{\soulaccent}[1]{}
\newcommand*{\soulregister}[2]{}
\newcommand{\sloppyword}[1]{#1}
\newcommand*{\sodef}[5]{\DeclareRobustCommand*#1[1]{\so{##1}}}
\newcommand*{\resetso}{}
\newcommand*{\capsdef}[5]{}
\newcommand*{\capsreset}{}
\newcommand*{\capssave}[1]{}
\newcommand*{\capsselect}[1]{}
\newcommand*{\setul}[2]{}
\newcommand*{\resetul}{}
\newcommand*{\setuldepth}[1]{}
\newcommand*{\setuloverlap}[1]{}
%    \end{macrocode}
%
% Set colors:
%    \begin{macrocode}
\newcommand*{\setulcolor}[1]{\renewcommand{\LWR@soululcolor}{#1}}
\newcommand*{\setstcolor}[1]{\renewcommand{\LWR@soulstcolor}{#1}}
\newcommand*{\sethlcolor}[1]{\renewcommand{\LWR@soulhlcolor}{#1}}
%    \end{macrocode}
%
% Long versions of the user-level macros:
%    \begin{macrocode}
\let\textso\so
\let\textul\ul
\let\texthl\hl
\let\textcaps\caps
%    \end{macrocode}
%
% \iffalse
%</soul>
% \fi
%
%
%
% \iffalse
%<*soulpos>
% \fi
%
% \part{lwarp-soulpos.sty}
%
% \section{soulpos}
%
% \credits{Javier Bezos}
%
% \DescribePackage{soulpos}
% \pkg{soulpos} is emulated.
%
% \changes{v0.44}{2017/11/10}{\pkg{soulpos}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\RequirePackage{soul}
\RequirePackage{soulutf8}
\LWR@ProvidesPackageDrop{soulpos}
%    \end{macrocode}
%
%    \begin{macrocode}
\NewDocumentCommand{\ulposdef}{m o m}{}

\newdimen\ulwidth

\newcommand\ifulstarttype[1]{%
\expandafter\@secondoftwo%
}

\newcommand\ifulendtype[1]{%
\expandafter\@secondoftwo%
}

\newcommand{\ulstarttype}{0}
\newcommand{\ulendtype}{0}
\newcommand\ulpostolerance{0}%
%    \end{macrocode}
%
% \iffalse
%</soulpos>
% \fi
%
%
%
%
%
%
% \iffalse
%<*soulutf8>
% \fi
%
% \part{lwarp-soulutf8.sty}
%
% \section{soulutf8}
%
% \DescribePackage{soulutf8}
% \pkg{soulutf8} is emulated.
%
% \pkg{lwarp}'s \HTML\ output naturally supports \acro{UTF}-8 encoding.
%
% \changes{v0.44}{2017/11/10}{\pkg{soulutf8}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{soulutf8}
%    \end{macrocode}
%
%
% \iffalse
%</soulutf8>
% \fi
%
%
%
%
%
%
% \iffalse
%<*stabular>
% \fi
%
% \part{lwarp-stabular.sty}
%
% \section{stabular}
%
% \credits{Sigitas Tolu\v{s}is}
%
% \DescribePackage{stabular}
% \pkg{stabular} is emulated.
%
% \changes{v0.40}{2017/09/07}{\pkg{stabular}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{stabular}
%    \end{macrocode}
%
% \oarg{vpos} \marg{colspec}
% \marginpar{\hfill {\footnotesize Env} \env{stabular}}
%    \begin{macrocode}
\newenvironment{stabular}[2][c]
{
\renewcommand{\noalign}[1]{}
\begin{tabular}[#1]{#2}
}
{\end{tabular}}
%    \end{macrocode}
%
% \marg{width} \oarg{vpos} \marg{colspec}
% \marginpar{\hfill {\footnotesize Env} \env{stabular}}
%    \begin{macrocode}
\NewDocumentEnvironment{stabular*}{m o m}
{
\renewcommand{\noalign}[1]{}
\begin{tabular}[#2]{#3}
}
{\end{tabular}}
%    \end{macrocode}
%
% \iffalse
%</stabular>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*subfig>
% \fi

% \part{lwarp-subfig.sty}
%
% \section{subfig}
%
% \credits{Steven Douglas Cochran}
%
% \DescribePackage{subfig}
% \pkg{subfig} is supported and patched by \pkg{lwarp}.
%
% \changes{v0.24}{2017/03/06}{\pkg{subfig}: Added.}
%
% \limitssubfig
%
% \codehtml
%
% Accept all options for \pkg{lwarp-subfig}:
%    \begin{macrocode}
\LWR@ProvidesPackagePass{subfig}
%    \end{macrocode}

% \begin{noindmacro}{\sf@@@subfloat}
%   \marg{1 type} \oarg{2 lof entry} \oarg{3 caption} \marg{4 contents}
%
% The outer minipage allows side-by-side subfloats with \cs{hfill} between.
%    \begin{macrocode}
\long\def\sf@@@subfloat#1[#2][#3]#4{%
\begin{minipage}{\linewidth}% new
\LWR@stoppars% new
    \@ifundefined{FBsc@max}{}%
        {\FB@readaux{\let\FBsuboheight\relax}}%
    \@tempcnta=\@ne
    \if@minipage
      \@tempcnta=\z@
    \else\ifdim \lastskip=\z@ \else
      \@tempcnta=\tw@
    \fi\fi
    \ifmaincaptiontop
      \sf@top=\sf@nearskip
      \sf@bottom=\sf@farskip
    \else
      \sf@top=\sf@farskip
      \sf@bottom=\sf@nearskip
    \fi
    \leavevmode
    \setbox\@tempboxa \hbox{#4}%
    \@tempdima=\wd\@tempboxa
    \@ifundefined{FBsc@max}{}%
        {\global\advance\Xhsize-\wd\@tempboxa
         \dimen@=\ht\@tempboxa
         \advance\dimen@\dp\@tempboxa
         \ifdim\dimen@>\FBso@max
           \global\FBso@max\dimen@
         \fi}%
    \vtop\bgroup
      \vbox\bgroup
        \ifcase\@tempcnta
          \@minipagefalse
        \or
          \vskip\sf@top
        \or
          \ifdim \lastskip=\z@ \else
            \@tempskipb\sf@top\relax\@xaddvskip
          \fi
        \fi
        \sf@ifpositiontop{%
          \ifx \@empty#3\relax \else
            \sf@subcaption{#1}{#2}{#3}%
            \vskip\sf@capskip
            \vskip\sf@captopadj
          \fi\egroup
          \hrule width0pt height0pt depth0pt
            \LWR@startpars% new
% 			\box\@tempboxa
            #4
            \LWR@stoppars% new
        }{%
        \LWR@startpars% new
        \@ifundefined{FBsc@max}%
            {
% 				\box\@tempboxa
                #4
            }%
            {\ifx\FBsuboheight\relax
%                \box\@tempboxa
                #4
             \else
%                \vbox to \FBsuboheight{\FBafil\box\@tempboxa\FBbfil}%
                #4
             \fi}%
        \LWR@stoppars% new
          \egroup
          \ifx \@empty#3\relax \else
            \vskip\sf@capskip
            \hrule width0pt height0pt depth0pt
            \sf@subcaption{#1}{#2}{#3}%
         \fi
        }%
      \vskip\sf@bottom
    \egroup
    \@ifundefined{FBsc@max}{}%
        {\addtocounter{FRobj}{-1}%
         \ifnum\c@FRobj=0\else
           \subfloatrowsep
         \fi}%
    \ifmaincaptiontop\else
      \global\advance\@nameuse{c@\@captype}\m@ne
    \fi
\end{minipage}% new
\LWR@startpars% new
  \endgroup\ignorespaces%
}%
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\sf@subcaption}
%   \marg{1 type} \marg{2 lof entry} \marg{3 caption}
%    \begin{macrocode}
\long\def\sf@subcaption#1#2#3{%
\LWR@stoppars% new
  \ifx \relax#2\relax \else
    \bgroup
      \let\label=\@gobble
      \let\protect=\string
      \def\@subcaplabel{%
        \caption@lstfmt{\@nameuse{p@#1}}{\@nameuse{the#1}}}%
      \sf@updatecaptionlist{#1}{#2}{\the\value{\@captype}}{\the\value{#1}}%
    \egroup
  \fi
  \bgroup
    \ifx \relax#3\relax
      \let\captionlabelsep=\relax
    \fi
%     \setbox0\vbox{%
%        \hb@xt@\the\@tempdima{%
% 
% %          \hss
% %         \parbox[t]{\the\@tempdima}{%
%           \caption@make
%               {\@nameuse{sub\@captype name}}%
%               {\@nameuse{thesub\@captype}}%
%               {#3}
% % 		}%
% %            \hss
%  		}
% 	}%
    \@ifundefined{FBsc@max}%
%         {\box0}%
        {
% 			\parbox[t]{\the\@tempdima}{%
\LWR@traceinfo{sfsubcap B1}% new
            \LWR@figcaption% new
            \caption@make
                {\@nameuse{sub\@captype name}}%
                {\@nameuse{thesub\@captype}}%
                {#3}
            \LWR@figcaption% new
\LWR@traceinfo{sfsubcap B2}% new
% 			}%
        }%
        {\dimen@\ht0%
         \advance\dimen@\dp0%
         \ifdim\dimen@>\FBsc@max
           \global\FBsc@max\dimen@
         \fi
         \FB@readaux{\let\FBsubcheight\relax}%
         \ifx\FBsubcheight\relax
           \def\next{
% 				\parbox[t]{\the\@tempdima}
            }%
         \else
           \def\next{
% 				\parbox[t][\FBsubcheight][t]{\the\@tempdima}
            }%
         \fi
         \vbox{%
%            \hb@xt@\the\@tempdima{%

%              \hss
%              \next{%
\LWR@traceinfo{sfsubcap C1}% new
               \caption@make
                   {\@nameuse{sub\@captype name}}%
                   {\@nameuse{thesub\@captype}}%
                   {#3}
\LWR@traceinfo{sfsubcap C1}% new
% 			}%
%              \hss

% 			}
          }
        }%
  \egroup
\LWR@startpars% new
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\caption@@@make}
%   \marg{caption label} \marg{caption text}
%    \begin{macrocode}
\renewcommand\caption@@@make[2]{%
\LWR@startpars% new
  \sbox\@tempboxa{#1}%
  \ifdim\wd\@tempboxa=\z@
    \let\caption@lsep\relax
  \fi
  \caption@ifempty{#2}{%
    \let\caption@lsep\@empty
    \let\caption@tfmt\@firstofone
  }%
%   \@setpar{\@@par\caption@@par}\caption@@par
\renewcommand{\@@par}{\LWR@closeparagraph\LWR@orig@@par}% new
  \caption@applyfont
  \caption@fmt
    {\ifcaption@star\else
       \begingroup
         \captionlabelfont
         #1%
       \endgroup
     \fi}%
    {\ifcaption@star\else
       \begingroup
         \caption@iflf\captionlabelfont
         \relax\caption@lsep
       \endgroup
     \fi}%
    {{\captiontextfont
      \caption@ifstrut
        {\vrule\@height\ht\strutbox\@width\z@}%
        {}%
      \nobreak\hskip\z@skip % enable hyphenation
      \caption@tfmt{#2}
    \LWR@ensuredoingapar% new
      \caption@ifstrut
        {\ifhmode\@finalstrut\strutbox\fi}%
        {}%
      \par}}
\LWR@stoppars% new
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\subfloat@label}
% Patches for \cs{sf@sub@label}:
%    \begin{macrocode}
\def\subfloat@label{%
\LWR@ensuredoingapar% new
  \@ifnextchar(%   %) match left parenthesis
    {\sf@sub@label}
    {\sf@sub@label(Sub\@captype\space
                   \@ifundefined{thechapter}{}{\@nameuse{thechapter}\space}%
                   \@nameuse{p@sub\@captype}%
                   \@nameuse{thesub\@captype}.)}}
%    \end{macrocode}
% \end{noindmacro}

% Patches for \cs{subref}.
%
% \begin{noindmacro}{\sf@subref} \marg{label}
%
% The unstarred version uses a \cs{ref} link whose printed text
% comes from the |sub@<label>|:
%    \begin{macrocode}
\renewcommand{\sf@subref}[1]{%
\LWR@subnewref{#1}{sub@#1}%
}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\sf@@subref} \marg{label}
%
% The starred version uses the printed |sub@<label>| which is stored as
% if it were a page number:
%    \begin{macrocode}
\renewcommand{\sf@@subref}[1]{\LWR@origpageref{sub@#1}}
%    \end{macrocode}
% \end{noindmacro}
%
%
% Defining new subfloats.  The |l@sub<type>| for each is redefined.
%
% \begin{noindmacro}{\@newsubfloat} \oarg{keys/values} \marg{float name}
%    \begin{macrocode}
\LetLtxMacro\LWR@orig@newsubfloat\@newsubfloat

\def\@newsubfloat[#1]#2{%
\LWR@orig@newsubfloat[#1]{#2}%
\renewcommand{\l@sub#2}[2]{\hypertocfloat{2}{sub#2}{\ext@sub#2}{##1}{##2}}
}
%    \end{macrocode}
% \end{noindmacro}
%
% Pre-defined for figures and tables:
%
% \begin{noindmacro}{\l@subfigure} \marg{text} \marg{pagenum}
%    \begin{macrocode}
\renewcommand{\l@subfigure}[2]{\hypertocfloat{2}{subfigure}{lof}{#1}{#2}}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\l@subtable} \marg{text} \marg{pagenum}
%    \begin{macrocode}
\renewcommand{\l@subtable}[2]{\hypertocfloat{2}{subtable}{lot}{#1}{#2}}
%    \end{macrocode}
% \end{noindmacro}
%
% ^^A \def\subfigure{\subfloat}
% ^^A \def\subtable{\subfloat}


% \iffalse
%</subfig>
% \fi
%
%
%
%
%
%
%
%
% \iffalse
%<*supertabular>
% \fi

% \part{lwarp-supertabular.sty}

% \section{supertabular}
% \label{sec:supertabular}
%
% \credits{Johannes Braams, Theo Jurriens}
%
%
% \DescribePackage{supertabular}
% \pkg{supertabular} is emulated.
%
% \changes{v0.39}{2017/08/30}{\pkg{supertabular}: Added.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{supertabular}
%    \end{macrocode}
%
% \limitssupertabular
%
%
%    \begin{macrocode}
\newcommand{\LWRST@firsthead}{}

\newcommand{\tablefirsthead}[1]{%
    \long\gdef\LWRST@firsthead{#1}%
}

\newcommand{\tablehead}[1]{}
\newcommand{\tabletail}[1]{}

\newcommand{\LWRST@lasttail}{}

\newcommand{\tablelasttail}[1]{%
    \long\gdef\LWRST@lasttail{#1}%
}

\newcommand{\tablecaption}[2][]{%
    \long\gdef\LWRST@caption{\caption[#1]{#2}}%
}

\let\topcaption\tablecaption
\let\bottomcaption\tablecaption

%    \end{macrocode}
% \changes{v0.44}{2017/11/19}{\pkg{supertabular}: Fix for caption.}
%    \begin{macrocode}
\newcommand*{\LWRST@caption}{}

\newcommand*{\shrinkheight}[1]{}

\NewDocumentEnvironment{supertabular}{s o m}
{
\LWR@traceinfo{supertabular}
\table
\LWRST@caption
\begin{tabular}{#3}
\TabularMacro\ifdefvoid{\LWRST@firsthead}%
{\LWR@getmynexttoken}%
{\expandafter\LWR@getmynexttoken\LWRST@firsthead}%
}
{%
\ifdefvoid{\LWRST@lasttail}%
{}%
{%
\TabularMacro\ResumeTabular%
\LWRST@lasttail%
}%
\end{tabular}
\endtable
\LWR@traceinfo{supertabular done}
}

\NewDocumentEnvironment{mpsupertabular}{s o m}
{\minipage{\linewidth}\supertabular{#3}}
{\endsupertabular\endminipage}
%    \end{macrocode}


% \iffalse
%</supertabular>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*syntonly>
% \fi
%
% \part{lwarp-syntonly.sty}
%
% \section{syntonly}
%
% \credits{Frank Mittelbach, Rainer Sch\"{o}pf}
%
% \DescribePackage{syntonly} Emulated.
%
% \changes{v0.34}{2017/07/26}{\pkg{syntonly}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-syntonly}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{syntonly}
%    \end{macrocode}
%
%    \begin{macrocode}
\newif\ifsyntax@
\syntax@false

\newcommand*{\syntaxonly}{}

\@onlypreamble\syntaxonly
%    \end{macrocode}
%
% \iffalse
%</syntonly>
% \fi
%
%
%
%
%
% \iffalse
%<*tabls>
% \fi
%
% \part{lwarp-tabls.sty}
%
% \section{tabls}
%
% \credits{Donald Arseneau}
%
% \DescribePackage{tabls}
% \pkg{tabls} is emulated.
% \cs{LWR@hline} is used to handle the optional argument when
% \pkg{tabls} is loaded.
%
% \changes{v0.40}{2017/09/06}{\pkg{tabls}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{tabls}
%    \end{macrocode}
%
%    \begin{macrocode}
\newdimen\tablinesep
\newdimen\arraylinesep
\newdimen\extrarulesep
%    \end{macrocode}
%
% \iffalse
%</tabls>
% \fi
%
%
%
%
%
% \iffalse
%<*tabularx>
% \fi

% \part{lwarp-tabularx.sty}

% \section{tabularx}
%
% \credits{David Carlisle}
%
% \DescribePackage{tabularx}
% \pkg{tabularx} is emulated by \pkg{lwarp}.
%
% \changes{v0.22}{2017/03/01}{\pkg{tabularx}: Added.}
% \changes{v0.28}{2017/04/11}{\pkg{tabularx}: Fix for optional pos.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-tabularx}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{tabularx}
%    \end{macrocode}

%    \begin{macrocode}
\NewDocumentEnvironment{tabularx}{m o m}
{\tabular{#3}}
{\endtabular}

\NewDocumentEnvironment{tabularx*}{m o m}
{\tabular{#3}}
{\endtabular}
%    \end{macrocode}

% \iffalse
%</tabularx>
% \fi
%
%
%
%
%
% \iffalse
%<*tabulary>
% \fi

% \part{lwarp-tabulary.sty}

% \section{tabulary}
%
% \credits{David Carlisle}
%
% \DescribePackage{tabulary}
% \pkg{tabulary} is emulated by \pkg{lwarp}.
%
% \changes{v0.28}{2017/04/11}{\pkg{tabulary}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-tabulary}.
%
% Column types |L|, |C|, |R|, and |J| are emulated by \pkg{lwarp}
% core code.
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{tabulary}
%    \end{macrocode}

%    \begin{macrocode}
\NewDocumentEnvironment{tabulary}{m o m}
{\tabular{#3}}
{\endtabular}

\NewDocumentEnvironment{tabulary*}{m o m}
{\tabular{#3}}
{\endtabular}

\newdimen\tymin
\newdimen\tymax
\def\tyformat{}
%    \end{macrocode}

% \iffalse
%</tabulary>
% \fi
%
%
%
% \iffalse
%<*textarea>
% \fi
%
% \part{lwarp-textarea.sty}
%
% \section{textarea}
%
% \credits{Alexander I. Rozhenko}
%
% \DescribePackage{textarea}
% \pkg{textarea} is emulated.
%
% \changes{v0.39}{2017/08/27}{\pkg{textarea}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{textarea}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand\StartFromTextArea{}
\newcommand\StartFromHeaderArea{}
\newcommand*\RestoreTextArea{}
\newcommand*\ExpandTextArea[1][*]{}
\let\NCC@restoretextarea\@empty
%    \end{macrocode}
%
% \iffalse
%</textarea>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*textcomp>
% \fi
%
% \part{lwarp-textcomp.sty}

% \section{textcomp}
%
% \credits{Frank Mittelbach, Robin Fairbairns, Werner Lemberg}

%
% \DescribePackage{textcomp}
% \pkg{textcomp} is patched for use by \pkg{lwarp}.
%
% \subsection{Limitations}
%
% \limitstextcomp
%
%
% \subsection{Package loading}
%
% \changes{v0.37}{2017/08/18}{\pkg{textcomp}: Improved support.}
% \changes{v0.38}{2017/08/21}{\pkg{textcomp}: Removed from \pkg{lwarp} core.}
% \changes{v0.40}{2017/09/07}{\pkg{textcomp}: Additional symbols,
%       improved XeLaTeX and LuaLaTeX support.}
% \changes{v0.42}{2017/10/13}{\pkg{textcomp}: Improved \cs{interrobangdown}.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{textcomp}
%    \end{macrocode}
%
%
% \subsection{Remembering original defintions}
%
% The following are restored for print when inside a \env{lateximage}:
%    \begin{macrocode}
\let\LWR@origtextdegree\textdegree
\let\LWR@origtextcelsius\textcelsius
\let\LWR@origtextohm\textohm
\let\LWR@origtextmu\textmu
\let\LWR@origtextlquill\textlquill
\let\LWR@origtextrquill\textrquill
\let\LWR@origtextcircledP\textcircledP
\let\LWR@origtexttwelveudash\texttwelveudash
\let\LWR@origtextthreequartersemdash\textthreequartersemdash
\let\LWR@origtextmho\textmho
\let\LWR@origtextnaira\textnaira
\let\LWR@origtextpeso\textpeso
\let\LWR@origtextrecipe\textrecipe
\let\LWR@origtextinterrobangdown\textinterrobangdown
\let\LWR@origtextpertenthousand\textpertenthousand
\let\LWR@origtextbaht\textbaht
\let\LWR@origtextdiscount\textdiscount
\let\LWR@origtextservicemark\textservicemark
\LetLtxMacro\LWR@origcapitalcedilla\capitalcedilla
\LetLtxMacro\LWR@origcapitalogonek\capitalogonek
\LetLtxMacro\LWR@origcapitalgrave\capitalgrave
\LetLtxMacro\LWR@origcapitalacute\capitalacute
\LetLtxMacro\LWR@origcapitalcircumflex\capitalcircumflex
\LetLtxMacro\LWR@origcapitaltilde\capitaltilde
\LetLtxMacro\LWR@origcapitaldieresis\capitaldieresis
\LetLtxMacro\LWR@origcapitalhungarumlaut\capitalhungarumlaut
\LetLtxMacro\LWR@origcapitalring\capitalring
\LetLtxMacro\LWR@origcapitalcaron\capitalcaron
\LetLtxMacro\LWR@origcapitalbreve\capitalbreve
\LetLtxMacro\LWR@origcapitalmacron\capitalmacron
\LetLtxMacro\LWR@origcapitaldotaccent\capitaldotaccent
\LetLtxMacro\LWR@origtextcircled\textcircled
%    \end{macrocode}
%
%
% \subsection{HTML symbols}
%
% For \HTML, use \HTML\ entities or direct Unicode, depending on the engine.
%
% \cs{AtBeginDocument} improves support for \LuaLaTeX\ and \XeLaTeX.
%
% \subsubsection{pdf\protect\LaTeX\ symbols}
%
%    \begin{macrocode}
\AtBeginDocument{
\ifPDFTeX
\renewcommand*{\textdegree}{\HTMLentity{deg}}
\renewcommand*{\textcelsius}{\HTMLunicode{2103}}
\renewcommand*{\textohm}{\HTMLunicode{2126}}
\renewcommand*{\textmu}{\HTMLunicode{00B5}}
\renewcommand*{\textlquill}{\HTMLunicode{2045}}
\renewcommand*{\textrquill}{\HTMLunicode{2046}}
\renewcommand*{\textcircledP}{\HTMLunicode{2117}}
\renewcommand*{\texttwelveudash}{\HTMLunicode{2014}}% emdash
\renewcommand*{\textthreequartersemdash}{\HTMLunicode{2014}}% emdash
\renewcommand*{\textmho}{\HTMLunicode{2127}}
\renewcommand*{\textnaira}{\HTMLunicode{20A6}}
\renewcommand*{\textpeso}{\HTMLunicode{20B1}}
\renewcommand*{\textrecipe}{\HTMLunicode{211E}}
\renewcommand*{\textinterrobangdown}{\HTMLunicode{2E18}}
\renewcommand*{\textpertenthousand}{\HTMLunicode{2031}}
\renewcommand*{\textbaht}{\HTMLunicode{0E3F}}
\renewcommand*{\textdiscount}{\%}
\renewcommand*{\textservicemark}{\HTMLunicode{2120}}
\else
%    \end{macrocode}
%
% \subsubsection{\protect\XeLaTeX\ and \protect\LuaLaTeX\ symbols}
%
% NOTE: Some of the following do not print well in the listing.
% Consult the .dtx or .sty file for the actual characters.
%    \begin{macrocode}
\renewcommand*{\textdegree}{°}
\renewcommand*{\textcelsius}{℃}
\renewcommand*{\textohm}{Ω}
\renewcommand*{\textmu}{µ}
\renewcommand*{\textlquill}{⁅}
\renewcommand*{\textrquill}{⁆}
\renewcommand*{\textcircledP}{℗}
\renewcommand*{\texttwelveudash}{—}% emdash
\renewcommand*{\textthreequartersemdash}{—}% emdash
\renewcommand*{\textmho}{℧}
\renewcommand*{\textnaira}{₦}
\renewcommand*{\textpeso}{₱}
\renewcommand*{\textrecipe}{℞}
\renewcommand*{\textinterrobangdown}{⸘}
\renewcommand*{\textpertenthousand}{‱}
\renewcommand*{\textbaht}{฿}
\renewcommand*{\textdiscount}{\%}
\renewcommand*{\textservicemark}{℠}
\fi
%    \end{macrocode}
%
%
% \subsection{HTML dicritics}
%
% For \HTML, Unicode diacritical marks are used:
%    \begin{macrocode}
\renewcommand*{\capitalcedilla}[1]{#1\HTMLunicode{0327}}
\renewcommand*{\capitalogonek}[1]{#1\HTMLunicode{0328}}
\renewcommand*{\capitalgrave}[1]{#1\HTMLunicode{0300}}
\renewcommand*{\capitalacute}[1]{#1\HTMLunicode{0301}}
\renewcommand*{\capitalcircumflex}[1]{#1\HTMLunicode{0302}}
\renewcommand*{\capitaltilde}[1]{#1\HTMLunicode{0303}}
\renewcommand*{\capitaldieresis}[1]{#1\HTMLunicode{0308}}
\renewcommand*{\capitalhungarumlaut}[1]{#1\HTMLunicode{30B}}
\renewcommand*{\capitalring}[1]{#1\HTMLunicode{30A}}
\renewcommand*{\capitalcaron}[1]{#1\HTMLunicode{30C}}
\renewcommand*{\capitalbreve}[1]{#1\HTMLunicode{306}}
\renewcommand*{\capitalmacron}[1]{#1\HTMLunicode{304}}
\renewcommand*{\capitaldotaccent}[1]{#1\HTMLunicode{307}}
%    \end{macrocode}
% \cs{textcircled} becomes a span with a rounded border:
%    \begin{macrocode}
\renewcommand*{\textcircled}[1]{%
\InlineClass[border: 1px solid \LWR@currenttextcolor]{textcircled}{#1}%
}
}% AtBeginDocument
%    \end{macrocode}
%
%
% \subsection{Inside a \env{lateximage}}
%
% When a \env{lateximage} is begun:
%    \begin{macrocode}
\appto{\LWR@restoreorigformatting}{%
\let\textdegree\LWR@origtextdegree%
\let\textcelsius\LWR@origtextcelsius%
\let\textohm\LWR@origtextohm%
\let\textmu\LWR@origtextmu%
\let\textlquill\LWR@origtextlquill%
\let\textrquill\LWR@origtextrquill%
\let\textcircledP\LWR@origtextcircledP%
\let\texttwelveudash\LWR@origtexttwelveudash%
\let\textthreequartersemdash\LWR@origtextthreequartersemdash%
\let\textmho\LWR@origtextmho%
\let\textnaira\LWR@origtextnaira%
\let\textpeso\LWR@origtextpeso%
\let\textrecipe\LWR@origtextrecipe%
\let\textinterrobangdown\LWR@origtextinterrobangdown%
\let\textpertenthousand\LWR@origtextpertenthousand%
\let\textbaht\LWR@origtextbaht%
\let\textdiscount\LWR@origtextdiscount%
\let\textservicemark\LWR@origtextservicemark%
\LetLtxMacro\capitalcedilla\LWR@origcapitalcedilla%
\LetLtxMacro\capitalogonek\LWR@origcapitalogonek%
\LetLtxMacro\capitalgrave\LWR@origcapitalgrave%
\LetLtxMacro\capitalacute\LWR@origcapitalacute%
\LetLtxMacro\capitalcircumflex\LWR@origcapitalcircumflex%
\LetLtxMacro\capitaltilde\LWR@origcapitaltilde%
\LetLtxMacro\capitaldieresis\LWR@origcapitaldieresis%
\LetLtxMacro\capitalhungarumlaut\LWR@origcapitalhungarumlaut%
\LetLtxMacro\capitalring\LWR@origcapitalring%
\LetLtxMacro\capitalcaron\LWR@origcapitalcaron%
\LetLtxMacro\capitalbreve\LWR@origcapitalbreve%
\LetLtxMacro\capitalmacron\LWR@origcapitalmacron%
\LetLtxMacro\capitaldotaccent\LWR@origcapitaldotaccent%
\LetLtxMacro\textcircled\LWR@origtextcircled%
}
%    \end{macrocode}
%
%
% \iffalse
%</textcomp>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*textpos>
% \fi

% \part{lwarp-textpos.sty}

% \section{textpos}
% \label{sec:textpos}
%
% \credits{Norman Gray}
%
% \changes{v0.20}{2017/01/11}{\pkg{textpos}: Added.}
%
% \DescribePackage{textpos}
% \pkg{textpos} is emulated.

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{textpos}
%    \end{macrocode}

%    \begin{macrocode}
\NewDocumentEnvironment{textblock}{m r()}{}{}
\NewDocumentEnvironment{textblock*}{m o r()}{}{}
\newcommand*{\TPGrid}[3][]{}
\NewDocumentCommand{\TPMargin}{s o}{}
\newcommand*{\textblockcolour}[1]{}
\newcommand*{\textblockrulecolour}[1]{}
\newcommand*{\textblockcolor}[1]{}
\newcommand*{\textblockrulecolor}[1]{}
\newcommand*{\tekstblokkulur}[1]{}
\newcommand*{\tekstblokrulekulur}[1]{}
\newlength{\TPHorizModule}
\newlength{\TPVertModule}
\newlength{\TPboxrulesize}
\newcommand{\textblocklabel}[1]{}
\newcommand*{\showtextsize}{}
\newcommand{\textblockorigin}[2]{}
%    \end{macrocode}

% \iffalse
%</textpos>
% \fi
%
%
%
%
%
%
% \iffalse
%<*theorem>
% \fi

% \part{lwarp-theorem.sty}
%
% \section{theorem}
%
% \credits{Frank Mittelbach}
%
% \DescribePackage{theorem}
% \pkg{theorem} is patched for use by \pkg{lwarp}.
%
% \changes{v0.25}{2017/03/16}{\pkg{theorem}: Added.}
%
% \begin{table}[ht]
% \hrule
% \smallskip
% \caption{Theorem package --- CSS styling of theorems and proofs}
% \begin{description}
% \item [Theorem:] \element{div} of class |theorembody<theoremstyle>|
% \item [Theorem Header:] \element{span} of class |theoremheader|
% \end{description}
% where |<theoremstyle>| is |plain|, |break|, etc.
% \smallskip
% \hrule
% \end{table}
%
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{theorem}
%    \end{macrocode}


% \subsection{Remembering the theorem style}

% Storage for the style being used for new theorems:
%    \begin{macrocode}
\newcommand{\LWR@newtheoremstyle}{plain}
%    \end{macrocode}

% Patched to remember the style being used for new theorems:
%    \begin{macrocode}
\gdef\theoremstyle#1{%
   \@ifundefined{th@#1}{\@warning
          {Unknown theoremstyle `#1'. Using `plain'}%
          \theorem@style{plain}%
           \renewcommand{\LWR@newtheoremstyle}{plain}% new
          }%
      {%
          \theorem@style{#1}%
          \renewcommand{\LWR@newtheoremstyle}{#1}% new
      }%
      \begingroup
        \csname th@\the\theorem@style \endcsname
      \endgroup}
%    \end{macrocode}

% Patched to remember the style for this theorem type,
% and set it later when the environment is started.
%    \begin{macrocode}
\gdef\@xnthm#1#2[#3]{%
   \expandafter\@ifdefinable\csname #1\endcsname
   {%
    \csedef{LWR@thmstyle#1}{\LWR@newtheoremstyle}% new
    \@definecounter{#1}\@newctr{#1}[#3]%
    \expandafter\xdef\csname the#1\endcsname
      {\expandafter \noexpand \csname the#3\endcsname
       \@thmcountersep \@thmcounter{#1}}%
    \def\@tempa{\global\@namedef{#1}}%
    \expandafter \@tempa \expandafter{%
      \csname th@\the \theorem@style
            \expandafter \endcsname \the \theorem@bodyfont
     \@thm{#1}{#2}}%
    \global \expandafter \let \csname end#1\endcsname \@endtheorem
    \AtBeginEnvironment{#1}{\edef\LWR@thisthmstyle{\csuse{LWR@thmstyle#1}}}% new
   }}

\gdef\@ynthm#1#2{%
    \expandafter\@ifdefinable\csname #1\endcsname
   {
    \csedef{LWR@thmstyle#1}{\LWR@newtheoremstyle}% new
    \@definecounter{#1}%
    \expandafter\xdef\csname the#1\endcsname{\@thmcounter{#1}}%
    \def\@tempa{\global\@namedef{#1}}\expandafter \@tempa
     \expandafter{\csname th@\the \theorem@style \expandafter
     \endcsname \the\theorem@bodyfont \@thm{#1}{#2}}%
    \global \expandafter \let \csname end#1\endcsname \@endtheorem
    \AtBeginEnvironment{#1}{\edef\LWR@thisthmstyle{\csuse{LWR@thmstyle#1}}}% new
   }}

\gdef\@othm#1[#2]#3{%
  \expandafter\ifx\csname c@#2\endcsname\relax
   \@nocounterr{#2}%
  \else
   \expandafter\@ifdefinable\csname #1\endcsname
   {
    \csedef{LWR@thmstyle#1}{\LWR@newtheoremstyle}% new
    \expandafter \xdef \csname the#1\endcsname
     {\expandafter \noexpand \csname the#2\endcsname}%
    \def\@tempa{\global\@namedef{#1}}\expandafter \@tempa
     \expandafter{\csname th@\the \theorem@style \expandafter
     \endcsname \the\theorem@bodyfont \@thm{#2}{#3}}%
    \global \expandafter \let \csname end#1\endcsname \@endtheorem
    \AtBeginEnvironment{#1}{\edef\LWR@thisthmstyle{\csuse{LWR@thmstyle#1}}}% new
    }%
  \fi}
%    \end{macrocode}
%
%
% \subsection{CSS patches}
%
% The following are patched for \CSS.
%
% These were in individual files |thp.sty| for plain,
% |thmb.sty| for margin break, etc.
% They are gathered together here.
%
% Each theorem is encased in a \env{BlockClass} environment
% of class |theorembody<style>|.
%
% Each header is encased in an \cs{InlineClass} of class |theoremheader|.
%    \begin{macrocode}
\gdef\th@plain{%\normalfont\itshape
  \def\@begintheorem##1##2{%
\LWR@forcenewpage% new
    \BlockClass{theorembody\LWR@thisthmstyle}% new
        \item[\hskip\labelsep
            \InlineClass{theoremheader}{##1\ ##2}
        ]}%
\def\@opargbegintheorem##1##2##3{%
\LWR@forcenewpage% new
    \BlockClass{theorembody\LWR@thisthmstyle}% new
   \item[\hskip\labelsep
        \InlineClass{theoremheader}{##1\ ##2\ (##3)}
    ]}
}

\gdef\th@break{%\normalfont\slshape
  \def\@begintheorem##1##2{%
\LWR@forcenewpage% new
    \BlockClass{theorembody\LWR@thisthmstyle}% new
    \item[\hskip \labelsep
        \InlineClass{theoremheader}{##1\ ##2}\newline%
    ]}%
\def\@opargbegintheorem##1##2##3{%
\LWR@forcenewpage% new
    \BlockClass{theorembody\LWR@thisthmstyle}% new
  \item[\hskip \labelsep
        \InlineClass{theoremheader}{##1\ ##2\ (##3)}\newline
    ]}
}

\gdef\th@marginbreak{%\normalfont\slshape
  \def\@begintheorem##1##2{
\LWR@forcenewpage% new
    \BlockClass{theorembody\LWR@thisthmstyle}% new
    \item[\hskip\labelsep %
        \InlineClass{theoremheader}{##2	\qquad ##1}\newline
    ]}%
\def\@opargbegintheorem##1##2##3{%
\LWR@forcenewpage% new
    \BlockClass{theorembody\LWR@thisthmstyle}% new
    \item[\hskip\labelsep %
        \InlineClass{theoremheader}{##2	\qquad ##1\ %
        (##3)}\newline
    ]}
}

\gdef\th@changebreak{%\normalfont\slshape
  \def\@begintheorem##1##2{
\LWR@forcenewpage% new
    \BlockClass{theorembody\LWR@thisthmstyle}% new
    \item[\hskip\labelsep
        \InlineClass{theoremheader}{##2\ ##1}\newline
    ]}%
\def\@opargbegintheorem##1##2##3{%
\LWR@forcenewpage% new
    \BlockClass{theorembody\LWR@thisthmstyle}% new
    \item[\hskip\labelsep
        \InlineClass{theoremheader}{ ##2\ ##1\ %
        (##3)}\newline
    ]}
}

\gdef\th@change{%\normalfont\slshape
  \def\@begintheorem##1##2{
\LWR@forcenewpage% new
    \BlockClass{theorembody\LWR@thisthmstyle}% new
    \item[\hskip\labelsep
        \InlineClass{theoremheader}{##2\ ##1}
    ]}%
\def\@opargbegintheorem##1##2##3{%
\LWR@forcenewpage% new
    \BlockClass{theorembody\LWR@thisthmstyle}% new
    \item[\hskip\labelsep
        \InlineClass{theoremheader}{##2\ ##1\ (##3)}
    ]}
}

\gdef\th@margin{%\normalfont\slshape
  \def\@begintheorem##1##2{
\LWR@forcenewpage% new
    \BlockClass{theorembody\LWR@thisthmstyle}% new
    \item[\hskip\labelsep
        \InlineClass{theoremheader}{##2 \qquad ##1}
    ]}%
\def\@opargbegintheorem##1##2##3{%
\LWR@forcenewpage% new
    \BlockClass{theorembody\LWR@thisthmstyle}% new
    \item[\hskip\labelsep
            \InlineClass{theoremheader}{##2 \qquad ##1\ (##3)}
    ]}
}
%    \end{macrocode}
%
% Patched for \CSS:
%    \begin{macrocode}
\gdef\@endtheorem{\endBlockClass\endtrivlist}
%    \end{macrocode}
%
% \iffalse
%</theorem>
% \fi
%
%
%
%
%
% \iffalse
%<*threeparttable>
% \fi

% \part{lwarp-threeparttable.sty}

% \section{threeparttable}
% \label{sec:threeparttable}
%
% \credits{Donald Arseneau}
%
% \DescribePackage{threeparttable}
% \pkg{threeparttable} is emulated.
%
% Table note are contained inside a \CSS\ \element{div} of class |tnotes|.
% If \pkg{enumitem} is used, the
% note item labels are also individually
% highlighted with an additional \CSS\ \element{span} of class |tnoteitemheader|,
% otherwise they are plain text.

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{threeparttable}
%    \end{macrocode}



% \begin{noindmacro}{\LWR@printtablenote} \marg{text}
%
% Prints the table note item header inside a \CSS\ class of |tnoteitemheader|.
%    \begin{macrocode}
\newcommand{\LWR@printtablenote}[1]{\InlineClass{tnoteitemheader}{#1}}
%    \end{macrocode}
% \end{noindmacro}



% \begin{noindenvironment}{threeparttable} \oarg{alignment}
% To emulate threeparttable:
%    \begin{macrocode}
\newenvironment*{threeparttable}[1][b]{}{}
%    \end{macrocode}
% \end{noindenvironment}

% \begin{noindenvironment}{tablenotes} \oarg{options}
% \changes{v0.19}{2016/06/01}{CSS for table note item.}
%    \begin{macrocode}
\newenvironment*{tablenotes}[1][]
{%
\LWR@forcenewpage
\BlockClass{tnotes}%
\ltx@ifpackageloaded{enumitem}{%
\setlist[description]{format=\LWR@printtablenote}%
}{}%
\description%
}
{%
\enddescription%
\endBlockClass%
}
%    \end{macrocode}
% \end{noindenvironment}
%
% \begin{noindmacro}{\tnote} \marg{text}
%    \begin{macrocode}
\newcommand{\tnote}[1]{\LWR@htmlspan{sup}{#1}}
%    \end{macrocode}
% \end{noindmacro}

% \iffalse
%</threeparttable>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*tikz>
% \fi

% \part{lwarp-tikz.sty}
%
% \section{tikz}
%
% \credits{Till Tantau}
%
% \DescribePackage{tikz}
% \pkg{tikz} is supported.
%
% \changes{v0.24}{2017/03/11}{\pkg{tikz}: For tikz v3.0.0 or later,
%	auto-loads tikz babel library if necessary.}
%
% Accept all options for \pkg{lwarp-tikz}:
%    \begin{macrocode}
\LWR@ProvidesPackagePass{tikz}
%    \end{macrocode}


% \pkg{lwarp} changes the catcode of |$| for its own use.
% \margintag{catcodes}
% The \tikz{} |babel| library temporarily changes catcodes
% back to normal for \tikz's use.
% \index{tikz>dollar redefined}
% \index{tikz>catcodes}
% \pkg{tikz} v3.0.0 introduced the |babel| library which handles catcode changes.
% For older versions, \pkg{lwarp} must change |$|'s catcode itself.
%
% Also see:\\
%	\href{https://tex.stackexchange.com/questions/16199/test-if-a-package-or-package-option-is-loaded}
%	{https://tex.stackexchange.com/questions/16199/\\
%		\hspace*{2em}test-if-a-package-or-package-option-is-loaded}


% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

%    \begin{macrocode}
\newboolean{LWR@tikzbabel}

\@ifpackagelater{tikz}{2013/12/20}% Test for Tikz version v3.0.0
{\usetikzlibrary{babel}\booltrue{LWR@tikzbabel}}
{\boolfalse{LWR@tikzbabel}}
%    \end{macrocode}


% \begin{environment}{tikzpicture}
% |tikzpicture| environment is enclosed inside a |\lateximage|.
% May be used as-is, and its contents will be converted to an image.
%
% \changes{v0.13}{2016/03/23}{Fix dollar-redefined bug for newer package.}
% \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.}
%
%    \begin{macrocode}
\BeforeBeginEnvironment{tikzpicture}{%
\begin{lateximage}%
\ifbool{LWR@tikzbabel}% Test for Tikz version v3.0.0
{}%
{\catcode`\$=3} % dollar sign is math shift
}

\AfterEndEnvironment{tikzpicture}{%
\end{lateximage}%
\ifbool{LWR@tikzbabel}% Test for Tikz version v3.0.0
{}%
{\catcode`\$=\active}%
}
%    \end{macrocode}
% \end{environment}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}

% \iffalse
%</tikz>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*titleps>
% \fi

% \part{lwarp-titleps.sty}

% \section{titleps}
%
% \credits{Javier Bezos}
%
% \DescribePackage{titleps}
% \pkg{titleps} is loaded and used by \pkg{lwarp} during \HTML\ output.
% All user options and macros are ignored and disabled.
%
% \changes{v0.19}{2016/05/27}{titleps: null \cs{pagestyle} and \cs{thispagestyle} for HTML.}
% \changes{v0.20}{2017/01/03}{\pkg{titleps}: Added.}
% \changes{v0.34}{2017/08/03}{\pkg{titleps}: No longer required.}
%
%
% Discard all options for \pkg{lwarp-titleps}:
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{titleps}
%    \end{macrocode}
%
% \cs{pagestyle} and \cs{thispagestyle} are already disabled in the \pkg{lwarp} code.
%
% \begin{noindmacro}{\newpagestyle} \marg{name} \oarg{style} \marg{commands}
%    \begin{macrocode}
\NewDocumentCommand{\newpagestyle}{m o m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\renewpagestyle} \marg{name} \oarg{style} \marg{commands}
%    \begin{macrocode}
\NewDocumentCommand{\renewpagestyle}{m o m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\sethead} \oarg{el} \oarg{ec} \oarg{er} \marg{ol} \marg{oc} \marg{or}
%    \begin{macrocode}
\NewDocumentCommand{\sethead}{o o o m m m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\setfoot} \oarg{el} \oarg{ec} \oarg{er} \marg{ol} \marg{oc} \marg{or}
%    \begin{macrocode}
\NewDocumentCommand{\setfoot}{o o o m m m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\settitlemarks} * \marg{names}
%    \begin{macrocode}
\NewDocumentCommand{\settitlemarks}{s m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\headrule}
%    \begin{macrocode}
\newcommand*{\headrule}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\footrule}
%    \begin{macrocode}
\newcommand*{\footrule}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\setheadrule} \marg{length}
%    \begin{macrocode}
\newcommand*{\setheadrule}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\setfootrule} \marg{length}
%    \begin{macrocode}
\newcommand*{\setfootrule}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\makeheadrule}
%    \begin{macrocode}
\newcommand*{\makeheadrule}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\makefootrule}
%    \begin{macrocode}
\newcommand*{\makefootrule}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\setmarkboth} \marg{code}
%    \begin{macrocode}
\newcommand{\setmarkboth}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\widenhead}
%    \begin{macrocode}
\NewDocumentCommand{\widenhead}{s o o m m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\bottitlemarks}
%    \begin{macrocode}
\newcommand*{\bottitlemarks}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\toptitlemarks}
%    \begin{macrocode}
\newcommand*{\toptitlemarks}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\firsttitlemarks}
%    \begin{macrocode}
\newcommand*{\firsttitlemarks}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\nexttitlemarks}
%    \begin{macrocode}
\newcommand*{\nexttoptitlemarks}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\outertitlemarks}
%    \begin{macrocode}
\newcommand*{\outertitlemarks}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\innertitlemarks}
%    \begin{macrocode}
\newcommand*{\innertitlemarks}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\newtitlemark} * \marg{name}
%    \begin{macrocode}
\NewDocumentCommand{\newtitlemark}{s m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\pretitlemark} * \marg{section} \marg{text}
%    \begin{macrocode}
\NewDocumentCommand{\pretitlemark}{s m m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\ifsamemark} \marg{group} \marg{command} \marg{true} \marg{false}
%    \begin{macrocode}
\newcommand{\ifsamemark}[4]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\setfloathead} * \oarg{.} \oarg{.} \oarg{.} \marg{.} \marg{.} \marg{.} \marg{extra} \oarg{which}
%    \begin{macrocode}
\NewDocumentCommand{\setfloathead}{s o o o m m m m m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\setfloatfoot} * \oarg{.} \oarg{.} \oarg{.} \marg{.} \marg{.} \marg{.} \marg{extra} \oarg{which}
%    \begin{macrocode}
\NewDocumentCommand{\setfloatfoot}{s o o o m m m m m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\nextfloathead} * \oarg{.} \oarg{.} \oarg{.} \marg{.} \marg{.} \marg{.} \marg{extra} \oarg{which}
%    \begin{macrocode}
\NewDocumentCommand{\nextfloathead}{s o o o m m m m m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\nextfloatfoot} * \oarg{.} \oarg{.} \oarg{.} \marg{.} \marg{.} \marg{.} \marg{extra} \oarg{which}
%    \begin{macrocode}
\NewDocumentCommand{\nextfloatfoot}{s o o o m m m m m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\newmarkset} \marg{markset}
%    \begin{macrocode}
\newcommand{\newmarkset}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\newextramark} * \marg{markset} \marg{macro-name}
%    \begin{macrocode}
\NewDocumentCommand{\newextramarkset}{s m m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\botextramarks} \marg{markset}
%    \begin{macrocode}
\newcommand{\botextramarks}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\topextramarks} \marg{markset}
%    \begin{macrocode}
\newcommand{\topextramarks}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\firstextramarks} \marg{markset}
%    \begin{macrocode}
\newcommand{\firstextramarks}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\nextextramarks} \marg{markset}
%    \begin{macrocode}
\newcommand{\nexttopextramarks}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\outerextramarks} \marg{markset}
%    \begin{macrocode}
\newcommand{\outerextramarks}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\innerextramarks} \marg{markset}
%    \begin{macrocode}
\newcommand{\innerextramarks}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \iffalse
%</titleps>
% \fi
%
%
%
%
%
%
%
%
% \iffalse
%<*titleref>
% \fi
%
% \part{lwarp-titleref.sty}
%
% \section{titleref}
%
% \DescribePackage{titleref}
% \pkg{titleref} is superceded by \pkg{hyperref} and \pkg{nameref}.
%
% \changes{v0.34}{2017/07/26}{\pkg{titleref}: Prevented.}
%
% \codehtml
%    \begin{macrocode}
\LWR@loadnever{titleref}{hyperref and nameref}
%    \end{macrocode}
%
% \iffalse
%</titleref>
% \fi
%
%
%
%
%
%
%
%
% \iffalse
%<*titlesec>
% \fi

% \part{lwarp-titlesec.sty}

% \section{titlesec}
%
% \credits{Javier Bezos}
%
% \DescribePackage{titlesec}
% \pkg{titlesec} is emulated.
% All user options and macros are ignored and disabled.

% \changes{v0.20}{2017/01/03}{\pkg{titlesec}: Added.}
%
%
% Discard all options for \pkg{lwarp-titlesec}:

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{titlesec}
%    \end{macrocode}

% \begin{noindmacro}{\titlelabel} \marg{label-format}
%    \begin{macrocode}
\newcommand*{\titlelabel}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\titleformat*} \marg{command} \marg{format}
%
% \begin{noindmacro}{\titleformat} \marg{command} \oarg{shape} \marg{format}
%						\marg{label} \marg{sep} \marg{begfore} \oarg{after}
%    \begin{macrocode}
\newcommand\titleformat{%
  \@ifstar{\ttl@format@s}%
          {\ttl@format@i}}
\newcommand{\ttl@format@s}[1]{}
\NewDocumentCommand{\ttl@format@i}{m o m m m m o}{}
%    \end{macrocode}
% \end{noindmacro}
% \end{noindmacro}

% \begin{noindmacro}{\chaptertitlename}
%    \begin{macrocode}
\@ifundefined{@chapapp}{\let\@chapapp\chaptername}{}
\newcommand\chaptertitlename{\@chapapp}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\titlespacing} * \marg{command} \marg{left} \marg{before} \marg{after} \oarg{right}
%
%    \begin{macrocode}
\NewDocumentCommand{\titlespacing}{s m m m m o}{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\filright}
%    \begin{macrocode}
\newcommand*{\filright}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\filcenter}
%    \begin{macrocode}
\newcommand*{\filcenter}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\filleft}
%    \begin{macrocode}
\newcommand*{\filleft}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\fillast}
%    \begin{macrocode}
\newcommand*{\fillast}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\filinner}
%    \begin{macrocode}
\newcommand*{\filinner}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\filouter}
%    \begin{macrocode}
\newcommand*{\filouter}{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\wordsep}
%    \begin{macrocode}
\newcommand\wordsep{\fontdimen\tw@\font \@plus
  \fontdimen\thr@@\font \@minus \fontdimen4\font}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\titleline} * \oarg{align} \marg{material}
%    \begin{macrocode}
\NewDocumentCommand{\titleline}{s o m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\titlerule} \oarg{height}
%    \begin{macrocode}
\providecommand*\titlerule{\@ifstar{\ttl@row}{\ttl@rule}}
\newcommand*{\ttl@rule}[1][]{}
\newcommand*{\ttl@row}[2][]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\iftitlemeasuring} \marg{true} \marg{false}
%    \begin{macrocode}
\newcommand{\iftitlemeasuring}[2]{#2}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\assignpagestyle} \marg{command} \marg{pagestyle}
%    \begin{macrocode}
\newcommand{\assignpagestyle}[2]{#2}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\titleclass} \marg{name} \oarg{startlevel} \marg{class} \oarg{cmd}
%    \begin{macrocode}
\NewDocumentCommand{\titleclass}{m o m o}
%    \end{macrocode}
% \end{noindmacro}

% \iffalse
%</titlesec>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*titletoc>
% \fi

% \part{lwarp-titletoc.sty}

% \section{titletoc}
%
% \credits{Javier Bezos}
%
% \DescribePackage{titletoc}
% \pkg{titletoc} is emulated.
% All user options and macros are ignored and disabled.

% \changes{v0.20}{2017/01/03}{\pkg{titletoc}: Added.}
%
%
% Discard all options for \pkg{lwarp-titletoc}:

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{titletoc}
%    \end{macrocode}
%

% \begin{noindmacro}{\dottedcontents} \marg{section} \oarg{left} \marg{above} \marg{label} \marg{leader}
%    \begin{macrocode}
\NewDocumentCommand{\dottedcontents}{m o m m m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\titlecontents} * \marg{section} \oarg{left} \marg{above}
%		\marg{numbered} \marg{numberless} \marg{filler}
%		\oarg{below or begin} \oarg{separator} \oarg{end}
%    \begin{macrocode}
\newcommand{\titlecontents}{\@ifstar{\ttl@tcstar}{\ttl@tcnostar}}
\NewDocumentCommand{\ttl@tcstar}{m o m m m m o o o}{}
\NewDocumentCommand{\ttl@tcnostar}{m o m m m m o}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\contentsmargin} \oarg{correction} \marg{right}
%    \begin{macrocode}
\newcommand{\contentsmargin}[2][]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\thecontentslabel}
%    \begin{macrocode}
\newcommand*{\thecontentslabel}{thecontentslabel}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\thecontentspage}
%    \begin{macrocode}
\newcommand*{\thecontentspage}{thecontentspage}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\contentslabel} \oarg{format} \marg{space}
%    \begin{macrocode}
\newcommand{\contentslabel}[2][]{\thecontentslabel}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\contentspage} \oarg{format}
%    \begin{macrocode}
\newcommand{\contentspage}[1][]{\thecontentspage}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\contentspush} \marg{text}
%    \begin{macrocode}
\newcommand{\contentspush}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\contentsuse} \marg{name} \marg{text}
%    \begin{macrocode}
\newcommand{\contentsuse}[2]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\startcontents} \oarg{name}
%    \begin{macrocode}
\newcommand*{\startcontents}[1][]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\stopcontents} \oarg{name}
%    \begin{macrocode}
\newcommand*{\stopcontents}[1][]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\resumecontents} \oarg{name}
%    \begin{macrocode}
\newcommand*{\resumecontents}[1][]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\printcontents} \oarg{name} \marg{prefix} \marg{start} \marg{code}
%    \begin{macrocode}
\newcommand{\printcontents}[4][]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\startlist} \oarg{name} \marg{list}
%    \begin{macrocode}
\newcommand{\startlist}[2][]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\stoplist} \oarg{name} \marg{list}
%    \begin{macrocode}
\newcommand{\stoplist}[2][]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\resumelist} \oarg{name} \marg{list}
%    \begin{macrocode}
\newcommand{\resumelist}[2][]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\printlist} \oarg{name} \marg{list} \marg{prefix} \marg{code}
%    \begin{macrocode}
\newcommand{\printlist}[4][]{}
%    \end{macrocode}
% \end{noindmacro}


% \iffalse
%</titletoc>
% \fi
%
%
%
%
%
%
% \iffalse
%<*titling>
% \fi

% \part{lwarp-titling.sty}

% \section{titling}
%
% \credits{Peter Wilson}
%
% \DescribePackage{titling}
%
% \limitstitlepage
%
% The various \pkg{titling} footnote restyling commands have no effect.
%
% \changes{v0.20}{2017/01/22}{\pkg{titling}: Improved compatibility.}
% \changes{v0.39}{2017/09/05}{\pkg{titling}: Improved compatibility.}
%
% Pass all options to \pkg{lwarp-titling}:

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{titling}
%    \end{macrocode}
%
%
% Patch \cs{@bsmtitlempty}:
% \marginpar{\hfill\cs{@bsmtitlempty}}
%    \begin{macrocode}
\let\LWR@orig@bsmtitlempty\@bsmtitlempty
\renewcommand*{\@bsmtitlempty}{%
\LWR@orig@bsmtitlempty%
}
%    \end{macrocode}
%
%
% Patch \cs{keepthetitle}:
% \marginpar{\hfill\cs{keepthetitle}}
%    \begin{macrocode}
\let\LWR@origkeepthetitle\keepthetitle
\renewcommand*{\keepthetitle}{%
\LWR@orig@keepthetitle%
}
%    \end{macrocode}
%
%
% Patch \cs{killtitle}:
% \marginpar{\hfill\cs{killtitle}}
%    \begin{macrocode}
\let\LWR@origkilltitle\killtitle
\renewcommand*{\killtitle}{%
\LWR@orig@killtitle%
}
%    \end{macrocode}
%
%
%
% \begin{environment}{titlingpage}
%
% \changes{v0.39}{2017/09/02}{Clear pending footnotes.}
%    \begin{macrocode}
\renewenvironment*{titlingpage}
{%
%    \end{macrocode}
% Start an \HTML\ titlepage div:
%    \begin{macrocode}
\LWR@printpendingfootnotes
\begin{titlepage}
%    \end{macrocode}
% Prepare for a custom version of \cs{maketitle} inside the \env{titlingpage}:
%    \begin{macrocode}
\LWR@maketitlesetup
\let\maketitle\LWR@titlingmaketitle
}
{
%    \end{macrocode}
% At the end of the environment,
% end the \HTML\ titlepage div:
%    \begin{macrocode}
\end{titlepage}
}
%    \end{macrocode}
% \end{environment}
%
%
%
% Patch the pre/post title/author/date to add \HTML\ tags,
% then initilize:
%
% \changes{v0.39}{2017/09/03}{\pkg{titling}: Removed extraneous \protect\env{center} environments.}
%    \begin{macrocode}

\pretitle{}
\posttitle{}

\preauthor{}
\postauthor{}

\predate{}
\postdate{}
%    \end{macrocode}
%
%
%
%\begin{macro}{\LWR@maketitlesetup} Patches \cs{thanks} macros.
%
%    \begin{macrocode}
\renewcommand*{\LWR@maketitlesetup}{%
%    \end{macrocode}
%
% Redefine the footnote mark:
%
%    \begin{macrocode}
\def\@makefnmark{\textsuperscript{\@thefnmark}}
%    \end{macrocode}
%
% \begin{center}
% \begin{minipage}{.7\linewidth}
% \cs{thefootnote} \goesto\ \cs{nameuse}\{arabic\}\{footnote\}, or
%
% \cs{thefootnote} \goesto\  \cs{nameuse}\{fnsymbol\}\{footnote\}
% \end{minipage}
% \end{center}
%
% Redefine the footnote text:
%
%    \begin{macrocode}
\long\def\@makefntext##1{%
%    \end{macrocode}
% Make the footnote mark and some extra horizontal space for the tags:
%    \begin{macrocode}
\makethanksmark \LWR@orighspace{1in}
%    \end{macrocode}
% \begin{center}
% \begin{minipage}{.7\linewidth}
% \cs{makethanksmark} \goesto\  \cs{thanksfootmark} \goesto\  \cs{tamark} \goesto\
%
% \hfill \cs{@thefnmark} \goesto\  \cs{itshape} a (or similar)
% \end{minipage}
% \end{center}
%
% Print the text:
%    \begin{macrocode}
##1%
}%
}
%    \end{macrocode}
% \end{macro}
%
%
%\begin{macro}{\maketitle}
%   \HTML\ mode.
%   Creates an \HTML\ titlepage div
%   and typesets the title, etc.
%
% Code from the \pkg{titling} package is adapted, simplified, and
% modified for \HTML\ output.
%
%    \begin{macrocode}
\renewcommand*{\maketitle}{%
%    \end{macrocode}
% An \HTML\ titlepage \element{div} is used for all classes.
%    \begin{macrocode}
\begin{titlepage}
%    \end{macrocode}
% Select which kind of footnote marks to use:
%    \begin{macrocode}
\@bsmarkseries
%    \end{macrocode}
% Set up special patches:
%    \begin{macrocode}
\LWR@maketitlesetup
%    \end{macrocode}
% Typeset the title, etc:
%    \begin{macrocode}
\@maketitle
%    \end{macrocode}
% Immediately generate any |\thanks| footnotes:
%    \begin{macrocode}
\@thanks
%    \end{macrocode}
% Close the \HTML\ titlepage div:
%    \begin{macrocode}
\end{titlepage}
%    \end{macrocode}
% Reset the footnote counter:
%    \begin{macrocode}
\@bscontmark
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@maketitle}
%  Typesets the title, etc.  Patched for \HTML.
%
% \changes{v0.39}{2017/09/01}{Supports \protect\pkg{authblk} with
% \element{div}s of class \attribute{oneauthor} instead of tabular.}
% \changes{v0.39}{2017/09/03}{Removed minipages.}
% \changes{v0.39}{2017/09/04}{\pkg{titling} version.}
%
%    \begin{macrocode}
\DeclareDocumentCommand{\@maketitle}{}{%
    \maketitlehooka
    {
        \LWR@stoppars\LWR@htmltag{\LWR@tagtitle}
        \@bspretitle \@title \@bsposttitle
        \LWR@htmltag{\LWR@tagtitleend}\LWR@startpars
    }
    \maketitlehookb
    {
        \begin{BlockClass}{author}
        \renewcommand{\and}{
            \end{BlockClass}
            \begin{BlockClass}{oneauthor}
        }
        \begin{BlockClass}{oneauthor}
        \@bspreauthor \@author  \@bspostauthor
        \end{BlockClass}
        \end{BlockClass}
    }
    \maketitlehookc
    {
        \begin{BlockClass}{titledate}
        \@bspredate \@date \@bspostdate
        \end{BlockClass}
    }
    \maketitlehookd
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@titlingmaketitle}
% \cs{maketitle} for use inside an \HTML\ \env{titlingpage} environment.
%    \begin{macrocode}
\renewcommand*{\LWR@titlingmaketitle}{%
%    \end{macrocode}
% Keep pending footnotes out of the title block:
%    \begin{macrocode}
\@thanks
%    \end{macrocode}
% Select which kind of footnote marks to use:
%    \begin{macrocode}
\@bsmarkseries
%    \end{macrocode}
% Set up special patches:
%    \begin{macrocode}
\LWR@maketitlesetup
%    \end{macrocode}
% Typeset the title, etc:
%    \begin{macrocode}
\@maketitle
%    \end{macrocode}
% Immediately generate any |\thanks| footnotes:
%    \begin{macrocode}
\@thanks
%    \end{macrocode}
% Reset the footnote counter:
%    \begin{macrocode}
\@bscontmark
}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\thanksmarkseries} \marg{series}
% \changes{v0.39}{2017/09/03}{Removed minipage footnotes.}
%
% Sets the type of footnote marks used by |\thanks|,
% where type is `arabic', `roman', `fnsymbol', etc.
%    \begin{macrocode}
\renewcommand{\thanksmarkseries}[1]{%
\def\@bsmarkseries{\renewcommand{\thefootnote}{\@nameuse{#1}{footnote}}}%
}
%    \end{macrocode}
% \end{macro}
%
%
% Set default titlepage thanks footnote marks.  See \cref{sec:titlehtml}.
%    \begin{macrocode}
\if@titlepage
   \thanksmarkseries{arabic}
\else
   \thanksmarkseries{fnsymbol}
\fi
%    \end{macrocode}
%
%
%
% \iffalse
%</titling>
% \fi
%
%
%
%
%
%
% \iffalse
%<*tocbasic>
% \fi
%
% \part{lwarp-tocbasic.sty}

% \section{tocbasic}
%
% \credits{Markus Kohm}
%
% \DescribePackage{tocbasic}
% \pkg{tocbasic} is patched for use by \pkg{lwarp}.
%
% \usedbykomascript
%
% \changes{v0.44}{2017/11/20}{\pkg{tocbasic}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{tocbasic}
%    \end{macrocode}

%    \begin{macrocode}
\DeclareDocumentCommand{\usetocbasicnumberline}{o}{}
\DeclareDocumentCommand{\DeclareTOCStyleEntry}{o m m}{}
\DeclareDocumentCommand{\DeclareTOCEntryStyle}{m o m}{}
\DeclareDocumentCommand{\DefineTOCEntryOption}{m o m}{}
\DeclareDocumentCommand{\DefineTOCEntryBooleanOption}{m o m m m}{}
\DeclareDocumentCommand{\DefineTOCEntryCommandOption}{m o m m m}{}
\DeclareDocumentCommand{\DefineTOCEntryIfOption}{m o m m m}{}
\DeclareDocumentCommand{\DefineTOCEntryLengthOption}{m o m m m}{}
\DeclareDocumentCommand{\DefineTOCEntryNumberOption}{m o m m m}{}
\DeclareDocumentCommand{\CloneTOCEntryStyle}{m m}{}
\DeclareDocumentCommand{\TOCEntryStyleInitCode}{m m}{}
\DeclareDocumentCommand{\TOCEntryStyleStartInitCode}{m m}{}
%    \end{macrocode}

% \iffalse
%</tocbasic>
% \fi
%
%
%
%
% \iffalse
%<*tocbibind>
% \fi
%
% \part{lwarp-tocbibind.sty}

% \section{tocbibind}
% \label{sec:tocbibind}
%
% \credits{Peter Wilson}
%
% \DescribePackage{tocbibind}
% \pkg{tocbibind} is patched for use by \pkg{lwarp}.
%
% \limitsindex
%
% \changes{v0.38}{2017/08/22}{\pkg{tocbibind}: Added.}
% \changes{v0.40}{2017/09/12}{\pkg{tocbibind}: Improved for \cs{simplechapter}.}
%
% \codehtml
%
%    \begin{macrocode}
\let\simplechapterdelim\relax

\LWR@ProvidesPackagePass{tocbibind}
%    \end{macrocode}

%    \begin{macrocode}
\renewenvironment{theindex}%
{%
     \if@bibchapter
        \if@donumindex
            \chapter{\indexname}
        \else
          \if@dotocind
            \chapter*{\indexname}
            \addcontentsline{toc}{chapter}{\indexname}
          \else
            \chapter*{\indexname}
          \fi
        \fi
     \else
        \if@donumindex
            \section{\indexname}
        \else
          \if@dotocind
            \section*{\indexname}
            \addcontentsline{toc}{\@tocextra}{\indexname}
          \else
            \section*{\indexname}
          \fi
        \fi
     \fi
\let\item\LWR@indexitem%
\let\subitem\LWR@indexsubitem%
\let\subsubitem\LWR@indexsubsubitem%
}{}
%    \end{macrocode}
%
% The following code is shared by \pkg{anonchap}.
%
%    \begin{macrocode}
\renewcommand{\simplechapter}[1][\@empty]{%
    \def\@chapcntformat##1{%
        #1~\csname the##1\endcsname\simplechapterdelim\protect\quad%
    }%
}

\renewcommand{\restorechapter}{%
\let\@chapcntformat\@seccntformat%
}
%    \end{macrocode}
%
% \iffalse
%</tocbibind>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*tocloft>
% \fi

% \part{lwarp-tocloft.sty}

% \section{tocloft}
%
% \credits {Peter Wilson}
%
% \DescribePackage{tocloft}
% \pkg{tocloft} is emulated.
% Most user options and macros are ignored and disabled.
% \cs{newlistof} and \cs{cftchapterprecis} are supported.
%
% \limitstocloft
%
% \changes{v0.20}{2017/01/03}{\pkg{tocloft}: Added.}
%
%
% Discard all options for \pkg{lwarp-tocloft}:

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{tocloft}
%    \end{macrocode}
%

% \begin{noindmacro}{\tocloftpagestyle} \marg{style}
%    \begin{macrocode}
\newcommand{\tocloftpagestyle}[1]{}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\cftmarktoc}
%    \begin{macrocode}
\newcommand*{\cftmarktoc}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cfttoctitlefont}
%    \begin{macrocode}
\newcommand*{\cfttoctitlefont}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftaftertoctitle}
%    \begin{macrocode}
\newcommand*{\cftaftertoctitle}{}
%    \end{macrocode}
% \end{noindmacro}

%    \begin{macrocode}
\newlength{\cftbeforetoctitleskip}
\newlength{\cftaftertoctitleskip}
%    \end{macrocode}


% \begin{noindmacro}{\cftmarklof}
%    \begin{macrocode}
\newcommand*{\cftmarklof}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftloftitlefont}
%    \begin{macrocode}
\newcommand*{\cftloftitlefont}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftafterloftitle}
%    \begin{macrocode}
\newcommand*{\cftafterloftitle}{}
%    \end{macrocode}
% \end{noindmacro}

%    \begin{macrocode}
\newlength{\cftbeforeloftitleskip}
\newlength{\cftafterloftitleskip}
%    \end{macrocode}


% \begin{noindmacro}{\cftmarklot}
%    \begin{macrocode}
\newcommand*{\cftmarklot}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftlottitlefont}
%    \begin{macrocode}
\newcommand*{\cftlottitlefont}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftafterlottitle}
%    \begin{macrocode}
\newcommand*{\cftafterlottitle}{}
%    \end{macrocode}
% \end{noindmacro}

%    \begin{macrocode}
\newlength{\cftbeforelottitleskip}
\newlength{\cftafterlottitleskip}
%    \end{macrocode}


% \begin{noindmacro}{\cftdot}
%    \begin{macrocode}
\newcommand*{\cftdot}{.}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftdotsep}
%    \begin{macrocode}
\providecommand*{\cftdotsep}{1}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftnodots}
%    \begin{macrocode}
\newcommand*{\cftnodots}{5000}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftdotfill} \marg{sep}
%    \begin{macrocode}
\providecommand{\cftdotfill}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftsetpnumwidth} \marg{length}
%    \begin{macrocode}
\newcommand*{\cftsetpnumwidth}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftsetrmarg} \marg{length}
%    \begin{macrocode}
\newcommand*{\cftsetrmarg}[1]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftpnumalign} \marg{alignment}
%    \begin{macrocode}
\newcommand*{\cftpnumalign}[1]{}
%    \end{macrocode}
% \end{noindmacro}

%    \begin{macrocode}
\newlength{\cftparskip}
%    \end{macrocode}



%    \begin{macrocode}
\newlength{\cftbeforepartskip}
\newlength{\cftpartindent}
\newlength{\cftpartnumwidth}
\newcommand*{\cftpartfont}{}
\newcommand*{\cftpartpresnum}{}
\newcommand*{\cftpartaftersnum}{}
\newcommand*{\cftpartaftersnumb}{}
\newcommand*{\cftpartleader}{}
\newcommand*{\cftpartdotsep}{1}
\newcommand*{\cftpartpagefont}{}
\newcommand*{\cftpartafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\newlength{\cftbeforechapskip}
\newlength{\cftchapindent}
\newlength{\cftchapnumwidth}
\newcommand*{\cftchapfont}{}
\newcommand*{\cftchappresnum}{}
\newcommand*{\cftchapaftersnum}{}
\newcommand*{\cftchapaftersnumb}{}
\newcommand*{\cftchapleader}{}
\newcommand*{\cftchapdotsep}{1}
\newcommand*{\cftchappagefont}{}
\newcommand*{\cftchapafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\newlength{\cftbeforesecskip}
\newlength{\cftsecindent}
\newlength{\cftsecnumwidth}
\newcommand*{\cftsecfont}{}
\newcommand*{\cftsecpresnum}{}
\newcommand*{\cftsecaftersnum}{}
\newcommand*{\cftsecaftersnumb}{}
\newcommand*{\cftsecleader}{}
\newcommand*{\cftsecdotsep}{1}
\newcommand*{\cftsecpagefont}{}
\newcommand*{\cftsecafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\newlength{\cftbeforesubsecskip}
\newlength{\cftsubsecindent}
\newlength{\cftsubsecnumwidth}
\newcommand*{\cftsubsecfont}{}
\newcommand*{\cftsubsecpresnum}{}
\newcommand*{\cftsubsecaftersnum}{}
\newcommand*{\cftsubsecaftersnumb}{}
\newcommand*{\cftsubsecleader}{}
\newcommand*{\cftsubsecdotsep}{1}
\newcommand*{\cftsubsecpagefont}{}
\newcommand*{\cftsubsecafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\newlength{\cftbeforesubsubsecskip}
\newlength{\cftsubsubsecindent}
\newlength{\cftsubsubsecnumwidth}
\newcommand*{\cftsubsubsecfont}{}
\newcommand*{\cftsubsubsecpresnum}{}
\newcommand*{\cftsubsubsecaftersnum}{}
\newcommand*{\cftsubsubsecaftersnumb}{}
\newcommand*{\cftsubsubsecleader}{}
\newcommand*{\cftsubsubsecdotsep}{1}
\newcommand*{\cftsubsubsecpagefont}{}
\newcommand*{\cftsubsubsecafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\newlength{\cftbeforeparaskip}
\newlength{\cftparaindent}
\newlength{\cftparanumwidth}
\newcommand*{\cftparafont}{}
\newcommand*{\cftparapresnum}{}
\newcommand*{\cftparaaftersnum}{}
\newcommand*{\cftparaaftersnumb}{}
\newcommand*{\cftparaleader}{}
\newcommand*{\cftparadotsep}{1}
\newcommand*{\cftparapagefont}{}
\newcommand*{\cftparaafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\newlength{\cftbeforesubparaskip}
\newlength{\cftsubparaindent}
\newlength{\cftsubparanumwidth}
\newcommand*{\cftsubparafont}{}
\newcommand*{\cftsubparapresnum}{}
\newcommand*{\cftsubparaaftersnum}{}
\newcommand*{\cftsubparaaftersnumb}{}
\newcommand*{\cftsubparaleader}{}
\newcommand*{\cftsubparadotsep}{1}
\newcommand*{\cftsubparapagefont}{}
\newcommand*{\cftsubparaafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\newlength{\cftbeforefigskip}
\newlength{\cftfigindent}
\newlength{\cftfignumwidth}
\newcommand*{\cftfigfont}{}
\newcommand*{\cftfigpresnum}{}
\newcommand*{\cftfigaftersnum}{}
\newcommand*{\cftfigaftersnumb}{}
\newcommand*{\cftfigleader}{}
\newcommand*{\cftfigdotsep}{1}
\newcommand*{\cftfigpagefont}{}
\newcommand*{\cftfigafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\newlength{\cftbeforesubfigskip}
\newlength{\cftsubfigindent}
\newlength{\cftsubfignumwidth}
\newcommand*{\cftsubfigfont}{}
\newcommand*{\cftsubfigpresnum}{}
\newcommand*{\cftsubfigaftersnum}{}
\newcommand*{\cftsubfigaftersnumb}{}
\newcommand*{\cftsubfigleader}{}
\newcommand*{\cftsubfigdotsep}{1}
\newcommand*{\cftsubfigpagefont}{}
\newcommand*{\cftsubfigafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\newlength{\cftbeforetabskip}
\newlength{\cfttabindent}
\newlength{\cfttabnumwidth}
\newcommand*{\cfttabfont}{}
\newcommand*{\cfttabpresnum}{}
\newcommand*{\cfttabaftersnum}{}
\newcommand*{\cfttabaftersnumb}{}
\newcommand*{\cfttableader}{}
\newcommand*{\cfttabdotsep}{1}
\newcommand*{\cfttabpagefont}{}
\newcommand*{\cfttabafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\newlength{\cftbeforesubtabskip}
\newlength{\cftsubtabindent}
\newlength{\cftsubtabnumwidth}
\newcommand*{\cftsubtabfont}{}
\newcommand*{\cftsubtabpresnum}{}
\newcommand*{\cftsubtabaftersnum}{}
\newcommand*{\cftsubtabaftersnumb}{}
\newcommand*{\cftsubtableader}{}
\newcommand*{\cftsubtabdotsep}{1}
\newcommand*{\cftsubtabpagefont}{}
\newcommand*{\cftsubtabafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand{\cftsetindents}[3]{}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand{\pagenumbersoff}[1]{}
\newcommand{\pagenumberson}[1]{}
%    \end{macrocode}


% \begin{noindmacro}{\newlistentry} \oarg{within} \marg{counter} \marg{ext} \marg{level-1}
% \changes{v0.44}{2017/11/09}{\pkg{tocloft}: Added \cs{newlistentry}.}
%    \begin{macrocode}
\NewDocumentCommand{\newlistentry}{o m m m}
{
\IfValueTF{#1}
{
    \newcounter{#2}[#1]
    \expandafter\edef\csname the#2\endcsname{
        \expandafter\noexpand\csname the#1\endcsname.\noexpand\arabic{#2}
    }
}
{\newcounter{#2}}
\@namedef{l@#2}##1##2{\hypertocfloat{1}{#2}{#3}{##1}{##2}}
\expandafter\newlength\csname cftbefore#2skip\endcsname
\expandafter\newlength\csname cft#2indent\endcsname
\expandafter\newlength\csname cft#2numwidth\endcsname
\@namedef{cft#2font}{}
\@namedef{cft#2presnum}{}
\@namedef{cft#2aftersnum}{}
\@namedef{cft#2aftersnumb}{}
\@namedef{cft#2leader}{}
\@namedef{cft#2dotsep}{1}
\@namedef{cft#2pagefont}{}
\@namedef{cft#2afterpnum}{}
\@namedef{toclevel@#2}{#4}
\@namedef{cft#2fillnum}##1{}
}
%    \end{macrocode}
% \end{noindmacro}


% \begin{noindmacro}{\newlistof} \oarg{within} \marg{type} \marg{ext} \marg{listofname}
%
% Emulated through the \cs{newfloat} mechanism.
% \changes{v0.44}{2017/11/09}{\pkg{tocloft}: Improved \cs{newlistof}.}
%    \begin{macrocode}
\NewDocumentCommand{\newlistof}{o m m m}
{%
\IfValueTF{#1}
{\newlistentry[#1]{#2}{#3}{0}}
{\newlistentry{#2}{#3}{0}}
\@namedef{ext@#2}{#3}
\newcounter{#3depth}
\setcounter{#3depth}{1}
\@namedef{cftmark#3}{}
\@namedef{listof#2}{\listof{#2}{#4}}
\@namedef{@cftmake#3title}{}
\expandafter\newlength\csname cftbefore#3titleskip\endcsname
\expandafter\newlength\csname cftafter#3titleskip\endcsname
\@namedef{cft#3titlefont}{}
\@namedef{cftafter#3title}{}
\@namedef{cft#3prehook}{}
\@namedef{cft#3posthook}{}
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftchapterprecis} \marg{text}
%    \begin{macrocode}
\newcommand{\cftchapterprecis}[1]{%
  \cftchapterprecishere{#1}
  \cftchapterprecistoc{#1}}
\newcommand{\cftchapterprecishere}[1]{%
  \begin{quote}\textit{#1}\end{quote}}
\newcommand{\cftchapterprecistoc}[1]{
  \addtocontents{toc}{%
  {
     \protect\begin{quote}#1\protect\end{quote}}
  }
}
%    \end{macrocode}
% \end{noindmacro}

% \iffalse
%</tocloft>
% \fi
%
%
%
%
%
% \iffalse
%<*tocstyle>
% \fi
%
% \part{lwarp-tocstyle.sty}
%
% \section{tocstyle}
%
% \DescribePackage{tocstyle}
% \pkg{tocstyle} is ignored.
%
% \testthis
%
% \changes{v0.44}{2017/11/19}{\pkg{tocstyle}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{tocstyle}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\usetocstyle}[2][]{}
\newcommand*{\deactivatetocstyle}[1][]{}
\newcommand*{\reactivatetocstyle}[1][]{}
\NewDocumentCommand{\settocfeature}{o o m m}{}
\NewDocumentCommand{\settocstylefeature}{o m m}{}
\NewDocumentCommand{\newtocstyle}{o o m m}{}
\newcommand*{\aliastoc}[2]{}
\newcommand*{\showtoc}[2][]{}
\newcommand{\iftochasdepth}[4]{}
%    \end{macrocode}
%
% \iffalse
%</tocstyle>
% \fi
%
%
%
%
%
% \iffalse
%<*todo>
% \fi
%
% \part{lwarp-todo.sty}

% \section{todo}
%
% \credits{Federico Garcia}
%
% \DescribePackage{todo}
% \pkg{todo} is patched for use by \pkg{lwarp}.
%
% \changes{v0.44}{2017/11/13}{\pkg{todo}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{todo}
%    \end{macrocode}

%    \begin{macrocode}
\renewcommand\todoitem[2]{%
    \refstepcounter{todo}%
    \item[%
        \HTMLunicode{2610} \quad
        \ref{todopage:\thetodo}
     ] : {\todoformat\ifx#1\todomark\else\textbf{#1} \fi}#2%
    \label{todolbl:\thetodo}%
}%

\renewcommand\doneitem[2]{%
    \stepcounter{todo}%
    \item[%
        \HTMLunicode{2611} \quad
        \ref{todopage:\thetodo}
    ] \@nameuse{@done\the\c@todo}:
        {\todoformat\ifx#1\todomark\else\textbf{#1} \fi}#2%
}

\xpatchcmd{\@displaytodo}
    {\todoformat #1}{\todoformat \textbf{#1}}{}
    {\PackageWarning{lwarp-todo}{Unable to patch @displaytodo.}}

\xpatchcmd{\@displayfulltodo}
    {\todoformat #1}{\todoformat \textbf{#1}}{}
    {\PackageWarning{lwarp-todo}{Unable to patch @displayfulltodo.}}

\patchcmd{\todoenv}{\itshape see text.}{\textit{see text.}}{}
    {\PackageWarning{lwarp-todo}{Unable to patch todoenv.}}

\patchcmd{\astodos}{\todoformat #1}{\todoformat \textbf{#1}}{}
    {\PackageWarning{lwarp-todo}{Unable to patch astodos.}}

\AtBeginDocument{
\crefname{todo}{todo}{todos}
\Crefname{todo}{Todo}{Todos}
}
%    \end{macrocode}

% \iffalse
%</todo>
% \fi
%
%
%
%
% \iffalse
%<*todonotes>
% \fi
%
% \part{lwarp-todonotes.sty}
%
% \section{todonotes}
%
% \credits{Henrik Skov Midtiby}
%
% \DescribePackage{todonotes}
% \pkg{todonotes} is emulated.
%
% \limitstodonotes
%
% \changes{v0.43}{2017/11/07}{\pkg{todonotes}: Added.}
% \changes{v0.44}{2017/11/10}{\pkg{todonotes}: Improved.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{todonotes}
%    \end{macrocode}
%
%    \begin{macrocode}
\if@todonotes@disabled
\else

\newcommand{\ext@todo}{tdo}

\renewcommand{\l@todo}[2]{\hypertocfloat{1}{todo}{ldo}{#1}{#2}}


\renewcommand{\@todonotes@drawMarginNoteWithLine}{
\fcolorbox
    {\@todonotes@currentbordercolor}
    {\@todonotes@currentbackgroundcolor}
    {\arabic{@todonotes@numberoftodonotes}}
\marginpar{\@todonotes@drawMarginNote}
}

\renewcommand{\@todonotes@drawInlineNote}{%
\fcolorboxBlock%
    {\@todonotes@currentbordercolor}%
    {\@todonotes@currentbackgroundcolor}%
    {%
        \if@todonotes@authorgiven%
        {\@todonotes@author:\,}%
        \fi%
        \@todonotes@text%
    }%
}

\renewcommand{\@todonotes@drawMarginNote}{%
    \if@todonotes@authorgiven%
        \@todonotes@author\par%
    \fi%
    \arabic{@todonotes@numberoftodonotes}: %
    \fcolorbox%
    {\@todonotes@currentbordercolor}%
    {\@todonotes@currentbackgroundcolor}%
    {%
        \@todonotes@sizecommand%
        \@todonotes@text %
    }%
}%

\renewcommand{\@todonotes@drawLineToRightMargin}{}

\renewcommand{\@todonotes@drawLineToLeftMargin}{}

\renewcommand{\missingfigure}[2][]{%
\setkeys{todonotes}{#1}%
\addcontentsline{tdo}{todo}{\@todonotes@MissingFigureText: #2}%
\fcolorboxBlock%
    {\@todonotes@currentbordercolor}%
    {\@todonotes@currentfigcolor}%
    {%
        \setlength{\fboxrule}{4pt}%
        \fcolorbox{red}{white}{Missing figure} \quad #2%
    }
}

\LetLtxMacro\LWRTODONOTES@orig@todo\@todo

\RenewDocumentCommand{\@todo}{o m}{%
\begingroup%
\renewcommand*{\phantomsection}{}%
\IfValueTF{#1}{%
    \LWRTODONOTES@orig@todo[#1]{#2}%
}{%
    \LWRTODONOTES@orig@todo{#2}%
}
\endgroup%
}

\fi% \if@todonotes@disabled
%    \end{macrocode}
%
% \iffalse
%</todonotes>
% \fi
%
%
%
%
%
%
% \iffalse
%<*transparent>
% \fi
%
% \part{lwarp-transparent.sty}
%
% \section{transparent}
%
% \credits{Heiko Oberdiek}
%
% \DescribePackage{transparent} Emulated.
% \cs{texttransparent} works for inline objects.
% \cs{transparent} only works for \cs{includegraphics}.
%
% Note that \pkg{transparent} does not work with \XeLaTeX.\watchout[Not \XeLaTeX!]
%
% \changes{v0.36}{2017/08/09}{\pkg{transparent}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-transparent}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{transparent}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\transparent}[1]{\edef\LWR@opacity{#1}}

\newcommand*{\texttransparent}[2]{%
\begingroup%
\transparent{#1}%
\InlineClass[opacity: #1]{transparent}{#2}%
\endgroup%
}
%    \end{macrocode}
%
% \iffalse
%</transparent>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*trivfloat>
% \fi

% \part{lwarp-trivfloat.sty}

% \section{trivfloat}
% \label{sec:trivfloat}
%
% \credits{Joseph Wright}
%
% \DescribePackage{trivfloat}
% \pkg{trivfloat} is forced to use the built-in \pkg{lwarp}
% emulation for floats.
%
%
% Discard all options for \pkg{lwarp-trivfloat}.
% This tells \pkg{trivfloat} not to use \pkg{floatrow} or \pkg{memoir}.
%
%
% To create a new float type and change its name:
% \begin{Verbatim}[gobble=2,frame=lines,obeytabs,tabsize=4]
% \trivfloat{example}
% \renewcommand{\examplename}{Example Name}
% \crefname{example}{example}{examples}
% \Crefname{example}{Example}{Examples}
% \end{Verbatim}
%
%
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{trivfloat}
\LWR@origRequirePackage{trivfloat}
%    \end{macrocode}

% \DescribeMacro{\tfl@chapter@fix}
% Nullified at the beginning of the document.
% Is used by \pkg{trivfloat} to correct float chapter numbers,
% but is not needed for \pkg{lwarp}.

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

%    \begin{macrocode}
\AtBeginDocument{\DeclareDocumentCommand{\tfl@chapter@fix}{m m}{}}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \subsection{Combining \cs{newfloat}, \cs{trivfloat}, and \pkg{algorithmicx}}
% \label{sec:combiningfloats}
% \index{newfloat>with trivfloat, algorithmic}
% \index{trivfloat>with newfloat, algorithmic}
% \index{algorithmic>with newfloat, trivfloat}
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \textcolor{red}{For both print and \HTML\ output:}
%
% When using \pkg{float}, \pkg{trivfloat}, or \pkg{algorithmicx} at the same time,
% be aware of conflicting file usage.
% \watchout
% \pkg{algorithmicx} uses |.loa|.
% \pkg{trivfloat} by default starts with |.loa| and goes up for additional floats,
% skipping |.lof| and |.lot|.
%
% When using \cs{newfloat},
% \watchout
% be sure to manually assign higher letters to the \cs{newfloat}
% files to avoid |.loa| used by \pkg{algorithmicx}, and any files used by \pkg{trivfloat}.
% Also avoid using |.lof| and |.lot|.
%
% When using \cs{trivfloat}, you may force it to avoid conflicting with
% \watchout
% \pkg{algorithmicx} by starting \pkg{trivfloat}'s file extensions with |.lob|:
%
% \begin{Verbatim}[gobble=2,frame=lines,obeytabs,tabsize=4]
% \makeatletter
% \setcounter{tfl@float@cnt}{1} % start trivfloats with .lob
% \makeatletter
% \end{Verbatim}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}

% \iffalse
%</trivfloat>
% \fi
%
%
%
%
%
%
% \iffalse
%<*typearea>
% \fi
%
% \part{lwarp-typearea.sty}
%
% \section{typearea}
%
% \credits{Markus Kohm}
%
% \DescribePackage{typearea}
% \pkg{typearea} is emulated.
%
% \usedbykomascript
%
% \changes{v0.39}{2017/08/28}{\pkg{typearea}: Added.}
% \changes{v0.44}{2017/11/22}{\pkg{typearea}: Added expert commands.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{typearea}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareDocumentCommand{\typearea}{o m}{}
\DeclareDocumentCommand{\recalctypearea}{}{}
\@ifundefined{footheight}{\newlength\footheight}{}
\DeclareDocumentCommand{\areaset}{o m m}{}
\DeclareDocumentCommand{\activateareas}{}{}
\DeclareDocumentCommand{\storeareas}{m}{}
\DeclareDocumentCommand{\BeforeRestoreareas}{s m}{}
\DeclareDocumentCommand{\AfterRestoreareas}{s m}{}
\DeclareDocumentCommand{\AfterCalculatingTypearea}{s m}{}
\DeclareDocumentCommand{\AfterSettingArea}{s m}{}
%    \end{macrocode}
%
% \iffalse
%</typearea>
% \fi
%
%
%
%
%
%
%
%
% \iffalse
%<*ulem>
% \fi
%
% \part{lwarp-ulem.sty}
%
% \section{ulem}
%
% \credits{Donald Arseneau}
%
% \DescribePackage{ulem} Emulated.
%
% \changes{v0.27}{2017/04/02}{\pkg{ulem}: Added.}
%
% \codehtml
%
% Original \pkg{lwarp} definitions:
%    \begin{macrocode}
\LetLtxMacro\LWR@ulemorigemph\emph
\LetLtxMacro\LWR@ulemorigtextbf\textbf
%    \end{macrocode}
%
% Basic markup commands, using \CSS:
%    \begin{macrocode}
\NewDocumentCommand{\uline}{+m}{%
\LWR@HTMLtextstyle%
    {text-decoration:underline;text-decoration-skip}%
    {uline}{#1}%
}

\NewDocumentCommand{\uuline}{+m}{%
\LWR@HTMLtextstyle%
    {%
        text-decoration:underline;text-decoration-skip;%
        text-decoration-style:double%
    }%
    {uuline}{#1}%
}

\NewDocumentCommand{\uwave}{+m}{%
\LWR@HTMLtextstyle%
    {%
        text-decoration:underline;text-decoration-skip;%
        text-decoration-style:wavy%
    }%
    {uwave}{#1}%
}

\NewDocumentCommand{\sout}{+m}{%
\LWR@HTMLtextstyle%
    {text-decoration:line-through}%
    {sout}{#1}%
}

\NewDocumentCommand{\xout}{+m}{%
\LWR@HTMLtextstyle%
    {text-decoration:line-through}%
    {xout}{#1}%
}

\NewDocumentCommand{\dashuline}{+m}{%
\LWR@HTMLtextstyle%
    {%
        text-decoration:underline;%
        text-decoration-skip;%
        text-decoration-style:dashed%
    }%
    {dashuline}{#1}%
}

\NewDocumentCommand{\dotuline}{+m}{%
\LWR@HTMLtextstyle%
    {%
        text-decoration:underline;%
        text-decoration-skip;%
        text-decoration-style:dotted%
    }%
    {dotuline}{#1}%
}
%    \end{macrocode}
%
% Nullified parameters:
%    \begin{macrocode}
\NewDocumentCommand{\ULthickness}{}{}
\newlength{\ULdepth}
%    \end{macrocode}
%
% Nullified/emulated macros:
%    \begin{macrocode}
\NewDocumentCommand{\markoverwith}{m}{}
\NewDocumentCommand{\ULon}{+m}{\uline{#1}\egroup}
%    \end{macrocode}
%
% \cs{useunder} only works with \cs{textbf}, etc, but not \cs{bfseries}, etc.
%    \begin{macrocode}
\NewDocumentCommand{\useunder}{m m m}{%
\relax%
\ifx\relax#3\relax\else % argumentative command
    \def#3{#1}\MakeRobust{#3}\fi
}
%    \end{macrocode}
%
% Triggered by package options, also available for the users:
%    \begin{macrocode}
\newcommand*{\normalem}{\LetLtxMacro\emph\LWR@ulemorigemph}
\newcommand*{\ULforem}{\LetLtxMacro\emph\uline}
\ULforem% default
%    \end{macrocode}
%
%
% Package options:
%    \begin{macrocode}
\DeclareOption{normalem}{\normalem}
\DeclareOption{ULforem}{\ULforem}
\DeclareOption{normalbf}{}
\DeclareOption{UWforbf}{\useunder{\uwave}{\bf}{\textbf}}
%    \end{macrocode}
%
% Emulate the original package:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{ulem}
%    \end{macrocode}
%
% \iffalse
%</ulem>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*upref>
% \fi
%
% \part{lwarp-upref.sty}
%
% \section{upref}
%
% \DescribePackage{upref} Ignored.
%
% \changes{v0.36}{2017/08/09}{\pkg{upref}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-upref}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{upref}
%    \end{macrocode}
%
%
% \iffalse
%</upref>
% \fi
%
%
%
%
%
%
% \iffalse
%<*verse>
% \fi
%
% \part{lwarp-verse.sty}
%
% \section{verse}
%
% \credits{Peter Wilson}
%
% \DescribePackage{verse}
% \pkg{verse} is supported and patched by \pkg{lwarp}.
%
% \changes{v0.22}{2017/03/02}{\pkg{verse}: Added.}
%
% \codehtml
%
% Pass all options for \pkg{lwarp-verse}:
%    \begin{macrocode}
\LWR@ProvidesPackagePass{verse}
%    \end{macrocode}

%
% \limitsverse
%
% \bigskip
%
% \begin{environment}{verse}
% \changes{v0.18}{2016/05/13}{Supports verse, memoir packages.}
% The \env{verse} environment will be placed inside a \HTML\ \element{pre}.
%    \begin{macrocode}
\AfterEndPreamble{
\LWR@traceinfo{Patching verse.}
%    \end{macrocode}
% At the beginning of the \env{verse} environment:
%    \begin{macrocode}
\AtBeginEnvironment{verse}
{%
%    \end{macrocode}
% Use the original \env{list} environment inside a \element{pre} to
% attempt to preserve formatting.
%    \begin{macrocode}
\LWR@restoreoriglists%
%    \end{macrocode}
% \DescribePackage{verse}\DescribePackage{memoir}\index{memoir>verse}
% The \pkg{verse} or \pkg{memoir} packages can place stanza numbers to the left
% with their \cs{flagverse} command. \DescribeMacro{\flagverse}
% Do not allow them to go into the left margin, which would cause |pdfcrop|
% to crop the entire page further to the left:
% \DescribeLength{vleftskip}
%    \begin{macrocode}
\ifdef{\vleftskip}{%
\setlength{\vleftskip}{\HTMLvleftskip}
\setlength{\leftmargini}{\HTMLleftmargini}
}{}
\LWR@forcenewpage
\LWR@atbeginverbatim{verse}
\unskip\LWR@origvspace{-\baselineskip}
}
%    \end{macrocode}
% After the end of the \env{verse} environment, which places the \element{pre} tag at the
% regular left margin:
%    \begin{macrocode}
\AtEndEnvironment{verse}{
\LWR@afterendverbatim
}
%    \end{macrocode}
% Patch to place poemtitle inside an \HTML\ \element{span} of class |poemtitle|:
%    \begin{macrocode}
\ifdef{\poemtitle}{
\DeclareDocumentCommand{\@vstypeptitle}{m}{%
   \vspace{\beforepoemtitleskip}%
   {\InlineClass{poemtitle}{\poemtitlefont #1}\par}%
   \vspace{\afterpoemtitleskip}%
 }
}{}

\LWR@traceinfo{Finished patching verse.}
}% AfterEndPreamble
%    \end{macrocode}
% \end{environment}

% \iffalse
%</verse>
% \fi
%
%
%
%
%
%
% \iffalse
%<*wallpaper>
% \fi

% \part{lwarp-wallpaper.sty}

% \section{wallpaper}
% \label{sec:wallpaper}
%
% \credits{Michael H.F. Wilkinson}
%
% \changes{v0.20}{2017/01/11}{\pkg{wallpaper}: Added.}
%
% \DescribePackage{wallpaper}
% \pkg{wallpaper} is emulated.

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{wallpaper}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\CenterWallPaper}[2]{}
\newcommand*{\ThisCenterWallPaper}[2]{}
\newcommand*{\TileWallPaper}[3]{}
\newcommand*{\ThisTileWallPaper}[3]{}
\newcommand*{\TileSquareWallPaper}[2]{}
\newcommand*{\ThisTileSquareWallPaper}[2]{}
\newcommand*{\ULCornerWallPaper}[2]{}
\newcommand*{\ThisULCornerWallPaper}[2]{}
\newcommand*{\LLCornerWallPaper}[2]{}
\newcommand*{\ThisLLCornerWallPaper}[2]{}
\newcommand*{\URCornerWallPaper}[2]{}
\newcommand*{\ThisURCornerWallPaper}[2]{}
\newcommand*{\LRCornerWallPaper}[2]{}
\newcommand*{\ThisLRCornerWallPaper}[2]{}
\newcommand*{\ClearWallPaper}{}
\newlength{\wpXoffset}
\newlength{\wpYoffset}
%    \end{macrocode}

% \iffalse
%</wallpaper>
% \fi
%
%
%
%
% \iffalse
%<*watermark>
% \fi
%
% \part{lwarp-watermark.sty}
%
% \section{watermark}
%
% \credits{Alexander I. Rozhenko}
%
% \DescribePackage{watermark}
% \pkg{watermark} is emulated.
%
% \changes{v0.44}{2017/11/10}{\pkg{watermark}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{watermark}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\watermark}[1]{}
\newcommand{\leftwatermark}[1]{}
\newcommand{\rightwatermark}[1]{}
\newcommand{\thiswatermark}[1]{}
\newcommand{\thispageheading}[1]{}
%    \end{macrocode}
%
% \iffalse
%</watermark>
% \fi
%
%
%
%
%
% \iffalse
%<*wrapfig>
% \fi

% \part{lwarp-wrapfig.sty}

% \section{wrapfig}
% \label{sec:wrapfig}
%
% \credits{Donald Arseneau}
%
% \changes{v0.20}{2017/01/11}{\pkg{wrapfig}: Added.}
%
% \DescribePackage{wrapfig}
% \pkg{wrapfig} is emulated.

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{wrapfig}
%    \end{macrocode}
%
%
% \changes{v0.42}{2017/10/26}{\pkg{wrapfig}: If \texttt{FormatWP}
%           add explicit HTML style.}
%
%    \begin{macrocode}
\newcommand*{\LWR@wrapposition}{}

\newcommand*{\LWR@subwrapfigure}[2]{%
\renewcommand*{\LWR@wrapposition}{}%
\ifthenelse{%
    \equal{#1}{r}\OR\equal{#1}{R}\OR%
    \equal{#1}{o}\OR\equal{#1}{O}%
}%
{\renewcommand*{\LWR@wrapposition}{float:right}}%
{\renewcommand*{\LWR@wrapposition}{float:left}}%
\setlength{\LWR@templengthone}{#2}%
\uselengthunit{PT}%
\LWR@BlockClassWP{%
    width:\rndprintlength{\LWR@templengthone}; \LWR@wrapposition; %
    margin:10pt%
}%
{%
    width:\rndprintlength{\LWR@templengthone}; \LWR@wrapposition%
}%
{marginblock}%
}


\NewDocumentEnvironment{wrapfigure}{o m o m}
{%
\LWR@subwrapfigure{#2}{#4}%
\captionsetup{type=figure}%
}
{%
\endLWR@BlockClassWP%
}


\NewDocumentEnvironment{wraptable}{o m o m}
{%
\LWR@subwrapfigure{#2}{#4}%
\captionsetup{type=table}%
}
{%
\endLWR@BlockClassWP%
}


\NewDocumentEnvironment{wrapfloat}{m o m o m}
{%
\LWR@subwrapfigure{#3}{#5}%
\captionsetup{type=#1}%
}
{%
\endLWR@BlockClassWP%
}

\newlength{\wrapoverhang}
%    \end{macrocode}

% \iffalse
%</wrapfig>
% \fi
%
%
%
%
%
% \iffalse
%<*xcolor>
% \fi

% \part{lwarp-xcolor.sty}

% \section{xcolor}
% \label{sec:xcolor}
%
% \credits{Dr. Uwe Kern}
%
% \DescribePackage{xcolor}
% \pkg{xcolor} is supported by lwarp.
%
% \changes{v0.36}{2017/08/10}{\pkg{xcolor}: Uses \cs{fboxrule} and \cs{fboxsep}.}
% \changes{v0.36}{2017/08/10}{\pkg{xcolor}: Added \cs{fcolorboxBlock}, \cs{colorboxBlock}.}
% \changes{v0.36}{2017/08/10}{\pkg{xcolor}: Fix: Background \protect\texttt{none} in print mode.}
% \changes{v0.36}{2017/08/12}{\pkg{xcolor}: \cs{fcolorbox} etc. now work inside \env{lateximage}.}
%
%
% \subsection{Limitations}
%
% \limitsxcolor
%
%
% \subsection{Xcolor definitions: location and timing}
%
% The \pkg{lwarp} core and its \pkg{lwarp-xcolor} package are tightly integrated
% to allow comparable results for print, \HTML\,
% and print inside an \HTML\ \env{lateximage}.
% This requires a number of definitions and redefintions depending on whether
% each of \pkg{xcolor} and \env{lateximage} is being used, and whether print
% or \HTML\ is being generated.
% Some of these actions are one-time when \pkg{xcolor} is loaded, and others
% are temporary as \env{lateximage} is used.
%
% \begin{description}
% \item [When \pkg{xcolor} is loaded in print mode:] \
%	No special actions are taken at the time that \pkg{xcolor} is loaded in
%	print mode, but see \cs{AtBeginDocument} below.
% \item [When \pkg{lwarp-xcolor} is loaded in HTML mode:] \
%	\pkg{xcolor}'s original definitions are saved for later restoration.
%	\cs{LWR@restoreorigformatting} is appended to restore these definitions
%	for use inside a \env{lateximage}.
%	New \HTML-mode definitions are created for \cs{textcolor}, \cs{pagecolor},
%	\cs{nopagecolor}, \cs{colorbox}, \cs{colorboxBlock}, \cs{fcolorbox},
%	\cs{fcolorboxBlock}, and \env{fcolorminipage}.
% \item [\cs{AtBeginDocument} in print or HTML mode:]
%	See \Cref{sec:xcolorpatches}.
%	If \pkg{xcolor} has been loaded, the print-mode \cs{fcolorbox} is modified
%	to accept a background color of |none|, and additional definitions are created
%	for \pkg{lwarp}'s new macros print-mode macros \cs{colorboxBlock},
%	\cs{fcolorboxBlock}, and \env{fcolorminipage}.  The \HTML\ versions of these
%	macros will already have been created by \pkg{lwarp-xcolor} if it has been loaded.
%
%   For use inside an \HTML\ \env{lateximage},
%   \cs{LWR@restoreorigformatting} is appended to temporarily set these functions
%   to their print-mode versions.
% \item [In a \env{lateximage} in HTML mode:] \
%	\cs{LWR@restoreorigformatting} temporarily restores the
%   print-mode definitions of \pkg{xcolor}'s functions.
%	See \cs{LWR@restoreorigformatting} on page \pageref{sec:restoreorigformatting}.
% \end{description}
%
% \begin{description}
%
% \item [\cs{color}:] \
%	\begin{description}
%		\item [Print:] Used as-is.
%		\item [HTML:] Ignored by |pdftotext|, and will not appear.
%		\item [HTML \env{lateximage}:] Colors will appear in a \env{lateximage}.
%	\end{description}
%
% \item [\cs{textcolor}:] \
%	\begin{description}
%		\item [Print:] Used as-is.
%		\item [HTML:] Redefined by \pkg{lwarp-xcolor}, page \pageref{sec:textcolor}.
%		\item [HTML \env{lateximage}:] Remembers and reuses the print version.
%	\end{description}
%
% \item [\cs{pagecolor}:] \
%	\begin{description}
%		\item [Print:] Used as-is.
%		\item [HTML:] Ignored.
%		\item [HTML \env{lateximage}:] Colors will be picked up in a \env{lateximage}.
%	\end{description}
%
% \item [\cs{nopagecolor}:] \
%	\begin{description}
%		\item [Print:] Used as-is.
%		\item [HTML:] Ignored.
%		\item [HTML \env{lateximage}:] Colors will be picked up in a \env{lateximage}.
%	\end{description}
%
% \item [\cs{colorbox}:] \
%	\begin{description}
%		\item [Print:] Used as-is.
%		\item [HTML:] Redefined by \pkg{lwarp-xcolor}, page \pageref{sec:colorbox}.
%		\item [HTML \env{lateximage}:] Remembers and reuses the print version.
%	\end{description}
%
% \item [\cs{colorboxBlock}:] \
%	\begin{description}
%		\item [Print:] Becomes \cs{colorbox}.
%		\item [HTML:] Newly defined by \pkg{lwarp-xcolor} to use a \element{div},
%			page \pageref{sec:colorboxBlock}.
%		\item [HTML \env{lateximage}:] Remembers and reuses the print version \cs{colorbox}.
%	\end{description}
%
% \item [\cs{fcolorbox}:] \
%	\begin{description}
%		\item [Print:] Modified to allow a background of |none|. \newline
%			\cs{LWRprint@fcolorbox} at \cref{sec:xcolorpatches}
%		\item [HTML:] Redefined by \pkg{lwarp-xcolor}, page \pageref{sec:fcolorbox}.
%		\item [HTML \env{lateximage}:] Remembers and reuses the print version.
%	\end{description}
%
% \item [\cs{fcolorboxBlock}:] \
%	\begin{description}
%		\item [Print:] Becomes \cs{fcolorbox}.  \Cref{sec:xcolorpatches}
%		\item [HTML:] Newly defined by \pkg{lwarp-xcolor} to use a \element{div},
%			page \pageref{sec:fcolorboxBlock}.
%		\item [HTML \env{lateximage}:] Remembers and reuses the print version \cs{fcolorbox}.
%	\end{description}
%
% \item [\env{fcolorminipage}:] \
%	\begin{description}
%		\item [Print:] Newly defined in the \pkg{lwarp} core.  \newline
%			\env{LWRprint@fcolorminipage} at \cref{sec:xcolorpatches}
%		\item [HTML:] Newly defined by \pkg{lwarp-xcolor}, page \pageref{sec:fcolorminipage}.
%		\item [HTML \env{lateximage}:] Uses the print version.
%	\end{description}
%
% \item [\cs{boxframe}:] \
%   \begin{description}
%       \item [Print:] Used as-is.
%       \item [HTML:] Redefined by \pkg{lwarp-xcolor}, page \pageref{sec:boxframe}.
%       \item [HTML \env{lateximage}:] Remembers and reuses the print version.
%   \end{description}
%
% \end{description}
%
%
% \subsection{Package loading}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{xcolor}
%    \end{macrocode}

%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
% \subsection{Remembering and restoring original definitions}
%
% Remember the following print-mode actions to be restored
% when inside a \env{lateximage} environment:
%    \begin{macrocode}
\LetLtxMacro\LWRprint@textcolor\textcolor
\LetLtxMacro\LWRprint@pagecolor\pagecolor
\LetLtxMacro\LWRprint@nopagecolor\nopagecolor
\LetLtxMacro\LWRprint@colorbox\colorbox
\LetLtxMacro\LWRprint@colorboxBlock\colorbox
\LetLtxMacro\LWRorigprint@fcolorbox\fcolorbox
\LetLtxMacro\LWRorigprint@fcolorboxBlock\fcolorbox
\LetLtxMacro\LWRorigprint@boxframe\boxframe
%    \end{macrocode}
%
%
% Inside a \env{lateximage} the following gets restored to their print-mode actions:
% \margintag{\small\cs{LWR@restoreorigformatting}}
%    \begin{macrocode}
\appto{\LWR@restoreorigformatting}{%
\LetLtxMacro\textcolor\LWRprint@textcolor%
\LetLtxMacro\pagecolor\LWRprint@pagecolor%
\LetLtxMacro\nopagecolor\LWRprint@nopagecolor%
\LetLtxMacro\colorbox\LWRprint@colorbox%
\LetLtxMacro\fcolorbox\LWRprint@fcolorbox%
\LetLtxMacro\boxframe\LWRorigprint@boxframe%
}
%    \end{macrocode}
%
%
% \subsection{HTML color style}
%
% \begin{noindmacro}{\LWR@tempcolor}
% The color converted to \HTML\ colorspace.
%    \begin{macrocode}
\newcommand*{\LWR@tempcolor}{}
\newcommand*{\LWR@tempcolortwo}{}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\LWR@findcurrenttextcolor}
% \changes{v0.44}{2017/11/10}{\pkg{xcolor}: Added \cs{LWR@findcurrentcolor}.}
% Sets \cs{LWR@tempcolor} to the current color.
%    \begin{macrocode}
\newcommand*{\LWR@findcurrenttextcolor}{%
\protect\colorlet{LWR@current@color}{.}%
\protect\convertcolorspec{named}{LWR@current@color}{HTML}\LWR@tempcolor%
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\LWR@currenttextcolorstyle}
% Prints a color style for the current color.
% \changes{v0.44}{2017/11/10}{\pkg{xcolor}: Added \cs{LWR@currenttextcolorstyle}.}
%    \begin{macrocode}
\newcommand*{\LWR@currenttextcolorstyle}{%
\LWR@findcurrenttextcolor%
\ifdefstring{\LWR@tempcolor}{000000}%
{}%
{color: \#\LWR@tempcolor ; }%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\LWR@textcurrentcolor} \marg{text}
% Like \cs{textcolor} but uses the current \cs{color} instead.
% \changes{v0.44}{2017/11/10}{\pkg{xcolor}: Added \cs{LWR@textcurrentcolor}.}
%    \begin{macrocode}
\newcommand*{\LWR@textcurrentcolor}[1]{%
\begingroup%
\LWR@FBcancel%
\LWR@findcurrenttextcolor%
\InlineClass[color:\#\LWR@tempcolor]{textcolor}{%
    \renewcommand*{\LWR@currenttextcolor}{\#\LWR@tempcolor}%
    #1%
}%
\endgroup%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\LWR@colorstyle}
% \marg{1: styletext} \marg{2: model} \marg{3: color}
%
% \changes{v0.19}{2016/06/01}{Supports colored \cs{rule}.}
% \changes{v0.36}{2017/08/11}{\pkg{xcolor}: Refactored \cs{LWR@colorstyle}.}
%
% For a color style, prints the color converted to \HTML\ colors.
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@colorstyle}{m m}{%
\begingroup%
\LWR@FBcancel%
%    \end{macrocode}
% Use the \pkg{xcolor} package to convert to an \HTML\ color space:
%    \begin{macrocode}
\convertcolorspec{#1}{#2}{HTML}\LWR@tempcolor%
%    \end{macrocode}
% Print the converted color:
%    \begin{macrocode}
\#\LWR@tempcolor%
\endgroup%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{macro}{\LWR@backgroundcolor}
% \oarg{model} \marg{color} \marg{text}
%
% Similar to \cs{textcolor}, but prints black text against a color background.
%
% Converted into an \HTML\ hex color span.
% \changes{v0.44}{2017/11/10}{Added.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@backgroundcolor}{O{named} m m}{%
\begingroup%
\LWR@FBcancel%
\InlineClass[background:\LWR@colorstyle{#1}{#2}]{backgroundcolor}{%
#3%
}%
\endgroup%
}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{HTML border}
%
% \begin{noindmacro}{\LWR@borderpadding} \marg{colorstyle} \marg{color}
% Prints the \HTML\ attributes for a black border and padding.
%
% \cs{LWR@forceminwidth} must be used first in order to set the border width.
%
%    \begin{macrocode}
\newcommand*{\LWR@borderpadding}[2]{%
\uselengthunit{PT}%
border:\rndprintlength{\LWR@atleastonept} solid \LWR@colorstyle{#1}{#2} ; %
padding:\rndprintlength{\fboxsep}%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \subsection{High-level macros}
%
% \DescribeMacro{\color}
% \cs{color} appears in the \LaTeX{} \PDF\ output,
% but is ignored by |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 |\let| to the final
% name once the \HTML\ conversion starts.
%
% \label{sec:textcolor}
% \begin{macro}{\textcolor}
% \oarg{model} \marg{color} \marg{text}
%
% Converted into an \HTML\ hex color span.
%    \begin{macrocode}
\RenewDocumentCommand{\textcolor}{O{named} m m}{%
\begingroup%
\LWR@FBcancel%
\InlineClass[color:\LWR@colorstyle{#1}{#2}]{textcolor}{%
\renewcommand*{\LWR@currenttextcolor}{\#\LWR@tempcolor}%
#3%
}%
\endgroup%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\pagecolor}
% \oarg{model} \marg{color}
%
% Ignored.  Use |\CSSFilename| instead.
%    \begin{macrocode}
\renewcommand*{\pagecolor}[2][named]{}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\nopagecolor}
% Ignored.
% \changes{v0.44}{2017/11/19}{\pkg{xcolor}: Fix for \cs{nopagecolor}.}
%    \begin{macrocode}
\renewcommand*{\nopagecolor}{}
%    \end{macrocode}
% \end{macro}


% \label{sec:colorbox}
% \begin{macro}{\colorbox}
% \oarg{model} \marg{color} \marg{text}
%
% Converted into an \HTML\ hex background color \element{span}.
%
%    \begin{macrocode}
\RenewDocumentCommand{\colorbox}{O{named} m +m}{%
\begingroup%
\LWR@FBcancel%
\uselengthunit{PT}%
\InlineClass[%
background:\LWR@colorstyle{#1}{#2} ; %
padding:\rndprintlength{\fboxsep}%
]{colorbox}{#3}%
\endgroup%
}
%    \end{macrocode}
% \end{macro}

% \label{sec:colorboxBlock}
% \begin{macro}{\colorboxBlock} \oarg{model} \marg{color} \marg{text}
%
% Converted into an \HTML\ hex background color \element{div}.
%
%    \begin{macrocode}
\NewDocumentCommand{\colorboxBlock}{O{named} m +m}{%
\begingroup%
\LWR@FBcancel%
\uselengthunit{PT}%
\begin{BlockClass}[%
background:\LWR@colorstyle{#1}{#2} ; %
padding:\rndprintlength{\fboxsep}%
]{colorboxBlock}
#3
\end{BlockClass}%
\endgroup%
}
%    \end{macrocode}
% \end{macro}

% \label{sec:fcolorbox}
% \begin{macro}{\fcolorbox}
%	\oarg{framemodel} \marg{framecolor} \oarg{boxmodel} \marg{boxcolor} \marg{text}
%
% Converted into a framed \HTML\ hex background color span.
%
% A background color of |none| creates a colored frame without a background color.
%
%    \begin{macrocode}
\RenewDocumentCommand{\fcolorbox}{O{named} m O{named} m +m}{%
\LWR@traceinfo{HTML fcolorbox #2 #4}%
\begingroup%
\LWR@FBcancel%
\uselengthunit{PT}%
\LWR@forceminwidth{\fboxrule}%
\ifthenelse{\equal{#4}{none}}%
{% no background color
    \InlineClass[%
    \LWR@borderpadding{#1}{#2}%
    ]{fcolorbox}{#5}%
}%
{% yes background color
    \InlineClass[%
    \LWR@borderpadding{#1}{#2} ; %
    background:\LWR@colorstyle{#3}{#4}%
    ]{fcolorbox}{#5}%
}%
\endgroup%
}
%    \end{macrocode}
% \end{macro}

% \label{sec:fcolorboxBlock}
% \begin{macro}{\fcolorboxBlock}
%	\oarg{framemodel} \marg{framecolor} \oarg{boxmodel} \marg{boxcolor} \marg{text}
%
% Converted into a framed \HTML\ hex background color span.
%
% A background color of |none| creates a colored frame without a background color.
%
%    \begin{macrocode}
\NewDocumentCommand{\fcolorboxBlock}{O{named} m O{named} m +m}{%
\LWR@traceinfo{HTML fcolorboxBlock #2 #4}%
\begingroup%
\LWR@FBcancel%
\uselengthunit{PT}%
\LWR@forceminwidth{\fboxrule}%
\ifthenelse{\equal{#4}{none}}%
{% no background color
    \begin{BlockClass}[%
    \LWR@borderpadding{#1}{#2}%
    ]{fcolorboxBlock}
    #5
    \end{BlockClass}%
}%
{% yes background color
    \convertcolorspec{#3}{#4}{HTML}\LWR@tempcolortwo%
    \begin{BlockClass}[%
    background:\#\LWR@tempcolortwo\ ; %
    \LWR@borderpadding{#1}{#2}%
    ]{fcolorboxBlock}
    #5
    \end{BlockClass}%
}%
\endgroup%
\LWR@traceinfo{HTML fcolorboxBlock done}%
}
%    \end{macrocode}
% \end{macro}


% \label{sec:fcolorminipage}
% Creates a framed \HTML\ \element{div} around its contents.
%
% A print-output version is defined in the \pkg{lwarp} core: \cref{sec:xcolorpatches}
%
% \changes{v0.34}{2017/07/31}{Added.}
%
% \begin{noindmacro}{\LWR@subfcolorminipage}
%	\marg{framemodel} \marg{framecolor} \marg{background tag} \marg{height}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@subfcolorminipage}{m m m m}{%
\begin{BlockClass}[%
#3%
\LWR@borderpadding{#1}{#2} ; %
\IfValueT{#4}{height:\rndprintlength{\LWR@tempheight} ; }%
width:\rndprintlength{\LWR@tempwidth}%
]{fcolorminipage}%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{environment}{fcolorminipage}
%	\oarg{1:framemodel} \marg{2:framecolor} \oarg{3:boxmodel} \marg{4:boxcolor} 
%	\oarg{5:align} \oarg{6:height} \oarg{7:inner-align} \marg{8:width}
%
%    \begin{macrocode}
\NewDocumentEnvironment{fcolorminipage}{O{named} m O{named} m O{c} o o m}
{%
\LWR@FBcancel%
\setlength{\LWR@tempwidth}{#8}%
\IfValueT{#6}{\setlength{\LWR@tempheight}{#6}}%
\uselengthunit{PT}%
\LWR@forceminwidth{\fboxrule}%
\convertcolorspec{#1}{#2}{HTML}\LWR@tempcolor%
\ifthenelse{\equal{#4}{none}}%
{\LWR@subfcolorminipage{#1}{#2}{}{#6}}%
{%
    \convertcolorspec{#3}{#4}{HTML}\LWR@tempcolortwo%
    \LWR@subfcolorminipage{#1}{#2}{background:\#\LWR@tempcolortwo\ ; }{#6}%
}%
}
{\end{BlockClass}}
%    \end{macrocode}
% \end{environment}
%
%
%
% \label{sec:boxframe}
% \begin{macro}{\boxframe} \marg{width} \marg{height} \marg{depth}
%
% The depth is added to the height, but the box is not decended below
% by the depth.  \cs{textcolor} is honored.
%    \begin{macrocode}
\renewcommand*{\boxframe}[3]{%
{%
\setlength{\LWR@tempwidth}{#1}%
\setlength{\LWR@tempheight}{#2}%
\addtolength{\LWR@tempheight}{#3}%
\uselengthunit{PT}%
\LWR@forceminwidth{\fboxrule}%
\InlineClass[%
display:inline-block ; %
border:\rndprintlength{\LWR@atleastonept} solid \LWR@currenttextcolor{} ; %
width:\rndprintlength{\LWR@tempwidth} ; %
height:\rndprintlength{\LWR@tempheight}%
]{boxframe}{}%
}%
}
%    \end{macrocode}
% \end{macro}
%
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
% \iffalse
%</xcolor>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*xfrac>
% \fi

% \part{lwarp-xfrac.sty}

% \section{xfrac}
% \label{sec:xfrac}
%
% \credits{The \LaTeX3 Project}
%
% \DescribePackage{xfrac} Supported by adding \pkg{xfrac} instances.
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{xfrac}
%    \end{macrocode}

% In the user's document preamble, \pkg{lwarp} should be loaded
% after font-related setup.
% \watchout[font size]
% During \HTML\ conversion, this font is used by \pkg{lwarp}
% to generate its initial \PDF\ output containing \HTML\ tags,
% later to be converted by |pdftotext| to a plain text file.
% While the text may be in any font which |pdftotext| can read, the math is
% directly converted into \SVG\ images using this same user-selected font.
% |xfrac| below is set for the Latin Modern (lmr) font.
% If another font is used, it may be desirable to redefine
% \cs{xfracHTMLfontsize} with a different em size.




% \DescribeMacro{\sfrac} \oarg{instance} \marg{num} \oarg{sep} \marg{denom}
%
% A text-mode instance for the default font is provided below.
% The numerator and denominator formats are adjusted to encase everything
% in \HTML\ tags.  \cs{scalebox} is made null inside the numerator and
% denominator, since the \HTML\ tags should not be scaled, and we do not
% want to introduce additional \HTML\ tags for scaling.
%
% In math mode, which will appear inside a \env{lateximage}, no adjustments
% are necessary.

% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}


% \begin{macro}{\xfracHTMLfontsize}
% \changes{v0.19}{2016/06/06}{Added.}
% \index{font>size --- xfrac}
% User-redefinable macro which controls the font size of the fraction.
%    \begin{macrocode}
\newcommand*{\xfracHTMLfontsize}{.6em}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}


% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% A span for a small font, used in the numerator and denominator:
% \margintag{font size}
%    \begin{macrocode}
\newcommand*{\LWR@htmlsmallfontstart}{%
\LWR@htmltagc{span style="font-size:\xfracHTMLfontsize"{}}%
\LWR@nestspan%
%
}

\newcommand*{\LWR@htmlsmallfontend}{%
\LWR@htmltagc{/span}%
\endLWR@nestspan%
}
%    \end{macrocode}
% A nullified \cs{scalebox} command, to avoid introducing \HTML\ scaling tags:
% \margintag{\cs{scalebox}}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@noscalebox}{m o m}{#3}
%    \end{macrocode}

% Instances of \pkg{xfrac} for various font choices:
% \margintag{instances}
%
% 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.
%
% \changes{v0.16}{2016/04/07}{xfrac: Adjusted for the use of any font:}
%    \begin{macrocode}
\DeclareInstance{xfrac}{default}{text}{
numerator-format = {%
\LetLtxMacro{\scalebox}{\LWR@noscalebox}%
\LWR@htmlsmallfontstart\textsuperscript{#1}\,\LWR@htmlsmallfontend},
denominator-format = {%
\LetLtxMacro{\scalebox}{\LWR@noscalebox}%
\LWR@htmlsmallfontstart{}\,#1\LWR@htmlsmallfontend},
%    \end{macrocode}
% For |pdftotext|, do not scale the text:
%    \begin{macrocode}
scaling = false
}

\DeclareInstance{xfrac}{lmr}{text}{
numerator-format = {%
\LetLtxMacro{\scalebox}{\LWR@noscalebox}%
\LWR@htmlsmallfontstart\textsuperscript{#1}\,\LWR@htmlsmallfontend},
denominator-format = {%
\LetLtxMacro{\scalebox}{\LWR@noscalebox}%
\LWR@htmlsmallfontstart{}\,#1\LWR@htmlsmallfontend},
%    \end{macrocode}
% For |pdftotext|, do not scale the text:
%    \begin{macrocode}
scaling = false
}

\DeclareInstance{xfrac}{lmss}{text}{
numerator-format = {%
\LetLtxMacro{\scalebox}{\LWR@noscalebox}%
\LWR@htmlsmallfontstart\textsuperscript{#1}\,\LWR@htmlsmallfontend},
denominator-format = {%
\LetLtxMacro{\scalebox}{\LWR@noscalebox}%
\LWR@htmlsmallfontstart{}\,#1\LWR@htmlsmallfontend},
%    \end{macrocode}
% For |pdftotext|, do not scale the text:
%    \begin{macrocode}
scaling = false
}

\DeclareInstance{xfrac}{lmtt}{text}{
numerator-format = {%
\LetLtxMacro{\scalebox}{\LWR@noscalebox}%
\LWR@htmlsmallfontstart\textsuperscript{#1}\,\LWR@htmlsmallfontend},
denominator-format = {%
\LetLtxMacro{\scalebox}{\LWR@noscalebox}%
\LWR@htmlsmallfontstart{}\,#1\LWR@htmlsmallfontend},
%    \end{macrocode}
% For |pdftotext|, do not scale the text:
%    \begin{macrocode}
scaling = false
}
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
% \iffalse
%</xfrac>
% \fi
%
%
%
%
%
% \iffalse
%<*xltxtra>
% \fi
%
% \part{lwarp-xltxtra.sty}
%
% \section{xltxtra}
%
% \credits{Will Robertson, Jonathan Kew}
%
% \DescribePackage{xltxtra}
% \pkg{xltxtra} is emulated.
%
% \changes{v0.38}{2017/08/25}{\pkg{xltxtra}: Added.}
% \changes{v0.40}{2017/09/07}{\pkg{xltxtra}: Fix for \cs{showhyphens} with XeLaTeX.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{xltxtra}
%    \end{macrocode}
%
%    \begin{macrocode}
\RequirePackage{realscripts}
\RequirePackage{metalogo}
\newcommand*\TeX@logo@spacing[6]{}

\newcommand*{\vfrac}[2]{%
\textsuperscript{#1}/\textsubscript{#2}%
}

\newcommand\namedglyph[1]{%
  \@tempcnta=\XeTeXglyphindex "#1"\relax
  \ifnum\@tempcnta>0
    \XeTeXglyph\@tempcnta
  \else
    \xxt@namedglyph@fallback{#1}%
  \fi}

\newcommand\xxt@namedglyph@fallback[1]{[#1]}

\DeclareDocumentCommand{\showhyphens}{m}{}
%    \end{macrocode}
%
% \iffalse
%</xltxtra>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*xmpincl>
% \fi
%
% \part{lwarp-xmpincl.sty}
%
% \section{xmpincl}
%
% \credits{Maarten Sneep}
%
% \DescribePackage{xmpincl} Emulated.
%
% \changes{v0.34}{2017/08/03}{\pkg{xmpincl}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-xmpincl}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{xmpincl}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\includexmp}[1]{}
%    \end{macrocode}
%
% \iffalse
%</xmpincl>
% \fi
%
%
%
%
%
%
% \iffalse
%<*xtab>
% \fi

% \part{lwarp-xtab.sty}

% \section{xtab}
% \label{sec:xtab}
%
% \credits{Peter Wilson}
%
% \DescribePackage{xtab}
% \pkg{xtab} is emulated.
%
% \changes{v0.39}{2017/08/30}{\pkg{xtabular}: Added.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{xtab}
%    \end{macrocode}
%
% \limitssupertabular
%
%
%    \begin{macrocode}
\newcommand{\LWRXT@firsthead}{}

\newcommand{\tablefirsthead}[1]{%
    \long\gdef\LWRXT@firsthead{#1}%
}

\newcommand{\tablehead}[1]{}

\newcommand{\tablelasthead}[1]{}

\newcommand{\notablelasthead}{}

\newcommand{\tabletail}[1]{}

\newcommand{\LWRXT@lasttail}{}

\newcommand{\tablelasttail}[1]{%
    \long\gdef\LWRXT@lasttail{#1}%
}

\newcommand{\tablecaption}[2][]{%
    \long\gdef\LWRXT@caption{\caption[#1]{#2}}%
}

\let\topcaption\tablecaption
\let\bottomcaption\tablecaption

%    \end{macrocode}
% \changes{v0.44}{2017/11/19}{\pkg{xtab}: Fix for caption.}
%    \begin{macrocode}
\newcommand*{\LWRXT@caption}{}

\newcommand*{\shrinkheight}[1]{}

\newcommand*{\xentrystretch}[1]{}

\NewDocumentEnvironment{xtabular}{s o m}
{
\LWR@traceinfo{xtabular}
\table
\LWRXT@caption
\begin{tabular}{#3}
\TabularMacro\ifdefvoid{\LWRXT@firsthead}%
{\LWR@getmynexttoken}%
{\expandafter\LWR@getmynexttoken\LWRXT@firsthead}%
}
{%
\ifdefvoid{\LWRXT@lasttail}%
{}%
{%
\TabularMacro\ResumeTabular%
\LWRXT@lasttail%
}%
\end{tabular}
\endtable
\LWR@traceinfo{xtabular done}
}

\NewDocumentEnvironment{mpxtabular}{s o m}
{\minipage{\linewidth}\xtabular{#3}}
{\endxtabular\endminipage}
%    \end{macrocode}


% \iffalse
%</xtab>
% \fi
%
%
%
%
%
%
% \iffalse
%<*zwpagelayout>
% \fi
%
% \part{lwarp-zwpagelayout.sty}
%
% \section{zwpagelayout}
%
% \credits{Zdeněk Wagner}
%
% \DescribePackage{zwpagelayout}
% \pkg{zwpagelayout} is ignored.
%
% \changes{v0.39}{2017/08/28}{\pkg{zwpagelayout}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{zwpagelayout}
%    \end{macrocode}
%
%    \begin{macrocode}
\def\noBboxes{}
\@onlypreamble\noBboxes

\expandafter\ifx\csname definecolor\endcsname\relax \else
  \definecolor{cmykblack}{cmyk}{0,0,0,1}
  \definecolor{grblack}{gray}{0}
%   \ifzwpl@redefineblack
%     \definecolor{black}{cmyk}{0,0,0,1}\color{black}
%   \fi
  \definecolor{cmykred}{cmyk}{0,1,1,0}
  \definecolor{cmykgreen}{cmyk}{1,0,1,0}
  \definecolor{cmykblue}{cmyk}{1,1,0,0}
  \definecolor{rgbred}{rgb}{1,0,0}
  \definecolor{rgbgreen}{rgb}{0,1,0}
  \definecolor{rgbblue}{rgb}{0,0,1}
%   \ifzwpl@redefinetocmyk
%     \definecolor{red}{cmyk}{0,1,1,0}
%     \definecolor{green}{cmyk}{1,0,1,0}
%     \definecolor{blue}{cmyk}{1,1,0,0}
%   \fi
\fi

\let\OverprintXeTeXExtGState\relax

\DeclareRobustCommand\SetOverprint{\ignorespaces}
\DeclareRobustCommand\SetKnockout{\ignorespaces}
\DeclareRobustCommand\textoverprint[1]{{\SetOverprint#1}}
\DeclareRobustCommand\textknockout[1]{{\SetKnockout#1}}

\def\SetPDFminorversion#1{}
\@onlypreamble\SetPDFminorversion

\newcommand*\Vcorr{}

\DeclareRobustCommand\vb[1][]{}
\NewDocumentCommand{\NewOddPage}{* o}{}
\NewDocumentCommand{\NewEvenPage}{* o}{}
\def\SetOddPageMessage#{\gdef\ZW@oddwarning}
\def\SetEvenPageMessage#{\gdef\Z@@evenwarning}
\def\ZW@oddwarning{Empty page inserted}\let\ZW@evenwarning\ZW@oddwarning

\def\clap#1{#1}

\def\CropFlap{2in}
\def\CropSpine{1in}
\def\CropXSpine{1in}
\def\CropXtrim{.25in}
\def\CropYtrim{.25in}
\def\UserWidth{5in}
\def\UserLeftMargin{1in}
\def\UserRightMargin{1in}
\def\UserTopMargin{1in}
\def\UserBotMargin{1in}
\def\thePageNumber{\#\,\arabic{page}}
\ifXeTeX
\def\ifcaseZWdriver{\ifcase2}
\else
\def\ifcaseZWdriver{\ifcase1}
\fi
\DeclareRobustCommand\ZWifdriver[2]{}
%    \end{macrocode}
%
% \iffalse
%</zwpagelayout>
% \fi
%
%
%
%
%
%
%
%
%
% \clearpage
% \renewcommand*{\partname}{}
% \renewcommand*{\thepart}{}
%
% \titleformat{\part}[hang]
%     {\needspace{15\baselineskip}\LARGE\rmfamily\bfseries}{}{0pt}{}
%
% \titleformat{\section}[hang]
%     {\Large\rmfamily\bfseries}{}{0pt}{}[\marginpar{\hfill\textsection\,\thesection}\smallskip\hrule]
% 
%
% \part{Change History and Index}
% \label{sec:changehistory}
%
% \pagestyle{plain}
%
% \Finale
%
%
%
%
%
\endinput





