%
% \iffalse meta-comment
%
% Copyright 2016-2019 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>    [2019/02/23 v0.67  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{sourcesanspro}
% \usepackage{cabin}
% \usepackage[tabular,semibold]{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{‰}{\textperthousand}
\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}

% redefine \part to modify \@currentlabelname:
\makeatletter
\LetLtxMacro\LWR@titlesec@part\part
\RenewDocumentCommand{\part}{s o m}{%
\def\@currentlabelname{#3}%
\IfBooleanTF{#1}{% star
    \IfValueTF{#2}{% star opt
        \LWR@titlesec@part*[#2]{#3}%
    }{% star noopt
        \LWR@titlesec@part*{#3}%
    }%
}{% no star
    \IfValueTF{#2}{% opt
        \LWR@titlesec@part[#2]{#3}%
    }{% noopt
        \LWR@titlesec@part{#3}%
    }%
}%
}
\makeatother


\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[
    left=2in,
    right=1.5in,
    top=1.5in,
    bottom=1in
]{geometry}

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


\usepackage{metalogo}

\makeatletter
\@ifpackageloaded{erewhon}{
% for erewhon:
\setlogokern{Te}{-.08em}
\setlogokern{eX}{-0.04em}
\setlogokern{La}{-.25em}
\setlogokern{aT}{-.10em}
\setlogokern{Xe}{-.04em}
\setlogokern{eL}{-.06em}
\setlogodrop{0.27ex}
}{}
\makeatother


\usepackage{enumitem}

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

\usepackage[normalem]{ulem}

\usepackage{fancyvrb}

\usepackage{capt-of}

\usepackage{comment}

\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}[2019/01/11]


\usepackage{splitidx}

\newindex[Index of Objects]{idx}
\newindex[General Index]{gen}
\newindex[Troubleshooting Index]{trb}
\newindex[Index of Indexes]{meta}

\makeindex

\newcommand*{\gindex}[1]{\sindex[gen]{#1}\ignorespaces}



\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}}

\renewenvironment{abstract}
    {
        \addvspace{\bigskipamount}
        \begin{center}
        \textbf{\abstractname}
        \end{center}
%         \small
        \setlength{\parindent}{2em}
        \setlength{\parskip}{0ex}
    }
    {
        \addvspace{\bigskipamount}
    }

\makeatletter
\newcommand*{\rulebreak}{%
    \bigskip\hfill\rule[.7ex]{.3\linewidth}{.4pt}\hspace*{\fill}\bigskip\@afterheading%
}
\makeatother

\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{\codeconfig}{\leavevmode\marginpar{\footnotesize\raggedleft\textcolor{codecolor}{\textbf{Config file:~}}}\vspace{-5.25ex}}

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

\newcommand{\textred}[1]{\textcolor{red}{#1}}
\newcommand{\textgreen}[1]{\textcolor{green!50!black}{#1}}
\newcommand{\textblue}[1]{\textcolor{blue!70!black}{#1}}

\newcommand{\pdflatexonly}{
\textred{Only pre-loaded if \prog{pdflatex} is being used.}
\marginpar{\raggedleft\textblue{\prog{pdflatex} only:}}
}


% \trouble[watchout phrase]{index entry}
\newcommand*{\trouble}[2][]{%
\ifblank{#1}{}{%
    \watchout[#1]%
}%
\sindex[trb]{#2}%
\ignorespaces%
}


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

\newcommand{\needhelp}{
\begin{minipage}{\linewidth}
\hrule\smallskip
\small
See the \nameref{sec:indexgen} for ``how-to'', and
the \nameref{sec:indextrb} if something doesn't work.
The \nameref{sec:indexidx} contains automated entries for each package, macro, environment,
counter, boolean, and other objects; individually and also sorted by category.
A \nameref{sec:troubleshooting} section is also available.
\smallskip
\hrule
\end{minipage}\margintag{Need help?}
}

\newcommand{\usedbykomascript}{
This package may be loaded standalone, but
is also loaded automatically if \pkg{koma-script} classes are in use.
\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{\describemathimagename}{%
When creating an \SVG\ math image, its \attribute{alt} tag may be set
to the math expression, which may be hashed for image reuse.
In the case of \cs{ensuremath} or after \cs{inlinemathother},
where the contents require a unique image for each instance of the same expression,
the \attribute{alt} tag is set to \cs{mathimagename}, and the image is not reused.

This expression is visible in the browser if images are not loaded,
and appears when the text is copied and pasted.
The default is ``math image'', and it may be changed according to the document's language.
This may be set in the preamble, or changed as necessary inside the document,
where it will affect the following \SVG\ math images.
}

\newcommand{\describepackagediagramname}{%
For many packages, the output is placed inside a \env{lateximage} with an
\HTML\ \attribute{alt} tag set to the package name followed by \cs{packagediagramname}.
For example:
\begin{sourcedisplay}
(-xy- diagram)
\end{sourcedisplay}
This expression is visible in the browser if images are not loaded,
and appears when the text is copied and pasted.
The default is ``diagram'', and may it be changed according to the document's language.
This may be set in the preamble, or changed as necessary inside the document,
where it will affect the following \env{lateximage}s.
}

\newcommand{\limitscpageref}{%
\pkg{cleveref} and \pkg{varioref} are supported,
\trouble[\pkg{cleveref} page numbers]{page numbers}
\trouble{reference>page number}
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 \textred{4.1} and
    \textbf{for} table \textred{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.

Do not place a comment with a \texttt{\%} character between arguments
\trouble[comments between arguments]{hyperref=\pkg{hyperref}>comments between arguments}
for \cs{hyperref}, etc., as it is neutralized for inclusion in \HTML\ \URL{}s.

\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 the print version of \pkg{url}
create hyperlinks.

When generating \HTML, \pkg{lwarp}'s emulation of \pkg{hyperref} does not
\trouble[\pkg{backref}]{hyperref=\pkg{hyperref}>backref=\pkg{backref}}
\trouble{backref=\pkg{backref}}
automatically load \pkg{backref}, so \pkg{backref} must be loaded explicitly.
}

\newcommand{\limitsabstract}{%
If using the \optn{number} option with file splits,
\trouble[missing \TOC]{abstract>missing \TOC}
be sure to place the table of contents before the abstract.
The \optn{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
\trouble[load order]{authblk=\pkg{authblk}>titling=\pkg{titling}}
\trouble{titling=\pkg{titling}>authblk=\pkg{authblk}}
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 \optn{toc} without
\trouble[incorrect \TOC\ link]{appendix>incorrect \TOC\ link}
the option \optn{page} results in a \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{\limitspdftotextenc}{%
The option
\DescribeOption{pdftotextEnc}
\DescribeDefault{UTF-8}
\optn{pdftotextEnc} sets the encoding used by \prog{pdftotext}.
This is passed to \prog{pdftotext} using its \optn{-enc} option, and is
used when converting \LaTeX\ \PDF\ output with \HTML\ tags into
a plain-text file with \HTML\ tags.
}

\newcommand{\limitsbibtex}{%
When enough authors are cited for a source,
\watchout[Modify *.bib]
\trouble{Improper \cs{prevdepth}>bibtex=\pkg{bibtex}}
\trouble{bibtex=\pkg{bibtex}>Improper \cs{prevdepth}}
\trouble{bibtex=\pkg{bibtex}>\cs{etalchar}}
\trouble{etalchar=\cs{etalchar}}
\BibTeX\ may use the \cs{etalchar} command
to display a math superscript with a $+$ character to indicate ``and others''.
Without modification, this will result in an ``Improper \cs{prevdepth}'' error.
At present, \pkg{lwarp} requires that \cs{etalchar} be replaced by a text superscript.
To do so, add to the start of the \filenm{.bib} file the following:
\begin{sourcedisplay}
\hspace*{-6em}@PREAMBLE\{"\cs{let}\cs{etalchar}\cs{relax}
\cs{newcommand}\{\cs{etalchar}\}[1]\{\cs{textsuperscript}\{\#1\}\}"\}
\end{sourcedisplay}
}

\newcommand{\limitsgloss}{%
To process the \HTML\ glossary:
\begin{sourcedisplay}
bibtex <projectname>\textred{\_html}.gls
\end{sourcedisplay}
}

\newcommand{\limitsglossaries}{%
\margintag{processing glossaries}
\DescribeOption{GlossaryCmd}\DescribeDefault{makeglossaries}
\DescribeOption[lwarpmk]{printglossary}
\DescribeOption[lwarpmk]{htmlglossary}
\prog{lwarpmk} has the commands \texttt{lwarpmk printglossary} and
\texttt{lwarpmk htmlglossary}, which process the glossaries created by the
\pkg{glossaries} package using that package's \prog{makeglossaries} program.

The shell command to execute is set by the \pkg{lwarp} option \optn{GlossaryCmd},
which defaults to \cmds{makeglossaries}.
The print or \HTML\ glossary filename is appended to this command.

In some situations it may be required to modify the default command,
\trouble[\prog{makeglossaries} not found]{makeglossaries=\prog{makeglossaries}>not found}
\trouble{glossaries=\pkg{glossaries}>makeglossaries=\prog{makeglossaries} not found}
such as to add the \cmds{perl} command in front:
\begin{sourcedisplay}
\cs{usepackage}[ \\
\fquad\ GlossaryCmd=\{\textred{perl} makeglossaries\}, \\
] \{lwarp\}
\end{sourcedisplay}

To set the language to use for processing glossaries with \prog{xindy}:
\margintag{\prog{xindy} language}
\begin{sourcedisplay}
\cs{usepackage}[ \\
\fquad\ GlossaryCmd=\{makeglossaries \textred{-L english}\}, \\
] \{lwarp\}
\end{sourcedisplay}
Other options for \prog{makeglossaries} may be set as well.

The glossaries may be placed in a numbered or unnumbered section, given
\margintag{placement and \TOC\ options}
a \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}

The default \optn{style=item} option for \pkg{glossaries} conflicts
\trouble[glossary style]{glossaries=\pkg{glossaries}>style}
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,
\trouble[number list]{glossaries=\pkg{glossaries}>page numbers}
which could become a very long string if many items are referenced.
For now, the number list is simply turned off.

The print and \HTML\ versions of the glossary differ
\margintag{print/\HTML\ versions}
in their internal page numbers.
Separate commands for generating print and \HTML\ glossaries are used, even
though the page number is currently ignored.
}

\newcommand{\limitsnomencl}{%
To process the \HTML\ nomenclature:
\begin{sourcedisplay}
makeindex <project>\textred{\_html}.nlo -s nomencl.ist -o <project>\textred{\_html}.nls
\end{sourcedisplay}
}

\newcommand{\limitstocbibind}{%
An index may be placed inline with other \HTML\ text, or on its own \HTML\ page:
\margintag{placement and \TOC\ options}
\gindex{index>placement and \TOC\ options}
\gindex{index>table of contents}

\begin{description}

\item [Inline, with a manual \TOC\ entry:] \
\DescribePackage{makeidx}

    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}

\needspace{3\baselineskip}
\item [On its own \HTML\ page, with a manual \TOC\ entry:] \
\DescribePackage{makeidx}
    \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:] \
    \DescribePackage{tocbibind}

    The \pkg{tocbibind}
    package may be used to automatically place an entry in the \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:] \
    \DescribePackage{tocbibind}
    \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} \optn{numindex} option to generate a numbered index.
\DescribeOption[tocbibind]{numindex}
Without this option, the index heading has no number.
\margintag{numbered index section}

Other packages, such as \pkg{imakeidx}, may also have options for including
the index in the Table of Contents.
}

\newcommand*{\limitssplitidx}{%
If the \optn{latexmk} option is selected for \pkg{lwarp},
\prog{latexmk} will compile the document but will \emph{not} compile the indexes.
\cmds{lwarpmk printindex} and \cmds{lwarpmk htmlindex} will still be required.

When using \cs{AtWriteToIndex} or \cs{AtNextWriteToIndex}, the user must not
\trouble[\cs{thepage}]{splitidx=\pkg{splitidx}>\cs{thepage} and \cs{AtWriteToIndex}}
refer to \cs{thepage} during \HTML\ output, as the concept of a page number is
meaningless.  Instead, do
\begin{sourcedisplay}
    \cs{addtocounter}\{LWR@autoindex\}\{1\} \\
    \cs{LWR@new@label}\{LWRindex-\cs{arabic}\{LWR@autoindex\}\} \\
\end{sourcedisplay}
where the \cs{index}-like action occurs,
and then refer to \texttt{\cs{arabic}\{LWR@autoindex\}} instead of \cs{thepage}
where the reference should occur.

See \cref{sec:specialindex} in the \pkg{lwarp-patch-memoir} package
for the \cs{@@wrspindexhyp} macro as an example.
}

\newcommand{\limitsimakeidx}{%
When using \prog{makeindex}, to match the print and \HTML\ output's
\margintag{letter headings}
\gindex{index>letter headings}
display of index letter headings, specify the \filenm{lwarp.ist} style:
\begin{sourcedisplay}
\cs{makeindex}[options=\{-s lwarp.ist\}]
\end{sourcedisplay}
(For \HTML\ the \filenm{lwarp.ist} style is used automatically,
which displays letter headings.
When using \prog{xindy} the default style also displays letter headings.)

See \cref{sec:indexingimakeidx} for how to setup \prog{lwarpmk}
\margintag{index setup}
to process the indexes with \pkg{imakeidx}, both with and without shell escape.
}

\newcommand{\limitstocloft}{%
If using \pkg{tocloft} with \pkg{tocbibind}, \pkg{anonchap},
\DescribePackage{tocloft}
\trouble[\pkg{tocloft} \& other packages]{tocloft=\pkg{tocloft}>chapter titles}
\pkg{fncychap}, or other packages which change chapter title formatting,
load \pkg{tocloft} with its \optn{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 \optn{page} option is disabled.
}

\newcommand*{\limitsendnotes}{%
To place the endnotes in the \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,
\trouble[\cs{bfseries}, etc.]{text>\cs{bfseries} etc.}
\trouble{formatting>\cs{bfseries} etc.}
but \cs{bfseries}, etc.\ work only in some situations.

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

For program listings, the \pkg{listings} package is supported,
\margintag{program listings}
and its \optn{literate} option is used to convert
\texttt{\&}, \texttt{\textless}, and \texttt{\textgreater}
to proper \HTML\ entities.

The various \env{verbatim}-related environments do not convert
\texttt{\&}, \texttt{\textless}, and \texttt{\textgreater},
\margintag{verbatim}
so care must be taken to avoid accidentally including valid \HTML\ code inside
these environments.  Adding a space on either side may be sufficient.
}

\newcommand{\limitshspace}{%
\DescribeMacro{\hspace}%
\gindex{space>horizontal}%
\gindex{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}.

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

\DescribeMacro{\kern}%
\DescribeMacro{\hskip}%
\cs{kern} and \cs{hskip} are entered into the \HTML\ \PDF\ output as-is,
then interpreted by \prog{pdftotext}, and thus usually appear as a single 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.
\trouble[missing symbols]{textcomp=\pkg{textcomp}>missing symbols}
\trouble{font>missing symbols}
In the \CSS\ try referencing fonts which are more complete, 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}
\trouble[label characters]{label>characters}
\trouble{reference>label characters}
It is best to stick with alpha-numeric, hyphen, underscore, and perhaps the colon (if not French).

\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},
\trouble[empty link]{label>\cs{nameref} empty}
the link will be empty.
Index entries also use \cs{nameref} and have the same limitation.
\trouble{index>empty link}
\trouble{reference>empty link}
}

\newcommand{\limitspfnote}{
While emulating \pkg{pfnote}, \pkg{lwarp} is not able to reset \HTML\ footnote
\trouble[\pkg{pfnote} numbers]{pfnote=\pkg{pfnote}>numbering}
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 mostly work as-is.

The \pkg{footmisc} \optn{stable} option is emulated by \pkg{lwarp}.

When using footnotes in sectioning commands,
\trouble[sectioning commands]{footnote>sectioning, \pkg{footmisc}}
to generate consistent results between print and \HTML, use
the \pkg{footmisc} package with the \optn{stable} option,
provide a short \TOC\ entry, and \cs{protect} the \cs{footnote}:
\begin{sourcedisplay}
\cs{usepackage}[\textred{stable}]\{footmisc\}\\
\dots\\
\cs{subsection}\textred{[Subsection Name]}\\
\fqquad\{Subsection Name\textred{\cs{protect}}\cs{footnote}\{A footnote.\}\}
\end{sourcedisplay}
If using \pkg{memoir} class, with which \pkg{lwarp} preloads \pkg{footmisc}, the
\optn{stable} option must be declared before \pkg{lwarp} is loaded:
\trouble[\pkg{memoir}]{footnote>memoir=\pkg{memoir}}
\begin{sourcedisplay}
\cs{PassOptionsToPackage}\{\textred{stable}\}\{footmisc\} \\
\cs{usepackage}\{lwarp\} \\
\dots
\end{sourcedisplay}

Do not use a starred sectioning command.  As an alternative, it may be possible to
adjust \cs{secnumdepth} instead.
% Attempting to use \cs{footnotemark} instead
% of \cs{footnote} may result in misnumbered footnotes in the print document.
}

\newcommand{\limitsverbatimfootnotes}{%
If using \pkg{fancybox} or \pkg{fancyvrb} with \cs{VerbatimFootnotes},
\trouble[\cs{VerbatimFootnotes}]{footnote>VerbatimFootnotes=\cs{VerbatimFootnotes}}
and using footnotes in a sectioning command or display math,
\trouble[sectioning or displaymath]{footnote>sectioning, verbatim}
\trouble{footnote>displaymath}
\trouble{VerbatimFootnotes}
\trouble{fancybox=\pkg{fancybox}>VerbatimFootnotes=\cs{VerbatimFootnotes}}
\trouble{fancyvrb=\pkg{fancyvrb}>VerbatimFootnotes=\cs{VerbatimFootnotes}}
\trouble{footnote>paragraph tags}
use \cs{footnotemark} and \cs{footnotetext}:
\begin{sourcedisplay}
\cs{subsection}[Subsection Name]\\
\fqquad\{Subsection Name\cs{protect}\textred{\cs{footnotemark}}\} \\
\textred{\cs{footnotetext}}\{A footnote with \cs{verb}+verbtim+.\} \\
\end{sourcedisplay}
and likewise for equations or display math.

At present there is a bug such that paragraph closing tags are not present in
footnotes when \cs{VerbatimFootnotes} are selected.  The browser usually compensates.
}

\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{\limitsmemoir}{
While emulating \pkg{memoir}, \pkg{lwarp} pre-loads
a number of packages (\cref{sec:patch-memoir-packages}).
This can cause an options clash when the user's document later loads the same
\trouble[options clash]{memoir=\pkg{memoir}>options clash}
\trouble{options clash>memoir=\pkg{memoir}}
packages with options.  To fix this problem, specify the options before
loading \pkg{lwarp}:
\begin{sourcedisplay}
\cs{documentclass}\{memoir\} \\
\dots \\
\cs{PassOptionsToPackage}\{options\_list\}\{package\_name\} \\
\dots \\
\cs{usepackage\{lwarp\}} \\
\dots \\
\cs{usepackage\{package\_name\}}
\end{sourcedisplay}

\pkg{memoir} emulates a number of packages, and declares a version date for each
\trouble[version numbers]{memoir=\pkg{memoir}>version clash}
\trouble{package>version numbers with \pkg{memoir}}
\trouble{version numbers>with \pkg{memoir}}
which often does not match the date of the corresponding freestanding package.
This can cause warnings about incorrect version numbers.
Since \pkg{lwarp} is intended to support the freestanding packages,
which are often newer than the date declared by \pkg{memoir}, it is hoped that
\pkg{memoir} will update and change its emulated version numbers to match.

\cs{verbfootnote} is not supported.

\cs{newfootnoteseries}, etc. are not supported.

\pkg{lwarp} loads \pkg{pagenote} to perform \pkg{memoir}'s pagenote functions,
but there are minor differences in \cs{pagenotesubhead} and related macros.

Poem numbering is not supported.

The \env{verbatim} environment does not yet support the \pkg{memoir} enhancements.
It is currently recommended to load and use \pkg{fancyvrb} instead.

The \pkg{memoir} glossary system is not yet supported by \prog{lwarpmk}.
The \pkg{glossaries} package may be used instead,
but does require the glossary entries be
changed from the \pkg{memoir} syntax to the \pkg{glossaries} syntax.
}

\newcommand{\limitsverse}{%
When using \pkg{verse} or \pkg{memoir}, always place a
\texttt{\textbackslash\textbackslash} after each line.

\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{sourcedisplay}
\cs{begin}\{warpHTML\} \\
\cs{let}\cs{attrib}\cs{attribution} \\
\cs{end}\{warpHTML\}
\end{sourcedisplay}

\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 \prog{pdftotext}'s ability to discern the layout
\trouble[spacing]{verse>spacing}
(\optn{-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}{%
For the \env{lateximage} environment,
the size of the math and text used
\margintag{SVG image font size}
in the \SVG\ image may be adjusted
\gindex{font>size>lateximage}%
\gindex{font>size>math, SVG}%
\gindex{math>font size --- SVG}%
\gindex{lateximage>font size}%
by setting \cs{LateximageFontSizeName} to a font size name \Dash \emph{without the backslash},
which defaults to:
\begin{sourcedisplay}
\cs{renewcommand}\{\cs{LateximageFontSizeName}\}\{\textred{normalsize}\}
\end{sourcedisplay}

For inline \SVG\ math, font size is instead controlled by \cs{LateximageFontScale},
which defaults to:
\begin{sourcedisplay}
\cs{newcommand}*\{\cs{LateximageFontScale}\}\{\textred{.75}\}
\end{sourcedisplay}
}



\newcommand{\limitsmath}{%

\subsubsection{Math in section names}
\limitsmathinsectionnames

\subsubsection{Rendering tradeoffs}

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

Rendering math as images creates a new \SVG\ file for each expression, \margintag{SVG files}
except that an MD5 hash is used to combine identical duplicates of the same
inline math expression into a single file, which must be converted to \SVG\ only once.
Display math is still handled as individual files, since it may contain labels
or references which are likely to change.

The \SVG\ images are currently stored separately, \margintag{SVG inline}
but they could be encoded in-line directly into the \HTML\ document.
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 \LaTeX-to-\HTML\ 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 \brand{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
\gindex{math>SVG summary}%
\gindex{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.

SVG math does not work inside \TeX\ boxes, since a \cs{newpage} is required
\trouble[SVG math in \TeX\ boxes]{math>in \TeX\ boxes}
before and after each image.

\subsubsection{\brand{MathJax} option}

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

When \brand{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 \brand{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 \brand{MathJax} cross-referencing system is ignored in favor of the \LaTeX\ internal system,
seamlessly integrating with the rest of the \LaTeX\ code.
\end{enumerate}

\subsubsection{Customizing \brand{MathJax}}
\gindex{MathJax=\brand{MathJax}>custom functions}
\gindex{math>MathJax=\brand{MathJax} custom functions}
\limitscustomizemathjax

\subsubsection{\brand{MathJax} limitations}
Limitations when using \brand{MathJax} include:
\margintag{\brand{MathJax} limitations}
\DescribeProgram{MathJax}
\begin{itemize}
\item \brand{MathJax} itself does not support subequations.
    \margintag{subequations}
\trouble{MathJax=\brand{MathJax}>subequations}%
\trouble{math>subequations}%
    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 \brand{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 \brand{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 \brand{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.
    \trouble[siunitx inside an equation]{siunitx=\pkg{siunitx}>MathJax=\brand{MathJax}}
    \trouble{MathJax=\brand{MathJax}>siunitx=\pkg{siunitx}}

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

    Also see \cref{sec:limitssiunitx}.

\item A \env{tabbing} environment is emulated
    using an \HTML\ \element{pre}.\margintag{tabbing}
    While \brand{MathJax} is enabled inside \env{tabbing}, the browser may not correctly
    render the horizontal alignment of the math and text following after on the same line.

\item Other math-related macros and packages are not supported by \brand{MathJax},
    \trouble[other macros and packages]{MathJax=\brand{MathJax}>unsupported packages}
    including \cs{ensuremath} and \pkg{bigdelim},
    along with occasionally-used macros such as \cs{relax}.
    \pkg{lwarp} emulates footnotes, \pkg{units}, and \pkg{nicefrac} for MathJax.
\end{itemize}
}

\newcommand{\limitsmathcatcode}{
The math shift character \texttt{\$} is not set for \HTML\ output until
\margintag{preamble macros with math}
after the preamble.  Macros defined in the preamble which contain \texttt{\$}
must be enclosed between \cs{StartDefiningMath} and \cs{StopDefiningMath}
to temporarily change to the \HTML\ meaning of \texttt{\$}:
\begin{sourcedisplay}
\textred{\cs{StartDefiningMath}} \\
\cs{newcommand}\{\dots\} \\
\textred{\cs{StopDefiningMath}}
\end{sourcedisplay}

As an alternative, use \cs{(} and \cs{)} instead of \texttt{\$}, in which
case \cs{StartDefiningMath} and \cs{StopDefiningMath} are not necessary.

If a package defines macros using \texttt{\$}, it may be nessary to use
\cs{StartDefiningMath} and \cs{StopDefiningMath} before and after loading the
package.
}

\newcommand{\limitsmathinline}{
\DescribeMacro{\inlinemathnormal}
\DescribeMacro{\inlinemathother}
An inline math expression is usually converted to a reusable hashed \SVG\ math
image, or a MathJax expression.  The hash or expression depends on the contents
of the math expression.  In most cases this math expression is static, such as \texttt{\$x+1\$},
so the image can be reused for multiples instances of the same expression.
In some cases,
\margintag{changing contents}
the math expression includes a counter or other object which may
change between uses.
Another problem is complicated contents
\margintag{complicated \attribute{alt} tag}
which do not expand well in an \attribute{alt} tag.
The macro \cs{inlinemathother} may be used before a dynamic
math expression, and \cs{inlinemathnormal} after.  Doing so tells \pkg{lwarp} to
use an unhashed \SVG\ math image, even if MathJax is in use.
See \cref{sec:localizingdynamicmath}.
}

\newcommand*{\limitsmathdisplay}{
\DescribeMacro{\displaymathnormal}
By default, or when selecting \cs{displaymathnormal},
\brand{Mathjax} math display environments print their contents
as text into \HTML,
and \SVG\ display math environments render their contents as \SVG\ images
and use their contents as the \attribute{alt} tag of \HTML\ output.
To do so, the contents are loaded into a macro for reuse.
In some cases, such as complicated \tikz\ pictures, compilation will fail.

\DescribeMacro{\displaymathother}
When selecting \cs{displaymathother},
it is assumed that the contents are more complicated than ``pure''
math.
An example is an elaborate \tikz\ picture,
\margintag{MathJax unsupported}
which will not render in \brand{MathJax} and
will not make sense as an \HTML\ \attribute{alt} tag.
\margintag{complicated \attribute{alt} tag}
In this mode, \brand{MathJax} is turned off,
math display environments become \SVG\ images, even if \brand{MathJax} is selected,
and the \HTML\ \attribute{alt} tags become simple messages.
The contents are internally processed as an environment instead of a macro argument,
so complicated objects such as \tikz\ pictures are more likely to compile successfully.
}


\newcommand{\limitscustomizemathjax}{%
\brand{MathJax} does not have preexisting support every possible math function.
Additional \brand{MathJax} function definitions may be
defined.  These will be declared at the start of each \HTML\ page,
and thus will have a global effect.

Examples:
\begin{sourcedisplay}
\cs{CustomizeMathJax}\{ \\
    \fqquad\cs{newcommand}\{\cs{expval}\}[1]\{\cs{langle}\#1\cs{rangle}\} \\
    \fqquad\cs{newcommand}\{\cs{abs}\}[1]\{\cs{lvert}\#1\cs{rvert}\} \\
\} \\
\cs{CustomizeMathJax}\{\cs{newcommand}\{\cs{arsinh}\}\{\cs{text}\{arsinh\}\}\} \\
\cs{CustomizeMathJax}\{\cs{newcommand}\{\cs{arcosh}\}\{\cs{text}\{arcosh\}\}\}
\cs{CustomizeMathJax}\{\cs{newcommand}\{\cs{NN}\}\{\cs{mathbb}\{N\}\}\}
\end{sourcedisplay}
}

%\newcommand{\limitscustomizeKaTeX}{%
%Ka\TeX\ does not have preexisting support every possible math function.
%Additional Ka\TeX\ function definitions may be
%defined.  These will be declared at the start of each \HTML\ page,
%and thus will have a global effect.

%Examples:
%\begin{sourcedisplay}
%\cs{CustomizeKaTeX}\{ \\
    %\fqquad\cs{gdef}\cs{expval}\#1\{\cs{langle}\#1\cs{rangle}\} \\
    %\fqquad\cs{gdef}\cs{abs}\#1]\{\cs{lvert}\#1\cs{rvert}\} \\
%\} \\
%\cs{CustomizeKaTeX}\{\cs{gdef}\cs{arsinh}\{\cs{text}\{arsinh\}\}\} \\
%\cs{CustomizeKaTeX}\{\cs{gdef}\cs{arcosh}\{\cs{text}\{arcosh\}\}\}
%\cs{CustomizeKaTeX}\{\cs{gdef}\cs{NN}\{\cs{mathbb}\{N\}\}\}
%\end{sourcedisplay}
%}

\newcommand*{\limitsmathinsectionnames}{
If using named \HTML\ files,
in section names use paren math \texttt{\textbackslash(x+y\textbackslash)}
\trouble[math in section names]{filename>math in}
\trouble{sectioning>math in name}
\trouble{math>section name}
\trouble{math>file name}
instead of dollar math \texttt{\$x+y\$}.
(Dollar math works, but appears in the filename.)
Or, use a short name for the \TOC\ entry without the math, or use \cs{texorpdfstring}:
\begin{sourcedisplay}
\cs{section}\{A math \cs{texorpdfstring}\{\$1+2=3\$\}\{text description\} name\}
\end{sourcedisplay}
}

\newcommand{\limitschemfig}{%
If using \cs{polymerdelim} to add delimiters to a \cs{chemfig},
wrap both inside a single \env{lateximage}:
\begin{sourcedisplay}
\cs{begin}\{lateximage\}[(-chemfig-\textasciitilde\cs{packagediagramname})] \\
\cs{chemfig}\{\dots\} \\
\cs{polymerdelim}[\dots]\{\dots\} \\
\cs{end}\{lateximage\}
\end{sourcedisplay}
}

\newcommand{\limitschemformula}{%
\pkg{chemformula} works best without \brand{MathJax}.
\trouble[\pkg{chemformula} with \brand{MathJax}]{MathJax=\brand{MathJax}>chemformula=\pkg{chemformula}}
\trouble{chemformula=\pkg{chemformula}>MathJax=\brand{MathJax}}
If \brand{MathJax} is used,
\cs{displaymathother} must be used before \env{array}, and then
\cs{displaymathnormal} may be used after.
(The \pkg{chemformula} package adapts to \env{array},
but does not know about \brand{Mathjax}, and
\brand{MathJax} does not know about \pkg{chemformula}.)

While using \brand{Mathjax}, \cs{displaymathother} may also be used
for other forms of display and inline math which contain \pkg{chemformula} expressions.
}

\newcommand{\limitsntheorem}{%
This conversion is not total.
\trouble[Font control]{ntheorem=\pkg{ntheorem}>font}
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%
\trouble[Equation numbering]{ntheorem=\pkg{ntheorem}>numbering}
\trouble{math>equation numbering>ntheorem=\pkg{ntheorem}}
\trouble{AMSmath>ntheorem=\pkg{ntheorem}>numbering}
when the option \optn{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
\optn{thref} option.
}

\newcommand{\limitsgraphics}{%
\limitsincludegraphicsscale

For \cs{includegraphics} with \filenm{.pdf} or \filenm{.eps} files,
\gindex{graphics>formats}
\gindex{includegraphics=\cs{includegraphics}>using}
\gindex{PDF image>using}
\gindex{EPS image>using}
\gindex{image>PDF or EPS>using}
\margintag{\cs{includegraphics} file formats}
the user must provide a \filenm{.pdf} or \filenm{.eps} image file for use
in print mode, and also a \filenm{.svg}, \filenm{.png}, or \filenm{.jpg} version
of the same image for use in \HTML.
\begin{sourcedisplay}
\cs{includegraphics}\{filename\}    \% print:.pdf/.eps  HTML:.svg, etc.
\end{sourcedisplay}
For print output, \pkg{lwarp} will automatically choose the \filenm{.pdf} or \filenm{.eps}
format if available, or some other format otherwise.
For \HTML, one of the other formats is used instead.

If a \filenm{.pdf} or \filenm{.eps} image is referred to with its file extension,
the extension will be changed to \filenm{.svg} for \HTML:
\begin{sourcedisplay}
\cs{includegraphics}\{filename.pdf\} \% uses .svg in \HTML \\
\cs{includegraphics}\{filename.eps\} \% uses .svg in \HTML \\
\end{sourcedisplay}

\DescribeProgram{pdftocairo}
\margintag{PDF to SVG}
To convert a \PDF\ image to \SVG, use the utility \prog{pdftocairo}:
\userentry{pdftocairo -svg filename.pdf}
For a large number of images, use \prog{lwarpmk}:
\DescribeProgram{lwarpmk pdftosvg}
\userentry{lwarpmk pdftosvg *.pdf \qquad \textrm{(or a list of filenames)}}

\DescribeProgram{lwarpmk epstopdf}
\DescribeProgram{epstopdf}
\margintag{\pkg{epstopdf} package}
For \EPS\ images converted to \PDF\ using the package \pkg{epstopdf},
use \userentry{lwarpmk pdftosvg *.PDF} to convert to \SVG\ images.

When using \DVI\ \prog{latex},
\margintag{DVI latex}
it is necessary to convert \EPS\ to \PDF\ and then to \SVG:
\gindex{image>PDF or EPS>converting}
\userentry{lwarpmk epstopdf *.eps\qquad \textrm{(or a list of filenames)}}
\userentry{lwarpmk pdftosvg *.pdf\qquad \textrm{(or a list of filenames)}}

For \PNG\ or \JPG
\margintag{PNG and JPG}
\gindex{image>PNG and JPG}
\gindex{PNG images}
\gindex{JPG images}
while using \prog{pdflatex}, \prog{lualatex}, or \prog{xelatex},
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.

GIF files may be used for \HTML,
\margintag{GIF}
\gindex{image>GIF}
\gindex{GIF images}
but another format must also be provided for print output.

If a file extension is not used,
\margintag{file extension priorities}
\trouble{image>format priorities}
\trouble{graphics>image format priorities}
for \HTML\ the file extension priorities
are: \SVG, \GIF, \PNG, then \JPG.

If using the older \pkg{graphics} syntax, use both optional arguments
\trouble[\pkg{graphics} vs. \pkg{graphicx}]{graphics>optional arguments}
\trouble{includegraphics=\cs{includegraphics}>optional arguments}
for \cs{includegraphics}.
A single optional parameter is interpreted as the newer \pkg{graphicx} syntax.
Note that viewports are not supported by \pkg{lwarp} \Dash
\trouble[viewport]{graphics>viewport}
\trouble[viewport]{image>viewport}
\trouble{viewport}
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 \optn{width=.5\cs{linewidth}},
or similar for \cs{textwidth} or \cs{textheight}
to give fixed-sized images proportional to a 6 by 9 inch text area.
Do not use the \optn{scale} option, since it is not well supported by \HTML\ browsers.

\cs{includegraphics} accepts \optn{width} and \optn{height},
\margintag{options}
\optn{origin}, \optn{rotate} and \optn{scale},
plus new \optn{class} and \optn{alt} keys.

With \HTML\ output, \cs{includegraphics} accepts an optional
\margintag{\HTML\ class}
\optn{class=xyz} keyval combination, and if this is given then
the \HTML\ output will include that class for the image.
The class is ignored for print output.

Likewise, the \cs{includegraphics} \optn{alt} key adds an \HTML\ \attribute{alt} tag to
\margintag{\HTML\ \attribute{alt} tags}
an image, and is ignored for print output.  If not assigned, each
image is given an \attribute{alt} tag of ``\optn{(image)}''.

\cs{rotatebox} accepts the optional \optn{origin} key.
\margintag{\cs{rotatebox}}

\cs{rotatebox}, \cs{scalebox}, and \cs{reflectbox} depend
\trouble[browser support]{graphics>\cs{rotatebox}, \cs{scalebox}, \cs{reflectbox}}
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*{\limitsincludegraphicsscale}{
Avoid using the \cs{includegraphics} \optn{scale} option.  Change:
\trouble[\optn{scale}]{scale=\optn{scale} (\cs{includegraphics} option)}
\trouble{includegraphics=\cs{includegraphics}>scale=\optn{scale}}
\trouble{graphics>scale=\optn{scale} option}
\begin{sourcedisplay}
\cs{includegraphics}[scale=<xx>]\{\,\dots\}
\end{sourcedisplay} to:
\begin{sourcedisplay}
\cs{includegraphics}[width=<yy>\textbackslash{linewidth}]\{\,\dots\}
\end{sourcedisplay}
}

\newcommand{\limitssvgimages}{%
When a math expression, \env{picture}, or \tikz\ environment is added or
\trouble[adding/removing]{SVG image>out of order}
\trouble{graphics>images out of order}
removed, the \SVG\ images must be re-created by entering \cmds{lwarpmk limages}
to maintain the proper image-file associations.
Inline \SVG\ math may be hashed and thus not need to be recreated, but
display math and objects such as \tikz\ may move to new image numbers when
the document is changed.

Before attempting to create the \SVG\ image files,
\prog{lwarpmk} verifies that the \HTML\ version of the document exists and
has correct internal image references.\footnote{This becomes important
when dealing with a document containing thousands of images.}
If it is necessary to recompile the document's \HTML\ version one more time,
\prog{lwarpmk} will inform the user with an error message.%

If \HTML\ appears where an \SVG\ image should be, %
\trouble[\HTML\ instead of images]{image>appears as \HTML\ code}%
\trouble{math>appears as \HTML\ code}%
\trouble{SVG image>appears as \HTML\ code}%
\trouble{image>appears as \HTML\ code}%
\trouble{HTML>image appear as \HTML\ code}
 recompile the document one more
time to get the page numbers back in sync, then remake the images one more time.
\prog{lwarpmk} attempts to detect this situation and print a warning.

Incorrect \SVG\ images will also occur if the document
changes the \progcode{page} counter:
\trouble[page counter]{page counter>SVG images}
\trouble{SVG image>incorrect}
\trouble{math>incorrect}
\trouble{image>incorrect}
\begin{sourcedisplay}
\cs{setcounter}\{page\}\{<value>\}
\end{sourcedisplay}
The \texttt{page} counter must \emph{not} be adjusted by the user.

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!]
For inline math, and some other objects, \pkg{lwarp} uses an MD5 hash
on its \LaTeX\ source to combine multiple instances of identical inline expressions
into a single image file,
but display math and other environments such as \env{picture} and \tikz\ require
one image file each.
For a document with a large amount of math,
see \cref{sec:tutorialmathjax} to use \brand{MathJax} instead.
}

\newcommand{\limitstikz}{%
If using display math with \env{tikzpicture} or \cs{tikz}, along
\trouble[displaymath and matrices]{tikz>matrices, \&}
with matrices with the \texttt{\&} character, the document must be modified as follows:
\begin{sourcedisplay}
\cs{usepackage}\{tikz\} \\
\cs{tikzset}\{every picture/.style=\{ampersand replacement=\textbackslash\&\}\} \\
\end{sourcedisplay}
and each instance of \texttt{\&} in the \pkg{tikz} expression must be
replaced with \texttt{\textbackslash\&}.\
}

\newcommand{\limitsgrffile}{%
\pkg{grffile} is supported as-is.
File types known to the browser are displayed, and unknown file types are given a link.
Each \PDF\ image for print mode should be accompanied
\trouble[matching \PDF\ and \SVG]{grffile=\pkg{grffile}}
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}.
When \pkg{color} is requested, \pkg{xcolor} is loaded 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 \optn{none},
\margintag{background: \optn{none}}
in which case only the frame is drawn, which can be useful for \HTML.

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

\cs{rowcolors} is supported, except that the optional argument is ignored so far.
\margintag{colored 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{\limitsepstopdf}{%
Images with an \filenm{.eps} extension will be converted to \filenm{.pdf}.
The \HTML\ output uses the \filenm{.svg} version, so
\trouble[convert to \filenm{.svg}]{epstopdf=\pkg{epstopdf}}
use \userentry{lwarpmk pdftosvg <listofPDFfiles>} to generate \filenm{.svg} versions.
}

\newcommand{\limitspstricks}{%
All \pkg{pstricks} content should be
\trouble[use \env{pspicture}]{pstricks=\pkg{pstricks}}
contained inside a \env{pspicture} environment.
}

\newcommand{\limitspdftricks}{%
The \pkg{pdftricks} image files \filenm{<jobname>-fig*.pdf} must be converted
\trouble[convert image files]{pdftricks=\pkg{pdftricks}}
to \filenm{.svg}, or else a missing file error will occur.
The image files must also be converted again whenever they change.
To convert the images:\userentry{lwarpmk pdftosvg <jobname>-fig*.pdf}
}

\newcommand{\limitspsfrag}{%
The \env{psfrags} environment is modified to use \env{lateximage} to encapsulate
\watchout[use \env{psfrags}]
the image.
Always use a \env{psfrags} environment to contain any local \cs{psfrag} macros and
the associated \cs{includegraphics} or \cs{epsfig} calls.
Outside of a \env{psfrags} environment, \pkg{psfrags} adjustments will not be seen
by \pkg{lwarp}.

Tip: Use a mono-spaced font for the tags in the \EPS\ file.
\watchout
}

\newcommand{\limitspstool}{%
\cs{graphicspath} is ignored, and the file directory must be stated.

The filename must not have a file extension.
\trouble[path and filename]{pstool=\pkg{pstool}}

Use \userentry{lwarpmk html} followed by \userentry{lwarpmk limages}.
}

\newcommand{\limitsasymptote}{%
To compile:
\begin{sourcedisplay}
pdflatex project.tex \\
asy project-*.asy \\
pdflatex project.tex \\ [\baselineskip]
lwarpmk print \\
asy project-*.asy \\
lwarpmk print1 \\
lwarpmk print1 \\[\baselineskip]
lwarpmk html \\
asy project\textred{\_html}-*.asy \\
lwarpmk html1 \\
lwarpmk html1 \\
\textred{lwarpmk limages} \\
\end{sourcedisplay}
}

\newcommand{\limitsoverpic}{%
The macros \cs{overpicfontsize} and \cs{overpicfontskip} are used during
\trouble[scaling]{overpic=\pkg{overpic}}
\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{\limitstabbing}{%
The \env{tabbing} environment works, except that \SVG\ math and \env{lateximage}s
do not yet work inside the environment.

If math is used inside \env{tabbing},
\trouble[math in \env{tabbing}]{tabbing=\env{tabbing}>math}
\trouble{math>tabbing=\env{tabbing}}
place \env{tabbing} inside
a \env{lateximage} environment, which will render the entire environment as
a single \SVG\ image.
}

\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 macros and environments:] \
    \begin{itemize}
    \item When defining environments or macros which include \env{tabular} and
        \trouble[Misplaced alignment tab character \&]%
            {Misplaced alignment tab character \&>tabular>macros}
        \trouble{tabular>Misplaced alignment tab character \&>macros}
        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}
        \textred{\cs{StartDefiningTabulars}} \\
        <define macros or environments using \env{tabular} and \texttt{\&} here> \\
        \textred{\cs{StopDefiningTabulars}}
        \end{sourcedisplay}
        This includes before and after defining any macro
        \trouble[floatrow]{floatrow=\pkg{floatrow}>ttabbox=\cs{ttabbox}}
        which used \cs{ttabbox} from \pkg{floatrow}.
    \item \limitsresumetabular
    \end{itemize}

\item [Cell contents:] \
    \begin{itemize}
    \item For \pkg{multirow}, insert \cs{mrowcell} into any empty multi-row cells.
        \trouble[\cs{multirow}]{tabular>multirow=\pkg{multirow}}
        \trouble{multirow=\pkg{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\ \& & \textred{\cs{mrowcell}} & \&\ \dots \\
        \end{tabular}
        \end{sourcedisplay}
        Note that recent versions of \pkg{multirow} include a new optional
        \margintag{\optn{vposn}}
        \optn{vposn} argument.
    \item The \pkg{multirow} documentation regarding colored cells recommends using
        a negative number of rows.  This will not work with \pkg{lwarp}, so
        \cs{warpprintonly} and \cs{warpHTMLonly} must be used to make versions for
        print and \HTML.
    \item
        See \cref{sec:multicolumnmultirow} for \cs{multicolumrow}.

        \limitsmulticolumnrow

    \item Using a custom macro inside a tabular data cell
        \trouble[macro in a table]{tabular>macro inside}
        \trouble{tabular>row corruption}
        \gindex{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}
        \textred{\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).
        \trouble[* column specification]{tabular>*=\texttt{*} 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}.
        \trouble[\cs{newcolumntype}]{tabular>newcolumntype=\cs{newcolumntype}}
    \end{itemize}

\item [Rules:] \
    \begin{itemize}
    \item Doubled \cs{hline}s, \cs{midrule}s, and vertical rules are supported.

    \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},
        \trouble[\cs{warpprintonly}]{Misplaced \cs{noalign}>tabular>rules}
        \trouble{tabular>rules}
        when combined with a \env{warpprint} or \env{warpHTML} environment,
        \trouble[Misplaced \cs{noalign}]{tabular>Misplaced \protect\cs{noalign}}%
        if a ``Misplaced \cs{noalign}'' error occurs,
        change
        \begin{sourcedisplay}
        This \& That \cs{endhead}
        \end{sourcedisplay}
        to
        \begin{sourcedisplay}
        \textred{\cs{warpprintonly}\{}This \& That \cs{endhead}\textred{\}}
        \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[\pkg{colortbl}:] \

    \limitscolortbl

\needspace{3\baselineskip}
\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),
        \trouble[S columns]{siunitx=\pkg{siunitx}>S column}
        \trouble{tabular>S column}
        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 \& \textred{\{}\cs{multirow}\{2\}\{2cm\}\{Text\}\textred{\}} \& 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
\trouble[\cs{multicolumn} \& \cs{multirow}]{multirow=\cs{multirow} and \cs{multicolumn}}
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\}}%
  \textgreen{[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\ \& & \textred{\cs{mcolrowcell}} \hfill \& \hfill \textred{\cs{mcolrowcell}} & \&\ \dots \\
\dots\ \& & \textred{\cs{mcolrowcell}} \hfill \& \hfill \textred{\cs{mcolrowcell}} & \&\ \dots \\
\end{tabular}
\end{sourcedisplay}

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

\newcommand{\limitsresumetabular}{%
When creating a new environment
\trouble[\env{tabular} inside another environment]{tabular>inside an environment}
\trouble{tabular>corrupt rows}
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}
\textred{\cs{StartDefiningTabulars}} \% because \& is used in a definition \\
\cs{newenvironment}\{outerenvironment\} \\
\{ \\
\cs{tabular}\{cc\} \\
left \& right \textbackslash\textbackslash \\
\} \\
\{ \\
\textred{\cs{TabularMacro}\cs{ResumeTabular}} \\
left \& right \textbackslash\textbackslash \\
\cs{endtabular} \\
\} \\
\textred{\cs{StopDefiningTabulars}} \\
\end{sourcedisplay}
}

\newcommand{\limitslongtable}{%
Longtable \cs{endhead}, \cs{endfoot}, and \cs{endlastfoot} rows are
not used for \HTML, and these rows should be disabled.
\trouble[Misplaced \cs{noalign}]{Misplaced \cs{noalign}}
\trouble{tabular>endhead=\cs{endhead}, \cs{endfoot}, \cs{endlastfoot}}
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
\trouble[\cs{kill}]{tabular>kill=\cs{kill}}
    \begin{sourcedisplay}
    \cs{begin}\{warpprint\} \ldots\  \cs{end}\{warpprint\}
    \end{sourcedisplay}
or place it inside \cs{warpprintonly}.

\pkg{longtable} is not supported inside a \env{lateximage}.%
\watchout[lateximage]
}

\newcommand{\limitssupertabular}{%
For \cs{tablefirsthead}, etc., enclose them as follows:
\trouble[Misplaced alignment tab character \&]%
    {Misplaced alignment tab character \&>supertabular=\pkg{supertabular}}
\begin{sourcedisplay}
\textred{\cs{StartDefiningTabulars}} \\
\cs{tablefirsthead} \\
\dots \\
\textred{\cs{StopDefiningTabulars}}
\end{sourcedisplay}
See \cref{sec:limitstabular}.

\pkg{supertabular} and \pkg{xtab} are not supported
inside a \env{lateximage}.\watchout[lateximage]
}

\newcommand{\limitsbigdelim}{%
\cs{ldelim} and \cs{rdelim} use \cs{multirow}, so
\trouble[use \cs{mrowcell}]{bigdelim=\pkg{bigdelim}}
\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\} \\
\textgreen{<empty>} \& a \& b \textbackslash\textbackslash \\
\cs{ldelim}\{\textbackslash\{\}\{2\}\{.25in\}[left ] \& c \& d \textbackslash\textbackslash \\
\textred{\cs{mrowcell}} \& e \& f \textbackslash\textbackslash \\
\textgreen{<empty>} \& g \& h \textbackslash\textbackslash \\
\cs{end}\{tabular\}
\smallskip\hrule
\begin{tabular}{lll}
\textgreen{<>} & a & b \\
\ldelim{\{}{2}{.25in}[left ] & c & d \\
\mrowcell & e & f \\
\textgreen{<>} & g & h \\
\end{tabular}
\hrule
\end{sourcedisplay}
}

\newcommand{\limitscolortbl}{%
Only use \cs{rowcolor} and \cs{cellcolor} at the start of a row,
in that order.
\trouble[row/cell color]{colortbl=\pkg{colortbl}}

\pkg{colortbl} ignores the overhang arguments.
}


\newcommand{\limitsmakelabel}{%
While inside a list environment, \pkg{lwarp} nullifies a number of
\TeX\ horizontal skip and fill commands, allowing the user to define
\cs{makelabel} for print mode while \HTML\ mode ignores those commands.

When defining \cs{makelabel} in a \env{list} environment, use
\trouble[label font]{lists>label formatting}
\trouble{makelabel=\cs{makelabel}}
\cs{textbf} etc. instead of \cs{bfseries}.
}

\newcommand{\limitslists}{%
}

\newcommand{\limitsmarginpars}{%
\DescribeMacro{\marginpar} \oarg{left} \marg{right}
\qquad
\trouble{marginpar=\cs{marginpar}}
\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}{%
\trouble{boxes}
\trouble{HTML>corrupted}
\TeX\ 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 \env{minipage}
\trouble[inline]{minipage>inline}
or \cs{parbox} will have the \env{minipage} or \cs{parbox} placed onto its own line,
because a paragraph is a block element and cannot be made \attribute{inline-block}.

\env{minipage}s and \cs{parbox}es will be placed side-by-side in \HTML\
\margintag{placement}
unless you place a \cs{newline} between them.

Side-by-side \env{minipage}s 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 \env{center} environment, the result is
similar in print and \HTML.  Paragraph tags are suppressed between
side-by-side \env{minipage}s and these spacing commands, but not at the start or end
of the paragraph.

There is limited support for \env{minipage}s inside an \HTML\ \element{span}.
\trouble[minipage in a span]{minipage>in a span}
An \HTML\ \element{div} cannot appear inside a \element{span}.
While in a \element{span}, \env{minipage}s, and \cs{parbox}es, 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},
\trouble[minipage size]{minipage>size}
widths and heights in \HTML\ are scaled proportionally to a 6\texttimes{}9 inch text area,
and inside a \env{multicols} \cs{linewidth} is divided by the specified number
of columns.

If a \env{minipage} or \cs{parbox} is assigned a width of exactly \cs{linewidth},
\margintag{if width is \cs{linewidth}}
in \HTML\ it is automatically given no \HTML\ width,
thus allowed to fill the line as needed, similar to how it appears in print output.

A new macro \cs{minipagefullwidth} requests
\margintag{full-width if \HTML}
that, during \HTML\ output, the next single \env{minipage} or \cs{parbox} be generated
without an \HTML\ \attribute{width} attribute, allowing it to be the full width of
the display rather than the declared print-output width.  This may be useful where
the printed version's width makes no sense in \HTML.

Inside a \env{tabular} or \env{multicols} environment,
\trouble[\env{tabular}, \env{multicols}]{minipage>tabular=\env{tabular}, width in}
\trouble{minipage>multicols=\env{multicols}, width in}
where the width depends on the browser window,
\cs{minipagefullwidth} is effectively used by default for
every \env{minipage} or \cs{parbox} inside the environment.
\DescribeMacro{\UseMinipageWidths}
\DescribeMacro{\IgnoreMinipageWidths}
\cs{UseMinipageWidths} may be used to tell \pkg{lwarp} to honor the specified
widths of all following \env{minipage}s and \cs{parboxes} until the end
of the local scope, and \cs{IgnoreMinipageWidths} may be used to tell \pkg{lwarp} to
ignore the specified widths.

Nested \env{minipage}s adopt their parent's text alignment in \HTML,
\trouble[text alignment]{minipage>alignment}
whereas in regular \LaTeX{} \PDF\ output they do not.
Use a \env{flushleft} or similar environment in the child \env{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 \env{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,
\trouble[framed verbatim]{verbatim>framed}
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 \prog{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 \optn{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.

\optn{theoremtitlefont} is not supported, since the following text is not
\margintag{theoremtitlefont}
in braces in the \pkg{mdframed} source.

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

Environments created or encapsulated by \pkg{mdframed} are enclosed in a
\margintag{\CSS\ classes}
\element{div} of class \attribute{mdframed}, and also
class \attribute{md<environmentname>} for new environments.

Frame titles are placed in a \element{div} of class |mdframedtitle|.
Subtitles are in a \element{div} of class |mdframedsubtitle|,
and likewise for subsubtitles.
}

\newcommand{\limitscaption}{%
To pass options to caption, select the options before loading \pkg{lwarp}:
\trouble[options]{caption=\pkg{caption}>options}
\begin{sourcedisplay}
\cs{documentclass}\{article\} \\
\dots \\
\cs{PassOptionsToPackage}\{options\_list\}\{caption\} \\
\dots \\
\cs{usepackage\{lwarp\}} \\
\dots \\
\cs{usepackage\{caption\}}
\end{sourcedisplay}

To ensure proper float numbering, set caption positions
such as:
\trouble[numbering]{caption=\pkg{caption}>numbering}
\trouble{subcaption=\pkg{subcaption}>numbering}
\begin{sourcedisplay}
\cs{captionsetup}[figure]\{position=bottom\} \\
\cs{captionsetup}[subfigure]\{position=bottom\} \\
\cs{captionsetup}[table]\{position=top\} \\
\cs{captionsetup}[subtable]\{position=top\}
\end{sourcedisplay}
Similarly for \pkg{longtable}.
These positions depend on where the user places the \cs{caption} command
inside each float.
}

\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 \optn{lofdepth} and \optn{lotdepth}
\trouble[\optn{lof/lotdepth}]{subfig=\pkg{subfig}>options}
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*}
\trouble{horizontal spacing}{subfig>inline}
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{\limitsfloatalignment}{%
\cs{centering}, etc. are honored in a \env{figure} or \env{table} if
\trouble[\env{figure} \& \env{table} alignment]{float>alignment}
they are the first command inside the float:
\begin{sourcedisplay}
\cs{begin}\{table*\} \\
\cs{centering} \\
\cs{caption}\{A Table\} \\
\dots
\end{sourcedisplay}
}

\newcommand{\limitsfloatrow}{%
Use \cs{StartDefiningTabulars} and \cs{StopDefiningTabulars} before and after
\trouble[Misplaced alignment tab character \&]%
    {Misplaced alignment tab character \&>floatrow=\pkg{floatrow}}
defining macros using \cs{ttabbox} with a tabular inside.
See \cref{sec:limitstabular}.

When combined with the \pkg{subfig} package,
\trouble[\pkg{subfig} package]{floatrow>with \pkg{subfig}}
\trouble{subfig=\pkg{subfig}>with \pkg{floatrow}}
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}.
\trouble[\cs{FBwidth}, \cs{FBheight}]{floatrow>\cs{FBwidth} and \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}{%
\trouble{keyfloat=\pkg{keyfloat}}
If placing a \cs{keyfig}\optn{[H]} inside a \env{keywrap},
\watchout[\env{keywrap}]
use an absolute width for
\cs{keyfig}, instead of \optn{lw}-proportional widths.
(The \optn{[H]} option forces the use of a minipage, which internally adjusts for
a virtual 6-inch wide minipage, which then corrupts the \optn{lw} option.)
}

\newcommand{\limitssiunitx}{%
Due to \prog{pdftotext} limitations, fraction output is replaced by symbol
\margintag{fractions}
output for \optn{per-mode} and \optn{quotient-mode}.

Some units will require that the expression be placed inside math mode.
\trouble[math mode required]{siunitx=\pkg{siunitx}}

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

Tabular \texttt{S} columns are rendered as simple \texttt{c} columns,
\trouble[\env{tabular}]{siunitx=\pkg{siunitx}>tabular S and s columns}
and tabular \texttt{s} columns are not supported.
These may be replaced by \texttt{c} columns with each cell contained in
\cs{num} or \cs{si}.
}

\newcommand{\limitsnicefrac}{%
\trouble{nicefrac=\pkg{nicefrac}}
\trouble{units=\pkg{units}}
\pkg{units} and \pkg{nicefrac} work with \pkg{lwarp}, but
\brand{MathJax} does not have an extension for \pkg{units} or \pkg{nicefrac}.
These packages do work with \pkg{lwarp}'s option \optn{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
\trouble[\cs{CaptionSeparator}]{babel=\pkg{babel}>French}
changed to a dash.  The following may be used to restore it to a colon:
\begin{sourcedisplay}
\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{\limitspolyglossia}{%
\trouble{Undefined control sequence>polyglossia=\pkg{polyglossia}}
\trouble{polyglossia=\pkg{polyglossia}>Undefined control sequence}
\pkg{lwarp} uses \pkg{cleveref}, which has some limitations when using
\pkg{polyglossia}, possibly resulting in the error
\begin{sourcedisplay}
!~Undefined control sequence. \dots\ \cs{@begindocumenthook}
\end{sourcedisplay}

To test compatibility, add
\begin{sourcedisplay}
\cs{usepackage}\{cleveref\}
\end{sourcedisplay}
near the end of the preamble (as the last package to be loaded),
and try to compile the print version.
It may be necessary to set
\begin{sourcedisplay}
\cs{setdefaultlanguage}\{english\}
\end{sourcedisplay}
or some other language supported by \pkg{cleveref}, then select
other languages using \cs{setotherlanguages}.

Once the print version works with \pkg{cleveref} and \pkg{polyglossia},
the \HTML\ version should work as well using \pkg{lwarp}.
}

\newcommand{\limitsnewclude}{%
\pkg{newclude} modifies \cs{label} in a non-adaptive way, so
\pkg{newclude} must be loaded before \pkg{lwarp} is loaded:
\trouble[loading]{newclude=\pkg{newclude}}
\begin{sourcedisplay}
\raggedright
\cs{documentclass\{article\}} \\
\ldots <font setup> \\
\cs{usepackage\{newclude\}} \\
\cs{usepackage[warpHTML]\{lwarp\}} \\
\ldots
\end{sourcedisplay}
}

\newcommand{\limitstodonotes}{%
\trouble{todonotes=\pkg{todonotes}}
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.
\trouble[external layouts]{fixme=\pkg{fixme}}

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{\limitsxparse}{%
\trouble{xparse=\pkg{xparse}}
To remove from the log any warnings about redeclaring objects,
place the following before \pkg{lwarp} is loaded:
\begin{sourcedisplay}
\cs{usepackage}[log-declarations=false]\{xparse\}
\end{sourcedisplay}
}

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


% For use in the documentation update section:
\newcommand*{\newlwarpmkconf}{
Due to changes in \prog{lwarpmk},
\watchout[Reset the configuration]
\textred{recompile any existing project a single time}
using \cmds{pdflatex filename.tex} or similar, after which
\prog{lwarpmk} may then be used with the new configuration files.
}


\newcommand*{\describehashing}{%
If starred, a hashed filename is used.\margintag{image filename hashing}
\gindex{hash>SVG image filename}
\gindex{filename>hashed}
\gindex{image>hashed filename}
\gindex{MD5 hash>SVG image filename}
If so, the hash is based on the \attribute{alt} tag and also the additional hashing argument.

This may be used to provide an expression with a simple \attribute{alt} tag
but also enough additional information to provide a unique hash.

An example is when the expression is a complicated \TeX\ expression, which would not
copy/paste well.  A simplified tag may be used, while the complicated expression is
duplicated in the additional hashing argument.

Another example is when the expression is simple, but the image depends
on options.  These options may be decoded into text form and
included in the additional hashing argument in order to make the hash
unique according to the set of options, even if the simple \attribute{alt} tag
is still the same.
}


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

\trouble{MS-Windows=\brand{MS-Windows}}
\trouble{Windows=\brand{Windows}}
If \brand{MS-Windows} is not correctly detected,
\DescribeProgram{MS-Windows} \DescribeProgram{Windows}
use the \pkg{lwarp} option \optn{OSWindows}.
\DescribeOption{OSWindows}

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


\setlength{\marginparsep}{1em}
\setlength{\marginparpush}{.7ex}
\setlength{\IndexMin}{40ex}

\setcounter{IndexColumns}{2}

\DisableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
  \DocInput{lwarp.dtx}
\end{document}
%</driver>
%
% \fi
%
%
% \iffalse
%<*package>
% \fi
%
% \CheckSum{29792}
%
% \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: \brand{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: \filenm{lwarp_mathjax.txt} added.}
% \changes{v0.19}{2016/06/01}{File: \filenm{lwarp.css}: \attribute{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: \filenm{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}
% \changes{v0.45}{2018/01/14}{\ 2018/01/14}
% \changes{v0.46}{2018/01/23}{\ 2018/01/23}
% \changes{v0.47}{2018/01/30}{\ 2018/01/30}
% \changes{v0.48}{2018/02/14}{\ 2018/02/14}
% \changes{v0.49}{2018/02/19}{\ 2018/02/19}
% \changes{v0.50}{2018/03/03}{\ 2018/03/03}
% \changes{v0.51}{2018/03/24}{\ 2018/03/24}
% \changes{v0.52}{2018/04/01}{\ 2018/04/01}
% \changes{v0.53}{2018/04/01}{\ 2018/04/01}
% \changes{v0.54}{2018/04/22}{\ 2018/04/22}
% \changes{v0.55}{2018/04/26}{\ 2018/04/26}
% \changes{v0.56}{2018/05/12}{\ 2018/05/12}
% \changes{v0.57}{2018/06/06}{\ 2018/06/06}
% \changes{v0.58}{2018/07/07}{\ 2018/07/07}
% \changes{v0.58}{2018/06/07}{Replaced each \cs{csuse} with \cs{@nameuse} to force error if undefined.}
% \changes{v0.59}{2018/09/07}{\ 2018/09/07}
% \changes{v0.60}{2018/09/19}{\ 2018/09/19}
% \changes{v0.61}{2018/10/13}{\ 2018/10/13}
% \changes{v0.62}{2018/11/19}{\ 2018/11/19}
% \changes{v0.63}{2018/12/03}{\ 2018/12/03}
% \changes{v0.64}{2018/12/08}{\ 2018/12/08}
% \changes{v0.65}{2018/12/22}{\ 2018/12/22}
% \changes{v0.66}{2019/02/08}{\ 2019/02/08}
% \changes{v0.67}{2019/02/23}{\ 2019/02/23}



% \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}
% \newgeometry{margin=1in}
%
% \begin{center}
% \includegraphics[width=.3\linewidth]{lwarp_logo.pdf}
%
% {\Huge The \pkg{lwarp} package}
%
% {\Large \LaTeX\ to \HTML}
%
% \fileversion{} \Dash \filedate
%
% {\small\textcopyright{} 2016--2019} Brian Dunn\\ \small \texttt{bd@BDTechConcepts.com}
%
% \end{center}
%
% \begin{abstract}
% \noindent
% The \pkg{lwarp} package converts \LaTeX\ to \HTML\ by using \LaTeX\ to process the 
% user's document and directly generate \HTML\ tags.  External utility programs are only 
% used for the final conversion of text and images.  Math may be represented 
% by \SVG\ images or MathJax.  Hundreds of \LaTeX\ packages are supported.
% 
% Documents may be produced by \DVI\ or \PDF\ \LaTeX, Lua\LaTeX, \XeLaTeX;
% by several CJK engines, classes, and packages;
% or by customized systems such as \pkg{perltex} and \pkg{pythontex}.
% A \prog{texlua} script automates compilation, index, 
% glossary, and batch image processing, and also supports \prog{latexmk}.
% Configuration is semi-automatic at the first manual compile.  Support files 
% are self-generated.  Print and \HTML\ versions of each document may coexist.
% 
% Assistance is provided for \HTML\ import into \EPUB\ conversion software and 
% word processors.
% 
% Requirements include the commonly-available \brand{Poppler} utilities
% (included with \brand{MiKTeX}) and \brand{Perl}.
% Detailed installation instructions are included for each of the 
% major operating systems and \TeX\ distributions.
% 
% A quick-start tutorial is provided, as well as extensive documentation
% for special cases, a general index, and a troubleshooting index.
% Automatic testing of package load order and image generation offers
% useful advice for resolving errors.
% 
% \SVG\ math and many other generated images
% include \LaTeX\ expressions in the \attribute{alt} tags.
% \brand{MathJax} may be used with advanced equation numbering
% under the direct control of \pkg{lwarp}.
% 
% Complicated tables are supported, which copy/paste well into \brand{LibreOffice Writer}.
% 
% Supported classes and packages include \pkg{memoir} and \pkg{koma-script},
% \pkg{cleveref}, \pkg{caption}, \pkg{mdframed}, \pkg{siunitx},
% and many popular packages for tabulars, floats, graphics, theorems, the title page,
% bibliography, indexing, footnotes, and editorial work.
% 
% \TeX\ is a self-modifying tokenized macro-expansion language.
% Since \pkg{lwarp} is written directly in \LaTeX, it is able to interpret the document's
% meaning at a deeper level than external conversions which merely approximate \TeX.
% \HTML5 and \CSS3 are leveraged to provide advanced features such as
% \pkg{booktabs} trim, multicolumns, side-by-side minipages, and
% \brand{JavaScript}-free navigation.
% 
% ^^A The \pkg{lwarp} package allows \LaTeX\ to directly produce \HTMLfive\ output,
% ^^A using external utility programs only for the final conversion of text and images.
% ^^A Math may be represented by \SVG\ files or \brand{MathJax}.
%
% ^^A Documents may be produced by pdf\LaTeX, \LuaLaTeX, or \XeLaTeX.
% ^^A A \prog{texlua} script removes the need for system utilities such as \prog{make} and \prog{gawk},
% ^^A and also supports \prog{xindy} and \prog{latexmk}.  Configuration is automatic at the
% ^^A first manual compile.
%
% ^^A Print and \HTML\ versions of each document may coexist, each with its own
% ^^A set of auxiliary files.  Support files are self-generated on request.
% ^^A Assistance is provided for import into \EPUB\ conversion software and word processors.
%
% ^^A A modular package-loading system uses the \pkg{lwarp} version of a package for
% ^^A \HTML\ when available.
% ^^A More than 300 \LaTeX\ packages are supported with these
% ^^A high-level source-compatibility replacements, and many others work as-is.
%
% ^^A A tutorial is provided to quickly introduce the user to the major components
% ^^A of the package.
%
% \end{abstract}
%
% \begin{center}
% \setlength{\parskip}{1ex}
% \color{blue}
% For a list of supported features, see \cref{tab:supported}: \nameref{tab:supported}.
%
% To update existing projects, see \cref{sec:updates}: \nameref{sec:updates}.
%
% \color{red!30!black}\bfseries
% \pkg{Lwarp} is still in development.  Changes are likely.
%
% \end{center}
%
% \begin{description}
% \footnotesize
% \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}
%
%
%
% \clearpage
%
% \restoregeometry
%
% \section{Support \protect\TeX\ development}
% \label{sec:supportinglatex}
% \changes{v0.42}{2017/10/30}{Docs: Added support page.}
% 
% \begingroup
% \setlength{\parindent}{0em}
% \setlength{\parskip}{2ex}
%
% \TeX\ and related projects:
% \begin{itemize}[nosep]
% \item are mostly open-sourced and a volunteer effort;
% \item benefit students, academics, scientists, engineers, and businesses;
% \item help drive education, public and private research, and commercial activity;
% \item are used in the fields of mathematics, science, engineering, and humanities;
% \item are international in reach;
% \item span decades of development;
% \item are enduring \Dash many older packages are still actively used and maintained;
% \item are largely backwards compatible;
% \item are portable across all the major computing platforms;
% \item are usable even on older computers and away from internet access;
% \item are continuing to maintain relevance with modern improvements;
% \item require no yearly subscription fees;
% \item and are supported by an active community of knowledgeable volunteers.
% \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 \Dash 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 country-specific \TeX\ users groups: \hfill
% \href{http://tug.org/usergroups.html}{\texttt{http://tug.org/usergroups.html}}
%
% For users of MiK\TeX: \hfill
% \href{https://miktex.org/donations.html}{\texttt{https://miktex.org/donations.html}}
%
% \endgroup
%
% \clearpage
%
%
% \tableofcontents
%
% \clearpage
% \listoffigures
% \listoftables
%
%
% \thispagestyle{pageheadfoot}
%
% \clearpage
%
% \section{Updates}
% \label{sec:updates}
%
% ^^A *updates
%
% The following is a summary of updates to \pkg{lwarp},
% highlighting new features and any special changes which must be made due
% to improvements or modifications in \pkg{lwarp} itself.
%
% For a detailed list of the most recent changes,
% see the end of the Change History on page \pageref{sec:changesend}.
%
% \begin{description}
% \needspace{2\baselineskip}
% \item[v0.67:] Filename generation, symbol fonts.
%   \begin{itemize}
%       \item Documentation fix for \filenm{<project>-images}, \filenm{<project>-images.txt}.
%           \margintag{docs}
%       \item Added discussion regarding section names.  See \cref{sec:limitssectionnames}.
%       \item Added \cs{FilenameNullify} and \cs{FilenameSimplify} for filename
%           \margintag{filenames}
%           generation.  See \cref{sec:limitssectionnames}.
%       \item Core, \pkg{textcomp}, \pkg{xunicode}: Nullified additional
%           symbols during filename generation.
%       \item \pkg{color}: Fix for version number warnings.
%           \margintag{packages}
%       \item Added \pkg{academicons}, \pkg{bbding}, \pkg{dingbat}, \pkg{eurosym},
%           \pkg{fontawesome}, \pkg{fontawesome5}, \pkg{marvosym}, \pkg{pifont}, 
%           \pkg{typicons}.
%       \item Added \pkg{changes},
%           \pkg{easyReview}, \pkg{fitbox}, \pkg{foreign}, \pkg{gloss},
%           \pkg{karnaugh-map}, \pkg{multicap}, \pkg{nomencl}, \pkg{notes},
%           \pkg{struktex}, \pkg{umoline}, \pkg{xfakebold}.
%       \item Tested to work as-is with \pkg{askmaps}, \pkg{curves}, \pkg{euro},
%           \pkg{karnaughmap}, \pkg{tikz-karnaugh}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.66:] \pkg{xr}, multiple projects, image names/directory, \HTML\ formatting
%   \begin{itemize}
%       \item \newlwarpmkconf
%       \item Adds options \optn{ImagesDirectory} and \optn{ImagesName}
%           \margintag{\env{lateximage}}
%           to assign directory and name prefixes for \env{lateximage} images.
%           The new defaults include the jobname, allowing the image directories for
%           multiple projects to coexist.
%       \item To reuse existing \filenm{lateximage} directories, add \pkg{lwarp} options
%           \watchout[existing projects]
% \begin{sourceverb}
% \usepackage[
%   ImagesDirectory={lateximages},
%   ImagesName={lateximage-}
% ]{lwarp}
% \end{sourceverb}
%           If not reused, the existing \filenm{lateximages} directory and
%           \filenm{lateximages.txt} file may be removed.
%       \item Added \cs{FilenameLimit} to control the maximum length of the
%           \margintag{filenames}
%           filenames generated by \pkg{lwarp}.
%       \item Improved filename generation
%           \watchout[Possible filename changes]
%           when special characters or macros are used in section names.
%		\item Fix for \cmds{lwarpmk cleanlimages} with \brand{Windows}.
%           \margintag{\brand{Windows}}
%       \item Fixes for floats in the home page.
%           \margintag{floats}
%       \item Improved \CSS\ for definition lists, table notes.
%           \margintag{lists, table notes}
%       \item \env{tabular}: Fixes for \cs{par} in column specifier,
%           minipage inside \env{tabular}.
%           \margintag{\env{tabular}}
%       \item Indexing: Fix for a long line of multiple entries.
%           \margintag{indexing}
%       \item \cs{minipagefullwidth}: Fix for global changes.
%           \margintag{\env{minipage}}
%       \item Added \cs{UseMinipageWidths} and \cs{IgnoreMinipageWidths}.
%           See \cref{sec:minipages}.
%       \item Improved \cs{fbox}, \cs{fboxBlock}, \cs{fminipage} to use current text color.
%           \margintag{colors}
%       \item Improved \HTML\ output formatting.
%           \margintag{\HTML}
%       \item Added discussion regarding invalid \HTML.  See \cref{sec:invalidhtml}.
%           \margintag{docs}
%       \item Added discussion regarding math in section names,
%           \cs{imagegraphics} \optn{scale} option.  See \cref{sec:convertexisting}.
%       \item Added discussion regarding international languages in section names.
%           See \cref{sec:international}.
%       \item \pkg{caption}: Fix for options clash.
%           \margintag{packages}
%       \item \pkg{xr}, \pkg{xr-hyper}: Now compatible.
%       \item \pkg{subcaption}: Improved horizontal spacing.
%       \item \pkg{multicol}: Fix for minipage inside \env{multicols}.
%       \item \pkg{multicolrule}: Updated for v1.2.
%       \item \pkg{tocbasic}: Minor update.
%       \item \pkg{acronym}: Fix for acronym in float caption.
%       \item \pkg{kotexutf}: Patch with \prog{pdflatex} and new
%               \pkg{lwarp} labels.
%       \item \pkg{extramarks}, \pkg{fancyhdr}: Updated for v3.10.
%       \item \pkg{memoir}: Added docs regarding version numbers.  See \cref{sec:limitsmemoir}.
%       \item \pkg{zref}: No longer required.
%       \item Added \pkg{ar}, \pkg{ed}, \pkg{indentfirst}, \pkg{nameauth}, \pkg{truncate}.
%       \item Verified to work as-is with \pkg{changelog}.
%       \item Prevented \pkg{colortab}, \pkg{epsf}, \pkg{hyper},
%               \pkg{picinpar}, \pkg{picins},
%               \pkg{sistyle}, \pkg{ucs}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.65:] \CSS\ layout, \attribute{alt} tags, Japanese.
%   \begin{itemize}
%       \item Moved the side\TOC\ to the left side,
%           \margintag{page layout}
%           allowing improved \CSS\ for margin notes.
%       \item Improved page layout \CSS.
%       \item \pkg{graphicx} \cs{includegraphics}: Added the \optn{alt} key
%           \margintag{image \attribute{alt} tags}
%           to assign an \attribute{alt} tag to an image.  Default is ``\optn{(image)}'',
%           assigned to pass validation.
%       \item Detects and causes an error
%           \margintag{duplicate \HTML\ files}
%           if duplicate \HTML\ file names are generated,
%           caused by identical or similar sectioning names.
%       \item Fix for \env{tabular*}.
%           \margintag{fixes}
%       \item Fix for tabular border colors.
%       \item Fixes \cs{quad}, \cs{enskip}, and figure captions to pass validation.
%       \item Added \pkg{ltj*} classes,
%           \margintag{Japanese}
%           \pkg{bounddvi}, \pkg{gentombow}, \pkg{lltjext}, \pkg{plarydshln},
%           \pkg{plext}, \pkg{plextarydshln},
%           \pkg{plextcolortbl}, \pkg{pxatbegshi},
%           \pkg{pxeveryshi}, \pkg{pxftnright}, \pkg{pxjahyper}, \pkg{tascmac}.
%       \item Verified to work with \pkg{plarray}, \pkg{plautopatch},
%           \pkg{plextarray}, \pkg{plextdelarray}, \pkg{pxgentombow},
%           \pkg{plsiunitx}, \pkg{pxpdfpages}, \pkg{pxpgfrcs}, \pkg{pxpgfmark}.
%       \item Added support for \pkg{fontspec} \cs{textsi} and \cs{sishape}.
%           \margintag{packages}
%       \item Added \pkg{multicol}'s \cs{docolaction}.
%       \item Added \pkg{embrac}, \pkg{footnoterange}, \pkg{multicolrule}, \pkg{versonotes}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.64:] Koma-Script, Japanese, Chinese.
%   \begin{itemize}
%       \item Added \pkg{utarticle} and related classes.
%       \margintag{Japanese}
%       \item Improved \pkg{ujarticle} and related classes.
%       \item Fix for \pkg{biblatex} with C\TeX\ and other classes.
%       \margintag{Chinese}
%       \item Fixes for \pkg{scrlayer}, \pkg{scrlayer-scrpage}.
%       \margintag{Koma-Script}
%       \item \pkg{addlines}: Updated to v0.3.
%       \margintag{packages}
%       \item Added \pkg{bsheaders},
%               \pkg{gmeometric}, \pkg{marginal},
%               \pkg{rmpage}, \pkg{scrpage2}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.63:] \pkg{mdframed}, Chinese, Japanese, Korean
%   \begin{itemize}
%       \item Added \cs{linkhomename}: A user-definable name for the \UI{Home} link.
%       \margintag{localization}
%       \item Documented \cs{sidetocname}: A user-definable name for the side\TOC.
%       \item Fix: \cs{LinkHome} for print output.
%       \margintag{fixes}
%       \item Moved package load checks to the \pkg{lwarp} core
%       \margintag{optimizations}
%           to reduce the number of \filenm{lwarp-*} files.
%       \item \pkg{mdframed}: Fix with \pkg{amsthm}, improved titles and font control.
%       \margintag{packages}
%           Improved rule widths.
%       \item Fixes for \pkg{xeCJK}.
%       \margintag{Chinese}
%       \item Added \pkg{xpinyin}, \pkg{zhlineskip}.
%       \item Verified to work with \pkg{cjkpunct}, \pkg{upzhkinsoku}, \pkg{zhspacing}.
%       \item Verified to work with \pkg{zxjatype}, \pkg{luatexja}, \pkg{luatexja-fontspec}.
%       \margintag{Japanese}
%       \item Added \pkg{bxjsarticle} and related classes.
%       \item Added \pkg{ltjsarticle} and related classes.
%       \item Added p\LaTeX, up\LaTeX, \pkg{ujarticle} and related classes.
%       \item Prevented \pkg{utarticle} and related classes.
%       \item Prevented \pkg{bxcjkatype}.
%       \item Verified to work with \pkg{kotex}, \pkg{xetexko}, \pkg{luatexko}.
%       \margintag{Korean}
%   \end{itemize}
%
% \needspace{2\baselineskip}
% \item[v0.62:] MiK\TeX\ docs, \HTML\ title, C\TeX, \pkg{xeCJK}, \pkg{bitpattern}.
%   \begin{itemize}
%       \item Docs: Setting a \UTF-8 locale.  See \cref{sec:utf8locale}.
%           \margintag{docs}
%       \item MiK\TeX: Docs for \prog{MiKTeX Console} and \pkg{miktex-poppler-bin}.
%           \margintag{MiK\TeX}
%       \item \HTML\ subpage titles: Added \cs{HTMLTitleBeforeSection} and
%           \margintag{\HTML\ \element{title}}
%           \cs{HTMLTitleAfterSection} to select whether
%           the \HTML\ \element{title} displays the website name before or
%           after the section name.
%           See \cref{sec:htmlsettings}.
%       \item Fix for package options handling.
%           \margintag{fixes}
%       \item Fixes for horizontal white space between \env{fminipage}, \env{fcolorminipage},
%           \env{colorboxBlock}, \env{fcolorboxBlock}.
%       \item Logos: Fix for \XeTeX\ logo, improved \CSS, made robust,
%           improved search-engine optimization.
%       \item |\\[$1]|: Additional \HTML\ \element{br} if $\$1 > 0\,\textrm{pt}$.
%       \item Fixes for \cs{includgraphics} filename, and with \bool{FormatWP}.
%       \item Fix: \CSS\ for \cs{textup}.
%       \item Fix: Added \cs{slshape}.
%       \item Added \pkg{ctex} package and related classes, \pkg{xeCJK}.
%       \margintag{Chinese}
%       \item Prevented \pkg{CJK}, \pkg{CJKutf8} unless \pkg{xeCJK}, \pkg{ctex} are used.
%       \item \pkg{chemfig}: Docs for new macro \cs{polymerdelim}.
%           \margintag{packages}
%       \item \pkg{asymptote}: Docs for compilation.
%       \item \pkg{chngpage}: Fix to load \pkg{lwarp-changepage}.
%       \item \pkg{algorithm2e}: Fix with non-\pkg{book} classes.
%       \item \pkg{register}: Updated to v1.8.
%       \item \pkg{nicefrac}: Improved font control and \CSS, honors \optn{nice} and \optn{ugly}.
%       \item \pkg{units}: Improved font control and \CSS, honors \optn{tight} and \optn{loose}.
%       \item \pkg{xfrac}: Improved \CSS.
%       \item \pkg{textcomp} and \pkg{xunicode}: Fix conflicts with \cs{textcircled}.
%       \item \pkg{ulem}: Improved compatibility with \pkg{CJKulem}, \env{lateximage}.
%       \item MathJax and \pkg{siunitx}: Removed inoperable extension.
%       \item Added \pkg{bitpattern}, \pkg{pdfcomment},
%           \pkg{pdfmarginpar}, \pkg{tram}, \pkg{unitsdef}, \pkg{xechangebar}.
%       \item Added \pkg{musicography}, \pkg{octave}, \pkg{semantic-markup}.
%       \item Added \pkg{2in1}, \pkg{flippdf}, \pkg{notespages}, \pkg{rviewport}, \pkg{twoup}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.61:] Custom compilation, \EPS-related packages, documentation, indexes.
%   \begin{itemize}
%       \item Split index into multiple indexes.  See \cpageref{sec:indexmeta}.
%           \margintag{docs}
%       \item Improved documentation regarding font selection.  See \cref{sec:fonts}.
%       \item Added documentation regarding debugging options.
%           See \cref{sec:debuggingmessages}.
%       \item Added documentation regarding \HTML\ entities inside program listings.
%           See \cref{sec:avoidtextformatting}.
%       \item Added options to specify the shell commands to execute for
%           \margintag{custom compiling}
%           \cmds{lwarpmk print} and \cmds{lwarpmk html}, allowing
%           the use of \pkg{lwarp} with \pkg{perltex}, \pkg{pythontex}, etc.
%           If not specified, these are set automatically depending on the \LaTeX\ engine,
%           \optn{-\/-shell-escape}, and \pkg{lwarp} options.
%           See \cref{sec:customcompiling}.
%       \item Changed macro names to match
%           \watchout[changed names]
%           \cs{displaymathother}, \cs{displaymathnormal}: \\
%           \begin{tabular}{cc}
%           \toprule
%           Old & New \\
%           \midrule
%           \cs{StartDynamicMath} & \cs{inlinemathother} \\
%           \cs{StopDynamicMath} & \cs{inlinemathnormal} \\
%           \bottomrule
%           \end{tabular}
%       \item Fix: Paragraph tags in a \env{tabular}.
%           \margintag{fixes}
%       \item Fix: \pkg{supertabular} and \pkg{xtab} captions.
%       \item Fix: \DVI\ \LaTeX\ \cs{includegraphics} \EPS\ images.
%       \item Fix: \pkg{newfloat} lists.
%       \item Fix: \CSS\ footnotes text align, minipage tabular and footnote margins.
%       \item Added \pkg{epsfig}, \pkg{psfrag}, \pkg{psfragx}, \pkg{pstool}.
%           \margintag{packages}
%       \item Added \pkg{copyrightbox}, \pkg{pdfprivacy}, \pkg{thinsp},
%           \pkg{threadcol}, \pkg{uspace}.
%       \item Added \pkg{chkfloat}, \pkg{cmdtrack}, \pkg{dprogress},
%           \pkg{lua-visual-debug}, \pkg{refcheck},
%           \pkg{srcltx}, \pkg{srctex}, \pkg{vpe}, \pkg{xbmks}.
%   \end{itemize}
% \item[v0.60:] Fixes for \pkg{longtable}, \pkg{listings}.
%   \begin{itemize}
%       \item \pkg{longtable}, etc.: Fixes for slowdown and memory management for very long tables.
%           \margintag{fixes}
%       \item \pkg{listings}: Fix for \HTML\ entities, and also when used inside a list.
%       \item \pkg{diagbox}: Fix for incorrect \HTML\ par tags.
%       \item Added \pkg{2up}, \pkg{booklet}.
%           \margintag{packages}
%       \item Added \pkg{bophook}, \pkg{draftfigure}, \pkg{fullminipage},
%           \pkg{grid-system}, \pkg{layaureo}.
%       \item Added \pkg{leading}, \pkg{widows-and-orphans}.
%       \item Added \pkg{fancytabs}, \pkg{thumb}, \pkg{thumbs}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.59:] \DVI\ \prog{latex}, \brand{MathJax}, \pkg{asymptote},
%       \pkg{pdftricks} and \pkg{pstricks}, \pkg{epstopdf}, \pkg{brqen}.
%   \begin{itemize}
%       \item \newlwarpmkconf
%       \item Added an error if \filenm{lwarpmk.conf}'s format has changed and
%           \margintag{\prog{lwarpmk}}
%           the document must be recompiled.
%       \item Added a warning if the \filenm{lwarpmk.conf} configuration file appears
%           to be for the wrong operating system, in case files are transferred between
%           systems.
%       \item Added
%           \begin{sourcedisplay}
%           lwarpmk epstopdf <list-of-EPS-files>
%           \end{sourcedisplay}
%           to quickly convert a document's \EPS\ images to \PDF\ or \SVG.
%           See \cref{sec:limitsgraphics}.
%       \item Added support for \DVI\ \prog{latex}.  See \cref{sec:loading}.
%           \margintag{\DVI\ \prog{latex}}
%       \item Fix for \optn{-\/-shell-escape} with \prog{latexmk}.
%           \margintag{\prog{latexmk}}
%       \item Updated MathJax script to v2.7.4.
%           \margintag{math}
%       \item Fix: Mathjax chapter number removed from non-numeric tagged equations.
%       \item Added MathJax support for \pkg{nicefrac}, \pkg{units}.
%       \item Fix for \cs{[} and \cs{]} with \cs{displaymathnormal}.
%       \item Fix for \cs{includegraphics} filename expansion.
%           \margintag{images}
%       \item \cs{includegraphics} now works with
%           \filenm{.pdf} and \filenm{.eps} filename extensions.
%       \item Moved \pkg{amsmath} out of the \pkg{lwarp} core.
%           \margintag{packages}
%       \item Fix for \pkg{chemformula} \cs{NMR}.
%       \item Added \pkg{asymptote}, \pkg{pdftricks}, \pkg{pstricks}, \pkg{pst-eps}.
%       \item Added \pkg{breqn}, \pkg{SIunits}.
%       \item Added \pkg{bxpapersize}, \pkg{canoniclayout}, \pkg{draftcopy},
%           \pkg{fnbreak}, \pkg{nccfancyhdr}.
%       \item Added \pkg{accsupp}, \pkg{axessibility}.
%       \item Added \pkg{xunicode}.
%       \item Improved and now supports \pkg{epstopdf}.
%       \item Tested to work as-is: \pkg{eepic}, \pkg{sepfootnotes}.
%       \item Added information about setting up a development version of \pkg{lwarp}.
%           \margintag{docs}
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.58:] Extensive improvements in indexing, glossaries.
%   Adds \PDF-inclusion packages.
%   \begin{itemize}
%       \item \newlwarpmkconf
%       \item \prog{lwarpmk}: Added the |-p| option to specify the project name.
%           \margintag{\prog{lwarpmk}}
%       \item \prog{lwarpmk}: Now uses \prog{makeglossaries} for glossary generation,
%           \margintag{\pkg{glossaries}}
%           allowing the processing of multiple glossaries at once.
%       \item Added \pkg{lwarp} option \optn{GlossaryCmd}
%           to specify the shell command used by \cmds{lwarpmk printglossary} and
%           \cmds{lwarpmk htmlglossary}.  Defaults to \cmds{makeglossaries}.
%       \item Docs: Extra indexing options.  See \cref{sec:indexingoverview}.
%           \margintag{index and glossary}
%       \item Added support for \prog{makeindex}.  (Previously supported only \prog{xindy}.)
%           Also added indexing packages listed below.
%       \item Added \pkg{lwarp} options \optn{PrintIndexCmd}, \optn{HTMLIndexCmd},
%           and \optn{LatexmkIndexCmd}
%           to specify shell commands used by \cmds{lwarpmk printindex},
%           \cmds{lwarpmk htmlindex}, and \prog{latexmk}.  May be preset with the
%           \optn{makeindex} or \optn{xindy} \pkg{lwarp} options. See \cref{sec:loading}.
%       \item Added \pkg{lwarp} options \optn{makeindex} and \optn{xindy} to
%           set \optn{PrintIndexCmd}, \optn{HTMLIndexCmd}, and \optn{LatexmkIndexCmd}
%           to sensible values for a typical single index.  See \cref{sec:loading}.
%       \item Added \pkg{lwarp} option \optn{makeindexStyle} to tell \prog{lwarpmk} to
%           use a custom style instead of \filenm{lwarp.ist}.
%           See \cref{sec:modifymakeindex}.
%       \item Fix for index entries with \cs{see}, \cs{seealso}, \cs{emph}, \cs{textbf}, etc.
%       \item Replaced each \cs{csuse} with \cs{@nameuse} for improved error detection.
%           \margintag{misc. fixes}
%       \item Additional internal print/\HTML\ macro selection improvements.
%       \item Fix: \cs{printindex} finishes pending \cs{index} writes first.
%       \item Fixes for \pkg{memoir}: \pkg{makeidx}, \pkg{ccaption}, multiple indexes, \cs{specialindex}.
%           \margintag{packages}
%       \item Fixes for \pkg{komascript}: Indexing improvements.
%       \item Added \pkg{imakeidx}, \pkg{index}, \pkg{repeatindex}, \pkg{splitidx}.
%       \item Added  \pkg{attachfile}, \pkg{attachfile2}, \pkg{intopdf},
%           \pkg{pdfpages}, \pkg{pdfx}.
%       \item Added \pkg{cases}.
%       \item Tested to work as-is: \pkg{notes2bib}, \pkg{hvindex}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.57:] \pkg{algorithm2e}, \pkg{float} styles, tabular packages, internal improvements.
%   \begin{itemize}
%       \item Added support for MathJax equations with \cs{footnote}, \cs{footnotemark}.
%           \margintag{MathJax}
%       \item Added \cs{StartDefiningMath} and \cs{StopDefiningMath} for
%           \margintag{math macros}
%           use when defining macros in the preamble which contain \$.
%           See \cref{sec:mathcatcode}.
%       \item Added \cs{inlinemathother} and \cs{inlinemathnormal} to
%           \margintag{dynamic math}
%           delimit math expressions which depend on a variable condition
%           such as a counter.  Such expressions will not be hashed for reuse,
%           and will be converted to \SVG\ math images even when MathJax is enabled.
%           See \cref{sec:mathdynamic}.
%       \item Renamed \cs{EndDefiningTabulars} to \cs{StopDefiningTabulars}.
%           \watchout[new name]
%       \item Improved localization for \env{lateximage} \HTML\ \attribute{alt} tags.
%           \margintag{\env{lateximage} \attribute{alt} tags}
%           For \SVG\ math images, the \attribute{alt} tag under some conditions
%           will be set to \cs{mathimagename}, which defaults to ``math image''.
%           For packages, the \attribute{alt} tag is set using the package name followed by
%           \cs{packagediagramname}, which defaults to ``diagram''.  Ex:
%           \begin{sourcedisplay}
%           (-xy- diagram)
%           \end{sourcedisplay}
%           See \cref{sec:packagediagramname}.
%       \item Fix: Improved print/\HTML\ macro selection.
%       \item Fix: \cs{href} text catcodes.
%       \margintag{misc. fixes}
%       \item Fix: \cs{subref} text.
%       \item Fixes: Colored \cs{rule} and \cs{boxframe}.
%       \item \pkg{float}, \pkg{rotfloat}: Adds support for float styles |ruled| and |boxed|.
%       \margintag{packages}
%       \item \pkg{float}: Fix: Do not create \cs{l@<type>} until \cs{listof} is used.
%       \item \pkg{marginnote}: Fix: Long optional argument.
%       \item \pkg{ellipsis}: Adds \cs{midwordellipsis}.
%       \item \pkg{breakurl}: Fix for text catcodes.
%       \item Added \pkg{algorithm2e}, \pkg{register}, \pkg{ltablex}, \pkg{xltabular},
%           \pkg{xellipsis}, \pkg{trimclip},  \pkg{errata}, \pkg{vowel}, \pkg{xpiano}.
%       \item Prevents \pkg{glossary}.
%       \item Tested to work as-is with \pkg{gauss}, \pkg{phonrule}, \pkg{piano},
%           \pkg{SIunits}, \pkg{tikzcodeblocks}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.56:] Shell escape, tabular packages.
%   \begin{itemize}
%       \item Added
%           \margintag{\prog{lwarpmk}}
%           \begin{sourcedisplay}
%           lwarpmk pdftosvg <list-of-PDF-files>
%           \end{sourcedisplay}
%           to quickly convert a document's \PDF\ images to \SVG, for use with \HTML.
%           See \cref{sec:limitsgraphics}.
%       \item Added support for \optn{-\/-shell-escape}.  See \cref{sec:shellescape}.
%       \item Added support for \pkg{array} |w| and |W| columns.
%           \margintag{\env{tabular}}
%       \item Fix: \cs{multicolumn} parameter handling.
%       \item Added support for double \cs{hline}s, \cs{midrule}s, and vertical rules.
%       \item Added support for \pkg{arydshln} dashed lines
%           with \HTML\ \env{tabular}, but
%           reverts to plain rules for \env{lateximage}
%           and \SVG\ math \env{array}.
%       \item Fix: \cs{thinspace}.
%           \margintag{misc. fixes}
%       \item Fix: \pkg{paralist} compact environments.
%       \item Added \pkg{parnotes}, \pkg{quoting}, \pkg{lua-check-hyphen},
%           \pkg{tocenter}, \pkg{underscore}.
%           \margintag{packages}
%       \item Tested to work as-is with \pkg{babelbib}, \pkg{bibunits}, \pkg{bodegraph},
%           \pkg{fast-diagram}, \pkg{nicematrix}, \pkg{structmech}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.55:] Various fixes.
%   \begin{itemize}
%       \item Fix: Extraneous space in file links, which also
%           \margintag{misc fixes}
%           prevented \prog{Calibre} \EPUB\ conversions.
%       \item Fix: Float optional argument regression.
%       \item Fix: \cs{ForceHTMLTOC} with \cs{phantomsection}.
%       \item Fix: Overfull boxes in \env{lateximage}s.
%       \item Fix: QED symbols in \env{lateximage}.
%       \item \pkg{koma-script}: Fix: Figure with \cs{centering}, etc.
%           \margintag{packages}
%       \item Added \pkg{clrdblpg}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.54:] Float \cs{centering}, improved image checks.
%   \begin{itemize}
%       \item \newlwarpmkconf
%       \item \progcode{lwarpmk limages} checks for the presence of the \HTML\ version
%           \margintag{\prog{lwarpmk}}
%           of the document and valid image references before attempting
%           to create the \env{lateximage}s.
%       \item \prog{lwarpmk}: Improved error message if configuration file
%           does not exist.
%       \item Added documentation for avoiding error with BibTeX and \cs{etalchar}.
%           \margintag{\BibTeX}
%           See \cref{sec:limitsbibtex}.
%       \item Added documentation regarding \pkg{polyglossia}.
%           \margintag{\pkg{polyglossia}}
%           See \cref{sec:limitspolyglossia}.
%       \item Added documentation regarding the use of macros in section names.
%           \margintag{macros in section names}
%           See \cref{sec:thingstoavoid}.
%       \item Renamed and added package options:
%           \margintag{document encoding}
%           \watchout[New and revised encoding options]
%           \begin{center}
%           \begin{tabular}{>{\ttfamily}c>{\ttfamily}c}
%           \toprule
%           \textrm{Old Package Option} & \textrm{New Package Option} \\
%           \midrule
%           xdyFilename & xindyStyle \\
%           IndexLanguage & xindyLanguage \\
%           \midrule
%           --- & xindyCodepage \\
%           --- & pdftotextEnc \\
%           \bottomrule
%           \end{tabular}
%           \end{center}
%           Use these options along with \pkg{inputenc} or \pkg{inputenx}
%           to process documents in an encoding other than UTF-8.
%           See \cref{sec:fonts}.
%
%       \item Floats now honor \cs{centering}, \cs{raggedright}, \cs{raggedleft},
%           \margintag{floats with \cs{centering}, etc.}
%           and their \pkg{ragged2e} equivalents,
%           when placed directly after:
%           \begin{sourceverb}
%           \begin{floattype}
%           \centering
%           \end{sourceverb}
%       \item \pkg{tikz}: \cs{pgfpicture}, fit, align, font.
%           \margintag{misc. fixes}
%       \item \pkg{ragged2e}: \cs{centering} etc.
%       \item \pkg{hyperref}: \cs{hypertarget} was creating duplicate of \cs{label}.
%       \item \pkg{hyperref}: Active chars inside \cs{hyperref}, \cs{hyperlink}.
%       \item \pkg{hyperref}: \cs{ref} inside \cs{hyperlink} caused a nested \HTML\ link.
%       \item \pkg{glossaries}: Fix when not using \pkg{babel} or \pkg{polyglossia}.
%       \item \pkg{textcomp}: \cs{textperthousand}.
%       \item \LaTeX\ core \env{verse} environment: line spacing.
%       \item Removed \cs{citetitle}, adjusted \cs{attribution}. \watchout
%       \item \pkg{memoir}: Minor update for v3.7g.
%           \margintag{packages}
%       \item Added \pkg{inputenx}, \pkg{bibunits}, \pkg{chngpage},
%           \pkg{forest}, \pkg{magaz}, \pkg{gridset}.
%       \item Prevents loading \pkg{ae}, \pkg{aecc}, \pkg{t1enc}, and \pkg{wasysym}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.53:] Improved image checks.
%   \begin{itemize}
%       \item \prog{lwarpmk}: Added a warning about corrupted images due to the
%           \margintag{\prog{lwarpmk}}
%           need to recompile the document one more time.
%       \item \prog{lwarpmk}: Added the \cmds{lwarpmk cleanlimages} command.
%       \item Added documentation for \cmds{lwarpmk cleanlimages} and
%           \cmds{lwarpmk pdftohtml}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.52:] Improved footnotes, \SVG\ math.
%   \begin{itemize}
%       \item Improved install instructions regarding \filenm{lwarp_baseline_marker.png}.
%           \margintag{documentation}
%       \item Added documentation regarding footnotes in section headings,
%           and footnotes with \cs{VerbatimFootnotes}
%           from \pkg{fancybox}, \pkg{fancyvrb}.  See \cref{sec:limitsfootnotes}.
%       \item Added documentation regarding font selection when using
%           \XeLaTeX\ or \LuaLaTeX\ with \pkg{fontspec} and traditional font packages.
%           See \cref{sec:fonts}.
%       \item Fix: Limit the number of background tasks
%           \margintag{SVG math}
%           when generating \env{lateximage}s.
%       \item Added user-adjustable \SVG\ math font scaling.  See \cref{sec:mathfontscale}.
%       \item Added warnings if \filenm{lwarp_baseline_marker.png} is not present, or
%               if \pkg{graphicx} or \pkg{graphics} is not loaded.
%       \item Improved \cs{ensuremath} hashing expansion.
%       \item Fix: \env{equation*} with \env{split}.
%       \item \env{tabbing} now works inside a \env{lateximage}.  Use for math in \env{tabbing}.
%       \item Fix: MathJax script was not executing in some conditions.
%               \margintag{MathJax}
%       \item Added \cs{CustomizeMathJax} to add custom functions.
%               See \cref{sec:limitsmath}.
%       \item Fix: Footnote numbering when using \progcode{HTMLDebugComments}.
%               \margintag{footnotes}
%       \item Fix: Footnote paragraph tags.
%       \item Fix: \progcode{FootnoteDepth} defaults to \cs{subsubsection}.
%       \item Fix: \cs{kill} in a \env{lateximage}. \margintag{misc. fixes}
%       \item Fix: \cs{FileDepth}, misc. others, when input encoding is not \optn{utf8}.
%       \item Fix: \cs{texorpdfstring} in a section name.
%       \item \pkg{hyperref} emulation: Fix for \progcode{\#}, \progcode{\%}, \margintag{packages}
%                   \progcode{\&}, \progcode{\~}, \progcode{\_} characters in \URL{}s.
%       \item \pkg{fancybox}, \pkg{fancyvrb}: Initial support for \cs{VerbatimFootnotes}.
%       \item \pkg{nicefrac}: Added with fix for \cs{ensuremath}.
%       \item \pkg{graphicx}: Fix for option defaults.  Added v1.1a/b options.
%       \item \pkg{endfloat}: Updated for v2.6.
%       \item \pkg{url}: Fixes for active characters.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.51:] Improved \SVG\ math, added numerous chemistry packages.
%   \begin{itemize}
%       \item Docs: Added \nameref{sec:thingstoavoid}.
%           \margintag{documentation}
%       \item Docs: Added to \nameref{sec:convertexisting}.
%       \item Docs: Multiple authors and affiliations with custom classes.
%           See \cref{sec:authorsaffils}.
%       \item Docs: \pkg{tikz} with matrices.  See \cref{sec:limitstikz}.
%       \item Improved \SVG\ math baseline.\margintag{SVG math}
%       \item Improved \SVG\ math font and color.
%       \item Faster \SVG\ math rendering.
%       \item Improved support for display math containing complicated math objects,
%               such as \pkg{tikz-cd}.  See \cref{sec:displaymathother}.
%       \item Fix: \cs{addcontentsline} inside \SVG\ math.
%       \item Fix: SVG math containing an embedded \env{lateximage}.
%       \item MathJax now handles \cs{ensuremath} in expressions.\margintag{MathJax}
%       \item Fix: Added \env{alignat} environment. \margintag{misc. fixes}
%       \item Fix: \pkg{afterpackage} no longer required, which conflicted with \pkg{scrlfile}.
%       \item Fix: \pkg{titling} \cs{thanks} mark.
%       \item Fix: \pkg{fancybox} improvements.
%       \item Fix: \pkg{tikz} \cs{tikz} macro.  (Previously only the \env{tikzpicture} environment worked.)
%       \item Fix: \pkg{tikz} with optional argument.
%       \item Added \pkg{mhchem},  \margintag{packages}
%           \pkg{chemfig}, \pkg{chemformula}, \pkg{chemmacros}, \pkg{chemnum}, \pkg{chemgreek},
%           \pkg{epstopdf-base}, \pkg{grid}, \pkg{ltxgrid}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.50:] Improved \SVG\ math.
%   \begin{itemize}
%       \item \SVG\ math and other \env{lateximage}s now are
%           converted to \SVG\ using \margintag{\SVG\ math}
%           parallel background tasks, utilizing all available \acro{CPU} cores.
%       \item Inline \SVG\ math image file names now are MD5 hashes made from 
%           their source \LaTeX\ code.
%           Identical inline math expressions, such as multiple instance of \$x\$,
%           now share a single image file.
%           This reduces the number of images to store, transmit, process, and display.
%           Each image file is only converted to \SVG\ a single time, and reused if it
%           already exists.
%           Display math and other forms of \SVG\ image such as \env{picture} and
%           \tikz\ still use individual image files which are recreated each time
%           \cmds{lwarpmk limages} is run.
%       \item Fixes: SVG math and/or \cs{underline} in a sectioning file name.
%       \item Improved \SVG\ display math and tags.
%       \item Improved \SVG\ math and \pkg{siunitx} \attribute{alt} tags.
%       \item Improved \pkg{siunitx} units.
%       \item Fix: \cs{ensuremath} with MathJax now creates a \env{lateximage}.
%       \item Fix: \cs{centering}, etc. in \SVG\ math, \env{lateximage}, \tikz.
%       \item Fix: Made various macros robust,
%           additionally fixing \pkg{authblk}.\margintag{misc. fixes}
%       \item Fix: \pkg{ntheorem} if neither \optn{standard} nor \optn{amsthm} selected.
%       \item Fix: \pkg{listings}: Improved column alignment.
%       \item Fix: Load \pkg{fontspec} if necessary.
%       \item Added \pkg{xy}, \pkg{epstopdf}, \pkg{diagbox}, \pkg{pbox}, \margintag{packages}
%           \pkg{bytefield}, \pkg{axodraw2}, \pkg{phfqit},
%           \pkg{schemata},
%           \pkg{dblfloatfix}, \pkg{nonfloat}, \pkg{morefloats}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.49:] \
%   \begin{itemize}
%       \item Added \pkg{xcolor} \cs{rowcolors}.\margintag{tabular}
%       \item Fix: \cs{noalign} inside a \env{tabular}.
%       \item Fix: \cs{eqref} in a caption.\margintag{math}
%       \item Fix: Incorrect \PDF\ font size changes
%           caused occasional \HTML\ corruption.\margintag{misc fixes}
%       \item Fix: \pkg{printlen} changes are now grouped for \HTML\ output.
%       \item Added \pkg{vwcol}, \pkg{vertbars}, \pkg{hyphenat}, \margintag{packages}
%           \pkg{lineno}, \pkg{fnlineno}, \pkg{figsize}, \pkg{hypdestopt}, \pkg{pagegrid},
%           \pkg{pdfrender}, \pkg{luacolor}, \pkg{resizegather}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.48:] \
%   \begin{itemize}
%       \item Added some documentation
%           \margintag{documentation}
%           regarding converting an existing document.  See \cref{sec:convertexisting}.
%       \item Updated compatibility for new \pkg{cleveref} v0.21.\margintag{\pkg{cleveref}}
%       \item Fix: Ignores optional tabular column arguments.\margintag{tabular}
%       \item Added \cs{leftline}, \cs{centerline},
%           \cs{rightline}.\margintag{minor updates}
%       \item Lists have improved font control via \cs{makelabel}.
%       \item Print-mode \env{lateximage} now boxed to the natural width of its
%           multiline contents.
%       \item \env{abstract} now allows an optional name, as required by some classes.
%       \item Fix: Improved spacing, \cs{mbox}, and font sizes
%           with \SVG\ math, \tikz.\margintag{math}
%       \item \pkg{siunitx}: Improved \SVG\ math, fraction compatibility, color output.
%       \item Fix: LOF/LOT links.\margintag{misc. fixes}
%       \item Fix: Virtual page size grouping caused excessive \PDF\ page breaks.
%       \item Fix: Parsing similar package names in a
%           single \cs{usepackage}.
%       \item Fix: Adapts to classes without \cs{part}.
%       \item Fix: \cs{newline} in \cs{title} was causing |<br>| in window title.
%       \item Fix: \cs{maketitle} with \cs{cr}, \cs{crcr}, \cs{noalign},
%                   for \pkg{IEEEtran} class.
%       \item Fix: \pkg{xfrac} neutralized \env{BlockClass} and others.
%       \item Fix: \pkg{todonotes} and \pkg{luatodonotes}: Improved \cs{todototoc}.
%       \item Added \pkg{colortbl}, \margintag{packages}
%                   \pkg{chapterbib}, \pkg{acro}, \pkg{acronym},
%                   \pkg{hypernat}, \pkg{hypcap}, \pkg{stfloats},
%                   \pkg{vmargin}, \pkg{fancyheadings}.
%       \item \pkg{fancyref}: Now directly supported.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.47:] \
%   \begin{itemize}
%       \item Improved \SVG\ math baseline and sizing.\margintag{math}
%       \item Fixes: \SVG math in captions, subcaptions, \cs{nameref}.
%       \item Fixes: Line wrap at hyphen in \HTML\ output.
%       \item Added \pkg{endheads}, \pkg{multitoc}, \pkg{sectionbreak},
%           \pkg{blowup}, \pkg{xurl}.\margintag{packages}
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.46:] \
%   \begin{itemize}
%       \item \cs{PrintStack} changed to \cs{LWRPrintStack}.\watchout[name change]
%       \item Fix: Empty lines between \env{tabular} rows.\margintag{misc. fixes}
%       \item Fix: Stack unnesting.
%       \item Fix: SVG math and \env{lateximage}s in numerous situations.
%       \item Fix: Spaces in \cs{usepackage}.
%       \item Fix: Now allows \brand{MathJax} inside \env{verse}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \item[v0.45:] \
%   \begin{itemize}
%       \item Improved \prog{MiKTeX} install instructions.
%           \margintag{documentation}
%       \item Improved graphics and \pkg{epstopdf} instructions.
%       \item Updates to the \nameref{sec:introduction}.
%       \item Added \pkg{memoir}, \pkg{memhfixc}.
%               See \cref{sec:limitsmemoir}.\margintag{memoir}
%       \item Fix: Now allows underscores in labels.\margintag{cross-references}
%       \item Fix: \cs{\_} and |\<blank>| in section/file names.
%       \item Fix: Now allows \brand{MathJax} inside \env{tabbing}.\margintag{math}
%       \item Fix: Bibliography \cs{em} names.\margintag{bibliography}
%       \item Added \pkg{cite}, \pkg{natbib}, \pkg{backref}.
%               (Also works as-is with \pkg{biblatex}.)
%       \item Fix: Empty lines between \env{tabular} rows.\margintag{misc. fixes}
%       \item Fix: ``Improper \cs{prevdepth}'' with minipages, lists.
%       \item Fix: Incorrect \SVG\ math and |lateximage|s with \pkg{subfig}.
%       \item Fix: Lateximages from incorrect pages with Mathjax.
%       \item Fix: Missing sidetoc if using \pkg{listings}.
%       \item Fix: Added an \pkg{array} emulation package.
%       \item Added
%           \pkg{subfigure}, \pkg{prettyref}, \margintag{packages}
%           \pkg{hanging}, \pkg{midpage},
%           \pkg{flafter}, \pkg{fltrace}, \pkg{changebar}, \pkg{endfloat},
%           \pkg{continue}, \pkg{fwlw}, \pkg{turnthepage}, \pkg{footnpag},
%           \pkg{pagesel}, \pkg{textfit}, \pkg{titleref}.
%   \end{itemize}
% \needspace{2\baselineskip}
% \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 \prog{pdflatex}, automatically loads T1 and \UTF-8 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: \brand{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}
% \needspace{2\baselineskip}
% \item[v0.43:] \
%   \begin{itemize}
%       \item Docs: Reorganized \HTML\ customization, added an \HTML\ settings table.
%           See \cref{sec:htmlsettings}.
%       \item Added \progcode{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,
%           \nameref{sec:supportinglatex}.\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 \textred{The} \watchout[name change]
%               \textred{boolean |FormatWordProcessor| has
%               been renamed |FormatWP|.}
%           \item \textred{The} \watchout[name change]
%               \textred{boolean |HTMLMarkFloats| has
%               been renamed |WPMarkFloats|.}
%           \item New booleans control whether to place additional
%               marks around minipages, at the table of contents,
%               at the \LOF\ and \LOT, and whether to
%               print math as \LaTeX\ source for copy/paste into the
%               \prog{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 \brand{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]
%           \textred{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.
%           \textred{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 \cmds{lwarpmk print1} and \cmds{lwarpmk html1} actions to
%       \margintag{forced single-pass compile}
%       force a compile of the project a single time.
%       Useful when multiple passes are not needed,
%       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 \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 \pkg{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{\prog{latexmk}}
%       independent cut files for print and \HTML\ versions, helping \prog{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 \brand{MathJax}.
%   \item Improved \pkg{siunitx} units.
%       \margintag{\pkg{siunitx}}
%   \item Fix for filenames while using \brand{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.
%		\brand{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 havetheir 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{StopDefiningTabulars} (previously called \cs{EndDefiningTabulars}.
%       See \cref{sec:localizingcatcodes}.
%		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 \optn{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 \prog{lwarpmk} has been adjusted to work with the latest \prog{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{sourceverb}
%		\usepackage{lwarp-newproject}
%		\end{sourceverb}
%
%		The \pkg{lwarp} package now produces the configuration files during
%		print output, and also accepts the option \optn{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}{cc}
%		\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
%		\optn{lwarpmklang} & \optn{xindyLanguage} \\
%		(new) & \optn{xindyStyle} \\[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{sourceverb}
%		\usepackage[
%			HomeHTMLFilename=index,
%			HTMLFilename={},
%			xindyLanguage=english
%		]{lwarp}
%		\end{sourceverb}
%
%	\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 \optn{xindyStyle} may be used to tell
%	\prog{lwarpmk} to use a custom |.xdy| file instead of |lwarp.xdy|.
%	See \cref{sec:modifyxindy}.
%
%	\item Improvements in index processing:
%		\begin{itemize}
%		\item \prog{xindy}'s language is now used for index processing
%			as well as glossary.
%		\item Print mode without \prog{latexmk} now uses \prog{xindy} instead of \prog{makeindex}.
%		\item \prog{texindy}/\prog{xindy} usage depends on \prog{pdflatex} vs \prog{xelatex}, \prog{lualatex}.
%		\item For \prog{pdflatex} and \prog{texindy}, the \optn{-C utf8} option is used.  This is
%			supported in modern distributions, but a customized \filenm{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: \optn{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 \optn{IndexLanguage} option.)
%       (As of v0.54, this has been changed to the \optn{xindyLanguage} 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 the boolean
%		|FormatWordProcessor| is |true|.
%       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 \brand{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}.
%		\prog{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 \brand{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 \prog{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 |lateximage|s.
% ^^A 		This allows the correct inclusion of |lateximage|s in footnotes, pagenotes, and endnotes.
% ^^A 	\item \pkg{cutwin} and \pkg{floatflt} are also supported.
% ^^A 	\end{itemize}
% ^^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 \brand{Windows} has been updated and improved.
% ^^A 	\item For \brand{Windows} compatibility, the |lateximages| shell script
% ^^A 		has been replaced with a |lateximages.txt| file, which is parsed
% ^^A 		by \prog{lwarpmk} to generate lateximages.
% ^^A 		This does not require any changes in the user's code.
% ^^A 	\item \brand{Windows} \cmds{lwarpmk again} now functions.
% ^^A 	\item For improved error handling, \pkg{lwarp} now verifies the
% ^^A 		order in which packages are loaded, and signals an error for misplaced packages.
% ^^A 		\pkg{inputenc}, \pkg{fontenc}, \pkg{newunicode}, and \pkg{fontspec}
% ^^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 \prog{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 \brand{Windows}. (As of v0.30, \cs{warpOSwindows} has been converted to
% ^^A 		the \optn{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 \brand{MathJax} now may be used to display math via the \optn{mathjax} option.
% ^^A 		See \cref{sec:loading,sec:limitsmath}.
% ^^A 	To use \brand{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}
% \label{sec:introduction}
% \changes{v0.19}{2016/05/25}{Introduction: \brand{MathJax} support mentioned.}
%
% The \pkg{lwarp} project aims to allow a rich \LaTeX{} document
% to be converted to a reasonable \HTMLfive\
% interpretation, with only minor intervention on the user's part.
% 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 \brand{Javascript}.
% Limited testing on older browsers shows that these new features
% degrade gracefully.
%
% \rulebreak
%
% \pkg{lwarp} is a native \LaTeX\ package, and operates by either patching or
% emulating various functions.  Source-level compatibility is a major goal, but
% occasional user intervention is required in certain cases.
%
% As a package running directly in \LaTeX, \pkg{lwarp} has some advantages over
% other methods of \HTML\ conversion.  \TeX\ itself is still used, allowing a
% wider range of \TeX\ trickery to be understood.
% Lua expressions are still available with \LuaTeX.
% Entire categories of
% \LaTeX\ packages work as-is when used with \pkg{lwarp}:
% definitions, file handling, utilities, internal data structures and calculations,
% specialized math-mode typesetting for various fields of science and engineering,
% and anything generating plain-text output.
% Blocks of \PDF\ output may be automatically converted to \SVG\ images
% while using the same font and spacing as the original print document,
% directly supporting \tikz\ and \env{picture}.
% Numerous packages are easily adapted for \HTML\ versions, either
% by loading and patching the originals, or by creating nullified or emulated
% replacements, and all without resorting to external programming.
% As a result, several hundred packages have already been adapted (\cref{tab:supported}), and
% an uncounted number more work as-is.
%
% Packages have been selected according to several criteria: perceived importance,
% popularity lists, recent CTAN updates, CTAN topics, mention in other packages,
% support by other \HTML\ conversion methods,
% and from sample documents taken from public archives.
% These include some ``obsolete'' packages as well.\footnote{An amazing number of
% decades-old packages are still in use today.}
%
% \rulebreak
%
% Assistance is also provided for modifying the \HTML\ output to suit the creation
% of \EPUB\ documents, and for modifying the \HTML\ output to ease import into
% a word processor.
%
% \rulebreak
%
% \prog{pdflatex}, \prog{xelatex}, or \prog{lualatex} may be used,
% allowing \pkg{lwarp} to process the usual image formats.
% While generating \HTML\ output, \SVG\ files are used in place of \PDF.
% Other formats such as \PNG\ and \JPG\ are used as-is.
%
% SVG images may be used for math,
% and are also used for \env{picture}, \tikz, and similar environments.
% The \SVG\ format has better browser and e-book support
% than \MathML\ (as of this writing),
% while still allowing for high-quality display and printing of images
% (again, subject to potentially
% bug-ridden\footnote{\brand{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.
% An MD5 hash is used to combine multiple instances of the same inline math expression
% into a single image file, which then needs to be converted to \SVG\ only a single time.
%
% The \brand{MathJax} JavaScript display engine may be selected
% for math display instead of using \SVG\ images.
% Subject to browser support and Internet access,
% \brand{MathJax} allows an \HTML\ page to display
% math without relying on a large number of
% external image files.\footnote{One \SVG\ image
% file per math expression, except that duplicate inline math expressions are combined
% into a single file according to the MD5 hash function of its contents.
% A common scientific paper can easily include several thousand files,
% and in one case the MD5 hash cut the number of files in half and the rendering
% time by 30\%.}
% \pkg{lwarp} maintains \LaTeX\ control for cross-referencing
% and equation numbering, and attempts to force \brand{MathJax} to tag equations accordingly.
%
% \rulebreak
%
% A \prog{texlua} program called \prog{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 \prog{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,
% \pkg{lwarp} first looks to see if it has its own modified version
% to use instead of the standard \LaTeX\ version.
% These |lwarp-packagename.sty| files contain
% code used to emulate or replace functions for \HTML\ output.
%
%
% \clearpage
%
% \subsection{Typesetting conventions}
%
% Font weight, family, and style are used to indicate various objects:
%
% \begin{table}[hbp]
% \caption{Typesetting conventions}
% \centering
% \begin{tabular}{lp{3in}}
% \toprule
% \pkg{package} & \LaTeX\ package. \\
% \prog{program} & Program's executable name. \\
% \optn{option} & Program or package option. \\
% \midrule
% \filenm{filename} & File name in the operating system. \\
% \brand{Brand Name} & Proper name for a program, operating system, etc. \\
% \midrule
% \cmds{commands} & Commands to be entered by the user. \\
% \progcode{code} & Program code. \\
% \cs{macroname} & \LaTeX\ macro. \\
% \env{environment} & \LaTeX\ environment. \\
% \ctr{counter} & \LaTeX\ counter. \\
% \bool{boolean} & \LaTeX\ boolean. \\
% \midrule
% \element{element} & \HTML\ element. \\
% \attribute{attribute} & \HTML\ attribute. \\
% \midrule
% \UI{User Interface} & A user-interface item. \\
% \acro{ACRO} & Acronym. \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% \clearpage
%
% \subsection{Supported packages and features}
%
% \changes{v0.15}{2016/04/05}{Docs: Moved the supported features table to the introduction.}
% \changes{v0.38}{2017/08/22}{Docs: Enhanced \protect\textit{Supported Features} table.}
%
% \Cref{tab:supported} lists some of the various \LaTeX{} features and packages
% which may be used.
% Many are tested to work as-is,
% some are patches for the original packages, and some are emulations written
% for source-level compatibility.
% Many are nullified as being irrelevent to \HTML\ output.
%
%
% \renewcommand{\arraystretch}{1.5}
%
% \begingroup
% \setlength{\parindent}{0em}
% \setlength{\parskip}{2ex}
%
% ^^A *supported features
%
% \begin{longtable}{>{\raggedright}p{.3\linewidth}p{.6\linewidth}}
% \caption{\LaTeX\ \pkg{lwarp} package --- Supported features\label{tab:supported}} \endfirsthead
% \warpprintonly{\multicolumn{2}{c}{\pkg{lwarp} Supported Functions --- continued} \\
%	Category & Status \\ \toprule \endhead}
%
% \toprule
%
% Category & Status and supported features. \\
%
% \midrule
%
% Engines: & \DVI\ \LaTeX, pdf\LaTeX, \XeLaTeX, \LuaLaTeX, up\LaTeX \\
%
% Compiling: & \pkg{latexmk}, \pkg{perltex}, \pkg{pythontex}, \prog{make}, etc. \\
%
% \midrule
%
% Classes: & \pkg{article}, \pkg{book}, \pkg{report},
%   \pkg{scrartcl}, \pkg{scrbook}, \pkg{scrreprt}, \pkg{memoir},
%       CJK-related as listed below. \\
%
% Koma-script: & \pkg{scrextend}, \pkg{scrhack}, \pkg{scrlayer}.
%   Others as listed below. \\
%
% Memoir: & \pkg{memhfixc} \\
%
% \midrule
%
% Languages: & \pkg{babel}, \pkg{polyglossia}.
%       \pkg{cjkpunct}, \pkg{xeCJK}.\\
%
% Chinese: & C\TeX, \pkg{ctex},
%       \pkg{upzhkinsoku},
%       \pkg{xpinyin}, \pkg{zhlineskip}, \pkg{zhspacing}. \\
%
% Japanese: & up\LaTeX, Lua\TeX-ja, \pkg{gentombow}, \pkg{lltjext},
%       \pkg{plarray}, \pkg{plarydshln}, \pkg{plautopatch}, 
%       \pkg{plext}, \pkg{plextarray}, \pkg{plextarydshln},
%       \pkg{plextcolortbl}, \pkg{plextdelarray}, \pkg{pxatbegshi},
%       \pkg{pxeveryshi}, \pkg{pxftnright}, \pkg{pxgentombow},
%       \pkg{pxjahyper}, \pkg{pxpdfpages}, \pkg{pxpgfrcs}, \pkg{pxpgfmark},
%       \pkg{tascmac}, \pkg{zxjatype}.
%       \pkg{bxjsarticle} and related,
%       \pkg{ltjsarticle} and related,
%       \pkg{luatexja}, \pkg{luatexja-fontspec},
%       \pkg{ujarticle} and related,
%       \pkg{utarticle} and related. \\
%
% Korean: & \pkg{kotex}, \pkg{luatexko}, \pkg{xetexko}. \\
%
% \midrule
%
% Page layout: & \pkg{2in1}, \pkg{2up}, \pkg{a4}, \pkg{a4wide}, \pkg{a5comb},
%       \pkg{addlines}, \pkg{anysize}, \pkg{atbegshi},
%       \pkg{blowup},  \pkg{booklet},  \pkg{bophook}, \pkg{bounddvi}, \pkg{bxpapersize},
%       \pkg{canoniclayout},
%       \pkg{changepage}, \pkg{chngpage}, \pkg{clrdblpg},
%       \pkg{continue}, \pkg{draftcopy}, \pkg{draftfigure}, \pkg{draftwatermark},
%       \pkg{ebook}, \pkg{everyshi},
%       \pkg{fancyhdr}, \pkg{fancytabs}, \pkg{flippdf},
%       \pkg{fullminipage}, \pkg{fullpage},
%       \pkg{fwlw}, \pkg{geometry}, \pkg{gmeometric},
%       \pkg{grid}, \pkg{grid-system}, \pkg{gridset},
%       \pkg{layaureo}, \pkg{leading},
%       \pkg{ltxgrid}, \pkg{nccfancyhdr}, \pkg{notespages}, \pkg{pagegrid},
%       \pkg{pdfprivacy}, \pkg{pagesel}, \pkg{preview}, \pkg{rmpage},
%       \pkg{scrlayer-scrpage}, \pkg{scrpage2}, \pkg{textarea}, \pkg{threadcol},
%       \pkg{thumb}, \pkg{thumbs}, \pkg{titleps}, \pkg{tocenter},
%       \pkg{turnthepage}, \pkg{twoup}, \pkg{typearea}, \pkg{vmargin},
%       \pkg{watermark}, \pkg{zwpagelayout}.
%
%       Tested to work as-is: \pkg{underlin}.\\
%
% \midrule
%
% Sectioning: & Adds \progcode{FileDepth} for splitting the \HTML\ output.
% 	Files may be numbered sequentially or named according to section name.
% 	Common short words and punctuation are removed from the filenames. 
%   \pkg{anonchap}, \pkg{bsheaders}, \pkg{fncychap}, \pkg{indentfirst}, \pkg{quotchap},
%	\pkg{section}, \pkg{sectionbreak}, \pkg{sectsty}, \pkg{titlesec}.
%
%       Tested to work as-is: \pkg{secdot}.\\
%
% Table of contents, figures, tables: & Supported, with hyperlinks.
%   \pkg{multitoc}, \pkg{shorttoc}, \pkg{titletoc},
%	\pkg{tocbasic}, \pkg{tocbibind}, \pkg{tocloft}, \pkg{tocstyle}. \\
%
% Title page: & \cs{maketitle}, \env{titlepage}, \pkg{authblk}, \pkg{titling}. \\
%
% Front \&\ back matter: & \pkg{abstract}, \pkg{appendix}. \\
%
% Indexing: & \prog{makeindex} and \prog{xindy} are supported, with hyperlinks.
%
%   \pkg{idxlayout}, \pkg{imakeidx}, \pkg{index}, \pkg{makeidx}, \pkg{repeatindex}, \pkg{splitidx}.
%
%   Tested to work as-is: \pkg{hvindex}, \pkg{sepfootnotes}.\\
%
% Glossary: & \pkg{gloss}, \pkg{glossaries} and \prog{xindy}, \pkg{nomencl}.\\
%
% Bibliography: & \pkg{babelbib}, \pkg{backref}, \pkg{biblatex}, \pkg{bibunits},
%   \pkg{chapterbib}, \pkg{cite}, \pkg{hypernat}, \pkg{natbib}.
%
%   Tested to work as-is: \pkg{notes2bib}. \\
%
% \midrule
%
% Cross-references: & 
%   \pkg{bookmark}, \pkg{breakurl}, \pkg{cleveref}, \pkg{fancyref}, 
%   \pkg{hypdestopt}, \pkg{hyperref}, \pkg{prettyref},
%   \pkg{titleref}, \pkg{url}, \pkg{varioref}, \pkg{xr}, \pkg{xr-hyper}, \pkg{xurl}. \\
%
% \midrule
%
% Margin notes: & \pkg{marginal}, \pkg{marginfit}, \pkg{marginfix},
%   \pkg{scrlayer-notecolumn}, \pkg{versonotes}. \\
%
% Footnotes: & Adds \progcode{FootnoteDepth} to print footnotes at section breaks.
%   \pkg{dblfnote},
%   \pkg{endheads}, \pkg{endnotes}, \pkg{fnbreak}, \pkg{fnpos},
%   \pkg{footmisc}, \pkg{footnote}, \pkg{footnoterange}, \pkg{footnpag}, 
%	\pkg{marginnote}, \pkg{nccfoots}, \pkg{pagenote},
%   \pkg{parnotes}, \pkg{pfnote}, \pkg{sidenote}.
%
%   Tested to work as-is: \pkg{fixfoot}. \\
%
% \midrule
%
% Math: & Converted to \SVG\ images with \HTML\ \element{alt} tags containing the
% 	\LaTeX\ source for the math expression.
%	\brand{MathJax} supported as an alternative.
% 	\pkg{amsmath}: \AmS\ environments are supported.
% 	User-defined macros are available during converson,
% 	due to native \LaTeX\ processing.\\
%
% Theorems: & Native \LaTeX\ theorems,
%	\pkg{amsthm}, \pkg{ntheorem}, \pkg{theorem}. \\
%
% Additional math: & Math fonts via \SVG\ images,
%   \pkg{breqn}, \pkg{cases}, \pkg{resizegather}, \pkg{xfakebold}, \pkg{xy}.
%
%   Tested to work as-is:
%   \pkg{amscd}, \pkg{bm}, \pkg{braket}, \pkg{delarray}, \pkg{guass}, \pkg{nicematrix},
%   \pkg{pb-diagram}, \pkg{tikz-cd}, etc. \\
%
% Display math with \cs{displaymathother}: & %
%   Complicated math objects in display math, such as \pkg{tikz-cd}, etc. \\
%
% \midrule
%
% Units and fractions: &
%   \pkg{nicefrac}, \pkg{SIunits}, \pkg{siunitx},
%   \pkg{units}, \pkg{unitsdef}, \pkg{xfrac}.
%
%   Tested to work as-is: \pkg{SIunits}. \\
%
% \midrule
%
% Floats: & Appear where declared.
%   \pkg{capt-of}, \pkg{caption}, \pkg{cutwin}, 
%   \pkg{dblfloatfix}, \pkg{endfloat}, \pkg{fix2col}, \pkg{flafter},
%   \pkg{float}, \pkg{floatflt}, \pkg{floatrow}, \pkg{fltrace}, 
%   \pkg{hypcap}, \pkg{keyfloat}, \pkg{morefloats}, \pkg{multicap}, \pkg{newfloat},
%   \pkg{nonfloat}, \pkg{placeins}, \pkg{rotfloat}, \pkg{stfloats},
%   \pkg{subcaption}, \pkg{subfig}, \pkg{subfigure}, \pkg{subfloat},
%   \pkg{trivfloat}, \pkg{wrapfig}. \\
%
% \midrule
%
% Tabular: &
%   \env{tabular} environment, \pkg{array}, \pkg{arydshln}, \pkg{bigdelim}, \pkg{booktabs},
%   \pkg{colortbl}, \pkg{diagbox}, \pkg{longtable}, \pkg{ltablex}, \pkg{ltxtable},
%   \pkg{multirow}, \pkg{supertabular}, \pkg{tabularx}, \pkg{tabulary},
%   \pkg{threeparttable}, \pkg{xltabular}, \pkg{xtab}. \\
%
% \midrule
%
% Graphics: & \pkg{graphics} and \pkg{graphicx}.
%   \cs{includegraphics} supports \optn{width}, \optn{height},
%   \optn{origin}, \optn{angle}, and \optn{scale} tags, and adds \optn{class}.
%   References to \PDF\ files are changed to \SVG, other image types
%   are accepted as well.
%   \cs{rotatebox} and \cs{scalebox} are supported as well as \HTML\ can handle.
%   \pkg{rotating} is emulated but all objects are unrotated.
%   \pkg{picture}, \pkg{tikz}, and \pkg{xy} are converted to an \SVG\ image.
%
%   \pkg{asymptote}, \pkg{epsfig}, \pkg{epstopdf}, \pkg{figsize}, \pkg{fitbox},
%   \pkg{grffile}, \pkg{overpic},
%   \pkg{psfrag}, \pkg{psfragx}, \pkg{pst-eps}, \pkg{pstool}, \pkg{pstricks},
%   \pkg{rviewport}.
%
%   Tested to work as-is:
%   \pkg{curves}, \pkg{eepic}, \pkg{tikz-3dplot}. \\
%
% \midrule
%
% \pkg{xcolor}: & \textcolor{DarkGreen}{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,
%	\pkg{enumerate}, \pkg{enumitem}, \pkg{hang}, \pkg{paralist}.\\
%
% \midrule
%
% Environments: & Standard \LaTeX{} environments. \\
%
% \env{minipage}, \cs{parbox}: & Some \HTMLfive-imposed limitations.
%	Nested minipages are supported. \pkg{pbox}.\\
%
% Quotations: & \pkg{copyrightbox}, \pkg{csquotes}, \pkg{epigraph},
%   \pkg{quoting}, \pkg{verse}. \\
%
% Verbatim: &
%   \pkg{fancyvrb}, \pkg{moreverb}, \pkg{shortvrb}, \pkg{verbatim}. \\
%
% Frames: & \pkg{boxedminipage2e}, \pkg{fancybox}, \pkg{framed}, \pkg{mdframed},
%   \pkg{shadow}, \pkg{vertbars}. \\
%
% Multi-columns: & \pkg{adjmulticol}, \pkg{multicol}, \pkg{multicolrule}, \pkg{vwcol}. \\
%
% Margins: & \pkg{fullwidth}, \pkg{hanging}, \pkg{midpage}. \\
%
% Line numbering: & \pkg{fnlineno}, \pkg{lineno}. \\
%
% \midrule
%
% Direct formatting: & \cs{emph}, \cs{textsuperscript},
% 	\cs{textbf}, etc are supported.
% 	\cs{bfseries}, etc.\ are only supported in some cases.
%   \pkg{cancel}, \pkg{ellipsis}, \pkg{embrac}, \pkg{enparen},
%   \pkg{hyphenat}, \pkg{lettrine}, \pkg{lips},
%   \pkg{lua-check-hyphen}, \pkg{luacolor},
%   \pkg{magaz}, \pkg{nowidow}, \pkg{pdfrender}, \pkg{realscripts}, \pkg{relsize},
%   \pkg{scalefnt}, \pkg{soul}, \pkg{soulpos}, \pkg{soulutf8},
%   \pkg{textfit}, \pkg{thinsp}, \pkg{trimclip}, \pkg{truncate},
%   \pkg{ulem}, \pkg{umoline}, \pkg{underscore}, \pkg{uspace},
%   \pkg{widows-and-orphans}, \pkg{xellipsis}. \\
%
% Acronyms: & \pkg{acro}, \pkg{acronym}. \\
%
% Ordinals: & \pkg{engord}, \pkg{fmtcount}, \pkg{nth}. \\
%
% 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 \SVG\ math expressions or embedded image environments. \\
%
% Symbols: & Native \LaTeX\ diacriticals, \pkg{academicons}, \pkg{bbding},
%   \pkg{chemgreek}, \pkg{dingbat}, \pkg{eurosym},
%   \pkg{fontawesome}, \pkg{fontawesome5}, \pkg{marvosym}, \pkg{pifont}, \pkg{textalpha},
%   \pkg{textcomp}, \pkg{textgreek}, \pkg{typicons}, \pkg{xunicode}.
%
%   Tested to work as-is:
%   \pkg{euro}, \pkg{gensymb}. \\
%
% \midrule
%
% Files: &
%   \pkg{attachfile}, \pkg{attachfile2}, \pkg{hyperxmp}, \pkg{intopdf},
%   \pkg{pdfpages}, \pkg{pdfx}, \pkg{xmpincl}. \\
%
% \midrule
%
% Science and engineering: &
%   \pkg{algorithm2e}, \pkg{algorithmicx}, \pkg{ar},
%   \pkg{axodraw2}, \pkg{bitpattern}, \pkg{bytefield},
%   \pkg{chemfig}, \pkg{chemformula}, \pkg{chemgreek}, \pkg{chemmacros}, \pkg{chemnum},
%   \pkg{karnaugh-map},
%   \pkg{listings}, \pkg{mhchem}, \pkg{phfqit}, \pkg{register}, \pkg{struktex}.
%
%   Tested to work as-is:
%       \pkg{askmaps}, \pkg{blochsphere}, \pkg{bodegraph}, \pkg{bohr}, \pkg{circuitikz},
%       \pkg{elements}, \pkg{engtlc}, \pkg{fast-diagram},
%       \pkg{hepnicenames}, \pkg{heppennames}, \pkg{karnaughmap},
%       \pkg{linop}, \pkg{pgfgantt}, \pkg{physics}, \pkg{simpler-wick}, \pkg{slashed},
%       \pkg{structmech}, \pkg{tikz-karnaugh}, \pkg{tikzcodeblocks}.
%   \\
%
% \midrule
%
% Arts and humanities: & \pkg{foreign}, \pkg{forest}, \pkg{musicography},  \pkg{nameauth},
%   \pkg{octave}, \pkg{schemata}, \pkg{semantic-markup}, \pkg{vowel}, \pkg{xpiano}.
%
%   Tested to work as-is:
%       \pkg{phonrule}, \pkg{piano}, \pkg{tikz-dependency}. \\
%
% \midrule
%
% Admonitions: & \pkg{notes}. \\
%
% Editorial: & \pkg{changebar}, \pkg{changes},
%   \pkg{easy-todo}, \pkg{ed}, \pkg{errata}, \pkg{fixme},
%   \pkg{fixmetodonotes},
%   \pkg{pdfcomment}, \pkg{pdfmarginpar},
%   \pkg{todo}, \pkg{todonotes}, \pkg{tram}, \pkg{xechangebar}.
%
%   Tested to work as-is:
%   \pkg{changelog}, \pkg{easyReview}. \\
%
% \midrule
%
% Accessibility: & \pkg{accsupp}, \pkg{axessibility}. \\
%
% \midrule
%
% Debug: & \pkg{chkfloat}, \pkg{cmdtrack}, \pkg{dprogress},
%   \pkg{lua-visual-debug}, \pkg{refcheck},
%   \pkg{srcltx}, \pkg{srctex}, \pkg{vpe}, \pkg{xbmks}. \\
%
% \midrule
%
% Working as-is: & 
%   Various utility, calculation, file, and text-only packages, such as
%   \pkg{calc},
%   \pkg{fileerr},
%   \pkg{somedefs},
%   \pkg{trace},
%   \pkg{xspace}.
%   Also, most math-only packages, including specialized typesetting for
%   various fields of science and engineering. \\
%
% \bottomrule
%
% \end{longtable}
%
% \endgroup
%
%
%
% \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{\pkg{internet} class}
%
% \changes{v0.21}{2017/02/15}{Docs: Added \pkg{internet} class.}
%
% The closest to \pkg{lwarp} in design principle is the
% \DescribeClass{internet}
% \verb+internet+ class by Andrew Stacey \Dash
% an interesting project which directly produces several versions
% of markdown, and also \HTML\ and \EPUB.
% \url{https://github.com/loopspace/latex-to-internet}
% 
% 
%
% \subsection{\brand{TeX4ht}}
%
% \url{http://tug.org/tex4ht/}\DescribeProgram{TeX4ht}\DescribeProgram{htlatex}
%
% \bigskip\noindent
% 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 some cases \pkg{lwarp} provides a better \HTML\ conversion, and it supports
% a different set of packages.
% TeX4ht produces several other forms of output beyond \HTML, including \ODT\ and
% a direct path to \EPUB, and is still being developed.
%
% \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{\brand{AsciiDoc} and \brand{Asciidoctor}}
%
% 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 project.)\DescribeProgram{AsciiDoctor}
% \end{description}
%
% \subsubsection{\brand{Asciidoctor-\LaTeX}}
% The Asciidoctor-LaTeX project is developing 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{\brand{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 \brand{Microsoft}\,\supregistered\ \prog{Word}\,\supregistered{}
% and \brand{LibreOffice}\,\texttrademark\ \prog{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 \brand{Adobe}\,\supregistered{} \prog{FrameMaker}\,\supregistered{},
% \brand{Adobe} \prog{InDesign}\,\supregistered,
% and \brand{Madcap} \prog{Flare}\,\texttrademark.
%
% \subsection{Comparisons}
% \gindex{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
%
% \setlength{\parindent}{0em}
% \setlength{\parskip}{2ex}
%
% \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.
%
% Detailed installation instructions follow.
%
% \gindex{utility>programs}
% \gindex{programs>utility}
%
% \begin{table}[hbp]
% \changes{v0.45}{2017/11/30}{Docs: Moved table so doesn't interfere with install docs.}
% \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:] \prog{pdflatex}, \prog{xelatex}, or \prog{lualatex}.
%	\DescribeProgram[requirement]{pdfLaTeX}
%	\DescribeProgram[requirement]{XeLaTeX}
%	\DescribeProgram[requirement]{LuaLaTeX}
%
% \item[The \pkg{lwarp} package:] This package.
%
% \item[The \prog{lwarpmk} utility:] Provided along with this package.  This
%	should be an operating-system executable in the same way that
%	\prog{pdflatex} or \prog{latexmk} is.  It is possible to have the
%	\pkg{lwarp} package generate a local copy of \prog{lwarpmk}
%	called \filenm{lwarpmk.lua}.
%	See \cref{sec:genlatexmk}.
%
% \item[\prog{luatex}:] Used by the \prog{lwarpmk} program to simplify and automate document generation.
%
% \item [\prog{xindy}:] The \prog{xindy} program 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[\prog{latexmk}:] Optionally used by \prog{lwarpmk} to compile \LaTeX\ code.
%	On a MiK\TeX\ system, \prog{Perl} may need to be installed first.
%
% \item[\prog{pdfcrop}:] Used to pull images out of the \LaTeX{} \PDF.
%	\DescribeProgram[requirement]{pdfcrop}
%
% \end{description}
%
% \item[\brand{Poppler} \PDF\ utilities:] \
%
% \begin{description}
%
% \item[\prog{pdftotext}:] Used to convert \PDF\ to text.
%	\DescribeProgram[requirement]{pdftotext}\gindex{Poppler=\brand{Poppler}}
%
% \item[\prog{pdfseparate}:] Used to pull images out of the \LaTeX{} \PDF.
%	\DescribeProgram[requirement]{pdfseparate}
%
% \item[\prog{pdftocairo}:] Used to convert images to \SVG.
%	\DescribeProgram[requirement]{pdftocairo}
%
% \end{description}
%
%	These might be provided by your operating-system package manager,
%   and MiK\TeX\ provides \pkg{miktex-poppler-bin-*} packages.
%
%	From \brand{Poppler}: \url{poppler.freedesktop.org}.
%
%	For \brand{MacOS}\supregistered, see
%		\url{https://brew.sh/}, install \prog{Homebrew}, then
%		\userentry{brew install poppler}
%
%	For \brand{Windows}, see Mik\TeX\ \pkg{miktex-poppler-bin-*}, or: \\
%		\url{https://sourceforge.net/projects/poppler-win32/} \quad and: \\
%		\url{http://blog.alivate.com.au/poppler-windows/}
%
% \item[\prog{Perl}:] \
%
% This may be provided by your operating-system package manager, and may be
% required for some of the \brand{Poppler} \PDF\ utilities.
%
% \url{strawberryperl.com} (recommended), \url{perl.org}
%
% \item[Automatically downloaded from the internet as required:] \
% \begin{description}
%
% \item[\brand{MathJax}:] Optionally used to display math.
%	From: \url{mathjax.org}
%	\DescribeProgram[requirement]{MathJax}
%
% \end{description}
% \end{description}
%
% \hrule
% \end{table}
% \clearpage
%
% \subsection{Installing the \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 and
%   you may skip to the next section.
%
% \item [\TeX\ Live:] If using a \TeX\ Live distribution,
%	try installing via \prog{tlmgr}:
%	\userentry{tlmgr install lwarp}
%
% \item [MiK\TeX:] \
%   \begin{enumerate}
%   \item For newer versions of MiK\TeX, install or update \pkg{lwarp}
%       using the \prog{MiKTeX Console} program.
% \changes{v0.62}{2018/11/03}{Docs: \prog{MiKTeX Console}}
%   \item For older versions of MiK\TeX,
%       to install \pkg{lwarp} the first time,
%       use the \prog{MiKTeX Package Manager (Admin)}.
%       To update \pkg{lwarp}, use \prog{MiKTeX Update (Admin)}.
%	\item Either way, also update the package \pkg{miktex-misc}, which will install and
%       update the \prog{lwarpmk} executable.
%   \end{enumerate}
% \changes{v0.26}{2017/03/23}{Docs: Improved MiK\TeX\ install instructions.}
% \changes{v0.45}{2017/11/30}{Docs: Improved MiK\TeX\ install instructions.}
% \changes{v0.62}{2018/11/03}{Docs: Improved MiK\TeX\ install instructions.}
%
% \item [Operating-system package:] The operating-system package manager may
%	already have \pkg{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 \UI{Settings} window, \UI{Roots} tab, look for a local \TDS\ root.
%		\end{description}
%		This should be something like:
%		\begin{sourceverb}
%		/usr/local/texlive/texmf-local/
%		\end{sourceverb}
%	\item Unpack the archive in the \TDS\ local directory.
%	\item Renew the cache:
%		\userentry{mktexlsr} \quad —\,or\,—
%		\userentry{texhash}
%
%		Or, for \brand{Windows} MiK\TeX, start the program called \prog{MiKTeX Settings (Admin)}
%		and click on the button called \UI{Refresh FNDB}.
%	\end{enumerate}
%
% \item[CTAN \filenm{.dtx} and \filenm{.ins} files:] Another form of \TeX\ package
%	is |.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 \filenm{lwarp.zip} into your own \filenm{lwarp} directory.
%	\item Unpack \filenm{lwarp.zip}.
%	\item Locate the contents \filenm{lwarp.dtx} and \filenm{lwarp.ins}
%   \item Create the |.sty| files: \userentry{pdflatex lwarp.ins}
%	\item Create the documentation:
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% pdflatex lwarp.dtx  (several times)
% makeindex -s gglo.ist -o lwarp.gls lwarp.glo
% makeindex -s gind.ist lwarp.idx
% pdflatex lwarp.dtx  (several times)
% \end{Verbatim}
%	\item Copy the |.sty| files somewhere such as the \TeX\ Live local tree
%		found in the previous \CTAN\ \TDS\ section, under the subdirectory:
%		\begin{sourceverb}
%		<texlocal>/tex/latex/local/lwarp
%		\end{sourceverb}
%   \item Copy \filenm{lwarp_baseline_marker.png} and \filenm{lwarp_baseline_marker.eps}
%       to the same place as the \filenm{.sty} files.
% \changes{v0.52}{2018/03/24}{Docs: Improved install instructions.}
%	\item Copy the documentation \filenm{lwarp.pdf} to a \filenm{source} directory in the local tree,
%		such as:
%		\begin{sourceverb}
%		<texlocal>/doc/local/lwarp
%		\end{sourceverb}
%	\item Renew the cache:
%		\userentry{mktexlsr} \quad —\,or\,—
%		\userentry{texhash}
%
%		Or, for \brand{Windows} MiK\TeX, start the program called \prog{MiKTeX Settings (Admin)}
%		and click on the button called \UI{Refresh FNDB}.
%
%	\item See \cref{sec:locallwarpmk} to generate your local copy of \prog{lwarpmk}.
%	\item Once the local version of \filenm{lwarpmk.lua} is installed, it may be made
%		available system-wide as per \cref{sec:installlwarpmk}.
%	\end{enumerate}
% \item[Project-local \CTAN\ \filenm{.dtx} and \filenm{.ins} files:] The
%		|.dtx| and |.ins| files may be downloaded to a project
%		directory, then compiled right there, alongside the
%		document source files.  The resultant |*.sty| and \filenm{lwarpmk.lua} files
%		may be used as-is, so long as they are in the same directory
%		as the document source.
%       The files \filenm{lwarp_baseline_marker.png} and
%       \filenm{lwarp_baseline_marker.eps}  must also be copied as well.
% \changes{v0.52}{2018/03/24}{Docs: Improved install instructions.}
%       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 \prog{lwarpmk} utility}
% \label{sec:installlwarpmk}
%
% \changes{v0.21}{2017/02/22}{Docs: Installing on \brand{Windows}.}
%
% {\small
% (Note: If \prog{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 \prog{lwarpmk} utility:
% \begin{enumerate}
% \item At a command line, try executing \cmds{lwarpmk}.
%   If the \prog{lwarpmk} help message appears, then \prog{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 \pkg{miktex-misc} package.  This may install
% the \prog{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 \filenm{lwarpmk.lua}, which should be in the |scripts| directory
%	of the \TDS\ tree.  On a \TeX\ Live or MiK\TeX\ system you may use
%	\userentry{kpsewhich lwarpmk.lua}
%
%	(If the file is not found, you may also generate a local copy and use it instead.
%	See \cref{sec:locallwarpmk}.)
%
% \item Create \prog{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{sourceverb}
% /usr/local/texlive/<year>
%		\end{sourceverb}
%			The binaries are then located in the |bin/<arch>| directory
%			under the root:
%		\begin{sourceverb}
% /usr/local/texlive/<year>/bin/<architecture>/
%		\end{sourceverb}
%			In this directory you will find programs
%			such as \prog{pdflatex} and \prog{makeindex}.
%		\item In the binaries directory,
%			create a new symbolic link from the binaries directory to \filenm{lwarpmk.lua}:
%			\userentry{ln -s <pathtolwarpmk.lua> lwarpmk}
%		\item Make the link executable:
%			\userentry{chmod 0755 lwarpmk}
%		\end{enumerate}
%	\item [\brand{Windows} \TeX\ Live:] Create a new |lwarpmk.exe| file:
%		\begin{enumerate}
%		\item Locate the \TeX\ Live binaries as shown above for \brand{Unix}.
%		\item In the binaries directory, make a \emph{copy} of |runscript.exe|
%			and call it |lwarpmk.exe|
%			This will call the copy of \filenm{lwarpmk.lua}
%			which is in the |scripts| directory of the distribution.
%		\end{enumerate}
%	\item [\brand{Windows} MiK\TeX:] Create a new |lwarpmk.bat| file:
%		\begin{enumerate}
%		\item Locate the MiK\TeX\ binaries.  These will be in a directory such as:
%		\begin{sourceverb}
% C:\Program Files\MiKTeX 2.9\miktex\bin\x64
%		\end{sourceverb}
%			In this directory you will find programs
%			such as |pdflatex.exe| and |makeindex.exe|.
%		\item Create a new file named |lwarpmk.bat| containing:
%		\begin{sourceverb}
% texlua "C:\Program Files\MiKTeX 2.9\scripts\lwarp\lwarp.texlua" %*
%		\end{sourceverb}
%			This will call the copy of \filenm{lwarpmk.lua}
%			which is in the |scripts| directory of the distribution.
%		\end{enumerate}
%	\end{description}
% \end{enumerate}
%
% \subsubsection{Using a local copy of \prog{lwarpmk}}
% \label{sec:locallwarpmk}
% It is also possible to use a local version of \prog{lwarpmk}:
% \begin{enumerate}
% \item When compiling the tutorial in \cref{sec:tutorial},
%	use the \optn{lwarpmk} option for the \pkg{lwarp} package:
%	\begin{sourceverb}
% \usepackage[lwarpmk]{lwarp}
%	\end{sourceverb}
% \item When the tutorial is compiled with \prog{pdflatex}, the file \filenm{lwarpmk.lua}
%	will be generated along with the other configuration files.
% \item \filenm{lwarpmk.lua} may be used for this project:
%	\begin{description}
%		\item[Unix:] \
%			\begin{enumerate}
%			\item Make \filenm{lwarpmk.lua} executable: \userentry{chmod 0755 lwarpmk.lua}
%			\item Compile documents with
%				\userentry{./lwarpmk.lua html}
%				\userentry{./lwarpmk.lua print} \quad etc.
%			\item It may be useful to rename or link to a version without the |.lua| suffix.
%			\end{enumerate}
%		\item[\brand{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 \brand{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}
% \changes{v0.45}{2017/11/30}{Docs: Fix for double hyphens.}
%
% \item [To install \prog{xindy}, \prog{latexmk}, and \prog{pdfcrop}:] \
%
% The \TeX\ utilities \prog{xindy}, \prog{latexmk}, and \prog{pdfcrop} may be installed
% in \prog{TexLive} with \prog{tlmgr}, installed by \prog{MiKTeX}, provided by
% your operating system's package manager, or downloaded from the \prog{CTAN} archive:
% \changes{v0.45}{2017/11/30}{Docs: Improved install instructions.}
%	\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 \brand{Poppler} utilities to a \brand{Unix}/\brand{Linux} system:] \
%	\DescribeProgram[requirement]{pdftotext}\gindex{Poppler=\brand{Poppler}}
%	\DescribeProgram[requirement]{pdfseparate}
%	\DescribeProgram[requirement]{pdftocairo}
%
% The tools from the \brand{Poppler} project should be provided by your
% operating system's package manager.
%
%
% \item [To install the \brand{Poppler} utilities to a \brand{MacOS} machine:] \
%	\begin{enumerate}
%	\item Install \prog{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 \brand{Poppler} utilities:
%		\userentry{brew install poppler}
%	\end{enumerate}
%
%
% \item [To install the \brand{Poppler} utilities to a \brand{Windows} machine:] \
%
% If using Mik\TeX, install a \pkg{miktex-poppler-bin-*} package.
% \changes{v0.62}{2018/11/03}{Docs: \pkg{miktex-poppler-bin-*}}
% Otherwise:
% \begin{enumerate}
% \item See \cref{tab:utility} on \cpageref{tab:utility}.
% \item Download and extract the \brand{Poppler} utilities \prog{pdftotext}, \prog{pdfseparate},
% and \prog{pdfseparate} to a directory, such as |Poppler|.
% \item In the \UI{Start} window, type "Path" to search for results
% related to Path.  Or, open the control panel and search for "Path".
% \item Choose \UI{Edit the system environment variables} in the control panel.
% \item Choose the \UI{Environment Variables} button.
% \item Choose the \UI{Path} variable, then the \UI{Edit} button.
% \item Choose the \UI{New} button to make an additional entry.
% \item Enter the |bin| directory of the \brand{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 \UI{Ok} when done.
% \end{enumerate}
%
% \needspace{2\baselineskip}
% \item [To install \brand{Perl} to a \brand{Windows} machine:] \
% \DescribeProgram[requirement]{perl}\gindex{Perl=\brand{Perl}}
% \begin{enumerate}
% \item Download and install a version of \brand{Perl}, such as \brand{Straweberry Perl},
%	to a directory without a space in its name, such as |C:\Strawberry|.
% \item Edit the \UI{Path} as seen above for the \brand{Poppler} utilities.
% \item Enter the |bin| directory of the \prog{perl} utility, such as:
%	\begin{sourcedisplay}
%	|C:\Strawberry\perl\bin|
%	\end{sourcedisplay}
%
%	Be sure to include |\bin|.
% \item Click \UI{Ok} when done.
% \end{enumerate}
%
% \end{description}
%
% \vfill
% \textred{\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.
%
% \needhelp
%
% \subsection{Starting a new project}
%
% \changes{v0.21}{2017/02/23}{File: \filenm{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 \brand{Windows}, use an editor other than \brand{Notepad},
%	\watchout[Bad formatting!]
%	since \brand{Notepad} does not accept the end-of-line from a \brand{Unix} text file.}
%
% \item Compile the project: \userentry{pdflatex tutorial.tex}
%				\quad (several times)
%
% (\prog{xelatex} or \prog{lualatex} may be used as well.
%   \pkg{lwarp} also supports \DVI\ \prog{latex} for use with \filenm{.eps} images.)
%
% \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 \prog{lwarpmk}.
% Whenever a print version of the document is created,
% the configuration files for \prog{lwarpmk} are updated to
% record the operating system, \LaTeX\ engine (\prog{latex}, \prog{pdflatex}, \prog{xelatex}, or \prog{lualatex}),
% the filenames of the source code and \HTML\ output, and whether
% the additional helper program \prog{latexmk} will be used to compile the document.)
%
%
% \clearpage
%
% \begingroup
% \captionof{figure}{tutorial.tex listing}
% \label{fig:tutorial}
%
% \begin{center}
% \footnotesize
% \textred{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{Configuration files created by 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 \prog{lwarpmk},
%	which is used to automate the compilation of \PDF\ or \HTML\
%	versions of the document.
%
% \item [|tutorial.lwarpmkconf|:] Another configuration file used by \prog{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.ist|:] Used by \pkg{lwarp} while creating an index using \prog{makeindex}.
%   This file should not be modified by the user.
%   A custom file may be used instead, if necessary.
%
% \item [|lwarp.xdy|:] Used by \pkg{lwarp} while creating an index using \prog{xindy}.
%	This file should not be modified by the user.
%	A custom file may be used instead, if necessary.
%
% \item [|lwarp\_one\_limage.txt|:] For \brand{Windows} only.
%   Used to process \SVG\ images in the background.  Copied to
%   |lwarp_one_limage.cmd| when images are generated.
%
% \item [|lwarp\_mathjax.txt|:] Inserted into the \HTML\ files when
%	\brand{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 \optn{lwarpmk} option is given to the \pkg{lwarp} package:
% \begin{description}
% \item [\filenm{lwarpmk.lua}:] A local copy of the \prog{lwarpmk} utility.
%
%	On \brand{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 \prog{lwarpmk}}
%
% The \prog{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}
%
%	\prog{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
%	\prog{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 \prog{latexmk} (introduced later), the changed date is
%	ignored and an actual change in contents must occur to cause a recompile.}
%
% \item Process the index.\gindex{index>processing}%
%   \footnote{The command \cmds{lwarpmk printglossary} is also
%	    available to process a glossary produced with the \textsf{glossaries} package.
%	    See \cref{sec:glossaries}.}%
%   \footnote{Also see \cref{sec:indexsetup} 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 \prog{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 \prog{lwarpmk} uses \LaTeX\ to process |tutorial_html.tex|
%		to create \\
%		|tutorial_html.pdf|.
%	\item \prog{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 \prog{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 \HTML\ page in a web browser.
%
%	\qquad Open the file |tutorial.html| in a web browser.
%
%	Note that math is still displayed as its \attribute{alt} tag, which is
%   \margintag{math}
%   the plain-text \LaTeX\ source,
%	until the
%	images of the math expressions have been generated.  Math may be
%	displayed as \SVG\ images or by a \brand{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:\gindex{index>processing}
%   \footnote{The command \cmds{lwarpmk htmlglossary} is also
%	available to process a glossary produced with the \textsf{glossaries} package.
%	See \cref{sec:glossaries}.}\footnote{Also see \cref{sec:indexsetup} 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 is displayed as it was drawn by \LaTeX, and the \LaTeX\ source
% may be copied and pasted into other documents.
%
% \pkg{lwarp} uses the same mechanism for \env{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 \HTML\ math page and reload the document in the browser.
%
% \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 \brand{MathJax} for math}
% \label{sec:tutorialmathjax}
%
% Math may also be represented using the \brand{MathJax} \brand{Javascript} project.
% \margintag{math with \brand{MathJax}}
%
% \begin{enumerate}
% \item In the tutorial's source code, uncomment the \optn{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}
%
% \brand{MathJax} requires web access unless a local copy of \brand{MathJax} is available,
% \watchout[\brand{MathJax} requirements]
% and it also requires that \brand{Javascript} is enabled for the web page.
% The math is rendered by \brand{MathJax}.  Right-click on math to see several
% options for rendering, and for copying the \LaTeX\ source.
%
% While using \brand{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 \\
% \textred{\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 \prog{latexmk}}
%
% \prog{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 \optn{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 \prog{lwarpmk} should
%	use \prog{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 \prog{latexmk} has a much better awareness of changes than
% the \prog{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,
% and 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 \prog{xelatex} or \prog{lualatex} to compile the printed version
%   a single time.
%	\userentry{xelatex tutorial.tex} \quad -or-
%	\userentry{lualatex tutorial.tex}
%
%	When the compile occurs,
%	the configuration files for \prog{lwarpmk} are modified to remember
%	which \TeX\ engine was used.  \XeLaTeX\ or \LuaLaTeX\ will be used for
%	future runs of \prog{lwarpmk}.
%
% \item To recompile the document:
%	\userentry{lwarpmk print} \quad -and-
%	\userentry{lwarpmk html}
%
% \item Also remember to update the indexes and recompile again:
%   \userentry{lwarpmk htmlindex}
%   \userentry{lwarpmk html}
%   \userentry{lwarpmk printindex}
%   \userentry{lwarpmk print}
% \end{enumerate}
%
%
% \subsection{Using \DVI\ \LaTeX}
%
% \gindex{DVI \LaTeX}
%
% Traditional \DVI\ LaTeX may also be used along with \filenm{.eps} image files.
% An \SVG\ version of each image must also be provided.
% \prog{lwarpmk} may be used to convert image formats.
%
% To convert \EPS\ files to \PDF:
% \userentry{lwarpmk epstopdf *.eps \qquad \textrm{(or a list of files)}}
%
% To convert \PDF\ files to \SVG:
% \userentry{lwarpmk pdftosvg *.pdf \qquad \textrm{(or a list of files)}}
%
% See \cref{sec:fonts} regarding font selection
% \watchout[bitmapped fonts]
% to avoid the use of bitmapped fonts.
%
%
% \clearpage
%
% \subsection{Using a glossary}
%
% \changes{v0.29}{2017/04/15}{Docs: Using a glossary}
%
% \pkg{lwarp} supports the \pkg{gloss} and \pkg{glossaries} packages,
% although this tutorial does not supply an example.
%
% \subsubsection{\pkg{gloss} package}
%
% See \cref{sec:gloss}.
%
% \subsubsection{\pkg{glossaries} package}
% \gindex{glossaries=\pkg{glossaries}>processing}
% To process the glossary for the print version:
%	\userentry{lwarpmk printglossary}
%
% \fquad (If \cmds{makeglossaries} is not found, see \cref{sec:glossaries}.)\watchout
%
% To process the glossary for the \HTML\ version:
%	\userentry{lwarpmk htmlglossary}
%
% In each case, the document will have to be recompiled afterwards:
% \userentry{lwarpmk html1}
% \userentry{lwarpmk html}
% \userentry{lwarpmk print1}
% \userentry{lwarpmk print}
%
% See \cref{sec:glossaries} to set options for processing glossaries.
%
%
% \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{Cleaning the images from the \filenm{<project>-images} directory}
% \changes{v0.53}{2018/04/01}{Docs: \cmds{lwarpmk cleanlimages}.}
%
% The \filenm{<project>-images} directory contains \SVG\ images
% automatically generated for inline and display math, \pkg{tikz}, etc.
% To remove all the images from the \filenm{lateximages} directory:
%   \userentry{lwarpmk cleanlimages}
%
%
% \subsection{Converting \PDF\ or \EPS\ images to \SVG}
% \changes{v0.56}{2018/04/29}{Docs: \cmds{lwarpmk pdftosvg}.}
% \changes{v0.59}{2018/09/05}{Docs: \cmds{lwarpmk epstopdf}.}
%
% \HTML\ cannot display \PDF\ or \EPS\ images, so any external \PDF\ graphics images must
% be converted to \SVG\ format.
% \gindex{SVG>converting from \PDF\ or \EPS}
% \gindex{PDF image>converting}
% \gindex{EPS image>converting}
% \gindex{image>PDF or EPS>converting}
% \prog{pdftocairo} and \prog{epstopdf} may be used one image at a time,
% but \prog{lwarpmk} also provides a way to convert \PDF\ or \EPS\ images in bulk:
% \userentry{lwarpmk epstopdf *.eps \qquad \textrm{(or a list of files)}}
% \userentry{lwarpmk pdftosvg *.pdf \qquad \textrm{(or a list of files)}}
% Be sure to always provide \SVG\ files for \HTML\ output.
%
%
% \subsection{Creating \HTML\ from an incomplete compile}
% \changes{v0.53}{2018/04/01}{Docs: \cmds{lwarpmk pdftohtml}.}
%
% During testing it may be useful to finish the \HTML\ conversion even when
% the document had errors and did not compile successfully.  To attempt an
% \HTML\ conversion of an incomplete document:
%   \userentry{lwarpmk pdftohtml [-p project]}
%
%
% \subsection{Processing multiple projects in the same directory}
%
% It is possible to have several projects in the same directory.
% \prog{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 -p project\_a}
% \userentry{lwarpmk html -p project\_b}
%
%
% \subsection{Using the \prog{make} utility}
%
% \prog{lwarpmk} has an action which may be useful for integration with the
% common \prog{make} utility:
%	\begin{sourcedisplay}
%	|lwarpmk pdftohtml [-p project]|
%	\end{sourcedisplay}
%
% \prog{make} may be used to compile the code to \PDF\ with \HTML\
% tags (|project_html.pdf|), then \prog{lwarpmk} may be used to
% convert each target to \HTML\ files.
%
%
% \clearpage
%
% \section{Converting an existing document}
% \label{sec:convertexisting}
%
% \gindex{modifying>document}
% \gindex{adapting>document}
% \gindex{converting>document}
% \gindex{document>convert existing}
%
% \changes{v0.48}{2018/02/05}{Docs: Converting an existing document.}
% \changes{v0.51}{2018/03/04}{Docs: Updated Converting an existing document.}
% \changes{v0.66}{2019/02/07}{Docs: Updated Converting an existing document.}
%
% To convert an existing document for use with \pkg{lwarp}:
% \begin{enumerate}
% \item Arrange the document in the following order:
% \begin{enumerate}
%   \item Declare the \cs{documentclass}.
%   \item Load text fonts.
%   \item Load \pkg{inputenc} or \pkg{inputenx}, \pkg{fontenc}, and/or \pkg{fontspec}.
%   \item Load \pkg{lwarp}.
%   \item Load remaining packages.
% \end{enumerate}
% \item Modify the document:
% \begin{enumerate}
% ^^A  \item Remove \filenm{.pdf} file extensions.  Change:
% ^^A      \begin{sourcedisplay}
% ^^A      \cs{includegraphics}\{filename.pdf\}
% ^^A      \end{sourcedisplay} to:
% ^^A      \begin{sourcedisplay}
% ^^A      \cs{includegraphics}\{filename\}
% ^^A      \end{sourcedisplay}
% ^^A      Other image formats may have a file extension.
%   \item \limitsmathinsectionnames
%   \item \limitsincludegraphicsscale
%   \item Possible changes to \env{tabular} environments include
%       |*| columns, \pkg{multirow}, \pkg{longtable}, \pkg{supertabular}, \pkg{xtab},
%       \pkg{bigdelim}.  See \cref{sec:limitstabular}.
%   \item Possible option clashes with \pkg{memoir}.  See \cref{sec:limitsmemoir}.
%   \item If using indexes, see \cref{sec:indexsetup}.
%   \item If using many indexes, glossaries, |.aux| files, etc.,
%       see \cref{sec:indexsetup} regarding \pkg{morewrites}.
%       If \pkg{morewrites} is already used, be sure to add the setup with |allocate=10|.
%   \item Other changes as per \nameref{sec:limitations}, \cref{sec:limitations}.
% \end{enumerate}
% \item Convert any \PDF\ images to \SVG.  See \cref{sec:limitsgraphics}.
% \item Manually compile the print version with \prog{latex}, \prog{pdflatex},
%           \prog{lualatex}, or \prog{xelatex}.
% \item |lwarpmk print| to finish the print version.
% \item |lwarpmk html| to create the \HTML\ version.
% \item |lwarpmk limages| to create the \SVG\ images of any \SVG\ math, \env{lateximage}, \tikz, etc.
% \end{enumerate}
%
% \needhelp
%
% \clearpage
%
% \section{Additional details}
%
%
% \subsection{Shell escape}
% \label{sec:shellescape}
% \gindex{shell escape}
%
% \DescribeOption{-\/-shell-escape}
% Some documents require the use of an external program,
% which is allowed when using the \optn{-\/-shell-escape} command-line option.
% When the document is first compiled manually,
% and also whenever the print version is recompiled,
% \pkg{lwarp} detects and remembers
% whether shell escape is enabled.  If so, it will also be enabled when
% the document is recompiled with \prog{lwarpmk}.
%
%
% \subsection{Font and \UTF-8 support}
% \label{sec:fonts}
% \trouble{font>UTF-8}
% \trouble{text>corrupted}
% \trouble{font>selection}
% \trouble{Unicode>fonts}
% \gindex{font>selection}
% \gindex{font>type 3 bitmapped}
% \gindex{font>type 1 vector}
% \gindex{type 1 vector fonts}
% \gindex{type 3 bitmapped fonts}
% \gindex{vector fonts}
% \gindex{bitmapped fonts}
% \gindex{Unicode>selection}
% \gindex{UTF-8>selection}
% \gindex{Computer Modern}
% \gindex{Latin Modern font}
% \gindex{DVI \LaTeX}
% \changes{v0.16}{2016/04/08}{Docs: Font and UTF-8 support.}
% \changes{v0.16}{2016/04/08}{Lwarp no longer selects fonts.}
% \changes{v0.61}{2018/09/25}{Docs: Fonts.}
%
% \pkg{lwarp} uses \prog{pdftotext} to convert \PDF\ output into UTF-8-encoded
% \watchout[type 3 bitmapped fonts]
% text.  This process requires that UTF-8 information be embedded in the \PDF\
% file, which may prevent the use of older ``type 3'' bit-mapped fonts,
% and of older packages such as \pkg{ae}.
% The \pkg{lwarp} option \optn{pdftotextEnc} may be useful in some situations.
% See \cref{sec:loading}.
%
% While using \DVI\ \prog{latex} or \PDF\ \prog{pdflatex},
% \margintag{vector fonts}
% if no font-related package is specified then the default
% Computer Modern font is used, which may be a ``type 3'' bit-mapped font which may not
% convert well to plain text.  A ``type 1'' vector font is required.
% \margintag{Computer Modern}%
% \gindex{font>Computer Modern}\gindex{Computer Modern}%
% \watchout[\prog{pdflatex}]%
% \watchout[DVI \prog{latex}]%
%
% \DescribePackage{cm-super}
% To use the updated \pkg{cm-super}'s type 1 fonts instead of Computer Modern,
% install the \pkg{cm-super} font package.
%
% \DescribePackage{lmodern}
% To use Latin Modern instead, add
%	\begin{sourcedisplay}
%	|usepackage{lmodern}|
%	\end{sourcedisplay}
% to the preamble.
%
% \DescribePackage{dejavu}
% Another useful option is the Deja Vu series of fonts, which have
% an increased coverage of language and glyphs:
%	\begin{sourcedisplay}
% |\usepackage{dejavu}|
%	\end{sourcedisplay}
% \gindex{Deja Vu}%
% \gindex{font>Deja Vu}%
% \gindex{Unicode>enhanced coverage}%
% \gindex{UTF-8>enhanced coverage}%
%
% While using \DVI\ \prog{latex} or \PDF\ \prog{pdflatex},
% \margintag{\prog{latex}, \prog{pdflatex}, T1, UTF8}
% \pkg{lwarp} automatically loads \pkg{fontenc} with T1 encoding.
% \pkg{fontenc} may be loaded with an additional encoding after \pkg{lwarp}.
% \pkg{inputenc} is automatically loaded with UTF8 encoding if if has not yet been loaded,
% but may also be specified with another encoding such as |latin1|.
% See the next section regarding index encoding.
%
% \XeLaTeX{} and \LuaLaTeX{} users must use the \pkg{fontspec} package.
% \trouble[\prog{xelatex} and \prog{lualatex}]{xelatex=xe\LaTeX}
% \trouble{lualatex=lua\LaTeX}
% \trouble{fontspec=\pkg{fontspec}}
% Do NOT use \pkg{fontenc}!
%
% Place \pkg{fontspec} or \pkg{fontenc}, \pkg{xunicode}, and other font and UTF-8 related commands
% after the \cs{documentclass} command and before |\usepackage{lwarp}|.
%
% In some cases, \trouble[package conflicts]{font>package conflicts}
% a package conflict may require that a font package be loaded
% after \pkg{lwarp}, which should work as well:
% \begin{enumerate}
% \item |documentclass{article/book/report}| comes first, 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.
% \gindex{ligatures}
% \gindex{font>ligatures}
% \trouble{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 \prog{pdflatex}:
% \begin{enumerate}
% \item |\usepackage{lmodern}|, or other font-related packages
%	\DescribePackage{lmodern}
%	\gindex{font>packages}
% \item |\usepackage[T1]{fontenc}|
% \DescribePackage{fontenc}
% \item |\usepackage[utf8]{inputenc}|, or |latin1|, etc.  Or use \pkg{inputenx}.
% \DescribePackage{inputenc}\DescribePackage{inputenx}
% \item |\usepackage{newunicodechar}| along with related definitions.
% \DescribePackage{newunicodechar}
% \item To assist with the \PDF-\HTML\ conversion:
%       \begin{enumerate}
%       \item |\input glyphtounicode.tex|
%           \DescribeFile{glyphtounicode.tex}
%       \item |\input glyphtounicode-cmr.tex% from the pdfx package|
%       \item |\pdfgentounicode=1|
%       \end{enumerate}
% \item Another option to assist with the \PDF-\HTML\ conversion:
%       \begin{itemize}
%       \item |\usepackage{cmap}|
%       \DescribePackage{cmap}
%       \end{itemize}
% \item |\usepackage{textcomp}|
% \DescribePackage{textcomp}
% ^^A \item \pkg{microtype} is automatically used by \pkg{lwarp}
% ^^A \DescribePackage{microtype}
% ^^A to turn off f,q,t,T,Q ligatures for the same
% ^^A \margintag{ligatures}
% ^^A browser-related reasons shown above.  Also, the monospaced font is used
% ^^A during \HTML\ tag generation to turn off \TeX{} ligatures.
% ^^A \gindex{ligatures}\gindex{font>ligatures}
% \end{enumerate}
% \end{itemize}
% \item |\usepackage{lwarp}| (\cref{sec:loading}) goes after any of the above, followed by:
% \item |\usepackage{newtxmath}| or other math-related font packages.
%       Many of these load \pkg{amsmath}, which must be loaded after \pkg{lwarp},
%       so they must also be loaded after \pkg{lwarp}.
% \item |\setmonofont{TeX Gyre Cursor}| or similar may be required if using
%       \trouble[\pkg{fontspec} with traditional font packages]{font>monospace}
%       \trouble{font>ligatures}
%       \trouble{ligatures}
%       \XeLaTeX\ or \LuaLaTeX\ and \pkg{fontspec} along with
%       traditional font packages such as \pkg{txfonts}, \pkg{newtxtext}, etc.
%       This is required to turn off the monospaced font's ligatures
%       with \pkg{fontspec} after loading the traditional font packages.
%       Monospaced output ligatures must be turned off
%       to produce the correct \HTML\ characters.
% \item \ldots{} the rest of the preamble and the main document.
% \end{enumerate}
%
% In some cases, an external program may require a \UTF-8 ``locale''.
% \watchout[UTF-8 locale]
% See \cref{sec:utf8locale}.
%
%
% \subsubsection{Indexes, glossaries, and encoding}
% \gindex{UTF-8>index}
% \gindex{index>UTF-8}
%
% \pkg{lwarp} uses the \prog{xindy} program to processes indexes.
% \prog{xelatex} and \prog{lualatex} use \prog{xindy} and
% \prog{pdflatex} uses \prog{texindy}.
%
% The \pkg{lwarp} option \optn{xindyLanguage} may be used to set the language option
% for \pkg{xindy}, and the \optn{xindyCodepage} option may be used to set the codepage
% option for \pkg{xindy}.  These are used for
% ^^A both
% index
% ^^A and glossary
% generation.
%
%
% \clearpage
%
% \subsection{\pkg{lwarp} package loading and options}
% \label{sec:loading}
% \gindex{settings>lwarp=\pkg{lwarp} package options}
% 
% \begin{table}
% \caption{\pkg{lwarp} package options\label{tab:options}}
% \centering
% \renewcommand{\arraystretch}{1.2}
% \begin{tabular}{>{\ttfamily}lp{3.25in}}
% Option & Description \\ \midrule
% mathsvg & Show math using \SVG\ images. \\
% mathjax & Show math using \brand{MathJax}. \\
% latexmk & Use \prog{latexmk} for compiling documents. \\
% dvips & Use \prog{dvips} and \prog{ps2pdf} to convert \DVI\ documents. \\
% dvipdfm & Use \prog{dvipdfm} to convert \DVI\ documents. \\
% dvipdfmx & Use \prog{dvipdfmx} to convert \DVI\ documents. \\
% HomeHTMLFilename & The filename of the home page. \\
% HTMLFilename & A prefix for the filenames of the remaining web pages. \\
% PrintLatexCmd & The shell commands for \cmds{lwarpmk print}. \\
% HTMLLatexCmd & The shell commands for \cmds{lwarpmk html}. \\
% \midrule
% \multicolumn{2}{l}{\small For indexing (\cref{sec:indexsetup}) and glossaries (\cref{sec:glossaries}):} \\
% makeindex & Use \prog{makeindex} to generate indices. \\
% xindy & Use \prog{xindy} to generate indices. \\
% makeindexStyle & Set a custom style for \prog{makeindex}. \\
% xindyStyle & Set a custom style for \prog{xindy}. \\
% xindyLanguage & The \prog{xindy} language option used for index
% ^^A and glossary
% generation. \\
% xindyCodepage & The \prog{xindy} codepage option used for index
% ^^A and glossary
% generation. \\
% PrintIndexCmd & Shell commands executed by \cmds{lwarpmk printindex}. \\
% HTMLIndexCmd & Shell commands executed by \cmds{lwarpmk htmlindex}. \\
% LatexmkIndexCmd & Shell commands executed by \prog{latexmk}. \\
% GlossaryCmd & Shell command executed by \cmds{lwarpmk printglossary} and \cmds{lwarpmk htmlglossary}. \\
% \midrule
% \multicolumn{2}{l}{\small Seldom necessary:} \\
% OSWindows & Force compatibility with \brand{MS-Windows}. \\
% pdftotextEnc & Set the encoding for \prog{pdftotext}. \\
% lwarpmk & Generate a local copy of \filenm{lwarpmk.lua}. \\
% \midrule
% \multicolumn{2}{l}{\small Used internally by \pkg{lwarp}:} \\
% warpprint & Generate print output, and also generate configuration files. \\
% warpHTML & Generate \HTML\ output. \\
% BaseJobname & The \cs{jobname} to use.
%   Set to the \cs{jobname} of the printed version even while generating \HTML. \\
% \bottomrule
% \end{tabular}
% \end{table}
%
%
% \pkg{lwarp} supports \pkg{book}, \pkg{report}, and \pkg{article} classes,
% as well as the equivalent Koma-script classes and \pkg{memoir}.
%
% Load the \pkg{lwarp} package immediately after the font and UTF-8 setup commands.
%
% Package options may be set while loading \pkg{lwarp}, or later with
% \begin{sourcedisplay}
% \cs{lwarpsetup}\{\meta{key=value, \dots}\}
% \end{sourcedisplay}
%
% \changes{v0.16}{2016/04/08}{Docs: Moved location of \cs{usepackage\{lwarp\}}.}
% \changes{v0.19}{2016/05/25}{Docs: Math options.}
% \DescribePackage{lwarp}
% \gindex{lwarp=\pkg{lwarp}>loading}
% \gindex{lwarp=\pkg{lwarp}>options}
% \pkg{lwarp} package options are as follows:
%
% \begin{description}
%
% \item[\optn{mathsvg}, \optn{mathjax}:]
% \DescribeOption{mathsvg}
% \DescribeOption{mathjax}
% ^^A \DescribeOption{mathKaTeX}
% ^^A For math display, select \optn{mathsvg} (default), \optn{mathjax},
% ^^A or \optn{mathKaTeX}.
% For math display, select \optn{mathsvg} (default) or \optn{mathjax}.
% For more information about the math options, see \cref{sec:limitsmath}.
%
% 
% \item[\optn{latexmk}:]
% \DescribeOption{latexmk}
% \DescribeDefault{false} Tells \prog{lwarpmk} to use \prog{latexmk} to recompile the
%   document several times if necessary.
%   Otherwise, \prog{lwarpmk} attempts to determing for itself whether to recompile.
%   See \cref{sec:htmlsettings}.
%
% \item[\optn{dvips}:]
% \DescribeOption{dvips}
% \DescribeDefault{false} Tells \prog{lwarpmk} to use \prog{dvips} and \prog{ps2pdf} to convert
%   \DVI\ output to \PDF.
%
% \item[\optn{dvipdfm}:]
% \DescribeOption{dvipdfm}
% \DescribeDefault{false} Tells \prog{lwarpmk} to use \prog{dvipdfm} to convert
%   \DVI\ output to \PDF.
%
% \item[\optn{dvipdfmx}:]
% \DescribeOption{dvipdfmx}
% \DescribeDefault{false} Tells \prog{lwarpmk} to use \prog{dvipdfmx} to convert
%   \DVI\ output to \PDF.
%
%
% \item[\optn{HomeHTMLFilename}:]
% \DescribeOption{HomeHTMLFilename}
% \DescribeDefault{\{\}}
% See \cref{sec:htmlsettings}.
%
%
% \item[\optn{HTMLFilename}:]
% \DescribeOption{HTMLFilename}
% \DescribeDefault{\{\}}
% See \cref{sec:htmlsettings}.
%
%
% \item[\optn{PrintLatexCmd}:]
% \DescribeOption{PrintLatexCmd}
% \DescribeDefault{<automatic>} Sets the shell commands executed by \cmds{lwarpmk print}.
%   If not specified, will automatically be set according to the detected \LaTeX\ engine
%   and the use of \optn{-\/-shell-escape}.
%
%
% \item[\optn{HTMLLatexCmd}:]
% \DescribeOption{HTMLLatexCmd}
% \DescribeDefault{<automatic>} Sets the shell commands executed by \cmds{lwarpmk html}.
%   If not specified, will automatically be set according to the detected \LaTeX\ engine
%   and the use of \optn{-\/-shell-escape}.
%
%
% \item[\optn{makeindex}:]
% \DescribeOption{makeindex}
% \DescribeDefault{makeindex} Sets \optn{PrintIndexCmd}, \optn{HTMLIndexCmd},
%   and \optn{LatexmkImageCmd}
%   to use \prog{makeindex} when generating indexes with
%   \cmds{lwarpmk printindex}, \cmds{lwarpmk htmlindex}, or \prog{latexmk}.
%   If neither \optn{makeindex} nor \optn{xindy} is used, \optn{makeindex} is assumed.
%
%
% \item[\optn{xindy}:]
% \DescribeOption{xindy}
% \DescribeDefault{makeindex} Sets \optn{PrintIndexCmd}, \optn{HTMLIndexCmd},
%   and \optn{LatexmkImageCmd}
%   to use \prog{xindy} when generating indexes with
%   \cmds{lwarpmk printindex}, \cmds{lwarpmk htmlindex}, or \prog{latexmk}.
%
%
% \item[\optn{makeindexStyle}:]
% \DescribeOption{makeindexStyle}
% \DescribeDefault{lwarp.ist}
%   If you wish to use a custom |.ist| file for
%   index generation, see \cref{sec:handlingpackageoptions}.
%
%
% \item[\optn{xindyStyle}:]
% \DescribeOption{xindyStyle}
% \DescribeDefault{lwarp.xdy}
%   If you wish to use a custom |.xdy| file for
%   index generation, see \cref{sec:handlingpackageoptions}.
%
%
% \item[\optn{xindyLanguage}:]
% \DescribeOption{xindyLanguage}
% \DescribeDefault{english} If using an index or glossary,
%   see \cref{sec:handlingpackageoptions}.
%
%
% \item[\optn{xindyCodepage}:]
% \DescribeOption{xindyCodepage}
% \DescribeDefault{utf8} If using an index,
% ^^A or glossary,
%   see \cref{sec:handlingpackageoptions}.
%
%
% \item[\optn{PrintIndexCmd}:]
% \DescribeOption{PrintIndexCmd}
% \DescribeDefault{<automatic>} Sets the shell commands executed by \cmds{lwarpmk printindex}.
%   If not specified, will be set by the selection of \optn{makeindex} or
%   \optn{xindy}.  May be used to specify the creation of multiple indexes.
%   See \cref{sec:indexsetup}.
%
% \needspace{2\baselineskip}
% Examples:
% \begin{sourcedisplay}
% \small
% makeindex  -s lwarp.ist  projectname.idx \hfill (\prog{makeindex}) \\
% xindy  -M lwarp.xdy  -L english  -C utf8 projectname.idx \hfill (\prog{xindy})
% \end{sourcedisplay}
%
% The use of the \optn{makeindex} or \optn{xindy} options sets \optn{PrintIndexCmd}
% \margintag{automatic setting}
% to sensible values for each of those programs while compiling a single index.
% \pkg{lwarp}'s \optn{makeindexStyle}, \optn{xindyStyle},
% \optn{xindyLanuage}, and \optn{xindyCodepage} options will be used if specified.
%
% If specifying \optn{PrintIndexCmd} manually,
% \trouble{PrintIndexCmd}
% \trouble[xindy]{xindy=\pkg{xindy}>options>PrintIndexCmd=\optn{PrintIndexCmd}}
% be sure to assign an \prog{xindy}
% language and codepage with the |-L| and |-C| \prog{xindy} options, as the
% \pkg{lwarp} \optn{xindyLanguage} and \optn{xindyCodepage} options are not
% used for the \optn{PrintIndexCmd} option when it is set manually.
%
% This option is stored in the configuration files \filenm{lwarpmk.conf}
% and \filenm{*.lwarpmkconf}, and is then passed by the \cmds{lwarpmk printindex}
% command to the operating system to compile the print indexes.
% Since the command string is parsed by \TeX, written to a file,
% read from the file by Lua\TeX, and finally passed to the operating system,
% any attempt at quoting will be problematic.  For complicated commands,
% it would be best to create a shell script, and simply refer to the script
% with the \pkg{lwarp} \optn{PrintIndexCmd} option.
%
%
% \item[\optn{HTMLIndexCmd}:]
% \DescribeOption{HTMLIndexCmd}
% \DescribeDefault{<automatic>} Sets the shell commands executed by \cmds{lwarpmk htmlindex}.
%   If not specified, will be set by the selection of \optn{makeindex} or
%   \optn{xindy}.  May be used to specify the creation of multiple indexes.
%   See \cref{sec:indexsetup}.
%
% \needspace{2\baselineskip}
% Example settings are similar to \optn{PrintIndexCmd},
% \trouble[filenames]{HTMLIndexCmd>filenames}
% but append |_html| to the filenames:
% \begin{sourcedisplay}
% \small
% makeindex  -s lwarp.ist  projectname\textred{\_html}.idx \hfill (\prog{makeindex}) \\
% xindy  -M lwarp.xdy  -L english  -C utf8  projectname\textred{\_html}.idx \hfill (\prog{xindy})
% \end{sourcedisplay}
%
% The use of the \optn{makeindex} or \optn{xindy} options sets \optn{HTMLIndexCmd}
% \margintag{automatic setting}
% to sensible values for each of those programs while compiling a single index.
% \pkg{lwarp}'s \optn{makeindexStyle}, \optn{xindyStyle},
% \optn{xindyLanuage}, and \optn{xindyCodepage} options will be used if specified.
%
% If specifying \optn{HTMLIndexCmd} manually,
% \trouble[xindy]{xindy=\pkg{xindy}>options>HTMLIndexCmd=\optn{HTMLIndexCmd}}
% be sure to assign an \prog{xindy}
% language and codepage with the |-L| and |-C| \prog{xindy} options, as the
% \pkg{lwarp} \optn{xindyLanguage} and \optn{xindyCodepage} options are not
% used for the \optn{HTMLIndexCmd} option when it is set manually.
%
% As with \optn{PrintIndexCmd}, to generate complicated indexes it may be
% worthwhile to use a shell script, then refer to that script with \optn{HTMLIndexCmd}.
%
%
% \item[\optn{LatexmkIndexCmd}:]
% \DescribeOption{LatexmkIndexCmd}
% \DescribeDefault{<automatic>} Sets the shell commands executed by \prog{latexmk}.
%   Unlike \optn{PrintIndexCmd} and \optn{HTMLIndexCmd}, \optn{LatexmkIndexCmd}
%   does not include any filenames, which will be provided instead by \prog{latexmk}.
%   See \cref{sec:indexsetup}.
%
% \needspace{2\baselineskip}
% Example settings are similar to \optn{PrintIndexCmd}, but without a filename:
% \begin{sourcedisplay}
% \small
% makeindex  -s lwarp.ist \hfill (\prog{makeindex}) \\
% xindy  -M lwarp.xdy  -L english  -C utf8 \hfill (\prog{xindy})
% \end{sourcedisplay}
%
% The use of the \optn{makeindex} or \optn{xindy} options sets \optn{LatexmkIndexCmd}
% \margintag{automatic setting}
% to either of the two settings show above.
% \pkg{lwarp}'s \optn{makeindexStyle}, \optn{xindyStyle},
% \optn{xindyLanuage}, and \optn{xindyCodepage} options will be used if specified.
% Unlike \optn{PrintIndexCmd} and \optn{HTMLIndexCmd},
% \prog{latexmk} uses either of the single-line settings of \optn{LatexmkIndexCmd}
% shown above to compile each of multiple indexes if necessary.
%
% If specifying \optn{LatexmkIndexCmd} manually,
% \trouble[xindy]{xindy=\pkg{xindy}>options>LatexmkIndexCmd=\optn{LatexmkIndexCmd}}
% be sure to assign an \prog{xindy}
% language and codepage with the |-L| and |-C| \prog{xindy} options, as the
% \pkg{lwarp} \optn{xindyLanguage} and \optn{xindyCodepage} options are not
% used for the \optn{LatexmkIndexCmd} option when it is set manually.
%
%
% \item[\optn{GlossaryCmd}:]
% \DescribeOption{GlossaryCmd}
% \DescribeDefault{\cmds{makeglossaries}} Sets the shell command
%   executed by \cmds{lwarpmk printglossary} and \cmds{lwarpmk htmlglossary}.
%   The print or \HTML\ glossary filename is appended to this command.
%   See \cref{sec:glossaries}.
%
%
% \item[\optn{OSWindows}:]
% \DescribeOption{OSWindows} \pkg{lwarp} attempts to automatically sense \brand{Windows},
%   but it may be forced with this option.
%   See \cref{sec:OSportabilityusage}.
%
%
% \item[\optn{pdftotextEnc}:]
% \DescribeOption{pdftotextEnc}
% \DescribeDefault{UTF-8} Used to specify
%   the encoding used by \prog{pdftotext} during the \PDF-\HTML\ conversion.
%   In most situations, the default is the correct choice.
%
%
% \item[\optn{lwarpmk}:]
% \DescribeOption{lwarpmk}  If you wish to have \pkg{lwarp} generate a local
%   copy of \filenm{lwarpmk.lua} for archival or local-installation purposes,
%   compile the print version with the \optn{lwarpmk} option set.
%   See \cref{sec:handlingpackageoptions}.
%
% \begin{quote}
% \hrule
% The following options are used internally by \pkg{lwarp}, and
% usually are not used in the user's document:
% \smallskip
% \hrule
% \end{quote}
%
%
% \item[\optn{warpprint} and \optn{warpHTML}:]
% \DescribeOption{warpprint}
% \DescribeOption{warpHTML}
% Usually controlled by \prog{lwarpmk}, and not set in the document.
% Select the \optn{warpprint} option to generate print output (default),
% or the \optn{warpHTML} option to generate \HTMLfive\ output.
% The default is print output, so the print version may be
% compiled with the usual \prog{pdflatex}, etc.
% When \pkg{lwarp} is loaded in print mode, it creates
% |<project>_html.tex|, which sets the \optn{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.
%
%
% \item[\optn{BaseJobname}:]
% \DescribeOption{BaseJobname}
% \DescribeDefault{\cs{jobname}} 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}.
%
% \end{description}
%
% \clearpage
%
% \subsection{Customizing the \HTML\ output}
% \label{sec:htmlsettings}
% \gindex{settings>HTML conversion}
% \gindex{HTML>conversion settings}
%
% \changes{v0.43}{2017/11/04}{Docs: \HTML\ settings table.}
% \changes{v0.43}{2017/11/06}{Docs: Reorganized \HTML\ customization.}
% \changes{v0.61}{2018/09/25}{Docs: HTMLDebugComments}
% \begin{table}[p]
% \caption{\HTML\ settings}
% \label{tab:htmlsettings}
% \begin{tabular}{>{\ttfamily}lp{3in}}
% \toprule
% Macro \Slash Cntr \Slash Bool & Description \\ \midrule
% \cs{linkhomename} & Name of the link to the homepage. \\
% \midrule
% SideTOCDepth & Sectioning depth of the side\TOC. \\
% \cs{sidetocname} & Name of the side\TOC. \\
% \midrule
% FileDepth & Sectioning depth of the file splits. \\
% CombineHigherDepths & Combine higher section levels. \\
% FileSectionNames & Use section names for file names, else use numbers. \\
% \cs{FilenameLimit} & Maximum length of the generated filenames. \\
% \midrule
% FootnoteDepth & Sectioning depth of footnotes. \\
% \midrule
% \cs{abstractname} & The name of the abstract. \\
% \cs{mathimagename} & The \SVG\ math image \env{lateximage} \attribute{alt} tag. \\
% \cs{packagediagramname} & The suffix for a package's \env{lateximage} \attribute{alt} tags. \\
% \midrule
% \cs{CSSFilename} & The \CSS\ for the following files. \\
% \midrule
% \cs{HTMLLanguage} & The \HTML\ \attribute{lang} tag. \\
% \cs{HTMLTitle} & The homepage's \element{title}, overriding \cs{title}. \\
% \cs{HTMLTitleBeforeSection} & Set subpage \element{title}s to \newline
%   \fqquad \attribute{\cs{HTMLTitle} - sectionname} \\
% \cs{HTMLTitleAfterSection} & Set subpage \element{title}s to \newline
%   \fqquad \attribute{sectioname - \cs{HTMLTitle}}\\
% \cs{HTMLAuthor} & The \HTML\ \attribute{author} meta tag, overriding \cs{author}. \\
% \cs{HTMLDescription} & The \HTML\ \attribute{description} meta tag. \\
% \midrule
% \cs{HTMLFirstPageTop} & Heading for the home page. \\
% \cs{HTMLPageTop} & Heading for the other pages. \\
% \cs{HTMLPageBottom} & Footing for all pages. \\
% \midrule
% HTMLDebugComments & Boolean to generate \HTML\ comments. \\
% \bottomrule
% \end{tabular}
% \end{table}
%
% \Cref{tab:htmlsettings} shows 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!]
% \trouble{HTML>settings>changed}
% 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 \prog{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 ``\filenm{.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}
%   \optn{HomeHTMLFilename} and \optn{HTMLFilename} options, but may need to be escaped
%   elsewhere, such as when appearing in a list:
%   \gindex{underscore>filename}\gindex{filename>underscore in}
%   \changes{v0.24}{2017/03/13}{Docs: Filename underscore.}
%   \begin{sourcedisplay}
%        \cs{item} [\cs{href}\{file\textred{\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 \prog{latexmk} to
%   compile the document.  This setting is written to \prog{lwarpmk}'s configuration
%   files.
%
% \ItemDescribeOption{mathsvg} \DescribeDefault{true}
%   Selects \SVG\ display for math output.  (The default.)
%
% \ItemDescribeOption{mathjax} \DescribeDefault{false}
%   Selects \brand{MathJax} for math output.
%
% ^^A \ItemDescribeOption{mathKaTeX} \DescribeDefault{false}
% ^^A  Selects Ka\TeX\ for math output.
%
% \ItemDescribeOption{makeindex} \DescribeDefault{makeindex}
%   Selects \prog{makeindex} for index generation by \prog{lwarpmk}.
%
% \ItemDescribeOption{xindy} \DescribeDefault{makeindex}
%   Selects \prog{xindy} for index generation by \prog{lwarpmk}.
%
%   \end{description} \bigskip
%
% \item[Placed in the preamble before \texttt{\cs{begin}\{document\}}:] \
%
%   \begin{description}
%
% \ItemDescribeMacro{\linkhomename} \DescribeDefault{Home}
%   Name of the link to the home page.  Paragraphs are allowed.
% \changes{v0.63}{2018/11/29}{Docs: \cs{linkhomename}.}
%
% \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 \UI{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|,
%       \trouble[inaccessible pages]%
%           {HTML>missing pages>Side=\optn{SideTOCDepth} and \optn{FileDepth}}
%       web pages will be inaccessible via the side\TOC.
%       \trouble{file>inaccessible}
%       \trouble{page>inacessible}
%       \trouble{HTML>inaccessible pages}
%       \trouble{sectioning>missing}
%
% \ItemDescribeMacro{\sidetocname} \DescribeDefault{Contents}
%   Name of the side\TOC.  Paragraphs are allowed.
% \changes{v0.63}{2018/11/29}{Docs: \cs{sidetocname}.}
%
% \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}
%       \trouble{file>inaccessible}
%       \trouble{page>inacessible}
%       \trouble{HTML>inaccessible pages}
%       \trouble{sectioning>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
%   \trouble[Inaccesible pages!]%
%       {HTML>missing pages>Side=\optn{SideTOCDepth} and \optn{tocdepth}}
%   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,
%   \trouble[Lost in an old page!]{HTML>page did not update}
%   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 \optn{HTMLFilename} option is used as a prefix.
%   See \cref{sec:filenameexamples} for examples of naming and numbering \HTML\ files.
%   The user must ensure that filenames are unique after begin sanitized.
%   \trouble[Unique filename!]{HTML>missing pages>filename not unique}
%   For example, math in the section name is removed before creating the filename,
%   so the rest of the filename must be sufficiently unique to avoid name collisions.
%   \gindex{filename>unique}
%
% \ItemDescribeMacro{\FilenameLimit} \DescribeDefault{80}
%   \gindex{filename>length}
%   The maximum length of the filenames generated by \pkg{lwarp}.
%   ``\filenm{.html}'' is added to this length.
%   Redefine with \cs{newcommand}.
%
% \ItemDescribeCounter{FootnoteDepth} \DescribeDefault{3}
%   Determines where to place pending footnotes.
%   |3| places footnotes before each break down to the \cs{subsubsection} 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.
%
% \ItemDescribeBoolean{HTMLDebugComments} \DescribeDefault{false}
%   Set |true| to generate \HTML\ comments, such as which section or \element{div}
%   is being opened or closed.
%
% \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\ \attribute{lang} meta tag.
%   Defaults to \attribute{en-US}.
%
% \ItemDescribeMacro{\HTMLTitle}  \marg{title} \DescribeDefault{\cs{thetitle}} \quad
% \gindex{HTML>meta tag>title}
%   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{\HTMLTitleBeforeSection} \DescribeDefault{\cs{HTMLTitleBeforeSection}}
%   Sets subpage \element{title} tags to show the website title followed
%   by the section name.
%
% \ItemDescribeMacro{\HTMLTitleAfterSection}
%   Sets subpage \element{title} tags to show the section name
%   followed by the website title.
%
% To customize subpage \element{title}s, redefine \cs{theHTMLTitleSection},
% \margintag{custom \element{title}}
% which defaults to:
% \gindex{HTML>meta tag>title}
% \begin{sourcedisplay}
% \cs{def}\cs{theHTMLTitleSection}\{\% \\
%    \fquad\cs{theHTMLTitle}\cs{theHTMLTitleSeparator}\cs{theHTMLSection}\% \\
% \}
% \end{sourcedisplay}
%
%
% \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.
%   \cs{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.
%   \cs{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,
% \trouble[TOC on the homepage!]{Table of Contents>missing}
% \trouble{HTML>inaccessible pages}
% 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}
%
% \ItemDescribeMacro{\mathimagename}  \DescribeDefault{math image}
% \label{sec:mathimagename}
%   \describemathimagename
%
% \ItemDescribeMacro{\packagediagramname}  \DescribeDefault{diagram}
% \label{sec:packagediagramname}
%   \describepackagediagramname
%
% \ItemDescribeEnv{warpprint} An environment which is only used
%   while generating print output.  Place inside 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.
%
%   \emph{Do not place anything else on the same line as \texttt{\cs{end}\{warpprint\}}}.
%   \watchout
%
% \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.
%
%   \emph{Do not place anything else on the same line as \texttt{\cs{end}\{warpHTML\}}}.
%   \watchout
%
% \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}
% \gindex{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]
%       ...
%       \CSSFilename{myCSS.css}
%       \chapter{Another Chapter}
%       ...
%   \end{Verbatim}
% \gindex{CSS>file selection}
% \gindex{CSS>per \HTML\ page}
% \gindex{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
% \trouble[Rename it!]{sample=\filenm{sample_projects.css}>overwritten}
% 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:
%   \gindex{CSS>project-specific changes}\gindex{CSS>lwarp.css=\filenm{lwarp.css}}
%   \gindex{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}
% \gindex{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}
% Do \emph{not} place anything else on the same line as |\end{warpHTML}|.
% \trouble[\texttt{\cs{end}\{warpHTML\}}]{warpHTML}
% The exact phrase is used to mark the end of the environment.
%
% \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}
% As above, do not place anything else on the line with |\end{warpprint}|.
% \trouble[\texttt{\cs{end}\{warpprint\}}]{warpprint}
%
% \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}
% As above, do not place anything else on the line with |\end{warpall}|.
%
%
% 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.
% \item Anything changing the |page| counter.  \pkg{lwarp} requires that the
% |page| counter not be adjusted during \HTML\ output.
% \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}
% \gindex{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 \cs{maketitle}.
% To use a \cs{subtitle} or \cs{published} field, see \cref{sec:publishedsubtitle}.
%
%
% \DescribeMacro{\maketitle}
% Use \cs{maketitle} just after the |\begin{document}|, as this will establish
% the title of the homepage.  Optionally, use a \env{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 \cs{title}; these will interfere with the
% file break and \CSS\ detection.
% \trouble[newlines]{title>newlines}
% \trouble{HTML>corrupted}
% Use a \cs{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 \cs{author}, \cs{protect} may be needed before some formatting commands.
% \trouble{author>formatting}
% 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}
%
% \cs{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}
% \gindex{HTML>meta tag>description}
% \gindex{description>HTML meta tag}
% \gindex{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:
% \begin{sourcedisplay}
% \fqquad \cs{HTMLDescription}\{\}
% \end{sourcedisplay}
%
%
% \subsection{\HTML\ homepage meta title}
%
% \gindex{HTML>meta tag>title}
% \gindex{title>HTML meta tag}
% \gindex{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.
%
% See \cref{sec:htmlsettings} for \cs{HTMLTitleBeforeSection} and
% \cs{HTMLTitleAfterSection}, used to set the title for \HTML\ subpages.
%
%
% \subsection{\HTML\ page meta author}
%
% \gindex{HTML>meta tag>author}
% \gindex{author>HTML meta tag}
% \gindex{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.
%
%
%
% \section{Special cases and limitations}
% \label{sec:limitations}
%
% \label{sec:successfulcommands}
% \gindex{HTML>conversion suggestions}
%
% \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.}
%
% Some commonly-used \LaTeX{} expressions should be modified as follows to allow
% for a smooth conversion to both \HTML\ and print-formatted outputs.
%
% \needhelp
%
% \subsection{Things to avoid}
% \label{sec:thingstoavoid}
% \changes{v0.51}{2018/03/04}{Docs: Things to avoid.}
%
% In the document, avoid the following:
%
% \begin{description}
%   \item [\texttt{page} counter:] Do not adjust the \texttt{page} counter.
%       If doing so is required for the print version, place the
%       adjustment inside a \env{warpprint} environment.
%   \item [Custom math environment macros:] Do not use expressions such as
%       \cs{beq} as a replacement for \texttt{\cs{begin}\{equation\}}.
%   \item [Custom macros in section, figure, table names:] Custom macros which appear in
%       sectioning commands or float captions then appear in the
%       \filenm{.toc}, \filenm{.lof}, and \filenm{.lot} lists, and should be made robust
%       using \cs{newrobustcmd} or \cs{robustify} from \pkg{etoolbox}, \pkg{xparse}, etc.
%
%       \changes{v0.54}{2018/04/21}{Docs: Macros in sectioning names.}
%       When setting |FileSectionNames| to |true| to name the \HTML\ files from the
%       section names, the file names are created from sanitized versions of the chapter
%       or section names, but the section names must be plain text or something
%       which expands into plain text.  Robust macros will not work at the sectioning
%       level which is used for file names, but a robust macro or other complicated
%       name may be used for the manditory argument of \cs{chapter}, \cs{section}, etc.,
%       if a plain-text version is also included in the optional argument:
%       \begin{sourcedisplay}
%       \cs{chapter}[Plain Name]\{\cs{ARobustMacro\{Fancy Name\}}\}
%       \end{sourcedisplay}
% \end{description}
%
%
% \subsubsection{Invalid \HTML}
% \label{sec:invalidhtml}
%
% \trouble{HTML>invalid}
% \trouble{HTML>validation}
% Additionally, some objects are valid \LaTeX, but invalid \HTML.
% An example is a tabular inside \cs{textbf}, since \HTML\ does not allow a table
% inside a span.  \pkg{lwarp} will create the table, and the browser may support it,
% but the result is technically invalid.
%
%
%
% \subsection{Formatting}
%
% \subsubsection{Text formatting}
% \label{sec:avoidtextformatting}
% \gindex{code listings}
% \gindex{program listings}
% \gindex{listings, program code}
% \gindex{HTML>entities, conversion}
% \gindex{HTML>verbatim, in}
% \gindex{verbatim>code and \HTML\ tags}
%
% \changes{v0.61}{2018/09/25}{Docs: \HTML\ entities.}
%
% \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}.
%
% \limitsfloatalignment
%
%
% \subsubsection{Accents}
%
% \limitsaccents
%
%
% \subsubsection{\pkg{textcomp} package}
%
% \DescribePackage{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] \|
%   \margintag{lists}
%   \trouble{list>empty item}
%
%
% \subsubsection{Filenames and \URL{}s in lists or footnotes}
%
%	\gindex{underscore>filename}\gindex{filename>underscore in}
%   \gindex{list>filename}
%	\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}
%
% \DescribePackage{relsize}
% \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}
%	\gindex{minipage>framed}
%	\gindex{framed objects}
%   \trouble{frames}
%	\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 \cref{sec:xcolorpatches} for a new environment \env{fcolorminipage}.
%		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},
%		\trouble[Misplaced alignment tab character \&]
%           {Misplaced alignment tab character \&>frames}
%		you will have to use \cs{StartDefiningTabulars}
%		before the start of the macro which uses \cs{fboxBlock} and the \env{tabular},
%		and \cs{StopDefiningTabulars} 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}
%
% \DescribePackage{fancybox}
% \limitsfancybox
%
% 
% \subsubsection{\pkg{mdframed} package}
%
% \DescribePackage{mdframed}
% \limitsmdframed
%
%
% \subsection{Section names}
% \label{sec:limitssectionnames}
%
% If using named \HTML\ files, by selecting |\booltrue{FileSectionNames}|:
%
% \DescribeMacro{\FilenameSimplify}
% \gindex{filename>simplify}
% \gindex{section>file names}
% To remove common short words from the automatically-generated filenames,
% replacing each with a single hyphen ``|-|'',
% use \cs{FilenameSimplify}:
% \begin{sourceverb}
% \FilenameSimplify*{-in-}
% \FilenameSimplify*{A-}
% \end{sourceverb}
% The first example removes the word ''in'' in the middle of a filename,
% and the second example removes ``A'' at the start of the filename.
% The star forces the arguments to be detokenized, which is required for
% a plain-text comparison.
% (The unstarred form is used for a token-sensitive comparison, which is
% seldom required by the user.)
% After simplfication, repeated hyphen characters will be further simplified
% to a single hyphen ``|-|''.
% Finally, single hyphens at the start or end of the filename are removed.
%
% \DescribeMacro{\FilenameNullify}
% Macro names may appear in the automatically-generated file names.
% \trouble[macros in section names]{sectioning>macro in name}
% \trouble{filename>corrupted}
% \trouble{filename>macro in name}
% To remove these, create \emph{non-robust} nullified versions
% of the macros,
% ensuring that each line ends with a percent character |%| as shown below.
% These are placed inside \cs{FilenameNullify}, which adds them to the
% list of macros which are nullfiied during filename generation.
% Low-level macros such as \cs{begingroup} will cause problems when
% nullfied.  Many macros such as \cs{textbf} are already nullfied.
% \pkg{lwarp} also already nullifies built-in symbol and \pkg{textcomp} macros,
% including if defined by \pkg{xunicode}, but not all \pkg{xunicode} macros.
% See the definition of \cs{LWR@nullfonts} for a complete list.
% \begin{sourcedisplay}
% \cs{FilenameNullify}\{\textred{\%}\\
%   \fquad\cs{renewcommand*}\{\cs{macroname}\}[1]\{\#1\}\textred{\%}\\
%   \fquad\cs{renewcommand*}\{\cs{anothermacro}\}\{\}\textred{\%}\\
% \}
% \end{sourcedisplay}
%
% Avoid duplicate file names.
% \trouble[duplicate filename]{filename>duplicate}
% \trouble{duplcate filename}
% \trouble{sectioning>duplicate name}
% Section names at levels which result in \HTML\ file splits must
% be unique.  \pkg{lwarp} will generate an error if a duplicate
% \HTML\ filename is generated.
% Use the optional \TOC\ caption entry parameter for formatting.
% Remember to \cs{protect} \LaTeX\ commands which appear in
% section names and \TOC\ captions.
%
% \limitsmathinsectionnames
%
%
% \subsection{Cross-references}
%
% \limitsreferences
%
% \subsubsection{Page references} The printed page does not translate
% to the \HTML\
% \trouble[\LaTeX\ page numbers]{page counter>references}
% 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.~\textred{1.23}
%    on page (\textbf{see}
%    sec.~\textred{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.}
%
% \DescribePackage{cleveref}
% \DescribePackage{varioref}
% \limitscpageref
%
% \subsubsection{Hyperlinks, \pkg{hyperref}, and \pkg{url}}
%
% \DescribePackage{hyperref}
% \DescribePackage{url}
% \limitshyperlinks
%
%
% \subsubsection{Footnotes and page notes}
% \label{sec:limitsfootnotes}
%
% \trouble{footnote>misnumbered}
% \trouble{footnote>in sectioning command}
%
% \limitsfootnotes
%
% \trouble{footnote>verbatim}
% \trouble{verbatim>footnote}
% \trouble{footnote>in math}
% \trouble{math>footnote}
% \limitsverbatimfootnotes
%
% \limitspfnote
%
%
%
% \subsection{Front and back matter}
% \label{sec:frontbackmatter}
%
% \subsubsection{Custom classes with multiple authors and affiliations}
% \label{sec:authorsaffils}
% \changes{v0.51}{2018/03/04}{Docs: Multiple authors and affiliations.}
%
% Some classes allow multiple authors and affiliations.
% \gindex{author>multiple}\gindex{affiliation>multiple authors}
% Often it is possible to emulate these using a standard class
% along with \pkg{authblk}:
% \begin{sourcedisplay}
% \%\cs{documentclass}\{customclass\}~\% for print document \\
% \cs{documentclass}\{article\}~\% for \HTML\ document \\
% \\
% \cs{usepackage}\{lwarp\} \\
% \cs{begin}\{warpHTML\} \\
% \cs{usepackage}\{authblk\} \\
% \cs{let}\cs{affiliation}\cs{affil}~\% maybe required \\
% \cs{end}\{warpHTML\}
% \end{sourcedisplay}
%
% \subsubsection{Starred chapters and sections}
% \label{sec:forcesectionstar}
%
% \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},
% bibliographies, and the index.
% See the following sections where applicable.
% Continue here if interested in the reason for adding these commands to \pkg{lwarp}.
% \trouble{endnotes>HTML=\HTML\ page and \TOC}
% \trouble{glossaries=\pkg{glossaries}>HTML=\HTML\ page and \TOC}
% \trouble{bibliography>HTML=\HTML\ page and \TOC}
% \trouble{index>HTML=\HTML\ page and \TOC}
% \gindex{endnotes>HTML=\HTML\ page and \TOC}
% \gindex{glossaries=\pkg{glossaries}>HTML=\HTML\ page and \TOC}
% \gindex{bibliography>HTML=\HTML\ page and \TOC}
% \gindex{index>HTML=\HTML\ page and \TOC}
%
% 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 \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 \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 \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 \TOC\ entry is created, or when creating an \EPUB\ where
% the \TOC\ entry will point to the page before the starred section.
% If the starred section has its own \HTML\ page but no correct \TOC\ entry
% \trouble[inaccessible \HTML\ page]{HTML>inaccessible pages>starred section}
% \trouble{sectioning>starred section}
% 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 \TOC\ entry
% for a starred section, use \cs{ForceHTMLTOC} just before
% the \cs{chapter*} or \cs{section*},
% and place \cs{phantomsection} and \cs{addcontentsline} inside a \env{warpprint}
% environment.
%
% For print output, \cs{ForceHTMLTOC} and \cs{ForceHTMLPage} have no effect.
%
%
%
% \subsubsection{\pkg{abstract} package}
%
% \DescribePackage{abstract}
% \limitsabstract
%
%
% \subsubsection{\pkg{titling} and \pkg{authblk}}
%
% \DescribePackage{titling}
% \DescribePackage{authblk}
% \limitstitlepage
%
%
% \subsubsection{\pkg{tocloft} package}
%
% \DescribeOption[tocloft]{titles}
% \DescribePackage{tocloft}
% \limitstocloft
%
%
% \subsubsection{\pkg{appendix} package}
%
% \DescribePackage{appendix}
% \limitsappendix
%
%
% \subsubsection{\pkg{pagenote} package}
%
% \DescribePackage{pagenote}
% \limitspagenote
%
%
% \subsubsection{\pkg{endnotes} package}
%
% \DescribePackage{endnotes}
% \limitsendnotes
%
%
% \subsubsection{\brand{BibTeX}}
% \label{sec:limitsbibtex}
% \DescribeMacro{\etalchar} Displays a superscript ``+'' to indicate ``and others''.
% \changes{v0.54}{2018/03/09}{Docs: BibTeX.}
%
% \limitsbibtex
%
%
% \needspace{6\baselineskip}
% \subsubsection{\pkg{gloss} package}
% \label{sec:gloss}
%
% \DescribePackage{gloss}
% \gindex{gloss=\pkg{gloss}}
% \trouble[compiling]{gloss=\pkg{gloss}}
% \limitsgloss
%
% \needspace{10\baselineskip}
% \subsubsection{\pkg{glossaries} package}
% \label{sec:glossaries}
%
% \DescribePackage{glossaries}
% \gindex{glossaries=\pkg{glossaries}>options}
% \gindex{language>glossaries=\pkg{glossaries}}
% \gindex{glossaries=\pkg{glossaries}>language}
% \limitsglossaries
%
%
% \subsubsection{\pkg{nomencl} package}
% \label{sec:nomencl}
%
% \DescribePackage{nomencl}
% \gindex{nomencl=\pkg{nomencl}}
% \trouble{nomencl=\pkg{nomencl}}
% \limitsnomencl
%
%
% \subsubsection{Indexing overview}
% \label{sec:indexingoverview}
%
% There are many ways to process indexes for a \LaTeX\ document,
% including native \LaTeX\ capabilities, a number of packages and classes,
% the possible availability of shell escape and \prog{latexmk}, and the
% need to process print and \HTML\ versions.
% \pkg{lwarp} attempts to provide easy recompilation of indexes along with
% the rest of the document, but the various indexing options must be set correctly.
% Numerous examples are given below.
% Some differ in minor details, so the important parts are highlighted in red,
% and options are in green.
%
% Once set up properly, the entire document may be recompiled with
% \cmds{lwarpmk print} and \cmds{lwarpmk html}.
% In some cases, it will also be necessary to compile the indexes with
% \cmds{lwarpmk printindex} and \cmds{lwarpmk htmlindex}.
% A recompile may then be forced with \cmds{lwarpmk print1} and \cmds{lwarpmk html1}.
%
% The user may continue to process indexes manually or by shell script
% \margintag{manual processing}
% without the use of \prog{lwarpmk}, but adjustments will be required to
% process \HTML\ indexes as well.  In general, \filenm{*.idx} and \filenm{*.ind} files
% will be accompanied by \filenm{*_html.idx} and \filenm{*_html.ind} files.
%
% If using a custom indexing style file,
% \margintag{custom index style}
% see \cref{sec:modifymakeindex,sec:modifyxindy}.
%
% See \cref{sec:index} for \pkg{lwarp}'s core index and glossary code,
% \margintag{source code}
% \gindex{index>source code}
% \cref{sec:indexpkg} for \pkg{index},
% \cref{sec:splitidx} for \pkg{splitidx},
% \cref{sec:imakeidx} for \pkg{imakeidx},
% \cref{sec:tocbibind} for \pkg{tocbibind},
% and \cref{sec:memoirbackmatter} for \pkg{memoir}'s indexing patches.
%
%
% \subsubsection{Indexing with basic \LaTeX\ and \pkg{makeidx}}
% \label{sec:indexsetup}
%
% \changes{v0.38}{2017/08/24}{Docs: Index, \pkg{tocbibind}.}
% \changes{v0.58}{2018/06/14}{Docs: Index, \prog{makeindex}, \pkg{imakeidx}.}
%
% \gindex{xindy=\pkg{xindy}>and \pkg{hyperref}}
% \gindex{hyperref=\pkg{hyperref}>and \pkg{xindy}}
% \gindex{index>xindy=\pkg{xindy} and \pkg{hyperref}}
% \trouble{index>missing entries}
% \gindex{index>see, seealso, ranges}
% \gindex{index>processing}
%
% The following allow the user to process indexes automatically, or
% \margintag{\prog{lwarpmk} processing}
% using \prog{lwarpmk}'s commands:
% \userentry{lwarpmk printindex}
% \userentry{lwarpmk htmlindex}
% 
% \begin{description}
% 
% \needspace{2\baselineskip}
% \item [For a single index using \prog{makeindex}:]
%     \begin{sourcedisplay}
%     \cs{usepackage}\textred{[makeindex\textgreen{,latexmk}]}
%           \{\textblue{lwarp}\}
%     \end{sourcedisplay}
%     The usual \filenm{.idx} and \filenm{.ind} files will be used,
%     along with the new \filenm{lwarp.ist} style file.
%     When creating the \HTML\ index, ``\filenm{_html}'' is automatically appended
%     to each of the names.
%
%     \prog{lwarpmk} will use \prog{latexmk} if specified, in which case
%     \prog{latexmk} will create the index automatically.
%     Otherwise, use \userentry{lwarpmk printindex} \userentry{lwarpmk htmlindex}
%     to compile the indexes.
%
% \needspace{8\baselineskip}
% \item [For a single index using \prog{xindy}:]
%     \begin{sourcedisplay}
%     \cs{usepackage}[ \\
%       \fqquad \textred{xindy,} \\
%       \fqquad \textgreen{xindyLanguage=english,}   \hfill \textrm{<optional>} \\
%       \fqquad \textgreen{xindyCodepage=utf8,}   \hfill \textrm{<optional>} \\
%       \fqquad \textgreen{latexmk} \hfill \textrm{<optional>}\\
%     ]\{\textblue{lwarp}\}
%     \end{sourcedisplay}
%     The usual \filenm{.idx} and \filenm{.ind} files will be used,
%     along with the new \filenm{lwarp.xdy} style file.
%
%     \prog{lwarpmk} will use \prog{latexmk} if specified, in which case
%     \prog{latexmk} will create the index automatically.
%     Otherwise, use \userentry{lwarpmk printindex} \userentry{lwarpmk htmlindex}
%     to compile the indexes.
% \end{description}
%
%
% \subsubsection{Indexing with \pkg{index}}
%
% \pkg{lwarp} is told how to use \prog{makeindex} using the
% \optn{PrintIndexCmd} and \optn{HTMLIndexCmd} options.
% The file \filenm{lwarp.ist} is specified, which generates index letter heads for
% print output and also allows special \HTML\ formatting for \HTML\ output.
%
% \begin{description}
%
% \needspace{20\baselineskip}
% \item [For multiple indexes using \prog{makeindex} and \pkg{index}:] \
%
% \textgreen{
%   (Assuming that the second index has file extensions \filenm{.sist} and \filenm{.sind})
% }
% \begin{sourcedisplay}
% \cs{usepackage}[ \\
%     \fquad\textred{makeindex,} \textgreen{latexmk,} \\
%     \fquad\textred{PrintIndexCmd}=\{ \\
%         \fqquad makeindex -s lwarp.ist  <projectname>.idx \textred{;} \\
%         \fqquad makeindex -s lwarp.ist  \\
%             \fqqquad -o <projectname>\textred{.sind}  <projectname>\textred{.sidx} \\
%     \fquad\}, \\
%     \fquad\textred{HTMLIndexCmd}=\{ \\
%         \fqquad makeindex -s lwarp.ist  <projectname>\textred{\_html}.idx \textred{;} \\
%         \fqquad makeindex -s lwarp.ist  \\
%             \fqqquad -o <projectname>\textred{\_html.sind}  <projectname>\textred{\_html.sidx} \\
%     \fquad\} \\
% ]\{\textblue{lwarp}\} \\
% \cs{usepackage}\{\textblue{index}\} \\
% \dots \\
% \cs{makeindex} \\
% \cs{newindex}\{secondname\}\{\textred{sidx}\}\{\textred{sind}\}\{Second Index\}
% \end{sourcedisplay}
% \emph{For \brand{Windows}, replace the two ``;'' characters with ``\&''.}\watchout[\brand{Windows}]
%
% When creating the \HTML\ index, ``\filenm{_html}'' is automatically appended
% to the index filenames.
%
% Use \userentry{lwarpmk printindex} \userentry{lwarpmk htmlindex}
% to compile the indexes.
%
% If the \optn{latexmk} option is selected for \pkg{lwarp},
% \prog{latexmk} will compile the document but will \emph{not} compile the indexes.
% \cmds{lwarpmk printindex} and \cmds{lwarpmk htmlindex} will still be required.
% 
% \end{description}
%
%
% \subsubsection{Indexing with \pkg{splitidx}}
%
% \pkg{lwarp} is told how to use \prog{splitindex} using the
% \optn{PrintIndexCmd} and \optn{HTMLIndexCmd} options.
% The file \filenm{lwarp.ist} is specified, which generates index letter heads for
% print output and also allows special \HTML\ formatting for \HTML\ output.
%
% \limitssplitidx
%
% \begin{description}
%
% \needspace{16\baselineskip}
% \item [For multiple indexes using \prog{makeindex} and \pkg{splitidx}:]
%     \begin{sourcedisplay}
%     \cs{usepackage}[ \\
%         \fquad\textred{makeindex,} \textgreen{latexmk,} \\
%         \fquad\textred{PrintIndexCmd}=\{ \\
%             \fqquad splitindex <projectname> \textred{-\/- -s lwarp.ist} \\
%         \fquad\}, \\
%         \fquad\textred{HTMLIndexCmd}=\{ \\
%             \fqquad splitindex <projectname>\textred{\_html} \textred{-\/- -s lwarp.ist} \\
%         \fquad\} \\
%     ]\{\textblue{lwarp}\} \\
%     \cs{usepackage}\{\textblue{splitidx}\} \\
%     \dots \\
%     \cs{makeindex} \\
%     \cs{newindex}[Second Index]\{secondname\} \\
%     \end{sourcedisplay}
%     When creating the \HTML\ index, ``\filenm{_html}'' is automatically appended
%     to each of the names.
%
%     Use \userentry{lwarpmk printindex} \userentry{lwarpmk htmlindex}
%     to compile the indexes.
%
% \needspace{18\baselineskip}
% \item [For multiple indexes using \prog{xindy} and \pkg{splitidx}:]
%     \begin{sourcedisplay}
%     \cs{usepackage}[ \\
%         \fquad\textred{xindy,} \textgreen{latexmk,} \\
%         \fquad\textred{PrintIndexCmd}=\{ \\
%             \fqquad splitindex  \textred{-m xindy}  <projectname>  \textred{-\/- -M lwarp.xdy} \\
%               \fqqquad \textgreen{-L english -C utf8} \hfill{<optional>} \\
%         \fquad\}, \\
%         \fquad\textred{HTMLIndexCmd}=\{ \\
%             \fqquad splitindex  \textred{-m xindy}  <projectname>\textred{\_html}  \textred{-\/- -M lwarp.xdy} \\
%               \fqqquad \textgreen{-L english -C utf8} \hfill{<optional>} \\
%         \fquad\} \\
%     ]\{\textblue{lwarp}\} \\
%     \cs{usepackage}\{\textblue{splitidx}\} \\
%     \dots \\
%     \cs{makeindex} \\
%     \cs{newindex}[Second Index]\{secondname\} \\
%     \end{sourcedisplay}
%     When creating the \HTML\ index, ``\filenm{_html}'' is automatically appended
%     to each of the names.
%
%     Use \userentry{lwarpmk printindex} \userentry{lwarpmk htmlindex}
%     to compile the indexes.
%
% \end{description}
%
%
%
%
% \subsubsection{Indexing with \pkg{imakeidx}}
% \label{sec:indexingimakeidx}
%
% Due to the number of methods which may be used to process multiple indexes,
% the options for style file and \prog{xindy} language and codepage must be
% specified in one of several different ways.  These are described in detail later in
% this section, but are summarized here.
%
% If shell escape is used, \pkg{imakeidx} will automatically compile the indexes by itself.
% Options specifying a custom style file and \prog{xindy} language and
% codepage must be specified for each \cs{makeindex} command using its
% \optn{options=} option, which must include
% \pkg{lwarp}'s special \filenm{lwarp.ist} or \filenm{lwarp.xdy} file,
% or a file based on them.
% If using a custom indexing style file, see \cref{sec:modifymakeindex,sec:modifyxindy}.
% The \optn{splitindex} option is also available of shell escape is used,
% in which case the \pkg{splitidx} package and \prog{splitindex} program will also be used.
%
% If shell escape is not possible, \prog{latexmk} may be used to
% automatically compile the indexes.
% The style, language, and codepage options are specified with \pkg{lwarp}'s
% \optn{makeindexStyle}, \optn{xindyStyle}, \optn{xindyLanguage}, and
% \optn{xindyCodepage} options.  These are passed to \prog{latexmk} by
% \prog{lwarpmk}'s \cmds{lwarpmk} \cmds{printindex} and \cmds{lwarpmk} \cmds{htmlindex} commands.
%
% Where shell escape and \prog{latexmk} are not possible,
% \prog{lwarpmk} may be used to manually compile the indexes.
% \pkg{lwarp}'s \optn{PrintIndexCmd} and \optn{HTMLIndexCmd} options are used.
%
% \begin{description}
% \needspace{2\baselineskip}
% \item [For a single or multiple indexes using \prog{makeindex} and \pkg{imakeidx}:] \
%
% The index style \filenm{lwarp.ist} is automatically used for \HTML\ output.
% This file turns on letter headings, so it may be desirable to specify it as
% an option, in which case it will also be used for print output, which will
% help match the print and \HTML\ output.
%     \begin{sourcedisplay}
%     \cs{usepackage}\textred{[makeindex\textgreen{,latexmk}]}
%       \{\textblue{lwarp}\} \\
%     \cs{usepackage}\textred{[makeindex]}\{\textblue{imakeidx}\} \\
%     \dots \\
%     \cs{makeindex}[\textgreen{options=\{-s lwarp.ist\}}] \\
%     \cs{makeindex}[name=secondname,\textgreen{options=\{-s lwarp.ist\}}] \\
%     \end{sourcedisplay}
%     \pkg{imakeidx} will automatically compile the indexes.
%     Shell escape is not required while using \prog{makeindex}.
%     \optn{latexmk} may be specified, and if so it will be used for
%     \cmds{lwarpmk print} and \cmds{lwarpmk html}, but \prog{imakeidx} will actually
%     create the indexes.
%
% \needspace{2\baselineskip}
% \item [For a single or multiple indexes using \prog{makeindex} and \prog{splitindex} with \pkg{imakeidx}:] \
%
% The index style \filenm{lwarp.ist} is automatically used for \HTML\ output.
% This file turns on letter headings, so it may be desirable to specify it as
% an option, in which case it will also be used for print output, which will
% help match the print and \HTML\ output.
%     \begin{sourcedisplay}
%     \cs{usepackage}\textred{[makeindex\textgreen{,latexmk}]}
%       \{\textblue{lwarp}\} \\
%     \cs{usepackage}\textred{[makeindex,splitindex]}\{\textblue{imakeidx}\} \\
%     \dots \\
%     \cs{makeindex}[\textgreen{options=\{-s lwarp.ist\}}] \\
%     \cs{makeindex}[name=secondname,\textgreen{options=\{-s lwarp.ist\}}] \\
%     \end{sourcedisplay}
%     Shell escape is required while using \prog{splitindex}.
%     For the first compile, use
%       \watchout[enable shell escape]
%     \userentry{pdflatex \textred{-\/-shell-escape} projectname.tex}
%     \userentry{pdflatex \textred{-\/-enable-write18} projectname.tex \quad \textrm{(MiKTeX)}}
%     or similar with \prog{xelatex} or \prog{lualatex}.
%     \pkg{lwarp} will remember that shell escape was used.
%
%     \prog{imakeidx} will automatically execute \prog{splitindex},
%       and will also use \prog{makeindex} to compile the indexes.
%
%     \optn{latexmk} may be specified, and if so it will be used for
%     \cmds{lwarpmk print} and \cmds{lwarpmk html}, but \prog{imakeidx} will actually
%     create the indexes.
%
% \needspace{2\baselineskip}
% \item [For multiple indexes using \prog{xindy} and \pkg{imakeidx}, using shell escape:] \
%
% Options may be given to \pkg{imakeidx}'s \cs{makeindex} command.
% The style file \filenm{lwarp.xdy} is automatically used for \HTML\ output,
% and is not necessary for print output since the output will be similar.
% If language or codepage must be set, they should be specified as
% options for \cs{makeindex}, since \pkg{imakeidx} will process the indexes.
%     \begin{sourcedisplay}
%     \cs{usepackage}\textred{[xindy\textgreen{,latexmk}]}
%       \{\textblue{lwarp}\} \\
%     \cs{usepackage}\textred{[xindy\textgreen{,splitindex}]}\{\textblue{imakeidx}\} \\
%     \dots \\
%     \cs{makeindex}[ \\
%       \fquad \textgreen{options=\{ -M lwarp.xdy \textgreen{-L english -c utf8} \}} \\
%     ] \\
%     \cs{makeindex}[ \\
%       \fquad name=secondname, \\
%       \fquad \textgreen{options=\{ -M lwarp.xdy \textgreen{-L english -c utf8} \}} \\
%     ] \\
%     \end{sourcedisplay}
%     For the first compile, use
%       \watchout[enable shell escape]
%     \userentry{pdflatex \textred{-\/-shell-escape} projectname.tex}
%     \userentry{pdflatex \textred{-\/-enable-write18} projectname.tex \quad \textrm{(MiKTeX)}}
%     or similar with \prog{xelatex} or \prog{lualatex}.
%     \pkg{lwarp} will remember that shell escape was used.
%
%     \prog{imakeidx} will automatically execute \prog{splitindex} if selected,
%       and will also use \prog{xindy} to compile the indexes.
%
%     If selected, \prog{latexmk} will automatically recompile the entire document
%       as necessary.
%
% \needspace{14\baselineskip}
% \item [For indexes using \prog{xindy} and \prog{imakeidx}, without shell escape,
%   but \emph{with} \prog{latexmk}:] \
%
% \pkg{lwarp}'s options are used, and are passed to \prog{latexmk}.
%
%   \begin{sourcedisplay}
%     \cs{usepackage}[ \\
%         \fquad\textred{xindy,} \\
%         \fquad \textgreen{xindyLanguage=english,}   \hfill \textrm{<optional>} \\
%         \fquad \textgreen{xindyCodepage=utf8,}   \hfill \textrm{<optional>} \\
%         \fquad\textred{latexmk,} \\
%     ]\{\textblue{lwarp}\} \\
%     \cs{usepackage}\textred{[xindy]}\{\textblue{imakeidx}\} \\
%     \dots \\
%     \cs{makeindex} \\
%     \cs{makeindex}[name=secondname] \\
%   \end{sourcedisplay}
%   \prog{latexmk} will create the indexes automatically when
%   \cmds{lwarpmk print} and \cmds{lwarpmk html} are executed.
%
% \needspace{20\baselineskip}
% \item [For indexes using \prog{xindy} and \prog{imakeidx}, without shell escape,
%   and \emph{without} \prog{latexmk}:] \
%
%   \prog{lwarpmk} must be told how to create the indexes:
%   \begin{sourcedisplay}
%     \cs{usepackage}[ \\
%         \fquad\textred{xindy,} \\
%         \fquad\textred{PrintIndexCmd}=\{ \\
%             \fqquad xindy \textred{-M lwarp.xdy} \textgreen{-L english -C utf8} \\
%               \fqqquad <projectname>.idx \textred{;} \\
%             \fqquad xindy \textred{-M lwarp.xdy} \textgreen{-L english -C utf8} \\
%               \fqqquad secondname.idx \\
%         \fquad\}, \\
%         \fquad\textred{HTMLIndexCmd}=\{ \\
%             \fqquad xindy \textred{-M lwarp.xdy} \textgreen{-L english -C utf8} \\
%             \fqqquad <projectname>\textred{\_html}.idx \textred{;} \\
%             \fqquad xindy \textred{-M lwarp.xdy} \textgreen{-L english -C utf8} \\
%             \fqqquad secondname\textred{\_html}.idx \\
%         \fquad\} \\
%     ]\{\textblue{lwarp}\} \\
%     \cs{usepackage}\textred{[xindy]}\{\textblue{imakeidx}\} \\
%     \dots \\
%     \cs{makeindex} \\
%     \cs{makeindex}[name=secondname] \\
% \end{sourcedisplay}
% \emph{For \brand{Windows}, replace the two ``;'' characters with ``\&''.}\watchout[\brand{Windows}]
% 
% \texttt{<projectname>} is the \cs{jobname}:
% if compiling ``\filenm{name.tex}'', use the filenames \filenm{name.idx} and
% \filenm{name_html.idx}.
%
%     Use \userentry{lwarpmk printindex} \userentry{lwarpmk htmlindex}
%     to compile the indexes.
% \end{description}
%
%
% \subsubsection{Indexes with \pkg{memoir}}
%
% \begin{description}
% \needspace{7\baselineskip}
% \item [For a single index with \pkg{memoir} and \pkg{makeindex}:]
%   \begin{sourcedisplay}
%       \cs{documentclass}\{\textblue{memoir}\} \\
%       \cs{usepackage}\textred{[makeindex\textgreen{,latexmk}]}\{\textblue{lwarp}\} \\
%       \dots \\
%       \cs{makeindex}
%   \end{sourcedisplay}
%     The usual \filenm{.idx} and \filenm{.ind} files will be used,
%     along with the \filenm{lwarp.ist} style file.
%
%     \prog{lwarpmk} will use \prog{latexmk} if specified, in which case
%     \prog{latexmk} will create the index automatically.
%     Otherwise, use \userentry{lwarpmk printindex} \userentry{lwarpmk htmlindex}
%     to compile the indexes.
%
% \needspace{9\baselineskip}
% \item [For multiple indexes with \pkg{memoir} and \pkg{makeindex},
%   using \prog{latexmk}:] \
%
% \pkg{lwarp}'s options are used, and are passed to \prog{latexmk}.
%   \begin{sourcedisplay}
%       \cs{documentclass}\{\textblue{memoir}\} \\
%       \cs{usepackage}\textred{[makeindex,latexmk]}\{\textblue{lwarp}\} \\
%       \dots \\
%       \cs{makeindex} \\
%       \cs{makeindex}[secondname]
%   \end{sourcedisplay}
%     \prog{lwarpmk} will use \prog{latexmk} to create the indexes automatically
%     when the user executes \cmds{lwarpmk print} and \cmds{lwarpmk html}.
%
% \needspace{19\baselineskip}
% \item [For multiple indexes with \pkg{memoir} and \pkg{makeindex},
%   \emph{without} \pkg{latexmk}:] \
%
%   \prog{lwarpmk} must be told how to create the indexes:
%   \begin{sourcedisplay}
%     \cs{documentclass}\{\textblue{memoir}\} \\
%     \cs{usepackage}[ \\
%         \fquad\textred{makeindex,} \\
%         \fquad\textred{PrintIndexCmd}=\{ \\
%             \fqquad makeindex \textred{-s lwarp.ist} <projectname>.idx \textred{;} \\
%             \fqquad makeindex \textred{-s lwarp.ist} secondname.idx \\
%         \fquad\}, \\
%         \fquad\textred{HTMLIndexCmd}=\{ \\
%             \fqquad makeindex \textred{-s lwarp.ist} <projectname>\textred{\_html}.idx \textred{;} \\
%             \fqquad makeindex \textred{-s lwarp.ist} secondname\textred{\_html}.idx \\
%         \fquad\} \\
%     ]\{\textblue{lwarp}\} \\
%     \dots \\
%     \cs{makeindex} \\
%     \cs{makeindex}[secondname] \\
%   \end{sourcedisplay}
%   \emph{For \brand{Windows}, replace the two ``;'' characters with ``\&''.}\watchout[\brand{Windows}]
% 
%   \texttt{<projectname>} is the \cs{jobname}:
%   if compiling ``\filenm{name.tex}'', use the filenames \filenm{name.idx} and
%   \filenm{name_html.idx}.
%
%     Use \userentry{lwarpmk printindex} \userentry{lwarpmk htmlindex}
%     to compile the indexes.
%
% \needspace{13\baselineskip}
% \item [For a single index with \pkg{memoir} and \pkg{xindy}:]
%       \begin{sourcedisplay}
%       \cs{documentclass}\{\textblue{memoir}\} \\
%       \cs{usepackage}[ \\
%           \fqquad \textred{xindy,} \\
%           \fqquad \textgreen{xindyLanguage=english,}   \hfill \textrm{<optional>} \\
%           \fqquad \textgreen{xindyCodepage=utf8,}   \hfill \textrm{<optional>} \\
%           \fqquad \textgreen{latexmk} \hfill \textrm{<optional>}\\
%       ]\{\textblue{lwarp}\} \\
%       \dots \\
%       \textred{\cs{xindyindex}} \\
%       \cs{makeindex}
%       \end{sourcedisplay}
%       The usual \filenm{.idx} and \filenm{.ind} files will be used,
%       along with the \filenm{lwarp.xdy} style file.
%
%       \prog{lwarpmk} will use \prog{latexmk} if specified, in which case
%       \prog{latexmk} will create the index automatically.
%       Otherwise, use \userentry{lwarpmk printindex} \userentry{lwarpmk htmlindex}
%       to compile the indexes.
%
% \needspace{17\baselineskip}
% \item [For multiple indexes with \pkg{memoir} and \pkg{xindy},
%   using \pkg{latexmk}:] \
%
% \pkg{lwarp}'s options are used, and are passed to \prog{latexmk}.
%       \begin{sourcedisplay}
%       \cs{documentclass}\{\textblue{memoir}\} \\
%       \cs{usepackage}[ \\
%           \fqquad \textred{xindy,} \\
%           \fqquad \textgreen{xindyLanguage=english,}   \hfill \textrm{<optional>} \\
%           \fqquad \textgreen{xindyCodepage=utf8,}   \hfill \textrm{<optional>} \\
%           \fqquad \textred{latexmk} \\
%       ]\{\textblue{lwarp}\} \\
%       \dots \\
%       \textred{\cs{xindyindex}} \\
%       \cs{makeindex} \\
%       \cs{makeindex}[secondname] \\
%       \end{sourcedisplay}
%       \prog{lwarpmk} will use \prog{latexmk} to create the indexes automatically.
%
% \needspace{24\baselineskip}
% \item [For multiple indexes with \pkg{memoir} and \pkg{xindy},
%   \emph{without} \pkg{latexmk}:] \
%
%   \prog{lwarpmk} must be told how to create the indexes:
%   \begin{sourcedisplay}
%     \cs{documentclass}\{\textblue{memoir}\} \\
%     \cs{usepackage}[ \\
%         \fquad\textred{xindy,} \\
%         \fquad\textred{PrintIndexCmd}=\{ \\
%             \fqquad xindy \textred{-M lwarp.xdy} \textgreen{-L english -C utf8} \\
%               \fqqquad <projectname>.idx \textred{;} \\
%             \fqquad xindy \textred{-M lwarp.xdy} \textgreen{-L english -C utf8} \\
%               \fqqquad secondname.idx \\
%         \fquad\}, \\
%         \fquad\textred{HTMLIndexCmd}=\{ \\
%             \fqquad xindy \textred{-M lwarp.xdy} \textgreen{-L english -C utf8} \\
%             \fqqquad <projectname>\textred{\_html}.idx \textred{;} \\
%             \fqquad xindy \textred{-M lwarp.xdy} \textgreen{-L english -C utf8} \\
%             \fqqquad secondname\textred{\_html}.idx \\
%         \fquad\} \\
%     ]\{\textblue{lwarp}\} \\
%     \dots \\
%     \textred{\cs{xindyindex}} \\
%     \cs{makeindex} \\
%     \cs{makeindex}[secondname] \\
%   \end{sourcedisplay}
%   \emph{For \brand{Windows}, replace the four ``;'' characters with ``\&''.}\watchout[\brand{Windows}]
% 
%   \texttt{<projectname>} is the \cs{jobname}:
%   if compiling ``\filenm{name.tex}'', use the filenames \filenm{name.idx} and
%   \filenm{name_html.idx}.
%
%     Use \userentry{lwarpmk printindex} \userentry{lwarpmk htmlindex}
%     to compile the indexes.
% \end{description}
%
%
% \subsubsection{Using a custom \prog{makeindex} style file}
% \label{sec:modifymakeindex}
%
% \DescribeProgram{makeindex}
% \DescribeFile{lwarp.ist}
% When using \prog{makeindex}, \prog{lwarpmk} uses the file |lwarp.ist| to process the index.
% \gindex{lwarp.ist=\filenm{lwarp.ist}>customizing}
% \gindex{makeindex>customizing}
% \gindex{index>custom \pkg{makeindex} style file}
% This file is over-written by \pkg{lwarp} whenever a print version of
% the document is processed.
%
% To use a custom \prog{makeindex} style file:
% \begin{enumerate}
% \item Copy |lwarp.ist| to a new filename such as |projectname.ist|
% \item Make changes to |projectname.ist|.
%   Keep the lines which refer to \cs{hyperindexref}.
%   These lines creates the hyperlinks for the \HTML\ index.  During print output
%   \cs{hyperindexref} becomes a null function.
% \item In the document source use the \optn{makeindexStyle} option for \pkg{lwarp}:
% \DescribeOption{makeindexStyle}
%   \begin{Verbatim}[gobble=2,tabsize=4]
%       \usepackage[
%           ... other options ...
%           \textred{makeindexStyle=projectname.ist},
%       ]{lwarp}
%   \end{Verbatim}
%   Likewise, refer to the custom style file if using \cs{PrintIndexCmd},
%   \cs{HTMLIndexCmd}, or \cs{LatexmkIndexCmd}.
% \item Recompile the print version, which causes
%   \pkg{lwarp} to rewrite the |lwarpmk.conf| configuration file.
%   This tells \prog{lwarpmk} to use the custom |projectname.ist| file
% instead of |lwarp.ist|.
% \end{enumerate}
%
%
% \subsubsection{Using a custom \prog{xindy} style file}
% \label{sec:modifyxindy}
%
% \DescribeProgram{xindy}
% \DescribeFile{lwarp.xdy}
% When using \prog{xindy}, \prog{lwarpmk} uses the file |lwarp.xdy| to process the index.
% \gindex{lwarp.xdy=\filenm{lwarp.xdy}>customizing}
% \gindex{xindy=\pkg{xindy}>customizing}
% \gindex{index>custom \pkg{xindy} style file}
% This file is over-written by \pkg{lwarp} whenever a print version of
% the document is processed.
%
% To use a custom \prog{xindy} style file:
% \begin{enumerate}
% \item Copy |lwarp.xdy| to a new filename such as |projectname.xdy|
% \item Make changes to |projectname.xdy|.
%
%   Keep the lines which refer to \cs{hyperindexref}:
%   \begin{Verbatim}[gobble=2,tabsize=4]
%   (define-attributes (("hyperindexref")))
%   (markup-locref :open "\hyperindexref{" :close "}")
%   ...
%   (markup-locref :open "\textit{\hyperindexref{" :close "}}" :attr "textit")
%   \end{Verbatim}
%   These lines create the hyperlinks for the \HTML\ index.  During print output
%   \cs{hyperindexref} becomes a null function.
%
%   To create custom styles, refer to the lines for \cs{textbf} and \cs{textit}.
% \item In the document source use the \optn{xindyStyle} option for \pkg{lwarp}:
% \DescribeOption{xindyStyle}
%   \begin{Verbatim}[gobble=2,tabsize=4]
%       \usepackage[
%           ... other options ...
%           \textred{xindyStyle=projectname.xdy},
%       ]{lwarp}
%   \end{Verbatim}
%   Likewise, refer to the custom style file if using \cs{PrintIndexCmd},
%   \cs{HTMLIndexCmd}, or \cs{LatexmkIndexCmd}.
% \item Recompile the print version, which causes
%   \pkg{lwarp} to rewrite the |lwarpmk.conf| configuration file.
%   This tells \prog{lwarpmk} to use the custom |projectname.xdy| file instead of |lwarp.xdy|.
% \end{enumerate}
% 
% 
% \subsubsection{Additional indexing limitations}
% \prog{xindy} and \pkg{hyperref} may not work well together for print output
% \trouble[\pkg{xindy} with \pkg{hyperref}]{xindy=\pkg{xindy}>hyperref=\pkg{hyperref}}
% \trouble{index>xindy=\pkg{xindy} and \pkg{hyperref}}
% \trouble{index>see and seealso}
% \trouble{index>reference ranges}
% \trouble{index>styling references}
% with ``see'', ``see also'', reference ranges, or stylized index references.
% It may be necessary to turn off hyper-referencing for indexes:
% \begin{sourcedisplay}
% \cs{usepackage}\textred{[hyperindex=false]}\{hyperref\}
% \end{sourcedisplay}
% 
% If an \HTML\ index is empty, it may be necessary to add the following
% \trouble[empty index]{index>empty}
% \trouble{morewrites=\pkg{morewrites}}
% before \pkg{lwarp} is loaded:
% \begin{sourcedisplay}
% \textred{\cs{usepackage}\{morewrites\}} \\
% \textred{\cs{morewritessetup}\{allocate=10\}} \\
% \dots \\
% \cs{usepackage}\{lwarp\}
% \end{sourcedisplay}
% 
% When using \prog{makeindex}, custom display styles are possible:
% \gindex{index>custom display styles}
% \margintag{\prog{makeindex} custom display styles}
% \begin{sourcedisplay}
% \cs{begin}\{warpprint\} \\
% \cs{newcommand}\{\cs{notesstyle}\}[1]\{\#1nn\} \\
% \cs{end}\{warpprint\} \\
% ~ \\
% \cs{begin}\{warpHTML\} \\
% \cs{makeatletter} \\
% \cs{newcommand}\{\cs{notesstyle}\}[1]\{\cs{LWR@doindexentry}\{\#1\} notes \} \\
% \cs{makeatother} \\
% \cs{end}\{warpHTML\} \\
% \dots \\
% A sentence.\cs{index}\{key\textbar{}notesstyle\}
% \end{sourcedisplay}
% 
% For custom styles with \prog{xindy},
% \margintag{\prog{xindy} custom display styles}
% see \filenm{lwarp.xdy} for \cs{textbf} and \cs{textit} as examples.
%
% 
% \subsubsection{Index positions, \TOC, \pkg{tocbibind}}
% \limitstocbibind
%
% \limitstocloft
% 
%
%
% \subsection{Math}
%
% \changes{v0.42}{2017/10/30}{Docs: Reorganized math limitations}
% \label{sec:limitsmath}
%
% \limitsmath
%
% \subsubsection{Catcode changes}
% \label{sec:mathcatcode}
% \limitsmathcatcode
%
% \subsubsection{Complicated inline math objects}
% \label{sec:mathdynamic}
% \gindex{inline math>complicated objects}
% \gindex{math>inline with complicated objects}
% \gindex{math>dynamic}
% \gindex{dynamic math}
% \limitsmathinline
%
% \subsubsection{Complicated display math objects}
% \label{sec:displaymathother}
% \gindex{display math>complicated objects}
% \gindex{math>display with complicated objects}
% \gindex{math>dynamic}
% \gindex{dynamic math}
% \trouble{math>tikz=\tikz}
% \trouble{tikz>in math}
% \trouble{MathJax=\brand{MathJax}>errors}
% \trouble{HTML>alt tags}
% \trouble{alt tags}
%
% \limitsmathdisplay
%
% \subsubsection{\pkg{ntheorem} package}
%
% \DescribePackage{ntheorem}
% \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}
%
% \DescribePackage{graphics}%
% \DescribePackage{graphicx}%
% \limitsgraphics
%
%
% \subsubsection{\pkg{tikz} package}
% \label{sec:limitstikz}
%
% \DescribePackage{tikz}
% \limitstikz
% \changes{v0.51}{2018/03/18}{Docs: \pkg{tikz} limitations.}
%
%
% \subsubsection{\pkg{grffile} package}
%
% \DescribePackage{grffile}
% \limitsgrffile
%
%
% \subsubsection{\pkg{color} package}
%
% \DescribePackage{color}
% \limitscolor
%
%
% \subsubsection{\pkg{xcolor} package}
%
% \DescribePackage{xcolor}
% \limitsxcolor
%
%
% \subsubsection{\pkg{epstopdf} package}
%
% \DescribePackage{epstopdf}
% \limitsepstopdf
%
%
% \subsubsection{\pkg{pstricks} package}
%
% \DescribePackage{pstricks}
% \limitspstricks
%
%
% \subsubsection{\pkg{pdftricks} package}
%
% \DescribePackage{pdftricks}
% \limitspdftricks
%
%
% \subsubsection{\pkg{psfrag} package}
%
% \DescribePackage{psfrag}
% \trouble{psfrag=\pkg{psfrag}}
% \limitspsfrag
%
%
% \subsubsection{\pkg{pstool} package}
%
% \DescribePackage{pstool}
% \trouble{pstool=\pkg{pstool}}
% \limitspstool
%
%
% \needspace{15\baselineskip}
% \subsubsection{\pkg{asymptote} package}
% \changes{v0.62}{2018/10/16}{Docs: \pkg{asymptote}.}
%
% \DescribePackage{asymptote}
% \limitsasymptote
%
%
% \subsubsection{\pkg{overpic} package}
%
% \DescribePackage{overpic}
% \limitsoverpic
%
%
% \subsection{Tabbing}
% \limitstabbing
%
%
% \subsection{Tabular}
% \label{sec:limitstabular}
% \changes{v0.39}{2017/08/30}{Docs: Reorganized tabular discussion.}
% \limitstabular
%
%
% \subsubsection{\pkg{longtable} package}
%
% \DescribePackage{longtable}
% \limitslongtable
%
%
% \subsubsection{\pkg{supertabular} and \pkg{xtab} packages}
%
% \DescribePackage{supertabular}
% \DescribePackage{xtab}
% \limitssupertabular
%
% \subsubsection{\pkg{bigdelim} package}
%
% \DescribePackage{bigdelim}
% \limitsbigdelim
%
%
% \subsection{Floats}
%
% \subsubsection{Float contents alignment}
%
% \limitsfloatalignment
%
%
% \subsubsection{\pkg{float}, \pkg{trivfloat}, and/or \pkg{algorithmicx} together}
%
% \DescribePackage{float}
% \DescribePackage{trivfloat}
% \DescribePackage{algorithmx}
% \limitscombiningfloats
%
%
% \subsubsection{\pkg{caption} and \pkg{subcaption} packages}
%
% \DescribePackage{caption}
% \DescribePackage{subcaption}
% \limitscaption
%
%
%
%
% \subsubsection{\pkg{subfig} package}
%
% \DescribePackage{subfig}
% \limitssubfig
%
%
% \subsubsection{\pkg{floatrow} package}
%
% \DescribePackage{floatrow}
% \limitsfloatrow
%
%
% \subsubsection{\pkg{keyfloat} package}
%
% \DescribePackage{keyfloat}
% \limitskeyfloat
%
%
% \subsection{\brand{Koma-Script} classes}
%
% \DescribeClass{komascript}
% \limitskomascript
%
%
% \subsection{\brand{Memoir} class}
% \label{sec:limitsmemoir}
%
% \changes{v0.66}{2019/02/06}{\pkg{memoir}: Docs re: version numbers.}
%
% \DescribeClass{memoir}
% \limitsmemoir
%
%
% \subsection{International languages}
% \label{sec:international}
%
% If using \prog{pdflatex} with the setting |\booltrue{FileSectionNames}|,
% \trouble[section and file names]{sectioning>international language}
% \trouble{filename>corrupted}
% \trouble{filename>international, \UTF-8}
% \gindex{international>section names}
% \gindex{foreign>section names}
% \gindex{section>international languages}
% \gindex{filename>international languages}
% non-\acro{ASCII} text in section names can result in corrupted \HTML\ file names.
% \prog{pdflatex} may be used if setting |\boolfalse{FileSectionNames}|, in which case
% \HTML\ file numbers will be generated.
%
% For correct \HTML\ file names, use \prog{xelatex}, \prog{lualatex},
% or dedicated document classes \Slash engines.
%
% (As of this writing, this warning is only relevent to the \pkg{kotex} package.)
%
%
% \subsection{Miscellaneous packages}
%
% \subsubsection{\pkg{verse} and \pkg{memoir}}
%
% \DescribePackage{verse}
% \DescribeClass{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{polyglossia} package}
% \label{sec:limitspolyglossia}
%
% \DescribePackage{polyglossia}
% \limitspolyglossia
%
%
% \subsubsection{\pkg{todonotes} and \pkg{luatodonotes} packages}
%
% \DescribePackage{todonotes}
% \DescribePackage{luatodonotes}
% \limitstodonotes
%
%
% \subsubsection{\pkg{fixme}}
%
% \DescribePackage{fixme}
% \limitsfixme
%
%
% \subsubsection{\pkg{chemfig} package}
%
% \limitschemfig
% \trouble{chemfig=\pkg{chemfig}}
%
%
% \subsubsection{\pkg{chemformula} package}
% \limitschemformula
% \trouble{array>chemformula=\pkg{chemformula}}
% \trouble{math>chemformula=\pkg{chemformula}}
%
%
% \subsubsection{\pkg{mhchem} package}
%
% See \cref{sec:mhchem}.
%
%
% \subsubsection{\pkg{xparse} package}
%
% \changes{v0.45}{2017/12/09}{Docs: \pkg{xparse} warnings.}
% \DescribePackage{xparse}
% \limitsxparse
% \gindex{xparse=\pkg{xparse}>warnings}
%
%
% \subsubsection{\pkg{kotex} package}
%
% \DescribePackage{kotex}
% See \cref{sec:international} regarding \prog{pdflatex} and
% Korean section names.
% \trouble[Korean section names]{filename>Korean}
%
%
% \clearpage
%
% \section{Compiling using custom shell commands}
% \label{sec:customcompiling}
% \gindex{compiling>custom}
%
% \changes{v0.61}{2018/09/21}{Docs: Compiling using custom shell commands.}
%
% \pkg{lwarp} and \prog{lwarpmk} try to make it easy to process
% print and \HTML\ compilation tasks in most situations.
% Depending on the operating system, command-line options, \TeX\ engine,
% and \pkg{lwarp} options, the commands \cmds{lwarpmk print} and
% \cmds{lwarpmk html} are automatically set up to correctly recompile the project.
% These actions may be overridden using \pkg{lwarp} options, thus allowing the use
% of packages such as \pkg{perltex} and \pkg{pythontex}.
%
% \subsection{Command options}
%
% \DescribeOption{PrintLatexCmd}
% \DescribeOption{HTMLLatexCmd}
% The \pkg{lwarp} options \optn{PrintLatexCmd} and \optn{HTMLLatexCmd}
% are used to set customized commands to be executed by
% \cmds{lwarpmk print} and \cmds{lwarpmk html}.
% \begin{description}
% \item [\optn{PrintLatexCmd}] should be set to shell commands which take \filenm{project.tex}
%     and generate \filenm{project.pdf}.
% \item[\optn{HTMLLatexCmd}] should be set to take \filenm{project_html.tex} and
%     generate \filenm{project_html.pdf}.
%     \prog{lwarpmk} will then take \filenm{project_html.pdf} and
%     automatically convert it and generate \filenm{project.html}.
% \end{description}
%
% \subsection{Literal character macros}
% The \pkg{lwarp} package options are parsed by \TeX, and so some characters
% require the use of a special macro to represent them.  See \cref{tab:literalchars}.
% \cs{LWRopquote} and \cs{LWRopseq} may be used to increase operating-system portability.
% \cs{jobname} must have |_html| appended for processing \HTML.
% \cs{space} may be necessary between other macros.
%
% To use these macros, either \pkg{kvoptions-patch} must be loaded before \pkg{lwarp}:
% \trouble[macro not found]{LWRopseq=\cs{LWRopseq}}
% \trouble{LWRpercent=\cs{LWRpercent}}
% \trouble{LWRdollar=\cs{LWRdollar}}
% \trouble{LWRhash=\cs{LWRhash}}
% \trouble{LWRbackslash=\cs{LWRbackslash}}
% \trouble{LWRopquote=\cs{LWRopquote}}
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% \usepackage{kvoptions-patch}
% \usepackage[
%     PrintLatexCmd={ ... } ,
%     HTMLLatexCmd={ ... }
% ]{lwarp}
% \end{Verbatim}
% \needspace{18\baselineskip}
% or \cs{lwarpsetup} must be used to set \optn{PrintLatexCmd} and \optn{HTMLLatexCmd}:
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% \usepackage[...]{lwarp}
% \lwarpsetup{
%   PrintLatexCmd=
%       {
%           latex tm \LWRopseq
%           dvips -o tm-pics.ps tm.dvi \LWRopseq
%           ps2pdf tm-pics.ps \LWRopseq
%           pdflatex tm.tex
%       } ,
%   HTMLLatexCmd=
%       {
%           latex tm_html \LWRopseq
%           dvips -o tm_html-pics.ps tm_html.dvi \LWRopseq
%           ps2pdf tm_html-pics.ps \LWRopseq
%           pdflatex tm_html.tex
%       }
% }
% \end{Verbatim}
%
% \begin{table}
% \centering
% \caption{Literal character macros}
% \label{tab:literalchars}
% \begin{tabular}{cll}
% Character & Macro & Comment \\
% |%| & \cs{LWRpercent} & \\
% |$| & \cs{LWRdollar} & \\
% |&| & \cs{LWRamp} & \\
% |%| & \cs{LWRhash} & \\
% |\| & \cs{LWRbackslash} & \\
% \texttt{\textquotesingle} or |"| & \cs{LWRopquote} & Depends on the operating system. \\
% |&| or |&&| & \cs{LWRopseq} & Depends on the operating system. \\
% (space) & \cs{space} & Forces an extra space. \\
% (jobname) & \cs{jobname} & Without file extension. \\
% \end{tabular}
% \hrule
% \end{table}
%
%
% \needspace{6\baselineskip}
%
% \subsection{\prog{latexmk}}
%
% \DescribeProgram{latexmk}
% If \prog{latexmk} is used for a project, it may be easiest to continue
% using it.
% \begin{description}
% \item[\cmds{latexmk project.tex}] would create \filenm{project.pdf} as normal.
% \item[\cmds{latexmk project\_html.tex}] would create \filenm{project_html.pdf},
%   then
% \item [\cmds{lwarpmk pdftohtml project\_html.pdf}] would take
%   \filenm{project_html.pdf} and convert it to \filenm{project.html}.
% \end{description}
%
% \prog{latexmk} may simplify the use of packages such as \pkg{sagetex}.
% \DescribePackage{sagetex}
%
%
% \subsection{\pkg{perltex} package}
%
% The \pkg{lwarp} package option settings to use \pkg{perltex} would be similar to:
% \DescribePackage{perltex}
% \begin{sourcedisplay}
% \cs{usepackage}[ \\
% \fquad \dots \\
% \fquad PrintLatexCmd=\{perltex -latex=pdflatex project.tex\} , \\
% \fquad HTMLLatexCmd=\{perltex -latex=pdflatex project\textgreen{\_html}.tex\} , \\
% \fquad \dots \\
% ]\{lwarp\}
% \end{sourcedisplay}
%
% Place \pkg{perltex} math expressions between
% \trouble[``impure'' math]{perltex=\pkg{perltex}}
% \cs{displaymathother} and \cs{displaymathnormal}, or
% \cs{inlinemathother} and \cs{inlinemathnormal}.
% See \cref{sec:displaymathother}.
%
%
% \subsection{\pkg{pythontex} package}
%
% \DescribePackage{pythontex}
% An example using \pkg{pythontex}:
% \begin{sourcedisplay}
% \cs{usepackage}[ \\
% \fquad \dots \\
% \fquad PrintLatexCmd=\{ \\
%     \fqquad pdflatex project.tex \cs{LWRopseq} \\
%     \fqquad pythontex project \cs{LWRopseq} \\
%     \fqquad pdflatex project.tex \\
% \fquad \} , \\
% \fquad HTMLLatexCmd=\{ \\
%     \fqquad pdflatex project\textgreen{\_html}.tex \cs{LWRopseq} \\
%     \fqquad pythontex project\textgreen{\_html} \cs{LWRopseq} \\
%     \fqquad pdflatex project\textgreen{\_html}.tex \\
% \fquad \} , \\
% \fquad \dots \\
% ]\{lwarp\}
% \end{sourcedisplay}
%
% Another possibility is to use \prog{latexmk}, placing the
% \cmds{latexmk \dots} commands in the \optn{PrintLatexCmd} and \optn{HTMLLatexCmd}
% options.
% While using these options, the \pkg{lwarp} option \optn{latexmk} would not be used.
%
% No attempt has yet been made to make \pkg{pythontex} robust with \HTML\ output.
% Some math objects must be surrounded by
% \trouble[``impure'' math]{pythontex=\pkg{pythontex}}
% \cs{displaymathother} \dots \cs{displaymathnormal},
% or \cs{inlinemathother} \dots \cs{inlinemathnormal}.
% Displays of code may have to be
% enclosed inside a \env{lateximage} environment
% \watchout[HTML look-alike]
% to prevent |<|, |>| and similar from being interpreted by the browser
% as \HTML\ entities.
%
%
% \subsection{Other packages}
%
% \DescribePackage{sympytex}
% \DescribePackage{rterface}
% Other packages such as \pkg{sympytex} and \pkg{rterface} would be set up
% similar to \pkg{pythontex}, and the same warnings would apply.
% \trouble{sympytex=\pkg{sympytex}}
% \trouble{rterface=\pkg{rterface}}
%
%
% \subsection{\prog{make} program}
% \gindex{make utility}
%
% \DescribeProgram{make}
% To use \pkg{lwarp} with the \prog{make} program,
% have the \filenm{makefile} take \filenm{project.tex} and
% generate the print version \filenm{project.pdf}, as normal.
% |\usepackage{lwarp}| must be used, and it generates \filenm{lwarpmk.conf}
% when the print version is created.
%
% To generate \HTML, first have \filenm{project_html.tex} be compiled to
% generate \filenm{project_html.pdf}.
% This must be in \PDF\ format.
% Finally, have \filenm{project_html.pdf} be converted to \HTML\ using
% \cmds{lwarpmk pdftohtml project\_html.pdf},
% and convert \SVG\ math with \cmds{lwarpmk limages}.
%
%
% \subsection{\UTF-8 locale}
% \label{sec:utf8locale}
% \gindex{locale}
% \gindex{UTF-8>locale}
%
% \changes{v0.62}{2018/10/20}{Docs: UTF-8 locale.}
%
% \prog{lwarpmk} uses the \prog{texlua} program, which sets the ``locale'' to ``|C|'',
% \trouble[UTF-8 locale]{UTF-8>locale}
% \trouble{Unicode>UTF-8 locale}
% \trouble{locale}
% including for external operating-system calls such as when executing \cmds{lwarpmk html}.
% In some cases, an external program called from the user's document
% may require the use of a \UTF-8 ``locale''.
% For \brand{Unix}-related operating systems, it may be required to use \pkg{lwarp}'s
% custom compilation options to add a locale change:
% \begin{sourcedisplay}
% \cs{usepackage}\{lwarp\}[\\
% \fquad PrintLatexCmd=\{\\
%   \fqquad \textred{env LC\_CTYPE=en\_US.UTF-8} \\
%       \fqqquad xelatex --shell-escape project.tex \\
% \fquad \} \\
% \fquad HTMLLatexCmd=\{\\
%   \fqquad \textred{env LC\_CTYPE=en\_US.UTF-8} \\
%       \fqqquad xelatex --shell-escape project\textgreen{\_html}.tex \\
% \fquad \} \\
% ] \\
% \end{sourcedisplay}
%
% \DescribePackage{ditaa}
% The only example seen so far where this is required is the \pkg{ditaa} package,
% \trouble{ditaa=\pkg{ditaa}}
% where the locale change allows the use of UTF-8 with Xe\LaTeX\ and \pkg{ditaa}.
% To use Lua\LaTeX\ instead, the locale change would have to be made inside the
% \pkg{ditaa} package where its calls the \prog{ditaa} program.
%
%
% \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:
%
% \begin{docsidebar}[\bool{FormatEPUB}]
% \DescribeBoolean{FormatEPUB}  \DescribeDefault{false}
%	\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}
%	\gindex{EPUB>HTML conversion settings}
%	\gindex{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 \prog{Calibre} (\url{https://calibre-ebook.com/}).
% \gindex{Calibre=\prog{Calibre}}
% \gindex{EPUB>conversion software}\margintag{\prog{Calibre}}
%
% The \EPUB\ conversion program must know what order the files are included.
% For \pkg{lwarp} projects, set the \EPUB\ conversion software to
% \trouble[search order]{EPUB>search order}
% \trouble{EPUB>page order}
% \trouble{Calibre=\prog{Calibre}>EPUB conversion}
% do a breadth-first search of the files.
% For \prog{Calibre}, this option is found in
% \begin{UIdisplay}
%	Preferences $\to$ Plugins $\to$ File type plugins $\to$ \HTML\ to Zip
% \end{UIdisplay}
% Check the box \textsf{Add linked files in breadth first order.}
% Set the document encoding as |utf-8|\trouble[encoding]{EPUB>encoding},
% which is what \pkg{lwarp} generates for \HTML,
% even if the original printed document uses some other encoding.
% 
% The \EPUB-conversion program must also know where the section breaks are located.
% \trouble[section breaks]{EPUB>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 \prog{Calibre}, this option is found in
% \begin{UIdisplay}
%	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 \textmd{\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 \prog{Calibre}, and then converted to an \EPUB.
%
% \begin{docsidebar}[\brand{MathJax} support]
% \brand{MathJax} may be used in \EPUB\ documents.
% Some e-readers include \brand{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 \brand{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 \brand{MathJax}, especially for equations numbered by chapter,
% or where \pkg{siunitx} support is important.
% \end{docsidebar}
%
%
%
%
% \clearpage
%
% \section{Word-processor conversion}
% \label{sec:wordprocessorconversion}
%   \gindex{word processor>HTML conversion settings}
%   \gindex{HTML>conversion settings>word processor}
%   \gindex{LibreOffice=\brand{LibreOffice}>import into}
%   \gindex{export>to word processor}
%   \trouble{word processor>import}
%   \trouble{LibreOffice=\prog{LibreOffice}>import}
%
% \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 \brand{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:
% \begin{docsidebar}[\bool{FormatWP}]
% \DescribeBoolean{FormatWP} \DescribeDefault{false}
%	\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 \prog{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 \prog{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 \prog{LibreOffice Writer}.
%       \brand{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 \brand{LibreOffice}.
%   \item \cs{includegraphics} and \SVG\ math width and height
%       are made explicit for \brand{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.
% }
%
%	\begin{docsidebar}[\bool{WPMarkFloats}]
% \DescribeBoolean{WPMarkFloats} \DescribeDefault{false}
%	\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.
% }
%
%   \begin{docsidebar}[\bool{WPMarkMinipages}]
% \DescribeBoolean{WPMarkMinipages} \DescribeDefault{false}
%   \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 \TOC.
%
%   \emph{If set |false|, the actual \TOC\ is printed instead.}
% }
%
%   \begin{docsidebar}[\bool{WPMarkTOC}]
% \DescribeBoolean{WPMarkTOC} \DescribeDefault{true}
%   \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.}
% }
%
%   \begin{docsidebar}[\bool{WPMarkLOFT}]
% \DescribeBoolean{WPMarkLOFT} \DescribeDefault{false}
%   \raggedright
%   \describeWPMarkLOFT
%   \end{docsidebar}
%
%
% \newcommand{\describeWPMarkMath}{
%   While formatting for word processors,
%   prints math as \LaTeX\ code instead of creating \SVG\ images or \brand{MathJax}.
%   This is useful for cut/paste into the \prog{LibreOffice Writer TeXMaths} extension.
% }
%
%   \begin{docsidebar}[\bool{WPMarkMath}]
% \trouble{TeXMaths}
% \trouble{siunitx>with TeXMaths}
%   \margintag{siunitx}
% \DescribeBoolean{WPMarkMath} \DescribeDefault{false}
% \DescribeProgram{TeXMaths}
%   \raggedright
%   \describeWPMarkMath
%
%   When using the \pkg{siunitx} package, enter
%   \begin{sourcedisplay}
%   \cs{usepackage}\{siunitx\}
%   \end{sourcedisplay}
%   in the \prog{TeXMaths} preamble.
%   Equation numbering is problematic for \AmS\ math environments.
%   \end{docsidebar}
%   \gindex{siunitx>with \prog{TeXMaths}}
%   \gindex{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 \brand{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}.
% }
%
%   \begin{docsidebar}[\bool{WPTitleHeading}]
% \DescribeBoolean{WPTitleHeading} \DescribeDefault{false}
%   \margintag{section headings}
%   \raggedright
%   \describeWPTitleHeading
%   \end{docsidebar}
% \gindex{section>heading, word processor}
% \gindex{heading, word processor}
% \gindex{word processor>section headings}
% \gindex{LibreOffice=\brand{LibreOffice}>section headings}
% \trouble{sectioning>word processor import}
% \trouble{word processor>sectioning 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}
%   \gindex{word processor>conversion recommendations}
%   \gindex{LibreOffice=\brand{LibreOffice}>conversion recommendations}
%
% For use with \prog{LibreOffice Writer}, it is recommended to:
% \margintag{TOC, LOF, LOT}
% \begin{enumerate}[nosep]
% \item Set |\booltrue{FormatWP}|
% \item Set |\booltrue{WPMarkTOC}| and |\boolfalse{WPMarkLOFT}|
% \item Use \pkg{lwarp} to generate the \HTML\ document.
% \item Copy/paste from the \HTML\ document into an empty \prog{LibreOffice Writer} document.
% \item Manually insert a \brand{LibreOffice} \TOC\ in the \brand{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 \brand{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}
%
% \brand{LibreOffice} has options in the \UI{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 \brand{LibreOffice} floats with their
% own captions.  Floats are surrounded by a thin frame in the \brand{LibreOffice} editor,
% and may be marked with |WPMarkFloats|, but are not given a proper \brand{LibreOffice}
% object frame.
% Captions are given an explicit italic formatting,
% but not a proper \brand{LibreOffice} paragraph style.
%
% Cross references are not actual \brand{LibreOffice} linked cross references.
%
% The List of Figures and List of Tables are not linked.
% The pasted pseudo \LOF\ and \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, \brand{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}
%
% \brand{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 \pkg{lwarp}}
% \pagestyle{pageheadfoot}
%
% To quickly find the source for a package in |lwarp.dtx|,
% \margintag{locating something}
% search for |*packagename|,
%   such as |*siunitx|.
%
% Likewise, to quickly find the source for a file in |lwarp.dtx|,
%   search for |*filename|, such as |*lwarp.css|.
%
% 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
% \margintag{image of \TeX\ output}
% 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,
% \margintag{\CSS\ classes}
% see \cref{sec:highlevelclasses}.
%
% To create print and \HTML\ versions of the same macro or environment,
% \margintag{print/HTML macros}
% see \cref{sec:definingprinthtml}.
%
% Any \TeX\ boxes must be undone, as \SVG\ math or \env{lateximage}s
% \watchout[\TeX\ boxes]
% require \cs{newpage}, which will not work in a \TeX\ box.
%
% \changes{v0.57}{2018/05/28}{Docs: Recreating the index for \pkg{lwarp} source.}
% To recreate the index for the \pkg{lwarp} documentation:
% \margintag{index recreation}
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% makeindex -s gglo.ist -o lwarp.gls lwarp.glo
% splitindex lwarp.idx -- -s gind.ist
% \end{Verbatim}
%
%
% \subsection{Creating a development system}
%
% The following creates a local development system for \pkg{lwarp} on a TeXLive system
% in a \brand{Unix}-like environment.
% Doing so allows anything requesting \pkg{lwarp} to use the development version
% instead of whichever version is installed in TeXLive.
%
% \begin{description}
% \item [Create a development directory:] \
%
%   Place into this directory \filenm{lwarp.dtx} and \filenm{lwarp.ins}.
%
%   To create \filenm{lwarp.sty},
%   execute \userentry{pdflatex lwarp.ins} which creates \filenm{lwarp.sty} and several
%   hundred additional \filenm{lwarp-*.sty} files for the various packages which are
%   supported.
%
%   To create the documentation \filenm{lwarp.pdf},
%   execute \userentry{pdflatex lwarp.dtx}
%
% \item[To make the development files visible to other projects:] \
%
%   Create the directory
%   \begin{quote}
%   \filenm{/usr/local/texlive/texmf-local/tex/latex/local/lwarp}
%   \end{quote}
%
%   Inside this directory, create the file \filenm{update}, containing:
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% ln -s /path_to_dev_directory/lwarp*.sty .
% ln -s /path_to_dev_directory/lwarp_baseline_marker.png .
% ln -s /path_to_dev_directory/lwarp_baseline_marker.eps .
% mktexlsr
% \end{Verbatim}
%   Run ./update now, and whenever a new lwarp-* package is added.

% \item[To make the development version of \prog{lwarpmk} visible to other projects:] \
%
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% cd /opt
% ln -s /usr/local/texlive/texmf-local/bin/x86_64-linux texbin_local
% cd texbin_local
% ln -s ../../scripts/lwarp/lwarpmk.lua lwarpmk
% cd /usr/local/texlive/texmf-local/scripts/
% mkdir lwarp
% cd lwarp
% ln -s /path_to_dev_directory/lwarpmk.lua lwarpmk
% \end{Verbatim}
% Verify that the correct version is found with \userentry{which lwarpmk}
%
% \item [To make the local versions visible to the shell:] \
%
%   Paths must be set by the shell startup, such as in \filenm{.bashrc} and \filenm{.cshrc}:
%
%   In \filenm{.bashrc}:
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% PATH=/opt/texbin_local:/opt/texbin:$PATH
% \end{Verbatim}
%
%   In \filenm{.cshrc}:
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% setenv PATH ${HOME}/bin:/opt/texbin_local:/opt/texbin:${PATH}
% \end{Verbatim}
%
% \end{description}
% 
%
%
% \subsection{Modifying a package for \pkg{lwarp}}
%
% \gindex{package>modifying for \pkg{lwarp}}
% \gindex{modifying>package}
% \gindex{adapting>package}
% \gindex{converting>package}
%
% If a class loads additional packages, it will be required to modify the
% class for \pkg{lwarp}, since \pkg{lwarp} must be loaded before most other packages.
%
% To work with \pkg{lwarp}, a class must first set up anything which replicates
% the functions of the basic \LaTeX\ classes, load any required fonts,
% then load \pkg{lwarp}, then finally load and adjust any other required packages.
%
% 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 of:
% \begin{sourcedisplay}
%   \cs{LWR@ProvidesPackage\textblue{Drop}} \\
%   \fquad \textrm{-or-} \\
%   \cs{LWR@ProvidesPackage\textblue{Pass}}
% \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.
%
%
% \subsubsection{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}.
% Finally, add an entry in \cref{tab:supported}, \nameref{tab:supported},
% and also the Updates section.
%
%
% \subsection{Modifying a class for \pkg{lwarp}}
%
% \gindex{class>modifying for \pkg{lwarp}}
% \gindex{modifying>class}
% \gindex{adapting>class}
% \gindex{converting>class}
%
% If a class loads additional packages, it will be required to modify the
% class for \pkg{lwarp}, since \pkg{lwarp} must be loaded before most other packages.
%
% To work with \pkg{lwarp}, a class must first set up anything which replicates
% the functions of the basic \LaTeX\ classes, load any required fonts,
% then load \pkg{lwarp}, then finally load and adjust any other required packages.
%
%
% \subsection{Testing \pkg{lwarp}}
%
% \changes{v0.25}{2017/03/22}{Docs: Testing \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.
%
% \changes{v0.57}{2018/05/28}{Docs: Recompiling \prog{lwarpmk} or \CSS\ files.}
% When changing the source to \prog{lwarpmk} or a \CSS\ file in \filenm{lwarp.dtx}:
% \begin{enumerate}
% \item Change the source in \filenm{lwarp.dtx}.
% \item |pdflatex lwarp.ins|
% \item |pdflatex lwarp.dtx|
% \item If modifying \prog{lwarpmk} the new version should now be active.
% \item If modifying \CSS\ files:
%   \begin{enumerate}
%   \item For the document, |lwarpmk print| to update the \CSS\ files
%       in the project.
%   \item Reload the \HTML\ document to see the effect of the new \CSS\ files.
%   \end{enumerate}
% \end{enumerate}
%
% 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 \prog{lwarpmk}}
% \label{sec:modifylwarpmk}
%
% \changes{v0.28}{2017/04/14}{Docs: Modfying lwarpmk and index processing.}
%
% \DescribeProgram{lwarpmk}
% \DescribeFile{lwarpmk.lua}
% In most installations, \filenm{lwarpmk.lua} is an executable file located somewhere
% \gindex{lwarpmk=\prog{lwarpmk}>customizing}
% the operating system knows about, and it is called by typing \cmds{lwarpmk} into
% a terminal.
%
% A project-local copy of \filenm{lwarpmk.lua} may be generated, modified, and then used to
% compile documents:
% \begin{enumerate}
% \item Add the \optn{lwarpmk} option to the \pkg{lwarp} package.
% \item Recompile the printed version of the document.
%	The \optn{lwarpmk} option causes \pkg{lwarp} to create a local copy of \filenm{lwarpmk.lua}
% \item The \optn{lwarpmk} option may now be removed from the \pkg{lwarp} package.
% \item Copy and rename \filenm{lwarpmk.lua} to a new file such as \filenm{mymake.lua}.
% \item Modify \filenm{mymake.lua} as desired.
% \item If necessary, make \filenm{mymake.lua} executable.
% \item Use \filenm{mymake.lua} instead of \filenm{lwarpmk.lua}.
% \end{enumerate}
%
%
%
% \clearpage
%
% ^^A *troubleshooting
% \section{Troubleshooting}
% \label{sec:troubleshooting}
% \gindex{FAQ}\gindex{Frequently Asked Questions}\gindex{bugs}
% \gindex{troubleshooting}\gindex{problems}\gindex{error messages}
% \gindex{debugging}
%
% \subsection{Using the \pkg{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}.}
% \changes{v0.58}{2018/06/07}{Docs: Misplaced \cs{omit}.}
%
% \begin{description}
%
% \item [Text is not converting correctly / corrupted \HTML\ tags:] ~
%   \trouble{HTML>corrupted}
%	\begin{itemize}
%	\item Font-related UTF-8 information must be embedded in the \PDF\ file.
%		See \cref{sec:fonts} regarding bitmapped vs. vector fonts.
%   \item See \cref{sec:avoidtextformatting} regarding \HTML\ entities and
%       the characters |&|, |<|, and |>|.
%	\end{itemize}
%
% \item [Undefined \HTML\ settings:] \
%   \trouble{HTML>settings>undefined}
%	\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}
%       \setlength{\parskip}{1ex}
%	    \item [Print first:] Be sure that a print version of the document compiles and
%		    that your document's \LaTeX{} code is correct, before attempting
%		    to generate an \HTML\ version.
%
%       \item [\texttt{\cs{end}\{warpHTML\}, \cs{end}\{warpprint\}, \cs{end}\{warpall\}}:]
%           \trouble{warpHTML}\trouble{warpprint}\trouble{warpall}
%           Each of these must be without any other characters on the same line.
%
%       \item [Options clash:] If using \pkg{memoir}, see \cref{sec:limitsmemoir}.
%
%       \item [``No room for a new \cs{write}.'':] Before |\usepackage{lwarp}|, add:
%           \trouble{No room for a new \cs{write}}
%           \trouble{morewrites}
%           \begin{sourcedisplay}
%           \cs{usepackage}\{morewrites\} \\
%           \cs{morewritessetup}\{allocate=10\}
%           \end{sourcedisplay}
%
%       \item [``Missing \$ inserted.'':] If using a filename or URL in a
%           footnote or \cs{item}, escape underscores with \cs{\_}.
%           \trouble{Missing \$ inserted>filename or URL}
%           \trouble{URL>Missing \$ inserted}
%           \trouble{filename>Missing \$ inserted}
%
%       \item [``Label(s) may have changed. Rerun to get cross-references right.'':] \
%
%           This warning may repeat endlessly if a math expression is used in a caption.
%           Simple math expressions such as \$X=1\$ may be replaced with
%           \begin{sourcedisplay}
%           \cs{textit}\{X\}\cs{,}=\cs{,}1
%           \end{sourcedisplay}
%           \trouble{Label(s) may have changed}
%
%         \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.
%           \trouble{Leaders not followed by proper glue}
% 
%         \item [``Improper \cs{prevdepth}'':]
%           \trouble{Improper \cs{prevdepth}>boxes}
%           \env{lateximage}s and \SVG\ math require \cs{newpage}, which
%           cannot work inside \TeX\ boxes or \cs{ensuremath}.
%           Anything using \cs{newsavebox}, \cs{newbox}, \env{lrbox},
%           \cs{savebox}, \cs{hbox}, \cs{vbox}, \cs{usebox}, \cs{sbox},
%           etc., must be modified to work without box commands.
%
%           \trouble{ensuremath=\cs{ensuremath}}
%           If you find something using \cs{ensuremath}, have it temporarily set:
%           \begin{sourcedisplay}
%           \cs{LetLtxMacro}\cs{@ensuredmath}\cs{LWR@origensuredmath}
%           \end{sourcedisplay}
%           inside a group first.
%
%           Also, custom macros which appear inside a section,
%           \trouble[macros in section,table,figure names]{sectioning>macro in name}
%           \trouble{table>macro in name}
%           \trouble{figure>macro in name}
%           figure, or table name should be
%           made robust since they appear inside the \filenm{.toc}, \filenm{.lof}, or
%           \filenm{.lot} files.
%           Use \cs{newrobustcmd} or \cs{robustify} from \pkg{etoolbox}, \pkg{xparse}, etc.
%
%           If using BibTeX, see \cref{sec:limitsbibtex}.\watchout[BibTeX]
%
%       \item[``\texttt{!~Undefined control sequence. \dots\ \cs{@begindocumenthook}''}:] ~
%           \watchout[\pkg{polyglossia}]
%           See \cref{sec:limitspolyglossia}
%           if using \pkg{polyglossia}.
%
%       \item[``\texttt{\cs{begin}\{equation\} ended by \cs{end}\{document\}}'':] Do not
%           \trouble[custom macros for environments]{math>custom macros}
%           use custom macros such as \cs{beq} and \cs{eeq} to replace
%           \begin{sourcedisplay}
%           \cs{begin}\{equation\} \\
%           \dots \\
%           \cs{end}\{equation\}
%           \end{sourcedisplay}
%
%       \item[``\texttt{Misplaced \cs{omit}}'':] If using \cs{LWR@formatted} to
%           \watchout[\cs{LWR@formatted}]
%           define new macros for print and \HTML\ modes, see \cref{sec:definingprinthtml}
%           regarding \cs{LWR@expandableformatted}.
%
%       \item[Complicated objects inside math:] Some objects, such as \tikz,
%           \trouble[``impure'' math objects]{math>non-math contents}
%           may not compile in \pkg{lwarp}'s normal math emulation.
%           Insert
%           \begin{sourcedisplay}
%           \cs{displaymathother} \textrm{-or-} \cs{inlinemathother}
%           \end{sourcedisplay}
%           before the math, and then
%           \begin{sourcedisplay}
%           \cs{displaymathnormal} \textrm{-or-} \cs{inlinemathnormal}
%           \end{sourcedisplay}
%           when displaying ``normal'' math.
%           See \cref{sec:displaymathother}.
%       \item[Slow compliation of math objects:] Complicated math objects
%           \trouble{math>slow or failed compile}
%           \trouble{math>alt tags}
%           \trouble{alt tags}
%           can also cause problems with \attribute{alt} tags, resulting in
%           very slow compilation, large \attribute{alt} tags, and possible
%           crashes.  Use \cs{inlinemathother} \dots \cs{inlinemathnormal} or
%           \cs{displaymathother} \dots \cs{displaymathnormal} around the
%           math expression.
%   \end{description}
%
% \needspace{3\baselineskip}
% \item [Incorrect \brand{MathJax}:] Some objects do not convert to \brand{Mathjax}.
%   \trouble[\brand{MathJax}]{MathJax=\brand{MathJax}>errors}
%   \trouble[\brand{MathJax}]{MathJax=\brand{MathJax}>unsupported packages}
%   Use \cs{displaymathother} before these objects, then \cs{displaymathnormal} to return
%   to ``normal'' display math.
%   See \cref{sec:displaymathother}.
%
% \needspace{3\baselineskip}
% \item [Missing sections:] See \cref{sec:filedepth} regarding the
%		|FileDepth| and |SideTOCDepth| counters,
%		and the use of \cs{tableofcontents} in the home page.
%
% \item [Misnumbered footnotes from section headings:] See \cref{sec:limitsfootnotes}.
%
% \item [Missing \HTML\ files:] \
%   \begin{itemize}
%	\item See the warning regarding changes to the \HTML\ settings
%		at \cref{sec:htmlsettings}.
%   \item Ensure that the filenames are unique after math and short words are removed.
%       See \optn{FileSectionNames} at \cref{sec:htmlsettings}.
%   \end{itemize}
%
% \item [Missing / incorrect cross-references:] ~
% \trouble{reference>missing or incorrect}
% \trouble{cross reference>missing}
%	\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 [BibTeX errors with \cs{etalchar}:] See \cref{sec:limitsbibtex}.
%
% \item [Malformed URLs:] Do not use the \texttt{\%} character between
%   \trouble{hyperref=\pkg{hyperref}>incorrect link}
%   \trouble{reference>incorrect link}
%   \trouble{cross reference>incorrect link}
%   \trouble{reference>\% character between arguments}
%   arguments of \cs{hyperref}, etc., as this character is among those which
%   is neutralized for inclusion in \HTML\ \URL{}s.
%
% \item [Em-dashes or En-dashes in listing captions and titles:] \
%
%	Use	\XeLaTeX\ or \LuaLaTeX.
%   \trouble{listings=\pkg{listings}}
%
% \item [Floats out of sequence:] ~
%   \trouble{float>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 [Images are appearing in strange places:] ~
% \trouble{image>incorrect}
% \trouble{SVG image>incorrect}
%	\begin{itemize}
%	\item Enter \cmds{lwarpmk limages} to refresh the \env{lateximage} images.
%	\end{itemize}
%
% \item[SVG images:] \
%
% \limitssvgimages
%
% \needspace{3\baselineskip}
% \item [Plain-looking document:] \
%   \trouble{CSS}
%	\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:] ~
%   \trouble{HTML>corrupted}
%	\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:] ~
%   \trouble{HTML>page did not update}
%   \trouble{HTML>missing pages>recompile}
%	\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}
%   \trouble{tracing lwarp}
%	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 \filenm{lwarp.dtx} file}
%
% \begin{description}
% \item [\filenm{lwarp_tutorial.tex}:] Copy or link \filenm{lwarp_tutorial.txt}
%		from the \TDS\ |doc| directory to the |source| directory,
%		or wherever you wish to compile the documentation.
%		This file is included verbatim in the documentation, but is in the \filenm{doc}
%		directory so that it may be found by \prog{texdoc} and copied by the user.
% \item [Illogical error messages caused by an out-of-sync \filenm{lwarp.sty} file:] ~
%	\begin{enumerate}
%	\item Delete the \filenm{lwarp.sty} file.
%	\item Enter \cmds{pdflatex lwarp.ins} to generate a new \filenm{lwarp.sty} file.
%	\item Enter \cmds{pdflatex lwarp.dtx} to recompile the \filenm{lwarp.pdf} documentation.
%	\end{enumerate}
%
% \item [Un-nested environments:]~
%
%	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}
%
%
%
% \clearpage
% \section{Trademarks}
%
% \changes{v0.14}{2016/03/29}{Docs: Trademarks section.}
%
% \begin{itemize}
% \item \TeX\ is a trademark of American Mathematical Society.
% \item \brand{Adobe}®  and \brand{Adobe} \prog{Framemaker}® are either registered trademarks or
%   trademarks of \brand{Adobe Systems Incorporated} in the United States and/or other countries.
% \item \brand{Linux}® is the registered trademark of Linus Torvalds in the U.S.\ and other countries.
% \item \brand{Mac\,OS}® is a trademark of \brand{Apple Inc.}
% \item \brand{MadCap Flare}™ is the property of \brand{MadCap Software, Inc.}
% \item \brand{MathJax} is copyright 2009 and later.
%   The \brand{MathJax Consortium} is a joint venture of the \brand{American Mathematical Society} (AMS)
%   and the \brand{Society for Industrial and Applied Mathematics} (SIAM)
%   to advance mathematical and scientific content on the web.
% \item \brand{Microsoft}®, \brand{Encarta}, \brand{MSN}, and \brand{Windows}® are either registered trademarks or
%   trademarks of \brand{Microsoft Corporation} in the United States and/or other countries.
% \item \brand{UNIX}® is a registered trademark of \brand{The Open Group}.
% \end{itemize}
%
% 
%
% \changes{v0.61}{2018/09/27}{Docs: Multiple indexes.}
%
% \makeatletter
%
% \StopEventually{
% ^^A \part{Change History and Index}
% ^^A  \part{Change History}
%
%
% \pagestyle{plain}
%
% ^^A Each index has a prologue which creates its own \part, label,
% ^^A and meta index entry.
%   \GlossaryPrologue{
%       \part{Change History}
%       \section{Chg Hist}
%       \label{sec:changehistory}
%       \sindex[meta]{Change History}
%       \markboth{{Change History}}{{Change History}}
%
%       For the most recent changes, see page \pageref{sec:changesend}.
%
%   }
%   \PrintChanges
%   \phantomsection
%   \label{sec:changesend}
%
%
% ^^A The instructions for the Index of Objects:
%   \IndexPrologue{
%       \clearpage
%       \expandafter\part\expandafter{\indexname}
%       \label{sec:index\indexshortcut}
%       \sindex[meta]{\indexname}
%         \markboth{Index of Objects}{Index of Objects}%
%
%       This is an index of macros, environments, booleans, counters, lengths,
%       packages, classes, options, keys, files, and various other programming objects.
%       Each is listed by itself, and also by category.
%       In some cases, they are further subdivided by [class].
%
%       Numbers written in italic refer to the page
%       where the corresponding entry is described;
%       numbers underlined refer to the
%       \ifcodeline@index
%       code line of the
%       \fi
%       definition.
% ^^A        ; numbers in roman refer to the
% ^^A         \ifcodeline@index
% ^^A         code lines
% ^^A         \else
% ^^A         pages
% ^^A         \fi
% ^^A         where the entry is used.
%   }
%
%   \printindex[idx][Index of Objects]
%
%
% ^^A The instructions for the General Index:
%   \IndexPrologue{
%       \clearpage
%       \expandafter\part\expandafter{\indexname}
%       \label{sec:index\indexshortcut}
%       \sindex[meta]{\indexname}
%
%       This is an index of instructions and concepts.
%       Look here when wondering how to do something, and
%       check the Troubleshooting Index when something goes wrong.
%   }
%
%   \printindex[gen][General Index]
%
%
% ^^A The instructions for the Troubleshooting Index:
%   \IndexPrologue{
%       \clearpage
%       \expandafter\part\expandafter{\indexname}
%       \label{sec:index\indexshortcut}
%       \sindex[meta]{\indexname}
%
%       This index is a sorted reference of problems and solutions.
%       In order to make it easier to locate a solution,
%       the same issue may be addressed by more than one entry.
%
%       Entries with higher page numbers are often duplicates of entries with
%       lower page numbers, as the same warning may occur within the user manual
%       and again within the source code for a given package.
%   }
%
%   \printindex[trb][Troubleshooting Index]
%
%
% ^^A The meta index does not get a meta index entry pointing  to itself:
%   \IndexPrologue{

%       \clearpage
%       \expandafter\part\expandafter{\indexname}
%       \label{sec:index\indexshortcut}
%   }
%
%   \printindex[meta][Index of Indexes]
% }
%
% \makeatother
%
%
% \clearpage
%
% \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 \prog{pdftotext}.
%
% Packages were emulated where their primary purpose was visual formatting which is not
% relevent to \HTML\ output.  For example, packages related to sectioning
% 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.
%
%
% \clearpage
%
% \section{Section depths and \HTML\ headings}
% \label{sec:stackdepths}
% \gindex{HTML>headings}
% \gindex{section>depths}\gindex{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}
%
% ^^A *source
%
% 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.
%
% \gindex{numbers>left margin}\gindex{line numbers}
% \gindex{margin>numbers}\gindex{margin>tags}
% \documentationnotes
% \gindex{warning icon}\gindex{danger icon}\gindex{icon>warning}
% \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 — \prog{pdflatex}, \prog{lualatex}, \prog{xelatex}}
%
% \changes{v0.16}{2016/04/07}{Added XeLaTeX, LuaLaTeX support.}
% See: \url{http://tex.stackexchange.com/a/47579}.
%
% Detects \XeTeX{} and \LuaLaTeX:
% \gindex{Xe\LaTeX>detection}\gindex{Lua\LaTeX>detection}
%
%    \begin{macrocode}
\RequirePackage{iftex}
\newif\ifxetexorluatex
\ifXeTeX
    \xetexorluatextrue
\else
    \ifLuaTeX
        \xetexorluatextrue
    \else
        \xetexorluatexfalse
    \fi
\fi

\ifLuaTeX
\RequirePackage{luatex85}% until the geometry package is updated
\fi

\RequirePackage{ifpdf}
%    \end{macrocode}
%
% \changes{v0.63}{2018/11/25}{Added p\TeX support.}
%
%    \begin{macrocode}
\RequirePackage{ifptex}
%    \end{macrocode}
%
%
%
% \section{Early package requirements}
%
% \DescribePackage{etoolbox}
% Provides \cs{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
% \brand{Windows} OS.
%
%    \begin{macrocode}
\RequirePackage{ifplatform}% sense op-system platform
%    \end{macrocode}
%
%
%
%
% \DescribePackage{letltxmacro}
%
%    \begin{macrocode}
\RequirePackage{letltxmacro}
%    \end{macrocode}
%
%
%
% \section{Package load order}
%
% \changes{v0.21}{2017/02/22}{Add: Errors for misplaced packages.}
%
%
% Several packages must never be used with \pkg{lwarp},
% others should only be loaded before \pkg{lwarp},
% and others should only be loaded after.
% The \pkg{lwarp} core checks most of these cases.
% In some \filenm{lwarp-*} packages, \cs{LWR@loadbefore} is used to trigger an error
% if they are loaded after \pkg{lwarp}, while additional code provides necessary
% patches for when they are loaded before.
%
% Packages which must be loaded after \pkg{lwarp} are enfoced by
% a large number of \cs{LWR@loadafter} statements, below.
% Some packages are emulated by \pkg{memoir}, and so these are tested by
% \cs{LWR@notmemoirloadafter}, which does not cause an error if \pkg{memoir} is used.
%
% \cs{LWR@checkloadfilename} is used to check each filename to see if
% it must never be loaded, or must always be loaded before \pkg{lwarp}.
%
%
% \subsection{Tests of package load order}
%
% \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@notmemoirloadafter} \marg{packagename} \quad
% Error if not \pkg{memoir} class and this package was loaded before \pkg{lwarp}.
%
% \pkg{memoir} emulates many packages, and pretends that they have already been loaded.
%
% \changes{v0.45}{2017/12/03}{Added.}
%    \begin{macrocode}
\@ifclassloaded{memoir}
{\newcommand*{\LWR@notmemoirloadafter}[1]{}}
{\LetLtxMacro\LWR@notmemoirloadafter\LWR@loadafter}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@notltjloadafter} \marg{packagename} \quad
% Error if not a \pkg{ltjs*} class and this package was loaded before \pkg{lwarp}.
%
% \changes{v0.63}{2018/11/24}{Added.}
% \changes{v0.63}{2018/12/20}{Added more classes.}
%    \begin{macrocode}
\LetLtxMacro\LWR@notltjloadafter\LWR@loadafter

\@ifclassloaded{ltjarticle}{\renewcommand*{\LWR@notltjloadafter}[1]{}}{}
\@ifclassloaded{ltjbook}{\renewcommand*{\LWR@notltjloadafter}[1]{}}{}
\@ifclassloaded{ltjreport}{\renewcommand*{\LWR@notltjloadafter}[1]{}}{}
\@ifclassloaded{ltjsarticle}{\renewcommand*{\LWR@notltjloadafter}[1]{}}{}
\@ifclassloaded{ltjsbook}{\renewcommand*{\LWR@notltjloadafter}[1]{}}{}
\@ifclassloaded{ltjsreport}{\renewcommand*{\LWR@notltjloadafter}[1]{}}{}
\@ifclassloaded{ltjspf}{\renewcommand*{\LWR@notltjloadafter}[1]{}}{}
\@ifclassloaded{ltjskiyou}{\renewcommand*{\LWR@notltjloadafter}[1]{}}{}
\@ifclassloaded{ltjtarticle}{\renewcommand*{\LWR@notltjloadafter}[1]{}}{}
\@ifclassloaded{ltjtbook}{\renewcommand*{\LWR@notltjloadafter}[1]{}}{}
\@ifclassloaded{ltjtreport}{\renewcommand*{\LWR@notltjloadafter}[1]{}}{}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@loadbefore} \marg{packagename} \quad
% Error if this package is loaded 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@checkloadbefore}
%   \marg{thispackagename} \marg{packagename}
%
% If package names match, error if it is loaded after \pkg{lwarp}.
%
% \changes{v0.63}{2018/12/02}{Added.}
%
%    \begin{macrocode}
\newcommand*{\LWR@checkloadbefore}[2]{%
    \edef\LWR@tempone{#1}%
    \ifdefstring{\LWR@tempone}{#2}{%
        \LWR@loadbefore{#1}%
    }{}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@loadnever} \marg{badpackagename} \marg{replacementpkgnames}
%
% 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}
%
%
% \begin{macro}{\LWR@checkloadnever}
%       \marg{thispackagename} \marg{badpackagename} \marg{replacementpkgnames}
%
% If this package name is the bad packagename, suggest the replacements instead.
%
% \changes{v0.63}{2018/12/01}{Added.}
%
%    \begin{macrocode}
\newcommand*{\LWR@checkloadnever}[3]{%
    \edef\LWR@tempone{#1}%
    \ifdefstring{\LWR@tempone}{#2}{%
        \LWR@loadnever{#2}{#3}%
    }{}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@earlyloadnever} \marg{badpackagename} \marg{replacementpkgname}
%
% The first package is not supported, so tell the user to use the second instead.
% This version checks immediately for packages which may have been loaded before \pkg{lwarp}.
%
% \changes{v0.54}{2018/04/06}{Added.}
%
%    \begin{macrocode}
\newcommand*{\LWR@earlyloadnever}[2]{%
\@ifpackageloaded{#1}{%
\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}
%
%
% \begin{macro}{\LWR@earlyclassloadnever} \marg{badclassname} \marg{replacementclassname}
%
% The first class is not supported, so tell the user to use the second instead.
% This version checks immediately for classes which may have been loaded before \pkg{lwarp}.
%
% \changes{v0.63}{2018/11/25}{Added.}
%
%    \begin{macrocode}
\newcommand*{\LWR@earlyclassloadnever}[2]{%
\@ifclassloaded{#1}{%
\PackageError{lwarp}
{Class #1 is not supported by lwarp's HTML conversion.
Class(es) #2 may be useful instead}
{Class #1 might conflict with lwarp in some way,
or is superceded by another class.
For a possible alternative, see class(es) #2.}
}{}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Error for disallowed packages and classes loaded before lwarp}
% \changes{v0.54}{2018/04/06}{Added early check for disallowed packages.}
% \changes{v0.54}{2018/09/26}{Never load \pkg{aecompl}.}
% \changes{v0.62}{2018/11/18}{Added early checks for \pkg{CJK}, \pkg{CJKutf8}.}
% \changes{v0.65}{2018/12/15}{Added early checks for \pkg{jarticle}, \pkg{tarticle}, and related.}
% \changes{v0.66}{2019/01/04}{Added early checks for \pkg{colortab}, \pkg{epsf}, \pkg{hyper},
%       \pkg{picinpar}, \pkg{picins}, \pkg{sistyle}, \pkg{ucs}.}
%
%    \begin{macrocode}
\LWR@earlyclassloadnever{jarticle}{ujarticle}
\LWR@earlyclassloadnever{jbook}{ujbook}
\LWR@earlyclassloadnever{jreport}{ujreport}
\LWR@earlyclassloadnever{tarticle}{utarticle}
\LWR@earlyclassloadnever{tbook}{utbook}
\LWR@earlyclassloadnever{treport}{utreport}
\LWR@earlyloadnever{ae}{cm-super, lmodern}
\LWR@earlyloadnever{aecompl}{cm-super, lmodern}
\LWR@earlyloadnever{aecc}{cm-super, lmodern}
\LWR@earlyloadnever{boxedminipage}{boxedminipage2e}
\LWR@earlyloadnever{caption2}{caption}
% \LWR@earlyloadnever{ccaption}{caption}% might be preloaded by memoir
%    \end{macrocode}
% The older \pkg{CJK} and \pkg{CJKutf8} only work with \pkg{xeCJK}:
%    \begin{macrocode}
\@ifpackageloaded{xeCJK}{}{
    \LWR@earlyloadnever{CJK}{ctex, xeCJK}
    \LWR@earlyloadnever{CJKutf8}{ctex, xeCJK}
}
%    \end{macrocode}
% \pkg{bxcjkatype} is based on \pkg{CJK}:
%    \begin{macrocode}
\LWR@earlyloadnever{bxcjkjatype}{upLaTeX, bxjsarticle, ujarticle, utarticle}
%    \end{macrocode}
% \pkg{hangul} is not in TeXLive, and is not tested:
%    \begin{macrocode}
\LWR@earlyloadnever{hangul}{kotex, xetexko, luatexko}
%    \end{macrocode}
% Others:
%    \begin{macrocode}
\LWR@earlyloadnever{colortab}{colortbl}
\LWR@earlyloadnever{epsf}{graphicx}
\LWR@earlyloadnever{fancyheadings}{fancyhdr}
\LWR@earlyloadnever{glossary}{glossaries}
\LWR@earlyloadnever{hyper}{hyperref}
\LWR@earlyloadnever{picinpar}{floatflt, wrapfig}
\LWR@earlyloadnever{picins}{floatflt, wrapfig}
\LWR@earlyloadnever{sistyle}{siunitx}
\LWR@earlyloadnever{t1enc}{fontenc, inputenc, inputenx}
\LWR@earlyloadnever{ucs}{inputenc, inputencx}
\LWR@earlyloadnever{wasysym}{textcomp, amssymb, amsfonts, mnsymbol, fdsymbol}
%    \end{macrocode}
%
%
% \subsection{Enforcing package loading after \pkg{lwarp}}
%
% 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.}
% \changes{v0.45}{2017/12/03}{Allows \pkg{memoir}'s preloaded packages.}
% \changes{v0.58}{2018/06/21}{Fix: \pkg{memoir} and \pkg{ccaption}.}
%
% The following packages must be loaded after \pkg{lwarp}:
% ^^A *loadafter
%    \begin{macrocode}
\LWR@loadafter{2in1}
\LWR@loadafter{2up}
\LWR@loadafter{a4}
\LWR@loadafter{a4wide}
\LWR@loadafter{a5comb}
\LWR@notmemoirloadafter{abstract}
\LWR@loadafter{academicons}
\LWR@loadafter{accsupp}
\LWR@loadafter{acro}
\LWR@loadafter{acronym}
\LWR@loadafter{adjmulticol}
\LWR@loadafter{addlines}
\LWR@loadafter{ae}
\LWR@loadafter{aecc}
\LWR@loadafter{afterpage}
\LWR@loadafter{algorithm2e}
\LWR@loadafter{algorithmicx}
\LWR@loadafter{alltt}
\LWR@loadafter{amsmath}
\LWR@loadafter{amsthm}
\LWR@loadafter{anonchap}
\LWR@loadafter{anysize}
\LWR@notmemoirloadafter{appendix}
\LWR@loadafter{ar}
\LWR@loadafter{arabicfront}
\LWR@notmemoirloadafter{array}
\LWR@loadafter{arydshln}
\LWR@loadafter{asymptote}
% \LWR@loadafter{atbegshi}% used by morewrites
\LWR@loadafter{attachfile}
\LWR@loadafter{attachfile2}
\LWR@loadafter{authblk}
\LWR@loadafter{axessibility}
\LWR@loadafter{axodraw2}
\LWR@loadafter{backref}
\LWR@loadafter{balance}
\LWR@loadafter{bbding}
\LWR@loadafter{bigdelim}
\LWR@loadafter{bigstrut}
\LWR@loadafter{bitpattern}
\LWR@loadafter{blowup}
\LWR@loadafter{booklet}
\LWR@loadafter{bookmark}
\LWR@notmemoirloadafter{booktabs}
\LWR@loadafter{bophook}
\LWR@loadafter{bounddvi}
\LWR@loadafter{boxedminipage}
\LWR@loadafter{boxedminipage2e}
\LWR@loadafter{breakurl}
\LWR@loadafter{breqn}
\LWR@loadafter{bsheaders}
\LWR@loadafter{bxpapersize}
\LWR@loadafter{bytefield}
\LWR@loadafter{cancel}
\LWR@loadafter{canoniclayout}
\LWR@loadafter{caption}
\LWR@loadafter{caption2}
\LWR@loadafter{cases}
% \LWR@loadafter{ccaption}% may be preloaded by memoir
\LWR@loadafter{changebar}
\LWR@notmemoirloadafter{changepage}
\LWR@loadafter{changes}
\LWR@loadafter{chappg}
\LWR@loadafter{chapterbib}
\LWR@loadafter{chemfig}
\LWR@loadafter{chemformula}
\LWR@loadafter{chemgreek}
\LWR@loadafter{chemmacros}
\LWR@loadafter{chemnum}
\LWR@loadafter{chkfloat}
\LWR@notmemoirloadafter{chngpage}
\LWR@loadafter{cite}
\LWR@loadafter{cmdtrack}
\LWR@loadafter{color}
\LWR@loadafter{colortbl}
\LWR@loadafter{continue}
\LWR@loadafter{copyrightbox}
\LWR@notmemoirloadafter{crop}
% ctex must be loaded before lwarp
\LWR@loadafter{cuted}
\LWR@loadafter{cutwin}
\LWR@loadafter{dblfloatfix}
\LWR@loadafter{dblfnote}
\LWR@notmemoirloadafter{dcolumn}
\LWR@loadafter{diagbox}
\LWR@loadafter{dingbat}
\LWR@loadafter{dprogress}
\LWR@loadafter{draftcopy}
\LWR@loadafter{draftfigure}
\LWR@loadafter{draftwatermark}
\LWR@loadafter{easy-todo}
\LWR@loadafter{ebook}
\LWR@loadafter{ed}
\LWR@loadafter{ellipsis}
\LWR@loadafter{embrac}
\LWR@loadafter{emptypage}
\LWR@loadafter{endfloat}
\LWR@loadafter{endheads}
\LWR@loadafter{endnotes}
\LWR@notmemoirloadafter{enumerate}
\LWR@loadafter{enumitem}
\LWR@notmemoirloadafter{epigraph}
\LWR@loadafter{epsfig}
\LWR@loadafter{epstopdf}
\LWR@loadafter{epstopdf-base}
\LWR@loadafter{errata}
\LWR@loadafter{eso-pic}
\LWR@loadafter{eurosym}
\LWR@loadafter{everypage}
\LWR@loadafter{everyshi}
\LWR@loadafter{extramarks}
\LWR@loadafter{fancybox}
\LWR@loadafter{fancyhdr}
\LWR@loadafter{fancyheadings}
\LWR@loadafter{fancyref}
\LWR@loadafter{fancytabs}
\LWR@loadafter{fancyvrb}
\LWR@loadafter{figcaps}
\LWR@loadafter{figsize}
\LWR@loadafter{fitbox}
\LWR@loadafter{fix2col}
\LWR@loadafter{fixme}
\LWR@loadafter{fixmetodonotes}
\LWR@loadafter{flafter}
\LWR@loadafter{flippdf}
\LWR@loadafter{float}
\LWR@loadafter{floatflt}
\LWR@loadafter{floatpag}
\LWR@loadafter{floatrow}
\LWR@loadafter{fltrace}
\LWR@loadafter{flushend}
\LWR@loadafter{fnbreak}
\LWR@loadafter{fncychap}
\LWR@loadafter{fnlineno}
\LWR@loadafter{fnpos}
\LWR@loadafter{fontawesome}
\LWR@loadafter{fontawesome5}
% fontenc must be loaded before lwarp
% fontspec must be loaded before lwarp
\LWR@loadafter{footmisc}
\LWR@loadafter{footnote}
\LWR@loadafter{footnotehyper}
\LWR@loadafter{footnoterange}
\LWR@loadafter{footnpag}
\LWR@loadafter{foreign}
\LWR@loadafter{forest}
\LWR@loadafter{framed}
\LWR@loadafter{ftnright}
\LWR@loadafter{fullminipage}
\LWR@loadafter{fullpage}
\LWR@loadafter{fullwidth}
\LWR@loadafter{fwlw}
\LWR@loadafter{gentombow}
% geometry is always loaded by lwarp, and lwarp-geometry is AtBeginDocument
\LWR@loadafter{gmeometric}
\LWR@loadafter{glossaries}
% \LWR@loadafter{graphics}% pre-loaded by xunicode
% \LWR@loadafter{graphicx}% pre-loaded by xunicode
\LWR@loadafter{gloss}
\LWR@loadafter{glossary}
\LWR@loadafter{grffile}
\LWR@loadafter{grid}
\LWR@loadafter{grid-system}
\LWR@loadafter{gridset}
\LWR@loadafter{hang}
\LWR@loadafter{hanging}
\LWR@loadafter{hypcap}
\LWR@loadafter{hypdestopt}
\LWR@loadafter{hypernat}
\LWR@loadafter{hyperref}
\LWR@loadafter{hyperxmp}
\LWR@loadafter{hyphenat}
\LWR@loadafter{idxlayout}
\LWR@loadafter{ifoddpage}
\LWR@loadafter{imakeidx}
\LWR@notmemoirloadafter{index}
% inputenc must be loaded before lwarp
% inputenx must be loaded before lwarp
\LWR@loadafter{intopdf}
\LWR@loadafter{karnaugh-map}
\LWR@loadafter{keyfloat}
\LWR@loadafter{layaureo}
\LWR@loadafter{layout}
\LWR@loadafter{leading}
\LWR@loadafter{letterspace}
\LWR@loadafter{lettrine}
\LWR@loadafter{lineno}
\LWR@loadafter{lips}
\LWR@loadafter{listings}
\LWR@loadafter{longtable}
\LWR@loadafter{lscape}
\LWR@loadafter{ltablex}
\LWR@loadafter{ltcaption}
\LWR@loadafter{ltxgrid}
\LWR@loadafter{ltxtable}
\LWR@loadafter{lua-check-hyphen}
\LWR@loadafter{lua-visual-debug}
\LWR@loadafter{luacolor}
\LWR@loadafter{luatodonotes}
\LWR@loadafter{magaz}
\LWR@notmemoirloadafter{makeidx}
\LWR@loadafter{marginfit}
\LWR@loadafter{marginfix}
\LWR@loadafter{marginnote}
\LWR@loadafter{marvosym}
\LWR@loadafter{mcaption}
\LWR@loadafter{mdframed}
\LWR@loadafter{memhfixc}
\LWR@loadafter{metalogo}
\LWR@loadafter{mhchem}
\LWR@loadafter{microtype}
\LWR@loadafter{midfloat}
\LWR@loadafter{midpage}
\LWR@loadafter{morefloats}
\LWR@notmemoirloadafter{moreverb}
% morewrites must be loaded before lwarp
\LWR@notmemoirloadafter{mparhack}
\LWR@loadafter{multicap}
%\LWR@loadafter{multicol}% loaded by ltxdoc
\LWR@loadafter{multicolrule}
\LWR@loadafter{multirow}
\LWR@loadafter{multitoc}
\LWR@loadafter{musicography}
\LWR@loadafter{nameauth}
\LWR@loadafter{nameref}
\LWR@loadafter{natbib}
\LWR@notmemoirloadafter{nccfancyhdr}
\LWR@notmemoirloadafter{needspace}
% newclude must be loaded before lwarp
\LWR@loadafter{newtxmath}
% newunicodechar must be loaded before lwarp
\LWR@notmemoirloadafter{nextpage}
\LWR@loadafter{nicefrac}
\LWR@loadafter{nomencl}
\LWR@loadafter{nonfloat}
\LWR@loadafter{nonumonpart}
\LWR@loadafter{nopageno}
\LWR@loadafter{notes}
\LWR@loadafter{notespages}
\LWR@loadafter{nowidow}
\LWR@loadafter{ntheorem}
\LWR@loadafter{octave}
\LWR@loadafter{overpic}
\LWR@loadafter{pagegrid}
\LWR@notmemoirloadafter{pagenote}
\LWR@loadafter{pagesel}
\LWR@loadafter{paralist}
\LWR@loadafter{parnotes}
\LWR@notmemoirloadafter{parskip}
\LWR@loadafter{pbox}
\LWR@loadafter{pdfcomment}
\LWR@loadafter{pdflscape}
\LWR@loadafter{pdfmarginpar}
\LWR@loadafter{pdfpages}
\LWR@loadafter{pdfprivacy}
\LWR@loadafter{pdfrender}
\LWR@loadafter{pdfsync}
\LWR@loadafter{pdftricks}
\LWR@loadafter{pdfx}
\LWR@loadafter{pfnote}
\LWR@loadafter{phfqit}
\LWR@loadafter{pifont}
\LWR@loadafter{placeins}
\LWR@loadafter{plarray}
\LWR@loadafter{plarydshln}
\LWR@loadafter{plextarray}
\LWR@loadafter{plextarydshln}
\LWR@loadafter{plcolortbl}
\LWR@loadafter{plextdelarray}
\LWR@loadafter{prelim2e}
\LWR@loadafter{prettyref}
\LWR@loadafter{preview}
\LWR@loadafter{psfrag}
\LWR@loadafter{psfragx}
\LWR@loadafter{pst-eps}
\LWR@loadafter{pstool}
\LWR@loadafter{pstricks}
% \LWR@loadafter{pxatbegshi}% may be used by morewrites
\LWR@loadafter{pxeveryshi}
\LWR@loadafter{pxftnright}
\LWR@loadafter{pxjahyper}
\LWR@loadafter{quotchap}
\LWR@loadafter{quoting}
\LWR@loadafter{ragged2e}
\LWR@loadafter{realscripts}
\LWR@loadafter{refcheck}
\LWR@loadafter{register}
\LWR@loadafter{relsize}
\LWR@loadafter{repeatindex}
\LWR@loadafter{resizegather}
\LWR@loadafter{rmpage}
\LWR@loadafter{romanbar}
\LWR@loadafter{romanbarpagenumber}
\LWR@loadafter{rotating}
\LWR@loadafter{rotfloat}
\LWR@loadafter{rviewport}
\LWR@loadafter{savetrees}
% scalefnt is loaded by babel-french
\LWR@loadafter{schemata}
\LWR@loadafter{scrextend}
\LWR@loadafter{scrhack}
\LWR@loadafter{scrlayer}
\LWR@loadafter{scrlayer-notecolumn}
\LWR@loadafter{scrlayer-scrpage}
\LWR@loadafter{scrpage2}
\LWR@loadafter{section}
\LWR@loadafter{sectionbreak}
\LWR@loadafter{sectsty}
\LWR@loadafter{semantic-markup}
\LWR@notmemoirloadafter{setspace}
\LWR@loadafter{shadow}
\LWR@notmemoirloadafter{showidx}
\LWR@loadafter{showkeys}
\LWR@loadafter{sidecap}
\LWR@loadafter{sidenotes}
\LWR@loadafter{SIunits}
\LWR@loadafter{siunitx}
\LWR@loadafter{soul}
\LWR@loadafter{soulpos}
\LWR@loadafter{soulutf8}
\LWR@loadafter{splitidx}
\LWR@loadafter{srcltx}
\LWR@loadafter{srctex}
\LWR@loadafter{stabular}
\LWR@notltjloadafter{stfloats}
\LWR@loadafter{struktex}
\LWR@loadafter{subcaption}
\LWR@loadafter{subfig}
\LWR@loadafter{subfigure}
\LWR@loadafter{supertabular}
\LWR@loadafter{t1inc}
\LWR@loadafter{tabls}
\LWR@notmemoirloadafter{tabularx}
\LWR@loadafter{tabulary}
\LWR@loadafter{tascmac}
\LWR@loadafter{textarea}
% \LWR@loadafter{textcomp}% maybe before lwarp with font packages
\LWR@loadafter{textfit}
\LWR@loadafter{textpos}
\LWR@loadafter{theorem}
\LWR@loadafter{thinsp}
\LWR@loadafter{threadcol}
\LWR@loadafter{threeparttable}
\LWR@loadafter{thumb}
\LWR@loadafter{thumbs}
\LWR@loadafter{tikz}
\LWR@loadafter{titleps}
\LWR@loadafter{titlesec}
\LWR@loadafter{titletoc}
\LWR@notmemoirloadafter{titling}
% \LWR@loadafter{tocbasic}% preloaded by koma-script classes
\LWR@notmemoirloadafter{tocbibind}
\LWR@loadafter{tocenter}
\LWR@notmemoirloadafter{tocloft}
\LWR@loadafter{tocstyle}
\LWR@loadafter{todo}
\LWR@loadafter{todonotes}
\LWR@loadafter{tram}
\LWR@loadafter{transparent}
\LWR@loadafter{trimclip}
\LWR@loadafter{trivfloat}
\LWR@loadafter{truncate}
\LWR@loadafter{turnthepage}
\LWR@loadafter{twoup}
%    \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{typicons}
% \LWR@loadafter{ulem}% preloaded by ctexart and related classes
\LWR@loadafter{umoline}
\LWR@loadafter{underscore}
\LWR@loadafter{units}
\LWR@loadafter{unitsdef}
\LWR@loadafter{upref}
\LWR@loadafter{url}
\LWR@loadafter{uspace}
\LWR@loadafter{varioref}% no lwarp package provided
\LWR@notmemoirloadafter{verse}
\LWR@loadafter{versonotes}
\LWR@loadafter{vertbars}
\LWR@loadafter{vmargin}
\LWR@loadafter{vowel}
\LWR@loadafter{vpe}
\LWR@loadafter{vwcol}
\LWR@loadafter{wallpaper}
\LWR@loadafter{watermark}
\LWR@loadafter{widows-and-orphans}
\LWR@loadafter{wrapfig}
\LWR@loadafter{xbmks}
\LWR@loadafter{xcolor}
\LWR@loadafter{xechangebar}
\LWR@loadafter{xellipsis}
% xetexko-vertical must be loaded before lwarp
\LWR@loadafter{xfakebold}
\LWR@loadafter{xfrac}
\LWR@loadafter{xltabular}
\LWR@loadafter{xltxtra}
\LWR@loadafter{xmpincl}
\LWR@loadafter{xpiano}
\LWR@loadafter{xpinyin}
\LWR@loadafter{xtab}
% xunicode must be loaded before lwarp
\LWR@loadafter{xurl}
\LWR@loadafter{xy}
\LWR@loadafter{zwpagelayout}
%    \end{macrocode}
%
%
%
%
%
% \section{MD5 hashing}
%
% The MD5 hash is used for \env{lateximage} filenames for \SVG\ math.
%
%    \begin{macrocode}
\newcommand{\LWR@mdfive}[1]{%
\PackageError{lwarp}
{No MD5 macro was found.}
{Lwarp must find the macros pdfmdfivesum or mdfivesum.}
}
%    \end{macrocode}
%
% The default for pdf\LaTeX, \DVI\LaTeX, up\LaTeX, etc:
% \changes{v0.63}{2018/11/30}{Fix: Default \cs{LWR@mdfive}.}
%    \begin{macrocode}
\let\LWR@mdfive\pdfmdfivesum
%    \end{macrocode}
%
% For \LuaLaTeX:
%    \begin{macrocode}
\ifLuaTeX
\RequirePackage{pdftexcmds}
\let\LWR@mdfive\pdf@mdfivesum
\fi
%    \end{macrocode}
%
% For \XeLaTeX:
%    \begin{macrocode}
\ifXeTeX
\@ifundefined{pdffivesum}{}
    {\let\LWR@mdfive\pdfmdfivesum}
\@ifundefined{mdfivesum}{}
    {\let\LWR@mdfive\mdfivesum}
\fi
%    \end{macrocode}
%
%
% \section{pdf\LaTeX\ T1 and \UTF-8 encoding}
%
% When using pdf\LaTeX, \pkg{lwarp} requires T1 encoding, and recommends \UTF-8 encoding.
%
% If some other input encoding is already defined, \pkg{lwarp} will
% try to use it instead, and hope for the best.
%
% \XeLaTeX\ and Lua\LaTeX\ are both \UTF-8 by nature.
%
% \changes{v0.44}{2017/11/16}{If pdfLaTeX, require T1 and \UTF-8 encoding.}
% \changes{v0.52}{2018/03/26}{If pdfLaTeX, allow other input encoding.}
% \changes{v0.63}{2018/11/25}{p\TeX: Encoding.}
%
% \begin{macro}{\LWR@pdfencoding}
% Sets \optn{T1}, and also \optn{utf8} if not already set.
%    \begin{macrocode}
\newcommand*{\LWR@pdfencoding}{%
    \RequirePackage[T1]{fontenc}

    \@ifpackageloaded{inputenc}{}{
        \@ifpackageloaded{inputenx}{}{
            \RequirePackage[utf8]{inputenc}
        }
    }
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\ifPDFTeX% pdflatex or dvi latex
    \LWR@pdfencoding
\fi

\ifpTeX
    \LWR@pdfencoding
\fi
%    \end{macrocode}
%
%
%
% \section{Unicode input characters}
% \changes{v0.18}{2016/05/17}{PDF Unicode input characters.}
% \gindex{Unicode>input characters}
%
% \codeall
%
% If using \prog{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.
%
% \changes{v0.63}{2018/11/25}{p\TeX: No \pkg{newunicodechar}.}
%    \begin{macrocode}
\ifpTeX
\else
\RequirePackage{newunicodechar}

\newunicodechar{⨯}{\texttimes}

\ifPDFTeX% pdflatex or dvi latex
\newunicodechar{ﬀ}{ff}% the first arguments are ligatures
\newunicodechar{ﬁ}{fi}
\newunicodechar{ﬂ}{fl}
\newunicodechar{ﬃ}{ffi}
\newunicodechar{ﬄ}{ffl}
\newunicodechar{—}{---}
\newunicodechar{–}{--}
\fi

\fi
%    \end{macrocode}
%
%
% \section{Upright quotes}
%
% In PDF\TeX, preserve upright quotes in verbatim text.
% \pkg{upquote} also loads \pkg{textcomp}.
%
% \changes{v0.63}{2018/11/25}{p\TeX: Load \pkg{upquote}.}
%    \begin{macrocode}
\ifPDFTeX
\RequirePackage{upquote}
\fi

\ifpTeX
    \RequirePackage{upquote}
\fi
%    \end{macrocode}
%
%
%
% \section{Miscellaneous tools}
%
%
% \begin{macro}{\LWR@providelength} \marg{\cs{lengthname}}
% Provides the length if it isn't defined yet.
%
% Used to provide source compatibility for lengths which will be ignored,
% but might or might not be already provided by other packages.
%
% \changes{v0.46}{2018/01/23}{Added.}
%    \begin{macrocode}
\newcommand*\LWR@providelength[1]{%
    \ifdeflength{#1}{}{\newlength{#1}}%
}
%    \end{macrocode}
% \end{macro}
%
%
% Prints a length in the given units, without printing the unit itself.
% \begin{macro}{\LWR@convertto} \marg{dest unit} \marg{length}
%    \begin{macrocode}
\newcommand*{\LWR@convertto}[2]{\strip@pt\dimexpr #2*65536/\number\dimexpr 1#1}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@patcherror} \marg{packagename} \marg{macroname}
%
% Prints an error if could not patch a macro.
%    \begin{macrocode}
\newcommand*{\LWR@patcherror}[2]{%
\PackageError{lwarp}
{Unable to patch package #1, macro #2}
{Please contact the author of the lwarp package.}
}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\LWR@isolate} \marg{text}
%   Isolates Chinese characters from the surrounding text.
%   This is required to avoid extra spaces on either side of the Chinese
%   characters, especially when written to a file.
%
% \changes{v0.62}{2018/11/17}{Added.}
% \changes{v0.63}{2018/11/24}{Fix for \pkg{xeCJK}.}
%
%    \begin{macrocode}
\newcommand{\LWR@isolate}[1]{#1}%

\@ifpackageloaded{ctexpatch}{
    \renewcommand{\LWR@isolate}[1]{\null#1\null}%
}{}

\@ifpackageloaded{xeCJK}{
    \renewcommand{\LWR@isolate}[1]{\null#1\null}%
}{}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@firstoffour} \marg{first} \marg{second} \marg{third} \marg{fourth}
% \changes{v0.63}{2019/01/25}{Added.}
% \begin{macro}{\LWR@secondoffour} \marg{first} \marg{second} \marg{third} \marg{fourth}
% \begin{macro}{\LWR@thirdoffour} \marg{first} \marg{second} \marg{third} \marg{fourth}
% \begin{macro}{\LWR@fourthoffour} \marg{first} \marg{second} \marg{third} \marg{fourth}
%
% Expands to the nth  of the four arguments.
% Used for extra cross referencing.
%
%    \begin{macrocode}
\long\def\LWR@firstoffour#1#2#3#4{#1}
\long\def\LWR@secondoffour#1#2#3#4{#2}
\long\def\LWR@thirdoffour#1#2#3#4{#3}
\long\def\LWR@fourthoffour#1#2#3#4{#4}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \section{Operating-System portability}
% \label{sec:OSportability}
% \changes{v0.11}{2016/03/11}{Added section: Operating-System portability.}
%
% \osportabilityusage
%
%
%
% \subsection{Literal characters}
%
% Literal characters to be used in \optn{PrintLatexCmd} and \optn{HTMLLatexCmd}.
% These are defined without |@| to easily allow their inclusion in the user's document.
%
% The literal |%| character:
%    \begin{macrocode}
\let\LWRpercent\@percentchar
%    \end{macrocode}
%
%
% The literal |$| character:
%    \begin{macrocode}
\catcode`\$=12
\def\LWRdollar{$}
\catcode`\$=3
%    \end{macrocode}
%
%
% The literal |&| character:
%    \begin{macrocode}
\catcode`\&=12
\def\LWRamp{&}
\catcode`\&=4
%    \end{macrocode}
%
%
% The literal |\| character.
% The ampersand is temporarily set to the escape character during the
% definition of the backslash macro.
%    \begin{macrocode}
\catcode`\&=0
&catcode`&\=12
&def&LWRbackslash{\}
&catcode`&\=0
\catcode`\&=4
%    \end{macrocode}
%
%
% The literal |{| character.
% The ampersand is temporarily set to the begin group character during the
% definition of the leftbrace macro.
%    \begin{macrocode}
\catcode`\&=1
\catcode`\{=12
\def\LWRleftbrace&{}
\catcode`\{=1
\catcode`\&=4
%    \end{macrocode}
%
%
% The literal |}| character.
% The ampersand is temporarily set to the end group character during the
% definition of the leftbrace macro.
%    \begin{macrocode}
\catcode`\&=2
\catcode`\}=12
\def\LWRrightbrace{}&
\catcode`\}=2
\catcode`\&=4
%    \end{macrocode}
%
%
% The literal |#| character:
%    \begin{macrocode}
\catcode`\#=12
\def\LWRhash{#}
\catcode`\#=6
%    \end{macrocode}
%
%
% \begin{macro}{\LWRopquote}
% The operating system's quote mark, \brand{Unix} default.
% For \brand{Windows}, see \cs{LWR@setOSWindows}, below.
%    \begin{macrocode}
\def\LWRopquote{'}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWRopseq}
% The operating system's sequential execution command, \brand{Unix} default.
% For \brand{Windows}, see \cs{LWR@setOSWindows}, below.
% \changes{v0.61}{2018/10/06}{Added spaces.}
%    \begin{macrocode}
\def\LWRopseq{\space\LWRamp\LWRamp\space\space}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Common portability code}
%
% \DescribeBoolean{usingOSWindows} Set if the \optn{OSWindows} option is used,
% or if \brand{Windows} is automatically detected.
%    \begin{macrocode}
\newbool{usingOSWindows}
\boolfalse{usingOSWindows}
%    \end{macrocode}


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

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


% \subsection{\brand{MS-Windows}}

% For \brand{MS-Windows}:
%
% \begin{macro}{\LWR@setOSWindows}
% Set defaults for the \brand{MS-Windows} operating system.
% \pkg{lwarp} attempts to auto-detect the operatings system,
% and the \optn{OSWindows} option may also be used to force
% \brand{MS-Windows} compatibility.
%
% \changes{v0.20}{2016/12/19}{Auto-detects operating system.}
%
%    \begin{macrocode}
\newcommand*{\LWR@setOSWindows}
{
\booltrue{usingOSWindows}
\renewcommand*{\OSPathSymbol}{\@backslashchar}
\def\LWRopquote{"}
\def\LWRopseq{\space\LWRamp\space\space}
}
%    \end{macrocode}
% \end{macro}
%
% Test for windows during compile.  The user may also specify
% \optn{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}


% \begin{macro}{\lwarpsetup}
% A user interface to set the keys:
% \changes{v0.61}{2018/09/21}{Added.}
%    \begin{macrocode}
\newcommand{\lwarpsetup}[1]{\setkeys{LWR}{#1}}
%    \end{macrocode}
% \end{macro}


% \DescribeBoolean{warpingprint}
% \DescribeBoolean{warpingHTML}
% \DescribeBoolean{mathjax}
% \DescribeBoolean{LWR@origmathjax}
% ^^A \DescribeBoolean{mathKaTeX}
%
% Set to true/false depending on the package option selections for
% print/\HTML/\EPUB\ output and mathsvg/mathjax.
%
% \optn{LWR@origmathjax} remembers the original setting to be restored
% by \cs{displaymathnormal}.
%    \begin{macrocode}
\newbool{warpingprint}
\newbool{warpingHTML}
\newbool{mathjax}
\newbool{LWR@origmathjax}
%    \end{macrocode}
% ^^A %    \begin{macrocode}
% ^^A \newbool{mathKaTeX}
% ^^A %    \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 \optn{warpprint} option is given,
% boolean |warpingprint| is true and boolean |warpingHTML| is false,
% and may be used for \cs{ifbool} tests.
%
%
%    \begin{macrocode}
\DeclareVoidOption{warpprint}{%
\PackageInfo{lwarp}{Using option 'warpprint'}
\booltrue{warpingprint}%
\boolfalse{warpingHTML}%
}
%    \end{macrocode}

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


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

% ^^A \DescribeOption{mathKaTeX}
% ^^A Option \optn{mathKaTeX} selects Ka\TeX\ math display:
% ^^A \gindex{math>mathKaTeX=\optn{mathKaTeX} option}
% ^^A \gindex{KaTeX=Ka\TeX>mathKaTeX=\optn{mathKaTeX} option}
% ^^A If the \optn{mathKaTeX} option is given, boolean |mathKaTeX| is true,
% ^^A may be used for \cs{ifbool} tests.
% ^^A Boolean |mathjax| is also set true, as most code is shared with
% ^^A \brand{MathJax} functions.
% ^^A    \begin{macrocode}
% ^^A \DeclareVoidOption{mathKaTeX}{%
% ^^A \PackageInfo{lwarp}{Using option 'mathKaTeX'}
% ^^A \booltrue{mathjax}%
% ^^A \booltrue{LWR@origmathjax}%
% ^^A \booltrue{mathKaTeX}%
% ^^A }
% ^^A   \end{macrocode}



% \DescribeOption{BaseJobname}
% \DescribeDefault{\cs{jobname}}
% Option \optn{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{ImagesDirectory}
% \DescribeDefault{\cs{jobname}-images}
% Option \optn{ImagesDirectory} sets the name of the directory
% to use for the \env{lateximage} images.
%
% \changes{v0.66}{2019/01/27}{Added option \optn{ImagesDirectory}.}
%    \begin{macrocode}
\DeclareStringOption[\BaseJobname-images]{ImagesDirectory}
%    \end{macrocode}


% \DescribeOption{ImagesName}
% \DescribeDefault{image-}
% Option \optn{ImagesName} sets the prefix
% to use for the \env{lateximage} images.
%
% \changes{v0.66}{2019/01/27}{Added option \optn{ImagesName}.}
%    \begin{macrocode}
\DeclareStringOption[image-]{ImagesName}
%    \end{macrocode}


% \DescribeOption{makeindexStyle} Selects a custom |.ist| file.
% \DescribeDefault{lwarp.ist}
% A customized file should be based on |lwarp.ist|, and must retain
% the lines related to \cs{hyperindexref}.
%
% \changes{v0.58}{2018/06/21}{Added option \optn{makeindexStyle.}}
%
%    \begin{macrocode}
\DeclareStringOption[lwarp.ist]{makeindexStyle}
%    \end{macrocode}


% \DescribeOption{xindyStyle} Selects a custom |.xdy| file.
% \DescribeDefault{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 \optn{xdyFilename} added.}
% \changes{v0.54}{2018/04/06}{Option \optn{xdyFilename} changed to \optn{xindyStyle.}}
%
%    \begin{macrocode}
\DeclareStringOption[lwarp.xdy]{xindyStyle}
%    \end{macrocode}


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


% \DescribeOption{xindyCodepage} Sets the \pkg{xindy} codepage to be assigned
% \DescribeDefault{utf8}
%   in \prog{lwarpmk}'s configuration files.  This is then used by \prog{lwarpmk} while
%   processing the index.
% ^^A and glossary.
%
% \changes{v0.54}{2018/04/06}{Add: \optn{xindyCodepage}.}
%
%    \begin{macrocode}
\DeclareStringOption[utf8]{xindyCodepage}
%    \end{macrocode}



% \limitspdftotextenc
%
% \changes{v0.54}{2018/04/06}{Add: \optn{pdftotextEnc}.}
%
%    \begin{macrocode}
\DeclareStringOption[UTF-8]{pdftotextEnc}
%    \end{macrocode}



% \DescribeOption{lwarpmk} Tells \pkg{lwarp} to
%	generate a local copy of \prog{lwarpmk} called \filenm{lwarpmk.lua}.
%	Useful for archiving for future use.
%	This file may be made executable and acts just like \prog{lwarpmk}.
%
% If \optn{lwarpmk} option, creates a local copy of \filenm{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 \brand{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 \optn{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 \optn{HomeHTMLFilename} and \optn{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{PrintLatexCmd} \DescribeDefault{<automatic>}
% The shell commands to use to compile the print document.
%
% \changes{v0.61}{2018/09/20}{Added \optn{PrintLatexCmd} option.}
%    \begin{macrocode}
\DeclareStringOption[]{PrintLatexCmd}
%    \end{macrocode}

% \DescribeOption{HTMLLatexCmd} \DescribeDefault{<automatic>}
% The shell commands to use to compile the \HTML\ document.
%
% \changes{v0.61}{2018/09/20}{Added \optn{HTMLLatexCmd} option.}
%    \begin{macrocode}
\DeclareStringOption[]{HTMLLatexCmd}
%    \end{macrocode}

% \DescribeOption{PrintIndexCmd} \DescribeDefault{<empty>}
% The shell commands to use to compile the print indexes.
%
%    \begin{macrocode}
\DeclareStringOption[]{PrintIndexCmd}
%    \end{macrocode}

% \DescribeOption{HTMLIndexCmd} \DescribeDefault{<empty>}
% The shell commands to use to compile the \HTML\ indexes.
%
%    \begin{macrocode}
\DeclareStringOption[]{HTMLIndexCmd}
%    \end{macrocode}


% \DescribeOption{LatexmkIndexCmd} \DescribeDefault{<empty>}
% The shell commands to by used by \prog{latexmk} to compile the print indexes.
% Unlike \optn{PrintIndexCmd} and \optn{HTMLIndexCmd},
% \optn{LatexmkIndexCmd} does not include the filename, which will be
% provided by \prog{latexmk}.
%
%    \begin{macrocode}
\DeclareStringOption[]{LatexmkIndexCmd}
%    \end{macrocode}

% \DescribeOption{makeindex} Tells \pkg{lwarp} to
%   use \pkg{makeindex} for index generation.
%   When \filenm{lwarpmk.conf} and \filenm{*.lwarpmkconf} are generated,
%   \optn{PrintIndexCmd} and \optn{HTMLIndexCmd} will be set for \prog{makeindex}
%   with a single index file.
% \changes{v0.58}{2018/06/20}{Added \optn{makeindex} option.}
%    \begin{macrocode}
\DeclareBoolOption[false]{makeindex}
%    \end{macrocode}


% \DescribeOption{xindy} Tells \pkg{lwarp} to
%   use \pkg{xindy} for index generation.
%   When \filenm{lwarpmk.conf} and \filenm{*.lwarpmkconf} are generated,
%   \optn{PrintIndexCmd} and \optn{HTMLIndexCmd} will be set for \prog{xindy}
%   with a single index file.
% \changes{v0.58}{2018/06/20}{Added \optn{xindy} option.}
%    \begin{macrocode}
\DeclareBoolOption[false]{xindy}
%    \end{macrocode}


% \DescribeOption{GlossaryCmd} \DescribeDefault{makeglossaries}
% The shell command to use to compile the glossary.
% The print or \HTML\ version of the glossary filename will be appended to this command.
%
%    \begin{macrocode}
\DeclareStringOption[makeglossaries]{GlossaryCmd}
%    \end{macrocode}


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


% \DescribeOption{dvips}
% Option \optn{dvips} tells \prog{lwarpmk} to use \prog{dvips}
% when compiling \DVI\ \prog{latex} documents.
%
% \changes{v0.59}{2018/09/02}{Added option \optn{dvips}.}
%
%    \begin{macrocode}
\DeclareBoolOption[false]{dvips}
%    \end{macrocode}


% \DescribeOption{dvipdfm}
% Option \optn{dvipdfm} tells \prog{lwarpmk} to use \prog{dvipdfm}
% when compiling \DVI\ \prog{latex} documents.
%
% \changes{v0.59}{2018/09/02}{Added option \optn{dvipdfm}.}
%
%    \begin{macrocode}
\DeclareBoolOption[false]{dvipdfm}
%    \end{macrocode}


% \DescribeOption{dvipdfmx}
% Option \optn{dvipdfmx} tells \prog{lwarpmk} to use \prog{dvipdfmx}
% when compiling \DVI\ \prog{latex} documents.
%
% \changes{v0.59}{2018/09/02}{Added option \optn{dvipdfmx}.}
%
%    \begin{macrocode}
\DeclareBoolOption[false]{dvipdfmx}
%    \end{macrocode}




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




% \subsection{Additional options support}


% 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}
% 
%
% Special handling for underscores in labels and filenames.
%
% \begin{macro}{\LWR@sanitized} The sanitized version of what was given
%   to \cs{LWR@sanitize}.
% Characters are set to their detokenized versions.
% Required for underscores in labels and filenames.
%    \begin{macrocode}
\newcommand*{\LWR@sanitized}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@sanitize} \marg{text}
%
% Sanitizes the text and returns the result in \cs{LWR@sanitized}.
%    \begin{macrocode}
\newcommand*{\LWR@sanitize}[1]{%
\edef\LWR@sanitized{#1}%
\edef\LWR@sanitized{\detokenize\expandafter{\LWR@sanitized}}%
}
%    \end{macrocode}
% \end{macro}


% Sanitize some string options to neutralize underscores.
% \changes{v0.66}{2019/01/28}{Sanitize filenames.}
%    \begin{macrocode}
\LWR@sanitize{\LWR@BaseJobname}
\edef\LWR@BaseJobname{\LWR@sanitized}

\LWR@sanitize{\LWR@ImagesDirectory}
\edef\LWR@ImagesDirectory{\LWR@sanitized}

\LWR@sanitize{\LWR@ImagesName}
\edef\LWR@ImagesName{\LWR@sanitized}
%    \end{macrocode}
%
%
%
% \cs{LWR@PrintIndexCmd} and \cs{LWR@HTMLIndexCmd} are tested to see if they are empty.
% If so, they are set to a reasonable defaults for a single index using \prog{makeindex},
% then possibly set to defaults for \prog{xindy}
% if the \pkg{lwarp} \optn{xindy} option was selected.
%
%    \begin{macrocode}
\ifdefempty{\LWR@PrintIndexCmd}{
    \renewcommand{\LWR@PrintIndexCmd}{%
        makeindex  -s \LWR@makeindexStyle \space  \jobname.idx%
    }
    \ifbool{LWR@xindy}{
        \renewcommand{\LWR@PrintIndexCmd}{%
            xindy
            -M \LWR@xindyStyle \space
            -L \LWR@xindyLanguage \space
            -C \LWR@xindyCodepage \space
            \jobname.idx%
        }
    }{}
}{}

\ifdefempty{\LWR@HTMLIndexCmd}{
    \renewcommand{\LWR@HTMLIndexCmd}{%
        makeindex  -s \LWR@makeindexStyle \space  \jobname_html.idx%
    }
    \ifbool{LWR@xindy}{
        \renewcommand{\LWR@HTMLIndexCmd}{%
            xindy
            -M \LWR@xindyStyle \space
            -L \LWR@xindyLanguage \space
            -C \LWR@xindyCodepage \space
            \jobname_html.idx%
        }
    }{}
}{}

\ifdefempty{\LWR@LatexmkIndexCmd}{
    \renewcommand{\LWR@LatexmkIndexCmd}{%
        makeindex  -s \LWR@makeindexStyle%
    }
    \ifbool{LWR@xindy}{
        \renewcommand{\LWR@LatexmkIndexCmd}{%
            xindy
            -M \LWR@xindyStyle \space
            -L \LWR@xindyLanguage \space
            -C \LWR@xindyCodepage%
        }
    }{}
}{}
%    \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.
%
% Attempts to use \pkg{versions} or \pkg{verbatim} fail in some cases, and do not
% provide much of a speed benefit even when they do work.
%
%    \begin{macrocode}
\RequirePackage{comment}
%    \end{macrocode}


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

\ifbool{warpingprint}{
\def\DefaultCutFileName{\def\CommentCutFile{comment_print.cut}}
}{}
%    \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 \prog{lwarpmk}.
% Default to no.
%    \begin{macrocode}
\ifbool{LWR@creatinglwarpmk}
{\includecomment{LWR@createlwarpmk}}
{\excludecomment{LWR@createlwarpmk}}
%    \end{macrocode}
%
%
%
%
%



% ^^A *required
% \section{Required packages}
% \label{sec:requiredpackages}
% \gindex{package>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.
%
% \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 % \gindex{font>during conversion}
% ^^A % For \XeLaTeX{} and \LuaLaTeX, uses DejaVu Serif for enhanced Cyrillic and Greek coverage.
% ^^A % \gindex{Unicode>XeLaTeX \& LuaLaTeX}
% ^^A 
% ^^A 
%
% Load \pkg{fontspec} if necessary:
% \changes{v0.50}{2018/02/24}{Fix: Load \pkg{fontspec} if necessary.}
%    \begin{macrocode}
\ifxetexorluatex
\@ifpackageloaded{fontspec}{}{
    \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 \prog{pdflatex}, use \pkg{fontenc} and \pkg{lmodern}:
% ^^A % \marginpar{\textcolor{blue}{\prog{pdflatex} only:}}
% ^^A % \gindex{Unicode>pdfLaTeX}
% ^^A % \gindex{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 % \prog{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
% \gindex{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.}
% \changes{v0.52}{2018/03/31}{Fix: MathJax script line wraps.  Reduced right margin.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%    \begin{macrocode}
\RequirePackage{geometry}
%    \end{macrocode}
%
% Avoid class and option conflict by changing settings after package load:
% \changes{v0.63}{2018/11/24}{\pkg{geometry}: Fix for \pkg{bxjs*} classes.}
% \changes{v0.65}{2018/12/21}{\pkg{geometry}: Fix for \pkg{bxjs*} classes.}
%    \begin{macrocode}
\geometry{
    paperheight=190in,%
    paperwidth=20in,%
    left=2in,right=6in,%
    top=1in,bottom=1in,%
}
%    \end{macrocode}
%
% \pkg{ltjtarticle} and other classes may require these to be reset by \pkg{lwarp}:
%    \begin{macrocode}
\setlength{\textheight}{0.8\paperheight}
\setlength{\textwidth}{0.7\paperwidth}

\@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}

% \changes{v0.51}{2018/03/06}{\pkg{afterpackage}: No longer required.}

% \DescribePackage{calc}
% \changes{v0.62}{2018/11/10}{\pkg{calc}: Fix: Required for print version.}
%    \begin{macrocode}
\RequirePackage{calc}
%    \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.
%
% \changes{v0.63}{2018/11/29}{\pkg{everyhook}: Fix for \pkg{bxjs*} classes.}
%    \begin{macrocode}
\@ifundefined{bxjs@everypar}{}{\let\everypar\bxjs@everypar}

\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 \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{verbatim}
%    \begin{macrocode}
\RequirePackage{verbatim}
%    \end{macrocode}


% \DescribePackage{refcount}
%
% Provides \cs{setcounterref}, \cs{setcounterpageref}, etc.
%    \begin{macrocode}
\RequirePackage{refcount}
%    \end{macrocode}


% \DescribePackage{newfloat}
%    \begin{macrocode}
\RequirePackage{newfloat}
%    \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{xstring}
% There was a short-term bug in \pkg{xstring} regarding \cs{IfInteger} which affected
% \pkg{lwarp}'s index generation.  The updated version is requested here.
% \trouble[index]{index>xstring=\pkg{xstring} bug}
% \trouble{index>numbers, not links}
% \trouble{xstring=\pkg{xstring}}
%    \begin{macrocode}
\RequirePackage{xstring}[2019/02/01]
%    \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}


% \changes{v0.40}{2017/09/07}{\pkg{xfrac}: No longer preloaded.}
% \changes{v0.66}{2019/01/27}{\pkg{zref}: No longer used.}


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

% \begin{macro}{\LWR@printlength} \marg{length}
%
% Prints a length using a locally-controlled unit and space.
% Rounding is used unless the length is small.
%
% \changes{v0.49}{2018/02/19}{Fix: Group \pkg{printlen} changes.}
%    \begin{macrocode}
\newrobustcmd*{\LWR@printlength}[1]{%
\begingroup%
\uselengthunit{PT}%
\renewcommand*{\unitspace}{}%
\ifdimless{#1}{10pt}{%
    \printlength{#1}%
}{%
    \rndprintlength{#1}%
}%
\endgroup%
}
%    \end{macrocode}
% \end{macro}


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



% \codeprint
%    \begin{macrocode}
\begin{warpprint}
%    \end{macrocode}

% \DescribePackage{varwidth}
% Used for print-mode \env{lateximage}:
%    \begin{macrocode}
\RequirePackage{varwidth}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpprint}
%    \end{macrocode}



% \section{Loading packages}
%
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \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@parsedrequirepackagenames}
%       Stores the parsed list of required package names
%       after spaces are removed and |lwarp-| is prepended.
% \changes{v0.48}{2018/02/03}{Fix: Parsing similar package names.}
%    \begin{macrocode}
\newcommand*{\LWR@parsedrequirepackagenames}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@nullifycomment}
%
%   Remove the preexisting \env{comment} environment.
%   Certain packages define it for their own use.
%
%    \begin{macrocode}
\newcommand*{\LWR@nullifycomment}{%
    \PackageInfo{lwarp}%
        {Nullifying the comment environment before loading \LWR@strresulttwo,}%
    \let\comment\relax%
    \let\endcomment\relax%
}
%    \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}
% 



% ^^A *checkload
% \begin{macro}{\LWR@checkloadfilename} \marg{filename}
% Checks if this filename should be loaded after \pkg{lwarp},
% or never at all.
%
% \changes{v0.63}{2018/12/02}{Added to reduce number of \filenm{lwarp-*} files.}
% \changes{v0.64}{2018/12/07}{Prevented \pkg{bitfield}, \pkg{doublespace},
%                               \pkg{newthm}, \pkg{rplain}, \pkg{si}.}
% \changes{v0.66}{2019/01/04}{Prevented \pkg{colortab}, \pkg{epsf}, \pkg{hyper}, \pkg{picinpar}, 
%                               \pkg{picins}, \pkg{sistyle}, \pkg{ucs}.}
%
% The following should never be loaded:
%    \begin{macrocode}
\newcommand*{\LWR@checkloadfilename}[1]{%
\LWR@checkloadnever{#1}{ae}{latinmodern}
\LWR@checkloadnever{#1}{aecc}{latinmodern}
\LWR@checkloadnever{#1}{bitfield}{bytefield}
\LWR@checkloadnever{#1}{boxedminipage}{boxedminipage2e}
\LWR@checkloadnever{#1}{caption2}{caption}
\LWR@checkloadnever{#1}{ccaption}{caption}
\LWR@checkloadnever{#1}{colortab}{colortbl}
\LWR@checkloadnever{#1}{doublespace}{setspace}
\LWR@checkloadnever{#1}{epsf}{graphicx}
\LWR@checkloadnever{#1}{fancyheadings}{fancyhdr}
\LWR@checkloadnever{#1}{glossary}{glossaries}
\LWR@checkloadnever{#1}{hyper}{hyperref}
\LWR@checkloadnever{#1}{newthm}{ntheorem}
\LWR@checkloadnever{#1}{picinpar}{floatflt, wrapfig}
\LWR@checkloadnever{#1}{picins}{floatflt, wrapfig}
\LWR@checkloadnever{#1}{rplain}{fancyhdr}
\LWR@checkloadnever{#1}{si}{siunitx}
\LWR@checkloadnever{#1}{sistyle}{siunitx}
\LWR@checkloadnever{#1}{t1enc}{fontenc, inputenc, inputenx}
\LWR@checkloadnever{#1}{ucs}{inputenc, inputencx}
\LWR@checkloadnever{#1}{wasysym}{textcomp, amssymb, amsfonts, mnsymbol, fdsymbol}
%    \end{macrocode}
%
% ^^A *loadbefore
% The following should only be loaded before \pkg{lwarp}:
%    \begin{macrocode}
\LWR@checkloadbefore{#1}{ctex}
\LWR@checkloadbefore{#1}{fontspec}
\LWR@checkloadbefore{#1}{inputenc}
\LWR@checkloadbefore{#1}{inputenx}
\LWR@checkloadbefore{#1}{kotex}
\LWR@checkloadbefore{#1}{luatexja}
\LWR@checkloadbefore{#1}{luatexja-fontspec}
\LWR@checkloadbefore{#1}{luatexko}
\LWR@checkloadbefore{#1}{morewrites}
\LWR@checkloadbefore{#1}{newclude}
\LWR@checkloadbefore{#1}{newunicodechar}
\LWR@checkloadbefore{#1}{plext}
\LWR@checkloadbefore{#1}{xeCJK}
\LWR@checkloadbefore{#1}{xetexko}
\LWR@checkloadbefore{#1}{zxjatype}
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@lookforpackagename} \marg{index}
%
% If \HTML, and if this is an \pkg{lwarp}-supported package name,
% re-direct it to the \pkg{lwarp} version
% by renaming it |lwarp-| followed by the original name.
%
% Looks |index| deep into the list of package names, \cs{LWR@requirepackagenames}, and
% builds \cs{LWR@parsedrequirepackagenames} which is the modified list of names.
% \changes{v0.48}{2018/02/03}{Fix: Parsing similar package names.}
%    \begin{macrocode}
\newcommand*{\LWR@lookforpackagename}[1]{%
%    \end{macrocode}
% Find the |index|'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 was found
%    \end{macrocode}
% Possible adjustments before loading the package.
% Maybe nullify the \env{comment} environment if the new package
% will be redefining it for a new purpose.
% \changes{v0.67}{2019/02/15}{\pkg{easyReview}: Supported.}
%    \begin{macrocode}
    \ifdefstring{\LWR@strresulttwo}{easyReview}{\LWR@nullifycomment}{}%
%    \end{macrocode}
% If \HTML, check if the package should be loaded before \pkg{lwarp},
% or never at all:
%    \begin{macrocode}
    \ifbool{warpingHTML}{\LWR@checkloadfilename{\LWR@strresulttwo}}{}%
%    \end{macrocode}
% If \HTML, and if found, and if an \pkg{lwarp}-equivalent name exists,
% use |lwarp-|* instead.
%    \begin{macrocode}
    \ifboolexpr{
        bool{warpingHTML} and
        test{\IfFileExists{lwarp-\LWR@strresulttwo.sty}}
    }%
    {% lwarp-* file found
        \ifdefvoid{\LWR@parsedrequirepackagenames}{%
            \edef\LWR@parsedrequirepackagenames{lwarp-\LWR@strresulttwo}%
        }{%
            \edef\LWR@parsedrequirepackagenames{%
                \LWR@parsedrequirepackagenames,lwarp-\LWR@strresulttwo%
            }%
        }%
    }%
    {%
%    \end{macrocode}
% Otherwise, use the current package name.
% \changes{v0.46}{2018/01/23}{Fix: Spaces in \cs{usepackage}.}
%    \begin{macrocode}
        \ifdefvoid{\LWR@parsedrequirepackagenames}{%
            \edef\LWR@parsedrequirepackagenames{\LWR@strresulttwo}%
        }{%
            \edef\LWR@parsedrequirepackagenames{%
                \LWR@parsedrequirepackagenames,\LWR@strresulttwo%
            }%
        }%
    }% 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 twenty names:\footnote{This was originally nine names, but
% then I came across a package which used twelve...}
% \changes{v0.61}{2018/10/02}{Support up to 20 packages.}
%    \begin{macrocode}
\renewcommand*{\LWR@requirepackagenames}{#2}%
\renewcommand*{\LWR@parsedrequirepackagenames}{}%
\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}%
\LWR@lookforpackagename{10}%
\LWR@lookforpackagename{11}%
\LWR@lookforpackagename{12}%
\LWR@lookforpackagename{13}%
\LWR@lookforpackagename{14}%
\LWR@lookforpackagename{15}%
\LWR@lookforpackagename{16}%
\LWR@lookforpackagename{17}%
\LWR@lookforpackagename{18}%
\LWR@lookforpackagename{19}%
\LWR@lookforpackagename{20}%
%    \end{macrocode}
% \cs{RequirePackage} depending on the options and version:
%    \begin{macrocode}
\IfValueTF{#1}%
{% options given
    \IfValueTF{#3}% version given?
    {\LWR@origRequirePackage[#1]{\LWR@parsedrequirepackagenames}[#3]}%
    {\LWR@origRequirePackage[#1]{\LWR@parsedrequirepackagenames}}%
}%
{% no options given
    \IfValueTF{#3}% version given?
    {\LWR@origRequirePackage{\LWR@parsedrequirepackagenames}[#3]}%
    {\LWR@origRequirePackage{\LWR@parsedrequirepackagenames}}%
}%
}
\LetLtxMacro\usepackage\RequirePackage
%    \end{macrocode}
% \end{macro}

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


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

% \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}
% In some cases, the following seems to be required
% to avoid an ``unknown option'' error, such
% as when loading \pkg{xcolor} with options.
% \changes{v0.62}{2018/11/11}{Fix: Unknown option error.}
%    \begin{macrocode}
\DeclareOption*{}%
\ProcessOptions\relax
}
%    \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}}
%    \end{macrocode}
% Ignore all options.
%    \begin{macrocode}
\DeclareOption*{}
%    \end{macrocode}
% Nullifies then processes the options.
% Seems to be required when options contain curly braces, which were causing
% ``|Missing \begin{document}|''.
% \changes{v0.48}{2018/02/04}{Fix: Options with braces.}
%    \begin{macrocode}
% \ProcessOptions\relax% original LaTeX code
\let\ds@\@empty%         from the original \ProcessOptions
\edef\@curroptions{}%    lwarp modification to \ProcessOptions
\@process@ptions\relax%  from the original \ProcessOptions
}
%    \end{macrocode}
% \end{macro}

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



% \section{Additional required packages}

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

% \DescribePackage{caption}
% \changes{v0.47}{2018/01/29}{\pkg{caption}: Also loads \pkg{lwarp-caption}.}
% \changes{v0.66}{2018/12/29}{\pkg{caption}: Fix for options clash.}
%    \begin{macrocode}
\LWR@origRequirePackage{caption}
\AtBeginDocument{\RequirePackage{lwarp-caption}}%
%    \end{macrocode}

%    \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 \filenm{<project>-images.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 \filenm{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% lwarp
\immediate\write\LWR@quickfile{\string\input{#1.tex}}% lwarp
\immediate\closeout\LWR@quickfile% lwarp
\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]{%
\LWR@traceinfo{LWR@copyfile: copying #1 to #2}

\immediate\openout\LWR@copyoutfile=#2
\openin\LWR@copyinfile=#1
\begingroup\endlinechar=-1
\makeatletter

\LWR@traceinfo{LWR@copyfile: about to loop}

\loop\unless\ifeof\LWR@copyinfile
  \LWR@traceinfo{LWR@copyfile: one line}
  \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
\immediate\closeout\LWR@copyoutfile
\LWR@traceinfo{LWR@copyfile: done}
\endgroup
}
%    \end{macrocode}
% \end{macro}

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


% \section{Debugging messages}
% \label{sec:debuggingmessages}
%
% \gindex{HTML>conversion settings>debug comments}
% \gindex{tracing log}
% \gindex{debugging>HTML debug comments}
% \gindex{debugging>tracing log}
% \gindex{troubleshooting>HTML debug comments}
% \gindex{troubleshooting>tracing log}
%
% \changes{v0.61}{2018/09/25}{Docs: HTMLDebugComments}
%
% To have the \HTML\ output include additional \HTML\ comments, such as
% \margintag{\HTML\ comments}
% which \element{div} is closing, use
% \begin{sourcedisplay}
% \cs{booltrue\{HTMLDebugComments\}}
% \end{sourcedisplay}
%
% \changes{v0.61}{2018/09/25}{Docs: \cs{tracinglwarp}}
%
% To have debug information written to the log,
% \margintag{debugging information}
% use
% \begin{sourcedisplay}
% \cs{tracinglwarp}
% \end{sourcedisplay}
%
% \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}%
}%
{}%
}
%    \end{macrocode}
% \end{macro}


% \DescribeBoolean{HTMLDebugComments}  \DescribeDefault{false}
%	Add comments in \HTML\
%	about closing \element{div}s, sections, etc.
%
% \changes{v0.28}{2017/04/09}{Added boolean \progcode{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{Defining print and \HTML\ versions of macros and environments}
% \label{sec:definingprinthtml}
% \gindex{print>selecting print/HTML definitions}
% \gindex{HTML>selecting print/HTML definitions}
%
% The following refers to defining objects inside \pkg{lwarp}, and is not
% for the user's document.
%
% Many macros and environments must be provided as both print and \HTML\ versions.
%
% While generating the print version of a document, the original macros
% as defined by \LaTeX\ and its packages are used as-is.
%
% While generating the \HTML\ version of a document,
% the original macro or environment is redefined to call a new \HTML\ version
% or a copy of the original print version.
% The new \HTML\ versions of macros and environments are used most of the time.
% Copies of the print versions are used inside a \env{lateximage} environment,
% which draws and remembers an image of the printed output, and also several
% other places.  The copies of the print versions may also be used by the \HTML\
% versions, such as when the \HTML\ version merely encloses the print version
% inside \HTML\ tags.
%
% The general structure for providing print and \HTML\ versions of a macro or
% environment is as follows:
%
% \begin{description}
%
% \item[For a preexisting macro, not defined with \pkg{xparse}:] An \HTML\ version
% is provided with a special name, inside a \env{warpHTML} environment,
% then \cs{LWR@formatted} is used to redefine and patch various macros:
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% \begin{warpHTML}
% \newcommand{\LWR@HTML@name}{...}% may also use xparse
%
% \LWR@formatted{name}
% \end{warpHTML}
% \end{Verbatim}
% |\LWR@formatted{name}| copies the original print version,
% then redefines \cs{name} to use either the print or \HTML\ version depending
% on which mode \pkg{lwarp} is using.  \pkg{xparse} may be used to
% define the new \HTML\ version, even if the original did not use \pkg{xparse}.

% \item[For a preexisiting environment, not defined with \pkg{xparse}:] The process
% is similar.  Note the use of \cs{LWR@formattedenv} instead of \cs{LWR@formatted}.
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% \begin{warpHTML}
% \newenvironment{LWR@HTML@name}{...}% may also use xparse
%
% \LWR@formattedenv{name}
% \end{warpHTML}
% \end{Verbatim}

% \item[If the original used \pkg{xparse}:] A copy must be made using a new name:
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% \begin{warpHTML}
% \NewDocumentCommand{\LWR@print@name}{..}{..}% copy the original
%
% \NewDocumentCommand{\LWR@HTML@name}{..}{..}% or use \newcommand
%
% \LWR@formatted{name}
% \end{warpHTML}
% \end{Verbatim}
% Similar for an environment, using \cs{LWR@formattedenv}.
% (\cs{LWR@formatted} and \cs{LWR@formattedenv} use \cs{LetLtxMacro} to
% copy the original print definiton,
% which may not work with macros and environments created by \pkg{xparse},
% so the print version must be manually recreated in the \pkg{lwarp} source.)

% \item[For a new macro or environment, not using \pkg{xparse} for the print version:] \
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% \begin{warpall}
% \newcommand{\name}{...}% NOT xparse!
% \end{warpall}
%
% \begin{warpHTML}
% \newcommand{\LWR@HTML@name}{...}% may use xparse for HTML
%
% \LWR@formatted{name}
% \end{warpHTML}
% \end{Verbatim}
% Similar for an environment.
% The plain \cs{name} or environment \env{name} is used for the printed
% version, and is placed inside \env{warpall}.
% \pkg{xparse} may be used for the \cs{LWR@HTML@<name>} version.
%
% \item [For a new macro or environment, using \pkg{xparse}:]
%   It is possible to use \pkg{xparse} for an entirely new macro or environment
%   by defining the \cs{LWR@print@<name>} version with \pkg{xparse}, along with
%   \cs{name} defined without \pkg{xparse} to refer directly to the \cs{LWR@print}
%   version:
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% \begin{warpall}
% \NewDocumentCommand{\LWR@print@name}{...} {...}%      -or-
% \NewDocumentEnvironment{\LWR@print@name}{...} {...} {...}
%
% % Simply a call to \LWR@print@name:
% \newcommand{\name}{\LWR@print@name}%        -or-
% \newenvironment{name}{\LWR@print@name}{\endLWR@print@name}
% \end{warpall}
%
% \begin{warpHTML}
% \NewDocumentCommand{\LWR@HTML@name}{...} {...}%      -or-
% \NewDocumentEnvironment{\LWR@HTML@name}{...} {...} {...}
%
% \LWR@formatted{name}%    -or-
% \LWR@formattedenv{name}
% \end{warpHTML}
% \end{Verbatim}
%
% \end{description}
%
% In general, \cs{LWR@formatted} or \cs{LWR@formattedenv} are placed inside
% a \env{warpHTML} environment, and while producing an \HTML\ document
% they do the following:
% \begin{itemize}
%   \item Macros are modified:
%     \begin{enumerate}
%     \item The pre-existing print version \cs{name} is saved as \cs{LWR@print@<name>},
%         unless \cs{LWR@print@<name>} is already defined.
%     \item The original \cs{name} is redefined to call either the print or \HTML\ version
%         depending on which format is in use at the moment, as set by \cs{LWR@formatting},
%        which is defined as either ``|print|'' or ``|HTML|''.
%     \end{enumerate}
%   \item When \pkg{lwarp} is producing a print document, the original definitions are
%       used, as well as any new definitions defined in \env{warpall} above.
%   \item When \pkg{lwarp} is generating \HTML\ output, \cs{LWR@formatting} is
%       set to ``|HTML|'', and \cs{name} is directed to \cs{LWR@HTML@<name>}.
%   \item When \pkg{lwarp} is generating \HTML\ output
%       but enters a \env{lateximage} environment,
%       or for some other reason needs to draw images using the original print
%       defintions, \cs{LWR@formatting} is changed to ``|print|'' and \cs{name} is
%       then redirected to \cs{LWR@print@<name>}, which was the original \cs{name}.
% \end{itemize}
%
% Since arguments are not handled by the new \cs{name}, any star and other arguments
% are processed by the print or \HTML\ version.
%
% Expandable versions are also provided as well.
% These usually are necessary for anything which could appear inside a \env{tabular},
% without which a ``|Misplaced \omit|'' error may occur.
% \trouble[Misplaced \cs{omit} error]{Misplaced \cs{omit}>tabular}
% \begin{sourcedisplay}
% \cs{LWR@expandableformatted} \\
% \cs{LWR@expandableformattedenv}
% \end{sourcedisplay}
%
% (Older versions of \pkg{lwarp} used \cs{LetLtxMacro} for everything,
% but this could fail when using macros defined by \pkg{xparse}.
% This older system is still in use for many definitions.)
% ^^A *8* Modify the above when all old \lets are removed.
%
% \changes{v0.57}{2018/05/28}{New system for switching print and \HTML\ outputs.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
% \begin{macro}{\LWR@formatting} Remembers if selected print/\HTML\ formatting.
%
% Used while \cs{LWR@restoreorigformatting}, such as in an \env{lateximage}.
% May be set to either ``|print|'' or ``|HTML|''.
%
%    \begin{macrocode}
\newcommand*{\LWR@formatting}{HTML}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@formatted} \marg{macroname} \qquad No backslash in the macro name.
%
% If not yet defined, defines \cs{LWR@print@<name>} as
% the original print-mode \cs{<name>}.
% Also redefines \cs{<name>} to use \cs{LWR@<format>@<name>},
% where <format> is set by \cs{LWR@formatting}, and is |print| or |HTML|.
%    \begin{macrocode}
\newcommand*{\LWR@formatted}[1]{%
    \ifcsundef{LWR@print@#1}{%
        \expandafter\LetLtxMacro\csname LWR@print@#1\expandafter\endcsname%
            \csname#1\endcsname%
    }{}%
    \ifcsundef{#1}{%
        \expandafter\newrobustcmd\csname #1\endcsname{%
            \@nameuse{LWR@\LWR@formatting @#1}%
        }%
    }{%
        \expandafter\renewrobustcmd\csname #1\endcsname{%
            \@nameuse{LWR@\LWR@formatting @#1}%
        }%
    }%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@expandableformatted} \marg{macroname} \qquad No backslash
%   in the macro name.
%
% An expandable version of \cs{LWR@formatted}.
%    \begin{macrocode}
\newcommand*{\LWR@expandableformatted}[1]{%
    \ifcsundef{LWR@print@#1}{%
        \expandafter\LetLtxMacro\csname LWR@print@#1\expandafter\endcsname%
            \csname#1\endcsname%
    }{}%
    \ifcsundef{#1}{%
        \expandafter\newcommand\csname #1\endcsname{%
            \@nameuse{LWR@\LWR@formatting @#1}%
        }%
    }{%
        \expandafter\renewcommand\csname #1\endcsname{%
            \@nameuse{LWR@\LWR@formatting @#1}%
        }%
    }%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@formattedenv} \marg{environmentname}
%
% If not yet defined, defines the environment \env{LWR@print@<name>} as
% the original print-mode \env{<name>}.
% Also redefines the environment |<name>| to use environment |LWR@<format>@<name>|,
% where <format> is set by \cs{LWR@formatting}, and is |print| or |HTML|.
%    \begin{macrocode}
\newcommand*{\LWR@formattedenv}[1]{%
    \ifcsundef{LWR@print@#1}{%
        \expandafter\LetLtxMacro\csname LWR@print@#1\expandafter\endcsname%
            \csname#1\endcsname%
        \csletcs{endLWR@print@#1}{end#1}%
    }{}%
    \DeclareDocumentEnvironment{#1}{}%
    {\@nameuse{LWR@\LWR@formatting @#1}}%
    {\@nameuse{endLWR@\LWR@formatting @#1}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LWR@expandableformattedenv} \marg{environmentname}
%
% An expandable version of \env{LWR@formattedenv}.
%    \begin{macrocode}
\newcommand*{\LWR@expandableformattedenv}[1]{%
    \ifcsundef{LWR@print@#1}{%
        \expandafter\LetLtxMacro\csname LWR@print@#1\expandafter\endcsname%
            \csname#1\endcsname%
        \csletcs{endLWR@print@#1}{end#1}%
    }{}%
    \DeclareExpandableDocumentEnvironment{#1}{}%
    {\@nameuse{LWR@\LWR@formatting @#1}}%
    {\@nameuse{endLWR@\LWR@formatting @#1}}%
}
%    \end{macrocode}
% \end{macro}
%
%    \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.
%	\gindex{EPUB>HTML conversion settings}
%	\gindex{HTML>conversion settings>EPUB}
%
% \changes{v0.28}{2017/04/09}{Added boolean \progcode{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.
%	\gindex{word processor>HTML conversion settings}
%	\gindex{HTML>conversion settings>word processor}
%
% \changes{v0.28}{2017/04/09}{Added boolean \progcode{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 caption tags
%   for figures and tables.}
%	\gindex{word processor>HTML conversion settings}
%	\gindex{HTML>conversion settings>word processor}
%
% \changes{v0.28}{2017/04/09}{Added boolean \progcode{HTMLMarkFloats}, changed
%   to \progcode{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 \progcode{WPMarkMinipages}.}
% \describeWPMarkMinipages
%    \begin{macrocode}
\newbool{WPMarkMinipages}
\boolfalse{WPMarkMinipages}
%    \end{macrocode}

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


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


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


% \DescribeBoolean{WPTitleHeading} \DescribeDefault{false}
% \changes{v0.42}{2017/10/19}{Added boolean \progcode{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 \progcode{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.
%
% Some packages redefine \cs{\#}, which is used to generate \HTML, so the original must
% be remembered here.
% \changes{v0.51}{2018/03/12}{Fix: Remember original \cs{\#} in case is redefined.}
%    \begin{macrocode}
\chardef\LWR@origpound=`\#
%    \end{macrocode}
%    \begin{macrocode}
\let\LWR@origcomma\,
\let\LWR@origthinspace\thinspace
\let\LWR@orignegthinspace\negthinspace
\let\LWR@origtilde~
\let\LWR@origenskip\enskip
\let\LWR@origquad\quad
\let\LWR@origqquad\qquad
\let\LWR@orighfil\hfil
\let\LWR@orighss\hss
\let\LWR@origllap\llap
\let\LWR@origrlap\rlap
\let\LWR@orighfilneg\hfilneg
\let\LWR@orighspace\hspace

\let\LWR@origrule\rule

\let\LWR@origmedskip\medskip
\let\LWR@origbigskip\bigskip

\let\LWR@origtextellipsis\textellipsis
\let\LWR@orig@textquotedbl\textquotedbl

\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
%    \end{macrocode}
% \changes{v0.65}{2018/12/10}{Added \cs{sishape}.}
%    \begin{macrocode}
\@ifundefined{sishape}{
    \LetLtxMacro\LWR@origsishape\scshape
}{
    \LetLtxMacro\LWR@origsishape\sishape
}
%    \end{macrocode}
%    \begin{macrocode}
\LetLtxMacro\LWR@origitshape\itshape
\LetLtxMacro\LWR@origem\em
\LetLtxMacro\LWR@orignormalfont\normalfont

\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
%    \end{macrocode}
%
%    \begin{macrocode}
\let\LWR@orignewpage\newpage

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

\let\LWR@orignewline\newline


\AtBeginDocument{% in case packages change definition
\let\LWR@orig@trivlist\@trivlist
\let\LWR@origtrivlist\trivlist
\let\LWR@origendtrivlist\endtrivlist
\LetLtxMacro\LWR@origitem\item
\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@orig@mklab\@mklab
\let\LWR@origmakelabel\makelabel
\let\LWR@orig@donoparitem\@donoparitem
\LetLtxMacro\LWR@orig@item\@item
\let\LWR@orig@nbitem\@nbitem
}

\let\LWR@origpar\par

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

\let\LWR@origclearpage\clearpage


\AtBeginDocument{% in case packages change definition
\LetLtxMacro\LWR@orighline\hline%
\LetLtxMacro\LWR@origcline\cline%
}
%    \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% pdflatex or dvi latex
\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% pdflatex or dvi latex
\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}.}



% \subsection{Decide whether to generate configuration files}

% Configuration files are only written if processing the print version of the document,
% and not processing a \pkg{pstool} image.
% \pkg{pstool} uses an additional compile for each image using the original
% document's preamble, which includes \pkg{lwarp}, so the \pkg{lwarp}
% configuration files are turned off if \filenm{-pstool} is part of the \cs{jobname}.
%
% Default to no configuration files:
% \changes{v0.61}{2018/10/02}{Don't write configuration files if processing \pkg{pstool} image.}
%    \begin{macrocode}
\excludecomment{LWRwriteconf}
%    \end{macrocode}
%
% Generate configuration files if print mode and not \filenm{-pstool}:
%
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\fullexpandarg%
\IfSubStr*{\jobname}{-pstool}
    {
        \typeout{lwarp: jobname with -pstool is found,}%
        \typeout{lwarp: \space\space not generating configuration files.}%
    }
    {
        \typeout{lwarp: generating configuration files}
        \includecomment{LWRwriteconf}
    }
\end{warpprint}
%    \end{macrocode}


% \subsection{\filenm{<project>_html.tex}}
%
% \DescribeFile{*_html.tex} Used to allow an \HTML\ version of the
% document to exist alongside the print version.
%
% \codeconfig
%    \begin{macrocode}
\begin{LWRwriteconf}
\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{LWRwriteconf}
%    \end{macrocode}


% \subsection{\prog{lwarpmk} configuration files}
% ^^A *lwarpmk.conf

% \codeconfig
%    \begin{macrocode}
\begin{LWRwriteconf}
%    \end{macrocode}


% \begin{macro}{\LWR@lwarpconfversion}
% The version number of the configuration file, allowing \prog{lwarpmk} to detect
% an obsolete configuration file format.
% Incremented by one each time the configuration file format changes.
% (This is NOT the same as the \pkg{lwarp} version number.)
%    \begin{macrocode}
\newcommand*{\LWR@lwarpconfversion}{2}% also in lwarpmk.lua
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsubsection{Helper macros}
%
% \begin{macro}{\LWR@shellescapecmd}
% The LaTeX compile option for shell escape, if used.
%    \begin{macrocode}
\ifshellescape
    \def\LWR@shellescapecmd{--shell-escape }
\else
    \def\LWR@shellescapecmd{}
\fi
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@compilecmd} \marg{engine} \marg{suffix}
%
% Used to form the basic compilation command for a document, adding
% the optional shell escape.
%
% Engine is \prog{pdflatex}, etc.  Suffix is empty or \filenm{_html}
%    \begin{macrocode}
\newcommand*{\LWR@compilecmd}[2]{%
    #1 \LWR@shellescapecmd \jobname#2%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@addcompilecmd} \marg{cmd} \marg{suffix}
%
% Adds to the compilation command.
%
% Cmd is \prog{dvipdfmx}, etc.  Suffix is empty or \filenm{_html}
% \changes{v0.61}{2018/10/06}{Removed spaces.}
%    \begin{macrocode}
\newcommand*{\LWR@addcompilecmd}[2]{%
    \LWRopseq
    #1 \jobname#2%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@unknownengine}
% Error message if not sure which \LaTeX\ engine is being used.
%    \begin{macrocode}
\newcommand*{\LWR@unknownengine}{%
    \PackageError{lwarp}
    {Unknown LaTeX engine.}
    {Lwarp only knows about pdflatex, dvi latex, xelatex, lualatex, and upLateX.}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@latexmkvar} \marg{varname} \marg{value}
%
% Adds a \prog{latexmk} variable assignment.
%    \begin{macrocode}
\newcommand*{\LWR@latexmkvar}[2]{%
    -e
    \LWRopquote%
    \LWRdollar #1=q/#2/%
    \LWRopquote
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LWR@latexmkcmd} \marg{\prog{latexmk} options}
%
% Sets a call to \prog{latexmk} with the given options, possibly adding
% \optn{-\/-shell-escape}, and also adding the indexing program.
% \changes{v0.59}{2018/09/05}{Fix: \optn{-\/-shell-escape} with \prog{latexmk}.}
%    \begin{macrocode}
\newcommand*{\LWR@latexmkcmd}[1]{%
    latexmk  \space \LWR@shellescapecmd \space  #1 \space
    -recorder \space
    \LWR@latexmkvar{makeindex}{\LWR@LatexmkIndexCmd}
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@latexmkdvipdfm} \marg{\prog{dvipdfm} or \prog{dvipdfmx}}
%
% Adds the options settings for \prog{dvipdfm} or \prog{dvipdfmx}.
%    \begin{macrocode}
\newcommand*{\LWR@latexmkdvipdfm}[1]{%
    -pdfdvi \space
    \LWR@latexmkvar{dvipdf}{%
        #1
        \@percentchar O
        -o \@percentchar D
        \@percentchar S%
    }
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@compileuplatex}
%   Sets compile options for up\LaTeX\ with \pkg{ujarticle} or related classes.
% \changes{v0.63}{2018/11/25}{Added.}
%    \begin{macrocode}
\newcommand*{\LWR@compileuplatex}{
    \def\LWR@tempprintlatexcmd{%
        \LWR@compilecmd{uplatex}{}
        \LWR@addcompilecmd{dvipdfmx}{}
    }
    \def\LWR@tempHTMLlatexcmd{%
        \LWR@compilecmd{uplatex}{_html}
        \LWR@addcompilecmd{dvipdfmx}{_html}
    }
}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\LWR@PrintLatexCmd}
% \begin{macro}{\LWR@HTMLLatexCmd}
%
% If not set by the user,
% the following sets the command to use to compile the source to \PDF\ form.
%
% If using \prog{latexmk}, a complicated string is created,
% eventually resulting in something such as:
%
% For \prog{xelatex} with \optn{-\/-shell-escape}:
%   \begin{Verbatim}[tabsize=4,gobble=2,frame=lines]
% [[latexmk   -xelatex   --shell-escape  -recorder
%     -e '$makeindex = q/makeindex -s lwarp.ist/'  <jobname>_html]]
%   \end{Verbatim}
%
% For \prog{dvipdfmx}:
%   \begin{Verbatim}[tabsize=4,gobble=2,frame=lines]
% [[latexmk   -pdfdvi  -e '$dvipdf=q/dvipdfmx %O -o %D %S/'
%     -recorder
%     -e '$makeindex=q/makeindex -s lwarp.ist/'   <jobname>_html]]
%   \end{Verbatim}
%
% For the following, temporary values are computed, but the permanent
% values are only set if the originals were not assigned by the user.
%    \begin{macrocode}
\ifbool{LWR@latexmk}{
%    \end{macrocode}
% For \prog{latexmk} with \prog{pdflatex} or \prog{lualatex}:
%    \begin{macrocode}
    \ifpdf
%    \end{macrocode}
% For \prog{latexmk} with \prog{pdflatex}:
%    \begin{macrocode}
        \ifPDFTeX
            \def\LWR@latexcmd{\LWR@latexmkcmd{-pdf -dvi- -ps-}}
        \else
%    \end{macrocode}
% For \prog{latexmk} with \prog{lualatex}:
%    \begin{macrocode}
            \ifLuaTeX
                \def\LWR@latexcmd{\LWR@latexmkcmd{-lualatex}}
            \else
                \LWR@unknownengine
            \fi
        \fi
    \else% \ifpdf
%    \end{macrocode}
% For \prog{latexmk} with \prog{xelatex} or \DVI\ \prog{latex}:
%    \begin{macrocode}
        \ifXeTeX
%    \end{macrocode}
% For \prog{latexmk} with \prog{xelatex}:
%    \begin{macrocode}
            \def\LWR@latexcmd{\LWR@latexmkcmd{-xelatex}}
        \else% \ifXeTeX
%    \end{macrocode}
% For \prog{latexmk} with \DVI\ \prog{latex}:
%    \begin{macrocode}
            \ifbool{LWR@dvipdfm}{
                \def\LWR@latexcmd{%
                    \LWR@latexmkcmd{%
                        \LWR@latexmkdvipdfm{dvipdfm}%
                    }
                }
            }{
                \ifbool{LWR@dvipdfmx}{
                    \def\LWR@latexcmd{%
                        \LWR@latexmkcmd{%
                            \LWR@latexmkdvipdfm{dvipdfmx}%
                        }
                    }
                }{
                    \def\LWR@latexcmd{\LWR@latexmkcmd{-pdfps}}
                }
            }
        \fi
    \fi% \ifpdf
%    \end{macrocode}
% The final assignment if \prog{latexmk}:
%    \begin{macrocode}
    \def\LWR@tempprintlatexcmd{\LWR@latexcmd \space \jobname}
    \def\LWR@tempHTMLlatexcmd{\LWR@latexcmd \space \jobname_html}
}% latexmk
%    \end{macrocode}
% Without \prog{latexmk}, the compiling command is simply the compiler name
% and the optional shell escape:
%    \begin{macrocode}
{% not latexmk
    \ifpdf
%    \end{macrocode}
% For \prog{pdflatex} or \prog{lualatex}:
%    \begin{macrocode}
        \ifPDFTeX
%    \end{macrocode}
% For \prog{pdflatex}:
%    \begin{macrocode}
            \def\LWR@tempprintlatexcmd{\LWR@compilecmd{pdflatex}{}}
            \def\LWR@tempHTMLlatexcmd{\LWR@compilecmd{pdflatex}{_html}}
        \else
            \ifLuaTeX
%    \end{macrocode}
% For \prog{lualatex}:
%    \begin{macrocode}
                \def\LWR@tempprintlatexcmd{\LWR@compilecmd{lualatex}{}}
                \def\LWR@tempHTMLlatexcmd{\LWR@compilecmd{lualatex}{_html}}
            \else
                \LWR@unknownengine
            \fi
        \fi
    \else% \ifpdf
%    \end{macrocode}
% For \DVI\ \prog{latex} or \prog{xelatex}:
%    \begin{macrocode}
        \ifXeTeX
%    \end{macrocode}
% For \prog{xelatex}:
%    \begin{macrocode}
            \def\LWR@tempprintlatexcmd{\LWR@compilecmd{xelatex}{}}
            \def\LWR@tempHTMLlatexcmd{\LWR@compilecmd{xelatex}{_html}}
        \else
%    \end{macrocode}
% For \DVI\ \prog{latex}.  Default to \prog{dvips}, unless
% told to use \prog{dvipdfm} or \prog{dvipdfmx}:
%    \begin{macrocode}
            \ifbool{LWR@dvipdfm}{
%    \end{macrocode}
% For \DVI\ \prog{latex} with \prog{dvipdfm}:
%    \begin{macrocode}
                \def\LWR@tempprintlatexcmd{%
                    \LWR@compilecmd{latex}{}
                    \LWR@addcompilecmd{dvipdfm}{}
                }
                \def\LWR@tempHTMLlatexcmd{%
                    \LWR@compilecmd{latex}{_html}
                    \LWR@addcompilecmd{dvipdfm}{_html}
                }
            }{
                \ifbool{LWR@dvipdfmx}{
%    \end{macrocode}
% For \DVI\ \prog{latex} with \prog{dvipdfmx}:
%    \begin{macrocode}
                    \def\LWR@tempprintlatexcmd{%
                        \LWR@compilecmd{latex}{}
                        \LWR@addcompilecmd{dvipdfmx}{}
                    }
                    \def\LWR@tempHTMLlatexcmd{%
                        \LWR@compilecmd{latex}{_html}
                        \LWR@addcompilecmd{dvipdfmx}{_html}
                    }
                }{% dvips
%    \end{macrocode}
% For \DVI\ \prog{latex} with \prog{dvips} and \prog{ps2pdf}:
%    \begin{macrocode}
                    \def\LWR@tempprintlatexcmd{%
                        \LWR@compilecmd{latex}{}
                        \LWR@addcompilecmd{dvips}{}
                        \LWR@addcompilecmd{ps2pdf}{}.ps
                    }
                    \def\LWR@tempHTMLlatexcmd{%
                        \LWR@compilecmd{latex}{_html}
                        \LWR@addcompilecmd{dvips}{_html}
                        \LWR@addcompilecmd{ps2pdf}{_html}.ps
                    }
                }
            }
        \fi% \ifXeTeX
    \fi% \ifpdf
}% latexmk
%    \end{macrocode}
% For \pkg{ujarticle}, \pkg{utarticle}, and related, using up\LaTeX\ and \prog{dvipdfmx}:
% \changes{v0.63}{2018/11/25}{\pkg{ujarticle} and related: Compile options.}
% \changes{v0.64}{2018/12/07}{\pkg{utarticle} and related: Added.}
%    \begin{macrocode}
\@ifclassloaded{ujarticle}{\LWR@compileuplatex}{}
\@ifclassloaded{ujbook}{\LWR@compileuplatex}{}
\@ifclassloaded{ujreport}{\LWR@compileuplatex}{}
\@ifclassloaded{utarticle}{\LWR@compileuplatex}{}
\@ifclassloaded{utbook}{\LWR@compileuplatex}{}
\@ifclassloaded{utreport}{\LWR@compileuplatex}{}
%    \end{macrocode}
% Only make the setting permanent if the original was empty:
% \changes{v0.61}{2018/09/20}{Added \optn{PrintLatexCmd} option.}
% \changes{v0.61}{2018/09/20}{Added \optn{HTMLLatexCmd} option.}
%    \begin{macrocode}
\ifdefempty{\LWR@PrintLatexCmd}{
    \def\LWR@PrintLatexCmd{\LWR@tempprintlatexcmd}
}{}
\ifdefempty{\LWR@HTMLLatexCmd}{
    \def\LWR@HTMLLatexCmd{\LWR@tempHTMLlatexcmd}
}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\LWR@writeconf} \marg{filename}
%
% Common code for each of \filenm{lwarpmk.conf} and \filenm{<project>.lwarpmkconf}.
% Each entry is a variable name, the equal sign, and a quoted string
% inside |[[| and |]]|, which are \prog{lua}'s long quote characters, allowing the
% use of single and double quotes inside.
%
% \changes{v0.59}{2018/08/21}{Compilation commands now preassigned by \pkg{lwarp} instead
%   of being computed by \prog{lwarpmk}.}
% \changes{v0.66}{2019/01/27}{Added \optn{ImagesDirectory} and \optn{ImagesName}.}
%    \begin{macrocode}
\newcommand{\LWR@writeconf}[1]{
\ifcsdef{LWR@quickfile}{}{\newwrite{\LWR@quickfile}}
\immediate\openout\LWR@quickfile=#1
\immediate\write\LWR@quickfile{confversion = [[\LWR@lwarpconfversion]]}
\ifbool{usingOSWindows}{
    \immediate\write\LWR@quickfile{opsystem = [[Windows]]}
}{
    \immediate\write\LWR@quickfile{opsystem = [[Unix]]}
}
\immediate\write\LWR@quickfile{sourcename = [[\jobname]]}
\immediate\write\LWR@quickfile{homehtmlfilename = [[\HomeHTMLFilename]]}
\immediate\write\LWR@quickfile{htmlfilename = [[\HTMLFilename]]}
\immediate\write\LWR@quickfile{imagesdirectory = [[\LWR@ImagesDirectory]]}
\immediate\write\LWR@quickfile{imagesname = [[\LWR@ImagesName]]}
\immediate\write\LWR@quickfile{latexmk = [[\ifbool{LWR@latexmk}{true}{false}]]}
\immediate\write\LWR@quickfile{printlatexcmd = [[\LWR@PrintLatexCmd]]}
\immediate\write\LWR@quickfile{HTMLlatexcmd = [[\LWR@HTMLLatexCmd]]}
\immediate\write\LWR@quickfile{printindexcmd = [[\LWR@PrintIndexCmd]]}
\immediate\write\LWR@quickfile{HTMLindexcmd = [[\LWR@HTMLIndexCmd]]}
\immediate\write\LWR@quickfile{latexmkindexcmd = [[\LWR@LatexmkIndexCmd]]}
\immediate\write\LWR@quickfile{glossarycmd = [[\LWR@GlossaryCmd]]}
\immediate\write\LWR@quickfile{pdftotextenc = [[\LWR@pdftotextEnc]]}
\immediate\closeout\LWR@quickfile
}

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

%    \begin{macrocode}
\end{LWRwriteconf}
%    \end{macrocode}



% \subsubsection{\filenm{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 \prog{xelatex} or \prog{lualatex}, in print-document generation mode,
% which is the default unless the \optn{warpHTML} option is given.
% |lwarpmk.conf| is then used by the utility \prog{lwarpmk}.
%
% \changes{v0.29}{2017/04/15}{\filenm{lwarpmk.conf}: Add: \optn{language}
%       option for config files.}
% \changes{v0.54}{2018/04/06}{\filenm{lwarpmk.conf}: Option \optn{xdyFilename} changed to \optn{xindyStyle}.}
% \changes{v0.54}{2018/04/06}{\filenm{lwarpmk.conf}: Option \optn{IndexLanguage} changed to \optn{xindyLanguage}.}
% \changes{v0.54}{2018/04/06}{\filenm{lwarpmk.conf}: Option \optn{xindyCodepage} added.}
% \changes{v0.54}{2018/04/06}{\filenm{lwarpmk.conf}: Option \optn{pdftotextEnc} added.}
% \changes{v0.56}{2018/05/11}{\filenm{lwarpmk.conf}: Records \texttt{-\/-shell-escape}.}
% \changes{v0.58}{2018/06/20}{\filenm{lwarpmk.conf}: Generated \cs{AtBeginDocument}.}
% \changes{v0.58}{2018/06/20}{\filenm{lwarpmk.conf}: Added options \optn{makeindex} and \optn{xindy}.}
% \changes{v0.58}{2018/06/21}{\filenm{lwarpmk.conf}: Added option \optn{makeindexstyle}.}
%
% \codeconfig
%    \begin{macrocode}
\begin{LWRwriteconf}

\AtBeginDocument{\LWR@writeconf{lwarpmk.conf}}

\end{LWRwriteconf}
%    \end{macrocode}



% \subsubsection{\filenm{<project>.lwarpmkconf}}
%
% \DescribeFile{project.lwarpmkconf} A project-specific configuration file for \prog{lwarpmk}.
%
% \changes{v0.29}{2017/04/15}{\filenm{*.lwarpmkconf}: Add: \optn{language}
%   option for config files.}
% \changes{v0.54}{2018/04/06}{\filenm{*.lwarpmkconf}: Option \optn{xdyFilename} changed to \optn{xindyStyle}.}
% \changes{v0.54}{2018/04/06}{\filenm{*.lwarpmkconf}: Option \optn{IndexLanguage} changed to \optn{xindyLanguage}.}
% \changes{v0.54}{2018/04/06}{\filenm{*.lwarpmkconf}: Option \optn{xindyCodepage} added.}
% \changes{v0.54}{2018/04/06}{\filenm{*.lwarpmkconf}: Option \optn{pdftotextEnc} added.}
% \changes{v0.56}{2018/05/11}{\filenm{*.lwarpmkconf}: Records \texttt{-\/-shell-escape}.}
% \changes{v0.58}{2018/06/20}{\filenm{*.lwarpmkconf}: Generated \cs{AtBeginDocument}.}
% \changes{v0.58}{2018/06/20}{\filenm{*.lwarpmkconf}: Added options \optn{makeindex} and \optn{xindy}.}
% \changes{v0.58}{2018/06/21}{\filenm{*.lwarpmkconf}: Added option \optn{makeindexstyle}.}
%
% The \optn{makeindex} and \optn{xindy} options have already been handled
%   for \filenm{lwarp.conf}.
%
% \codeconfig
%    \begin{macrocode}
\begin{LWRwriteconf}

\AtBeginDocument{\LWR@writeconf{\jobname.lwarpmkconf}}

\end{LWRwriteconf}
%    \end{macrocode}






% \subsection{\filenm{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}{\filenm{lwarp.css}: Improved responsive
%	\attribute{marginpar} and \attribute{marginblock}.}
% \changes{v0.30}{2017/04/26}{Fix: \filenm{*.css} files only written in print mode.}
% \changes{v0.50}{2018/03/02}{\filenm{lwarp.css}: Improved \SVG\ display math centering.}
% \changes{v0.54}{2018/04/24}{\filenm{lwarp.css}: Fix: Text-decoration-skip: auto.}
% \changes{v0.56}{2018/04/27}{\filenm{lwarp.css}: Added \attribute{span.textbf}, etc.}
% \changes{v0.56}{2018/05/09}{\filenm{lwarp.css}: Added \attribute{div.textbf}, etc.}
% \changes{v0.57}{2018/05/21}{\filenm{lwarp.css}: Added ruled, boxed, boxruled floats.}
% \changes{v0.57}{2018/05/21}{\filenm{lwarp.css}: Increased float vertical margins.}
% \changes{v0.61}{2018/10/05}{\filenm{lwarp.css}: Footnotes text align left.}
% \changes{v0.61}{2018/10/05}{\filenm{lwarp.css}: Minipage table and footnotes: tighter margin.}
% \changes{v0.62}{2018/11/02}{\filenm{lwarp.css}: Reduced margins in titlepage.}
% \changes{v0.62}{2018/11/02}{\filenm{lwarp.css}: Fixed \CSS\ for \cs{textup}.}
% \changes{v0.62}{2018/11/02}{\filenm{lwarp.css}: Added \CSS\ for \pkg{xfrac}, \pkg{nicefrac}.}
% \changes{v0.63}{2018/11/30}{\filenm{lwarp.css}: Added \CSS\ for vertical writing.}
% \changes{v0.63}{2018/12/01}{\filenm{lwarp.css}: Improved \CSS\ for \pkg{mdframed}.}
% \changes{v0.65}{2018/12/09}{\filenm{lwarp.css}: Improved \CSS\ for quotations.}
% \changes{v0.65}{2018/12/09}{\filenm{lwarp.css}: Side\TOC to left for improved \cs{marginpar}s.}
% \changes{v0.65}{2018/12/09}{\filenm{lwarp.css}: Added \cs{sishape}, \cs{textsi}.}
% \changes{v0.65}{2018/12/18}{\filenm{lwarp.css}: Improved \CSS\ for page layout.}
% \changes{v0.66}{2019/01/02}{\filenm{lwarp.css}: Improved \CSS\ for definition lists.}
%
% ^^A *lwarp.css
%
% \codeconfig
%    \begin{macrocode}
\begin{LWRwriteconf}
\begin{filecontents*}{lwarp.css}
/*
  CSS stylesheet for the LaTeX lwarp package
  Copyright 2016-2018 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 ;}
table p {margin: .5ex 0em .5ex 0em ;}

/* Holds a section number */
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, span.texttt {
    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, span.textbf, div.strong, div.textbf { font-weight: bold; }

span.textit, div.textit { font-style: italic; }

span.textmd, div.textmd { font-weight: normal; }

span.textsc, div.textsc {
    font-variant: small-caps;
    font-variant-numeric: oldstyle-nums ;
}

span.textsi, div.textsi {
    font-style: italic ;
    font-variant: small-caps;
    font-variant-numeric: oldstyle-nums ;
}

span.textsl, div.textsl { font-style: oblique; }

span.textup, div.textup {
    font-style: normal;
    font-variant: normal;
    font-variant-numeric: normal ;
}

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

span.textsf, div.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: auto ;
}

span.overline {
    text-decoration: overline ;
    text-decoration-skip: auto ;
}


/* for vertical text: */
div.verticalrl { writing-mode: vertical-rl }
div.horizontaltb { writing-mode: horizontal-tb }


/* for diagbox */
div.diagboxtitleN { border-bottom: 1px solid gray }
div.diagboxtitleS { border-top: 1px solid gray }

div.diagboxE {
    padding-left: 2em ;
    text-align: right ;
}

div.diagboxW {
    padding-right: 2em ;
    text-align: left ;
}



/* 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;
}

div.attribution p {
    text-align: right ;
    font-size: 80%
}

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 {
    display: block ;
    margin-left: 2em ;
    margin-right: 2em ;
}

blockquotation {
    display: block ;
    margin-left: 2em ;
    margin-right: 2em ;
}

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

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

/* 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 ;
}

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 }


/* copyrightbox package */
div.copyrightbox { margin: .5ex .5em }
div.copyrightbox p {margin: 0px .5em ; padding: 0px}
div.copyrightboxnote {text-align: left ; font-size: 60%}


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

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

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

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

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

span.oline {
    text-decoration: overline ;
    text-decoration-skip: auto ;
}

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

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

span.dotuline {
    text-decoration: underline ;
    text-decoration-skip: auto ;
    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 ;
}

h1 {
  margin: 0ex 0em 0ex 0em ;
  line-height: 1.3;
  text-align: center ;
}

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

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

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

h5 {
  margin: 3ex 0em 1ex 0em ;
  line-height: 1.3;
}

h6 {
  margin: 3ex 0em 1ex 0em ;
  line-height: 1.3;
}


div.titlepage {
  text-align: center ;
}

.footnotes {
    text-align: left ;
    font-size: .85em ;
    margin: 3ex 2em 0ex 2em ;
    border-top: 1px solid silver ;
}

.marginpar, .marginparblock {
    max-width: 50%;
    float: right ;
    clear: both ;
    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 ; }

div.bodycontainer {
    float: left ;
    width: 80% ;
}

div.bodywithoutsidetoc div.bodycontainer {
    float: none ;
    width: 100% ;
}

section.textbody div.footnotes{
    margin: 3ex 2em 0ex 2em ;
    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 ;
}



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

body dir, body menu {
  margin: 3ex 1em 3ex 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 ;
}


div.displaymath {
    text-align: center ;
}

div.displaymathnumbered {
    text-align: right ;
    margin-left: 5% ;
    margin-right: 5% ;
    min-width: 2.5in ;
}

@media all and (min-width: 400px) {
    div.displaymathnumbered {
        margin-left: 10% ;
        margin-right: 10% ;
    }
}

@media all and (min-width: 800px) {
    div.displaymathnumbered {
        margin-right: 20% ;
    }
}

@media all and (min-width: 1200px) {
    div.displaymathnumbered {
        margin-right: 30% ;
    }
}


.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 ;
    margin: 2ex 0em 2ex 0em ;
}

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

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

.mdframedtitle {
    padding: .5ex 0pt 0pt 0pt ;
    border-radius: 10pt 10pt 0pt 0pt ;
    display: block ;
    margin-bottom: 1ex ;
}

.mdframedsubtitle {
    display: block ;
}

.mdframedsubsubtitle {
    display: block ;
}

.mdtheorem {
    padding: 0ex .5em 0ex .5em ;
    margin: 3ex 5% 3ex 5% ;
}


/* 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 ;
}

.shaded {
    margin: 3ex 0em 3ex 0em ;
    padding: .3ex 1em .3ex 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 {
    display: block ;
    float:left ;
    font-weight: bold;
    padding-right: 1em ;
}

dl dd { display: block ; }

dl dd:after { content: "" ; display: block ; clear: both }

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

dd ul, dd ol, dd dl { clear: both ; padding-top: 1ex }


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: 5ex auto 5ex 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 figure { margin: 0pt }

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

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

div.figurecaption .minipage { margin:0 ; padding: 0 }

div.minipage figure { border: none ; box-shadow: none ; }
div.minipage figure.table { margin: 0ex }
div.minipage div.footnotes { margin: 1ex 2em 0ex 2em }

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 ; }

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

figure.subfigure div.figurecaption, figure.subtable div.figurecaption  {
    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 div.figurecaption {
    border: none ;
    background: none ;
}


/* For packages such as float, rotfloat, and algorithm2e: */

figure.boxed, figure.boxruled {
    border: 1px solid black ;
}

figure.ruled {
    border-top: 1px solid black ;
    border-bottom: 1px solid black ;
    border-left: 0px ;
    border-right: 0px ;
    border-radius: 0px ;
    background: none ;
    box-shadow: none ;
}

figure.ruled div.figurecaption, figure.boxruled div.figurecaption {
    border-top: 1px solid silver ;
    border-bottom: 1px solid silver ;
}


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: .5ex .5em .5ex .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.tvertbarldouble { border-left: 4px double black }
table td.tvertbarr { border-right: 1px solid black }
table td.tvertbarrdouble { border-right: 4px double black }

table td.tvertbarldash { border-left: 1px dashed black }
table td.tvertbarldoubledash { border-left: 2px dashed black }
table td.tvertbarrdash { border-right: 1px dashed black }
table td.tvertbarrdoubledash { border-right: 2px dashed 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:.80em;
    text-align: left ;
}

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

.tnoteitemheader {margin-right: 1em;}


/* for colortbl and cell color */
div.cellcolor {
    width: 100% ;
    padding: .5ex .5em .5ex .5em ;
    margin: -.5ex -.5em -.5ex -.5em ;
}


/* 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 ;
}

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



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

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

div.subtitle p { margin: 1ex ; }

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

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

/*
div.author table {
    margin: 1ex 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: 1ex 0em 1ex 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:both ;
}

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:both ;
}


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


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


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


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

img.lateximage{
    padding: 0pt ;
    margin: 0pt ;
    box-shadow: none ;
    border: none ;
    background: none ;
    max-width: 100% ;
    border-radius: 0ex ;
    border: none ;
}


/* The -1px right margin compensates for the 1px right border. */
/* Without this -1px margin, the body container appears below instead */
/* of floating to the side. */
div.sidetoccontainer {
    font-family: "DejaVu Serif", "Bitstream Vera Serif",
        "Lucida Bright", Georgia, serif;
    float: left ;
    width: 20%;
    margin: 0pt -1px 3ex 0pt ;
    border-right: 1px solid silver;
    border-bottom: 1px solid silver;
    background: #FAF7F4 ;
    font-size:.9em ;
    border-radius: 0px 0px 20px 0px ;
}

div.sidetoccontents {
    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 for xfrac and nicefrac: */
span.numerator {
    font-size: 60% ;
    vertical-align: .4em ;
}

span.denominator {
    font-size: 60%
}


/* Used for algorithm2e: */
div.alg2evline{
    margin-left: 1em ;
    padding-left: 1em ;
    border-left: 1px solid black ;
    border-radius: 0px 0px 0px 1ex ;
}

div.alg2evsline{
    margin-left: 1em ;
    padding-left: 1em ;
    border-left: 1px solid black ;
}

div.alg2enoline{
    margin-left: 1em ;
    padding-left: 1em ;
}

span.alg2elinenumber{
    margin-right: .5em ;
    font-size: 50% ;
    color: red ;
}


/* Used for 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 the notes package: */
div.notesimportantnote, div.noteswarningnote, div.notesinformationnote {
    clear: both ;
    margin: 2ex 2em 2ex 2em ;
    border: 1px solid silver ;
}

div.notesicon {
    float:left ;
    display: inline-block ;
    background: gold ;
    padding: 0ex 1em 0ex 1em ;
    margin-right: 1em ;
    font-weight: bold ;
}

div.notescontents { font-style: italic }


/*
For CSS LaTeX and related logos:
Based on spacing demonstrated by the metafont package.
*/

.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;
    font-size: 1.1em;
}

.latexlogosup {
  text-transform: uppercase;
  letter-spacing: .03em ;
  font-size: 0.7em;
  vertical-align: 0.25em;
  margin-left: -0.4em;
  margin-right: -0.15em;
}

.latexlogosub {
  text-transform: uppercase;
  vertical-align: -0.27ex;
  margin-left: -0.08em;
  margin-right: -0.07em;
  font-size: 1em;
}

.latexlogotwoe {
  text-transform: none ;
  font-variant-numeric: oldstyle-nums ;
}

.latexlogotwoesub {
  font-style:italic ;
  vertical-align: -0.27ex;
  margin-left: -0.11em;
  margin-right: -0.1em;
  font-size: 1em;
}

.xelatexlogo {
    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;
}

.xelatexlogosub {
  vertical-align: -0.27ex;
  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; }

/* Only display the sidetoc's webpage title if a small screen */
span.sidetocthetitle { display: none }

@media screen and (max-width: 50em) {
    div.sidetoccontainer {
        float: none ;
        width: 100% ;
        padding: 0 ;
        border-radius: 0 ;
        border-bottom: 1px solid black ;
        border-top: 1px solid black ;
        box-shadow: none ;
    }
    span.sidetocthetitle { display: inline }
    nav.botnavigation { display:block }
    div.bodycontainer { width: 100% }
    .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;
    }
    div.sidetoccontainer { display:none; }
    nav.topnavigation { display: none; }
    nav.botnavigation { display: none; }
    div.bodycontainer { width: 100% }
}

@media handheld {
    div.sidetoccontainer { display:none; }
    nav.topnavigation { display:block }
    nav.botnavigation { display:block }
    div.bodycontainer { width: 100% }
}

@media projection {
    div.sidetoccontainer { display:none; }
    nav.topnavigation { display:block }
    nav.botnavigation { display:block }
    div.bodycontainer { width: 100% }
}
\end{filecontents*}
% \end{Verbatim}% for syntax highlighting
\end{LWRwriteconf}
%    \end{macrocode}




% \subsection{\filenm{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.
%
% \changes{v0.65}{2018/12/09}{\filenm{lwarp_sagebrush.css}: Side\TOC to left for improved \cs{marginpar}s.}
%
% ^^A *lwarp_sagebrush.css
%
% \codeconfig
%    \begin{macrocode}
\begin{LWRwriteconf}
\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 ;
}

table div.minipage { background: none ; border: none ; }

div.framebox div.minipage {border:none ; background:none}

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, div.figurecaption .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 ;
}

/*
div.figurecaption {
    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);
}



div.sidetoccontainer {
    background-color: #F7F7F0 ;
    background-image: linear-gradient(to bottom, #F7F7F0, #C0C0C0);
    box-shadow: 3px 3px 3px #808080 ;
    }

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) {
    div.sidetoccontainer { border-radius: 0 ; }
}


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




% \subsection{\filenm{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.
%
% \changes{v0.62}{2018/11/10}{\filenm{lwarp_formal.css}: Fix: Font for verse.}
% \changes{v0.65}{2018/12/09}{\filenm{lwarp_formal.css}: Side\TOC to left for improved \cs{marginpar}s.}
% \changes{v0.66}{2019/01/02}{\filenm{lwarp_formal.css}: Improved \CSS\ for table notes.}
%
% ^^A *lwarp_formal.css
%
% \codeconfig
%    \begin{macrocode}
\begin{LWRwriteconf}
\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 ;
}



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


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

.tnotes {
    background: #fffcf5 ;
    border-top: 1px solid silver ;
    border-bottom: 1px solid silver ;
}

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

div.sidetoccontainer {
    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);
}

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 ;
    text-align:left ;
}

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



% \subsection{\filenm{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.
%
% ^^A *sample_project.css
%
% \codeconfig
%    \begin{macrocode}
\begin{LWRwriteconf}
\begin{filecontents*}{sample_project.css}
/* ( --- Start of project.css --- ) */
/* ( --- A sample project-specific CSS file for lwarp --- ) */

/* Uncomment one of the following: */
@import url("lwarp.css") ;
/* @import url("lwarp_formal.css") ; */
/* @import url("lwarp_sagebrush.css") ; */

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

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


% \subsection{\filenm{lwarp.ist}}

% \DescribeFile{lwarp.ist}
% 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.
%
% The page compositor line is for \pkg{memoir}'s \cs{specialindex}.
%
% \changes{v0.58}{2018/06/17}{\filenm{lwarp_html.ist}: Added.}
%
% ^^A *lwarp.ist
%
% \codeconfig
%    \begin{macrocode}
\begin{LWRwriteconf}
\begin{filecontents*}{lwarp.ist}
preamble
"\\begin{theindex}
  \\providecommand*\\lettergroupDefault[1]{}
  \\providecommand*\\lettergroup[1]{%
      \\par\\textbf{#1}\\par
      \\nopagebreak
  }
"
headings_flag 1
heading_prefix "
  \\lettergroup{"
heading_suffix "}"
delim_0 ", \\hyperindexref{"
delim_1 ", \\hyperindexref{"
delim_2 ", \\hyperindexref{"
delim_n "}, \\hyperindexref{"
delim_r "} -- \\hyperindexref{"
delim_t "}"
page_compositor "."
\end{filecontents*}
% \end{Verbatim}% for syntax highlighting
\end{LWRwriteconf}
%    \end{macrocode}



% \subsection{\filenm{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.
%
% See: \\
% \href{https://tex.stackexchange.com/questions/80300/how-can-i-convince-hyperref-and-xindy-to-play-together-nicely}
% {https://tex.stackexchange.com/questions/80300/ \\ \fqquad\ how-can-i-convince-hyperref-and-xindy-to-play-together-nicely}
%
% \changes{v0.30}{2017/04/28}{File: \filenm{lwarp_html.xdy} renamed to \filenm{lwarp.xdy}.}
% \changes{v0.30}{2017/04/26}{Fix: \filenm{lwarp.xdy} only written in print mode.}
% \changes{v0.58}{2018/06/19}{\filenm{lwarp.xdy}: Requires \filenm{makeindex.xdy}.}
% \changes{v0.58}{2018/06/21}{\filenm{lwarp.xdy}: Supports bold, italic.}
%
% ^^A *lwarp.xdy
%
% \codeconfig
%    \begin{macrocode}
\begin{LWRwriteconf}
\begin{filecontents*}{lwarp.xdy}
(require "tex/inputenc/latin.xdy")
(merge-rule "\\PS *" "Postscript")
(require "texindy.xdy")
(require "page-ranges.xdy")
(require "book-order.xdy")
(define-location-class "arabic-page-numbers"
    ("arabic-numbers") :min-range-length 1)
(require "makeindex.xdy")
(define-attributes (("hyperindexref")))
(markup-locref :open "\hyperindexref{" :close "}")
(markup-locref :open "\hyperindexref{" :close "}" :attr "hyperpage")
(markup-locref :open "\textbf{\hyperindexref{" :close "}}" :attr "textbf")
(markup-locref :open "\textit{\hyperindexref{" :close "}}" :attr "textit")
(define-location-class-order ("roman-page-numbers"
                  "arabic-page-numbers"
                  "alpha-page-numbers"
                  "Roman-page-numbers"
                  "Alpha-page-numbers"
                  "see"
                  "seealso"))
\end{filecontents*}
% \end{Verbatim}% for syntax highlighting
\end{LWRwriteconf}
%    \end{macrocode}


% \subsection{\filenm{lwarp_one_limage.cmd}}
%
% \DescribeFile{lwarp_one_limage.cmd}
% Used by \pkg{lwarp} to help make \env{lateximage}s when using \brand{Windows}.
%
% This must be present when compiling the project,
% but does not need to be present when distributing
% the resulting \HTML\ files.
%
% The arguments are each of the three fields from \filenm{<project>-images.txt},
% and also the base name of the source file.
%
% \prog{MiKTeX} does not allow file \filenm{lwarp_one_limage.cmd} to be
% created directly by \prog{lwarpmk}, so \filenm{lwarp_one_limage.txt} is created instead,
% then copied to \filenm{lwarp_one_limage.cmd} by \prog{lwarpmk}.
% This occurs each time \prog{lwarpmk} used to create \env{lateximage}s.
%
% \changes{v0.50}{2018/02/27}{\filenm{lwarp_one_limage.txt}: Added.}
% \changes{v0.51}{2018/03/16}{\filenm{lwarp_one_limage.txt}: \prog{pdftocairo} \optn{-noshrink} added.}
% \changes{v0.66}{2019/01/30}{\filenm{lwarp_one_limage.txt}: Image directory and prefix.}
%
% ^^A *lwarp_one_limage.txt
%
% \codeconfig
%    \begin{macrocode}
\begin{LWRwriteconf}
\immediate\openout\LWR@quickfile=lwarp_one_limage.txt
\immediate\write\LWR@quickfile{%
    pdfseparate -f \LWRpercent 1 -l \LWRpercent 1 \LWRpercent 4_html.pdf %
    \LWR@ImagesDirectory\OSPathSymbol lateximagetemp-\LWRpercent\LWRpercent d.pdf%
}
\immediate\write\LWR@quickfile{%
    pdfcrop --hires  \LWR@ImagesDirectory\OSPathSymbol lateximagetemp-\LWRpercent 1.pdf %
    \LWR@ImagesDirectory\OSPathSymbol\LWRpercent 3.pdf%
}
\immediate\write\LWR@quickfile{%
    pdftocairo  -svg -noshrink  \LWR@ImagesDirectory\OSPathSymbol\LWRpercent 3.pdf %
    \LWR@ImagesDirectory\OSPathSymbol\LWRpercent 3.svg%
}
\immediate\write\LWR@quickfile{%
    del \LWR@ImagesDirectory\OSPathSymbol\LWRpercent 3.pdf%
}
\immediate\write\LWR@quickfile{%
    del \LWR@ImagesDirectory\OSPathSymbol lateximagetemp-\LWRpercent 1.pdf%
}
\immediate\write\LWR@quickfile{exit}
\immediate\closeout\LWR@quickfile
\end{LWRwriteconf}
%    \end{macrocode}



% \subsection{\filenm{lwarp_mathjax.txt}}

% \DescribeFile{lwarp_mathjax.txt}
% Used by \pkg{lwarp} when using \brand{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: \filenm{lwarp_mathjax.txt}: Updated \protect\acro{CDN} repository.}
% \changes{v0.30}{2017/04/26}{Fix: \filenm{lwarp_mathjax.txt}: Only written in print mode.}
% \changes{v0.34}{2017/07/27}{File: \filenm{lwarp_mathjax.txt}: Version change.}
% \changes{v0.42}{2017/10/16}{File: \filenm{lwarp_mathjax.txt}: Updated \pkg{siunitx} script.}
% \changes{v0.45}{2017/12/21}{File: \filenm{lwarp_mathjax.txt}: Allow \brand{MathJax} inside \env{tabbing}.}
% \changes{v0.45}{2018/01/23}{File: \filenm{lwarp_mathjax.txt}: Allow \brand{MathJax} inside \env{verse}.}
% \changes{v0.59}{2018/07/13}{File: \filenm{lwarp_mathjax.txt}: Updated to MathJax v2.7.4.}
% \changes{v0.59}{2018/07/16}{File: \filenm{lwarp_mathjax.txt}: Fix: Removed chapter number from tagged non-numeric MathJax equations.}
% \changes{v0.62}{2018/11/05}{File: \filenm{lwarp_mathjax.txt}: Removed inoperable \pkg{siunitx} extension.}
%
%
% ^^A *lwarp_mathjax.txt
%
% \codeconfig
%    \begin{macrocode}
\begin{LWRwriteconf}
\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) {
                <!-- if not numeric, don't include the chapter -->
                if (!n.match(/^ *[0-9]+ *$/ ))
                <!-- $ syntax highlighting -->
                    return "("+(n).replace(/^\./,"")+")" ;
                else
                    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>

<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.4/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{LWRwriteconf}
%    \end{macrocode}

% ^^A A possible addition for siuntix:
% ^^A <!-- https://github.com/burnpanck/MathJax-siunitx -->
% ^^A 
% ^^A <script type="text/x-mathjax-config">
% ^^A  MathJax.Hub.Config({
% ^^A    extensions: ["tex2jax.js","[siunitx]/siunitx.js"],
% ^^A    jax: ["input/TeX","output/HTML-CSS"],
% ^^A    tex2jax: {
% ^^A         inlineMath: [["$","$"],["\\(","\\)"]] ,
% ^^A         processClass: "tabbing|verse"
% ^^A     },
% ^^A    TeX: {extensions: ["AMSmath.js","AMSsymbols.js", "sinuitx.js"]}
% ^^A  });
% ^^A  MathJax.Ajax.config.path['siunitx']  = 'http://rawgit.com/burnpanck/MathJax-siunitx/master/';
% ^^A  </script>
 
 

% ^^A \subsection{\filenm{lwarp_KaTeX.txt}}

% ^^A \DescribeFile{lwarp_KaTeX.txt}
% ^^A Used by \pkg{lwarp} when using Ka\TeX.
%
% ^^A This must be present when compiling the project,
% ^^A but does not need to be present when distributing
% ^^A the resulting \HTML\ files.
%
% ^^A \changes{v0.59}{2018/11/03}{File: \filenm{lwarp_KaTeX.txt}: Added.}
%
%
% ^^A ^^A *lwarp_KaTeX.txt
%
% ^^A \codeconfig
% ^^A    \begin{macrocode}
% ^^A \begin{LWRwriteconf}
% ^^A \begin{filecontents*}{lwarp_KaTeX.txt}
% ^^A <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous">
% ^^A <script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/katex.min.js" integrity="sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx" crossorigin="anonymous"></script>
% ^^A <script defer src="https://cdn.jsdelivr.net/npm/katex@0.10.0/dist/contrib/auto-render.min.js" integrity="sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe" crossorigin="anonymous"
% ^^A     onload="renderMathInElement(document.body);"></script>
% ^^A \end{filecontents*}
% ^^A % \end{Verbatim}% for syntax highlighting
% ^^A \end{LWRwriteconf}
% ^^A   \end{macrocode}



% \subsection{\filenm{lwarpmk.lua} — \optn{lwarpmk} option}

% \DescribeOption{lwarpmk} Creates a local copy of \prog{lwarpmk}.
%
% \DescribeProgram{lwarpmk} Command-line utility to process \pkg{lwarp} files and images.
%
% \env{lateximage}s and \SVG\ math images are generated using
% \margintag{parallel processing}
% \gindex{image>processing}
% \gindex{lateximage>processing}
% \gindex{SVG>image processing}
% multiple processes in parallel.
% For \brand{Unix} and \brand{Linux}, every 32 images the |wait| command is
% issued to wait for the previous batch of images to finish processing before
% starting a new batch.
% For \brand{Windows}, every 32 images one task is dispatched with
% \begin{sourcedisplay}
% START /B /WAIT /BELOWNORMAL
% \end{sourcedisplay}
% which causes the operating system to wait until this lesser-priority tasks finishes,
% hopefully also waiting for the normal priority tasks which were already in
% progress to also complete.  Afterwards, the next batch of images is started.
%
% \changes{v0.21}{2017/02/11}{\prog{lwarpmk}: Fix: \cmds{lwarpmk again} for \brand{Windows}.}
% \changes{v0.21}{2017/02/22}{\prog{lwarpmk}: Fix: \cmds{lwarpmk limages} for \brand{Windows}.}
% \changes{v0.21}{2017/02/22}{\prog{lwarpmk}: Fix: \prog{lwarpmk} uses \filenm{lateximages} text file instead of shell script.}
% \changes{v0.28}{2017/04/14}{\prog{lwarpmk}: Add: \cmds{printglossary} and \cmds{htmlglossary} commands.}
% \changes{v0.29}{2017/04/15}{\prog{lwarpmk}: Add: \optn{language} option for config files.}
% \changes{v0.30}{2017/04/22}{\prog{lwarpmk}: \optn{language} now used for both index and glossary generation.}
% \changes{v0.30}{2017/04/22}{\prog{lwarpmk}: Fix: \prog{xindy} now used for print index generation with \prog{latexmk}.}
% \changes{v0.30}{2017/04/28}{\prog{lwarpmk}: Fix: \prog{xindy} and \prog{texindy}
%		adjusted for \prog{pdflatex}, \prog{xelatex} and \prog{lualatex}.}
% \changes{v0.30}{2017/04/28}{\prog{lwarpmk}: Add: \optn{xdyfile} configuration option.}
% \changes{v0.32}{2017/06/08}{\prog{lwarpmk}: Fix: \cmds{io.lines()} changed to \cmds{file:lines()}
%		due to \prog{luatex} changes.}
% \changes{v0.37}{2017/08/19}{\prog{lwarpmk}: Removes additional \HTML\ \filenm{aux} files.}
% \changes{v0.38}{2017/08/24}{\prog{lwarpmk}: Added \cmds{print1} and \cmds{html1} actions.}
% \changes{v0.47}{2018/01/24}{\prog{lwarpmk}: \prog{pdfcrop}: Removed \optn{hires} option for improved crop accuracy.}
% \changes{v0.50}{2018/02/22}{\prog{lwarpmk}: MD5 hash avoids duplicate \SVG\ math.}
% \changes{v0.50}{2018/02/27}{\prog{lwarpmk}: Multiprocess support making lateximages.}
% \changes{v0.50}{2018/02/28}{\prog{lwarpmk}: Error if \filenm{lateximages.txt} does not exist.}
% \changes{v0.50}{2018/02/28}{\prog{lwarpmk}: Error if \filenm{lwarpmk.conf} points to \pkg{lwarp}.}
% \changes{v0.50}{2018/02/28}{\prog{lwarpmk}: Improved error messages.}
% \changes{v0.51}{2018/03/14}{\prog{lwarpmk}: \prog{pdfcrop}: Restored \optn{hires} option.}
% \changes{v0.51}{2018/03/16}{\prog{lwarpmk}: \prog{pdftocairo} \optn{-noshrink} added.}
% \changes{v0.52}{2018/03/31}{\prog{lwarpmk}: Fix: Memory overflow when spawning tasks.}
% \changes{v0.52}{2018/04/01}{\prog{lwarpmk}: Fix: Skip image generation if from page 0.}
% \changes{v0.53}{2018/04/01}{\prog{lwarpmk}: Added warning for corrupted images.}
% \changes{v0.53}{2018/04/01}{\prog{lwarpmk}: Added \cmds{lwarpmk cleanlimages}.}
% \changes{v0.54}{2018/04/06}{\prog{lwarpmk}: Changed \optn{xdyfile} to \optn{xindystyle}.}
% \changes{v0.54}{2018/04/06}{\prog{lwarpmk}: Changed \optn{language} to \optn{xindylanguage}.}
% \changes{v0.54}{2018/04/06}{\prog{lwarpmk}: Added \optn{xindycodepage}.}
% \changes{v0.54}{2018/04/06}{\prog{lwarpmk}: Added \optn{pdftotextenc}.}
% \changes{v0.54}{2018/04/09}{\prog{lwarpmk}: Increased prominence for error for an unknown command.}
% \changes{v0.54}{2018/04/11}{\prog{lwarpmk}: Verifies image references before \progcode{lwarpmk limages}.}
% \changes{v0.54}{2018/04/11}{\prog{lwarpmk}: Verifies \HTML\ version exists before \progcode{lwarpmk limages}.}
% \changes{v0.54}{2018/04/19}{\prog{lwarpmk}: Improved error if configuration file does not exist.}
% \changes{v0.56}{2018/04/29}{\prog{lwarpmk}: Added \progcode{lwarpmk pdftosvg}.}
% \changes{v0.56}{2018/05/11}{\prog{lwarpmk}: Supports \texttt{-\/-shell-escape}.}
% \changes{v0.57}{2018/05/20}{\prog{lwarpmk}: Improved code factoring.}
% \changes{v0.57}{2018/05/20}{\prog{lwarpmk}: Improved error handling.}
% \changes{v0.58}{2018/06/14}{\prog{lwarpmk}: Added \texttt{-p} option for project name.}
% \changes{v0.58}{2018/06/14}{\prog{lwarpmk}: Added optional list of names for \cmds{lwarpmk printindex} and /cmds{lwarpmk htmlindex}.}
% \changes{v0.58}{2018/06/18}{\prog{lwarpmk}: Glossary generation now uses \prog{makeglossaries}.}
% \changes{v0.58}{2018/06/20}{\prog{lwarpmk}: Added \optn{makeindex} and \optn{xindy} options.}
% \changes{v0.58}{2018/06/20}{\prog{lwarpmk}: \cmds{lwarpmk clean} removes all \filenm{*.ind} and \filenm{*.idx} files.}
% \changes{v0.59}{2018/07/29}{\prog{lwarpmk}: Warning if operating system changed.}
% \changes{v0.59}{2018/07/29}{\prog{lwarpmk}: Error if \filenm{lwarpmk.conf} format changed.}
% \changes{v0.59}{2018/08/05}{\prog{lwarpmk}: Double insead of single-dashed \optn{-\/-shell-escape} option.}
% \changes{v0.59}{2018/08/21}{\prog{lwarpmk}: Consolidated compiling options into \optn{printlatexcmd} and \optn{HTMLlatexcmd}.}
% \changes{v0.59}{2018/09/06}{\prog{lwarpmk}: Added \cmds{lwarpmk epstopdf}.}
% \changes{v0.66}{2019/01/27}{\prog{lwarpmk}: Added \optn{ImagesDirectory} and \optn{ImagesName}.}
% \changes{v0.66}{2019/01/30}{\prog{lwarpmk}: Fix for \cmds{cleanlimages}.}%
%
% The following is only generated if the \optn{lwarpmk} option
%   was given to \pkg{lwarp}.
%    \begin{macrocode}
\begin{LWR@createlwarpmk}
%    \end{macrocode}
%
% ^^A *lwarpmk.lua
%    \begin{macrocode}
\begin{filecontents*}{lwarpmk.lua}
#!/usr/bin/env texlua

-- Copyright 2016-2018 Brian Dunn


printversion = "v0.67"
requiredconfversion = "2" -- also at *lwarpmk.conf

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


function printusage ()
--
-- Print the usage of the lwarpmk command:
--
print ( [[

lwarpmk print [-p project]: Compile the print version if necessary.
lwarpmk print1 [-p project]: Forced single compile of the print version.
lwarpmk printindex [-p project]: Process print indexes.
lwarpmk printglossary [-p project]: Process the glossary for the print version.
lwarpmk html [-p project]: Compile the HTML version if necessary.
lwarpmk html1 [-p project]: Forced single compile of the HTML version.
lwarpmk htmlindex [-p project]: Process HTML indexes.
lwarpmk htmlglossary [-p project]: Process the glossary for the html version.
lwarpmk again [-p project]: Touch the source code to trigger recompiles.
lwarpmk limages [-p project]: Process the "lateximages" created by lwarp.sty.
lwarpmk pdftohtml [-p project]:
    For use with latexmk or a Makefile:
    Converts project_html.pdf to project_html.html and individual HTML files.
    Finishes the HTML conversion even if there was a compile error.
lwarpmk pdftosvg <list of file names>: Converts each PDF file to SVG.
lwarpmk epstopdf <list of file names>: Converts each EPS file to PDF.
lwarpmk clean [-p project]: Remove *.aux, *.toc, *.lof/t,
    *.idx, *.ind, *.log, *_html_inc.*, .gl*
lwarpmk cleanall [-p project]: Remove auxiliary files, project.pdf, *.html
lwarpmk cleanlimages: Removes all images from the "lateximages" directory.
lwarpmk -h: Print this help message.
lwarpmk --help: Print this help message.

]] )
-- printconf ()
end


function splitfile (destfile,sourcefile)
--
-- Split one large sourcefile into a number of files,
-- starting with destfile.
-- The file is split at each occurance of <!--|Start file|newfilename|*
--
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


function cvalueerror ( line, linenum , cvalue )
--
-- Incorrect value, so print an error and exit.
--
    print ("lwarpmk: ===")
    print ("lwarpmk: " .. linenum .. " : " .. line ) ;
    print (
        "lwarpmk: incorrect variable value \"" .. cvalue ..
        "\" in lwarpmk.conf.\n"
    ) ;
    print ("lwarpmk: ===")
--    printconf () ;
    os.exit(1) ;
end


function ignoreconf ()
-- Global argument index
argindex = 2
end

function loadconf ()
--
-- Load settings from the project's "lwarpmk.conf" file:
--
-- Default configuration filename:
local conffile = "lwarpmk.conf"
local confroot = "lwarpmk"
-- Global argument index
argindex = 2
-- Optional configuration filename:
if ( arg[argindex] == "-p" ) then
    argindex = argindex + 1
    confroot = arg[argindex]
    conffile = confroot..".lwarpmkconf"
    argindex = argindex + 1
end
-- Additional defaults:
confversion = "0"
opsystem = "Unix"
imagesdirectory = "lateximages"
imagesname = "image-"
latexmk = "false"
printlatexcmd = ""
HTMLlatexcmd = ""
printindexcmd = ""
HTMLindexcmd = ""
latexmkindexcmd = ""
-- to be removed:
-- indexprog = "makeindex"
-- makeindexstyle = "lwarp.ist"
-- xindylanguage = "english"
-- xindycodepage = "utf8"
-- xindystyle = "lwarp.xdy"
-- pdftotextenc = "UTF-8"
glossarycmd = "makeglossaries"
-- Verify the file exists:
if (lfs.attributes(conffile,"mode")==nil) then
    -- file not exists
    print ("lwarpmk: ===")
    print ("lwarpmk: File \"" .. conffile .."\" does not exist.")
    print ("lwarpmk: Move to the project's source directory,")
    print ("lwarpmk: recompile using pdflatex, xelatex, or lualatex,")
    print ("lwarpmk: then try using lwarpmk again.")
    if ( arg[argindex] ~= nil ) then
        print (
            "lwarpmk: (\"" .. confroot ..
            "\" does not appear to be a project name.)"
        )
    end
    print ("lwarpmk: ===")
    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, parsing each line as: name = [[string]]
local linenum = 0
for line in cfile:lines() do -- scan lines
linenum = linenum + 1
i,j,cvarname,cvalue = string.find (line,"([%w-_]*)%s*=%s*%[%[([^%]]*)%]%]") ;
-- Error if incorrect enclosing characters:
if ( i == nil ) then
    print ("lwarpmk: ===")
    print ("lwarpmk: " ..  linenum .. " : " .. line ) ;
    print ("lwarpmk: Incorrect entry in " .. conffile ..".\n" ) ;
    print ("lwarpmk: ===")
--    printconf () ;
    os.exit(1) ;
end -- nil
if ( cvarname == "confversion" ) then
    confversion = cvalue
elseif ( cvarname == "opsystem" ) then
    -- Verify choice of opsystem:
    if ( (cvalue == "Unix") or (cvalue == "Windows") ) then
        opsystem = 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 == "imagesdirectory" ) then imagesdirectory = cvalue
elseif ( cvarname == "imagesname" ) then imagesname = cvalue
elseif ( cvarname == "latexmk" ) then latexmk = cvalue
elseif ( cvarname == "printlatexcmd" ) then printlatexcmd = cvalue
elseif ( cvarname == "HTMLlatexcmd" ) then HTMLlatexcmd = cvalue
elseif ( cvarname == "printindexcmd" ) then printindexcmd = cvalue
elseif ( cvarname == "HTMLindexcmd" ) then HTMLindexcmd = cvalue
elseif ( cvarname == "latexmkindexcmd" ) then latexmkindexcmd = cvalue
elseif ( cvarname == "glossarycmd" ) then glossarycmd = cvalue
elseif ( cvarname == "pdftotextenc" ) then pdftotextenc = cvalue
else
    print ("lwarpmk: ===")
    print ("lwarpmk: " .. linenum .. " : " .. line ) ;
    print (
        "lwarpmk: Incorrect variable name \"" .. cvarname .. "\" in " ..
        conffile ..".\n"
    ) ;
    print ("lwarpmk: ===")
--    printconf () ;
os.exit(1) ;
end -- cvarname
end -- do scan lines
io.close(cfile)
end -- file exists
-- Error if sourcename is "lwarp".
-- This could happen if a local copy of lwarp has recently been recompiled.
if sourcename=="lwarp" then
    print ("lwarpmk: ===")
    print ("lwarpmk: lwarp.sty has recently been recompiled in this directory,")
    print ("lwarpmk: and \"lwarpmk.conf\" is no longer set for your own project.")
    print ("lwarpmk: Recompile your own project using pdf/lua/xelatex <projectname>.")
    print ("lwarpmk: After a recompile, \"lwarpmk.conf\" will be set for your project,")
    print ("lwarpmk: and you may again use lwarpmk.")
    print ("lwarpmk: ===")
    os.exit(1)
end -- sourcename of "lwarp"
-- Select some operating-system commands:
if opsystem=="Unix" then  -- For Unix / Linux / Mac OS:
    rmname = "rm"
    mvname = "mv"
    cpname = "cp"
    touchnamepre = "touch"
    touchnamepost = ""
    newtouchname = "touch"
    dirslash = "/"
    opquote= "\'"
    cmdgroupopenname = " ( "
    cmdgroupclosename = " ) "
    seqname = " && "
    bgname = " &"
elseif opsystem=="Windows" then -- For Windows
    rmname = "DEL"
    mvname = "MOVE"
    cpname = "COPY"
    touchnamepre = "COPY /b"
    touchnamepost = "+,,"
    newtouchname = "echo empty >"
    dirslash = "\\"
    opquote= "\""
    cmdgroupopenname = ""
    cmdgroupclosename = ""
    seqname = " & "
    bgname = ""
else
    print ("lwarpmk: ===")
    print ("lwarpmk: Select Unix or Windows for opsystem." )
    print ("lwarpmk: ===")
    os.exit(1)
end --- for Windows
-- Warning if the operating system does not appear to be correct,
-- in case files were transferred to another system.
if ( (package.config:sub(1,1)) ~= dirslash ) then
    print ("lwarpmk: ===")
    print ("lwarpmk: It appears that lwarpmk.conf is for a different operating system." )
    print ("lwarpmk: To adjust lwarpmk.conf for the current operating system," )
    print ("lwarpmk:   recompile the original document using xe/lua/pdflatex." )
    print ("lwarpmk: ")
    print ("lwarpmk: lwarpmk shall attempt to continue...")
    print ("lwarpmk: ===")
end
-- Error if the configuration file's version is not current:
if ( confversion ~= requiredconfversion ) then
    print ("lwarpmk: ===")
    print ("lwarpmk: The configuration files lwarpmk.conf and "..sourcename..".lwarpmkconf" )
    print ("lwarpmk:   must be updated.  To update the configuration files," )
    print ("lwarpmk:   recompile "..sourcename..".tex using xe/lua/pdflatex," )
    print ("lwarpmk:   then use lwarpmk again.")
    print ("lwarpmk: ===")
    os.exit(1)
end
end -- loadconf


function executecheckerror ( executecommands , errormessage )
--
-- Execute an operating system call,
-- and maybe exit with an error message.
--
local err
err = os.execute ( executecommands )
if ( err ~= 0 ) then
    print ("lwarpmk: ===")
    print ("lwarpmk: " .. errormessage )
    print ("lwarpmk: ===")
    os.exit(1)
end
end -- executecheckerror


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



function reruntoget (filesource)
--
-- Scan the LaTeX log file for the phrase "Rerun to get",
-- indicating that the file should be compiled again.
-- Return true if found.
--
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 -- if
end -- do
io.close(fsource)
return false
end



function onetime (latexcmd, fsuffix)
--
-- Compile one time, return true if should compile again.
-- fsuffix is "" for print, "_html" for HTML output.
--
print("lwarpmk: Compiling with: " .. latexcmd)
executecheckerror (
    latexcmd ,
    "Compile error."
)
return (reruntoget(sourcename .. fsuffix .. ".log") ) ;
end


function manytimes (latexcmd, fsuffix)
--
-- Compile up to five times.
-- fsuffix is "" for print, "_html" for HTML output
--
if onetime(latexcmd, fsuffix) == true then
if onetime(latexcmd, fsuffix) == true then
if onetime(latexcmd, fsuffix) == true then
if onetime(latexcmd, fsuffix) == true then
if onetime(latexcmd, fsuffix) == true then
end end end end end
end


function verifyfileexists (filename)
--
-- Exit if the given file does not exist.
--
if (lfs.attributes ( filename , "modification" ) == nil ) then
    print ("lwarpmk: ===")
    print ("lwarpmk: " .. filename .. " not found." ) ;
    print ("lwarpmk: ===")
    os.exit (1) ;
end
end



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


function removeaux ()
--
-- Remove auxiliary files:
-- All .aux files are removed since there may be many bbl*.aux files.
--
os.execute ( rmname .. " *.aux " ..
    sourcename ..".toc " .. sourcename .. "_html.toc " ..
    sourcename ..".lof " .. sourcename .. "_html.lof " ..
    sourcename ..".lot " .. sourcename .. "_html.lot " ..
    " *.idx " ..
    " *.ind " ..
    sourcename ..".ps " .. sourcename .."_html.ps " ..
    sourcename ..".log " .. sourcename .. "_html.log " ..
    sourcename ..".gl* " .. sourcename .. "_html.gl* " ..
    " *_html_inc.* "
    )
end

function checkhtmlpdfexists ()
--
-- Error if the HTML document does not exist.
-- The lateximages are drawn from the HTML PDF version of the document,
-- so "lwarpmk html" must be done before "lwarpmk limages".
--
local htmlpdffile = io.open(sourcename .. "_html.pdf", "r")
if ( htmlpdffile == nil ) then
    print ("")
    print ("lwarpmk: ===")
    print ("lwarpmk: The HTML version of the document does not exist.")
    print ("lwarpmk: Enter \"lwarpmk html\" to compile the HTML version.")
    print ("lwarpmk: ===")
    os.exit(1)
end
io.close (htmlpdffile)
end -- checkhtmlpdfexists


function warnlimages ()
--
-- Warning of a missing <sourcename>-images.txt file:
    print ("lwarpmk: ===")
    print ("lwarpmk: \"" .. sourcename .. "-images.txt\" does not exist.")
    print ("lwarpmk: Your project does not use SVG math or other lateximages,")
    print ("lwarpmk: or the file has been deleted somehow.")
    print ("lwarpmk: Use \"lwarpmk html\" to recompile your project")
    print ("lwarpmk: and recreate \"" .. sourcename .. "-images.txt\".")
    print ("lwarpmk: If your project does not use SVG math or other lateximages,")
    print ("lwarpmk: then \"" .. sourcename .. "-images.txt\" will never exist, and")
    print ("lwarpmk: \"lwarpmk limages\" will not be necessary.")
    print ("lwarpmk: ===")
end -- warnlimages


function checklimages ()
--
-- Check <sourcename>.txt to see if need to recompile first.
-- If any entry has a page number of zero, then there were incorrect images.
--
print ("lwarpmk: Checking for a valid " .. sourcename .. "-images.txt file.")
local limagesfile = io.open(sourcename .. "-images.txt", "r")
if ( limagesfile == nil ) then
    warnlimages ()
    os.exit(1)
end
-- Track warning to recompile if find a page 0
local pagezerowarning = false
-- Scan <sourcename>.txt
for line in limagesfile:lines() do
    -- lwimgpage is the page number in the PDF which has the image
    -- lwimghash is true if this filename is a hash
    -- lwimgname is the lateximage filename root to assign for the image
    i,j,lwimgpage,lwimghash,lwimgname = string.find (line,"|(.*)|(.*)|(.*)|")
    -- For each entry:
    if ( (i~=nil) ) then
        -- If the page number is 0, image references are incorrect
        --  and must recompile the soure document:
        if ( lwimgpage == "0" ) then
            pagezerowarning = true
        end
    end -- if i~=nil
end -- do
if ( pagezerowarning ) then
    print ("")
    print ("lwarpmk: ===")
    print ("lwarpmk: The document must be recompiled before creating the lateximages.")
    print ("lwarpmk: Enter \"lwarpmk html\" again, then try \"lwarpmk limages\" again.")
    print ("lwarpmk: ===")
    os.exit(1) ;
end -- pagezerowarning
end -- checklimages


function createuniximage ( lwimgfullname )
--
-- Create one lateximage for Unix / Linux / Mac OS.
--
executecheckerror (
    cmdgroupopenname ..
    "pdfseparate -f " .. lwimgpage .. " -l " .. lwimgpage .. " " .. 
        sourcename .."_html.pdf " ..
        imagesdirectory .. dirslash .."lateximagetemp-%d" .. ".pdf" ..
        seqname ..
    -- Crop the image:
    "pdfcrop  --hires  " .. imagesdirectory .. dirslash .. "lateximagetemp-" ..
        lwimgpage .. ".pdf " ..
        imagesdirectory .. dirslash .. lwimgname .. ".pdf" ..
        seqname ..
    -- Convert the image to svg:
    "pdftocairo -svg  -noshrink  " .. imagesdirectory .. dirslash .. lwimgname .. ".pdf " ..
        imagesdirectory .. dirslash .. lwimgname ..".svg" ..
        seqname ..
    -- Remove the temporary files:
    rmname .. " " .. imagesdirectory .. dirslash .. lwimgname .. ".pdf" .. seqname ..
    rmname .. " " .. imagesdirectory .. dirslash .. "lateximagetemp-" .. lwimgpage .. ".pdf" ..
    cmdgroupclosename .. " >/dev/null " .. bgname
    ,
    "File error trying to convert " .. lwimgfullname
)
-- Every 32 images, wait for completion at below normal priority,
--  allowing other image tasks to catch up.
numimageprocesses = numimageprocesses + 1
if ( numimageprocesses > 32 ) then
    numimageprocesses = 0
    print ( "lwarpmk: waiting" )
    executecheckerror ( "wait" , "File error trying to wait.")
end
end -- createuniximage


function createwindowsimage ( lwimgfullname )
--
-- Create one lateximage for Windows.
--
-- Every 32 images, wait for completion at below normal priority,
--  allowing other image tasks to catch up.
numimageprocesses = numimageprocesses + 1
if ( numimageprocesses > 32 ) then
    numimageprocesses = 0
    thiswaitcommand = "/WAIT /BELOWNORMAL"
    print ( "lwarpmk: waiting" )
else
    thiswaitcommand = ""
end
-- Execute the image generation command
executecheckerror (
    "start /B " .. thiswaitcommand .. " \"\" lwarp_one_limage " ..
    lwimgpage .. " " ..
    lwimghash .. " " ..
    lwimgname .. " " ..
    sourcename .. " <nul >nul"
    ,
    "File error trying to create image."
)
end -- createwindowsimage


function createonelateximage ( line )
--
-- Given the next line of <sourcename>.txt, convert a single image.
--
-- lwimgpage is the page number in the PDF which has the image
-- lwimghash is true if this filename is a hash
-- lwimgname is the lateximage filename root to assign for the image
i,j,lwimgpage,lwimghash,lwimgname = string.find (line,"|(.*)|(.*)|(.*)|")
-- For each entry:
if ( (i~=nil) ) then
    -- Skip if the page number is 0:
    if ( lwimgpage == "0" ) then
        pagezerowarning = true
    else
        -- Skip is this image is hashed and already exists:
        local lwimgfullname = imagesdirectory .. dirslash .. lwimgname .. ".svg"
        if (
            (lwimghash ~= "true") or
            (lfs.attributes(lwimgfullname,"mode")==nil) -- file not exists
        )
        then -- not hashed or not exists:
            -- Print the name of the file being generated:
            print ( "lwarpmk: " .. lwimgname )
            -- Touch/create the dest so that only once instance tries to build it:
            executecheckerror (
                newtouchname .. " " .. lwimgfullname ,
                "File error trying to touch " .. lwimgfullname
            )
            -- Separate out the image into its own single-page pdf:
            if opsystem=="Unix" then
                createuniximage (lwimgfullname)
            elseif opsystem=="Windows" then
                createwindowsimage (lwimgfullname)
            end
        end -- not hashed or not exists
    end -- not page 0
end -- not nil
end -- createonelateximage


function createlateximages ()
--
-- Create lateximages based on <sourcename>-images.txt:
--
-- See if the document must be recompiled first:
checklimages ()
-- See if the print version exists:
checkhtmlpdfexists ()
-- Attempt to create the lateximages:
print ("lwarpmk: Creating lateximages.")
local limagesfile = io.open(sourcename .. "-images.txt", "r")
if ( limagesfile == nil ) then
    warnlimages ()
    os.exit(1)
end
-- Create the lateximages directory, ignore error if already exists
err = os.execute("mkdir " .. imagesdirectory)
-- For Windows, create lwarp_one_limage.cmd from lwarp_one_limage.txt:
if opsystem=="Windows" then
    executecheckerror (
        cpname .. " lwarp_one_limage.txt lwarp_one_limage.cmd" ,
        "File error trying to copy lwarp_one_limage.txt to lwarp_one_limage.cmd"
    )
end -- create lwarp_one_limage.cmd
-- Track the number of parallel processes
numimageprocesses = 0
-- Track warning to recompile if find a page 0
pagezerowarning = false
-- Scan <sourcename>.txt
for line in limagesfile:lines() do
    createonelateximage ( line )
end -- do
io.close(limagesfile)
print ( "lwarpmk limages: ===")
print ( "lwarpmk limages: Wait a moment for the images to complete" )
print ( "lwarpmk limages:   before reloading the page." )
print ( "lwarpmk limages: ===")
print ( "lwarpmk limages: Done." )
if ( pagezerowarning == true ) then
    print ( "lwarpmk limages: WARNING: Images will be incorrect." )
    print ( "lwarpmk limages:   Enter \"lwarpmk cleanlimages\", then" )
    print ( "lwarpmk limages:   recompile the document one more time, then" )
    print ( "lwarpmk limages:   repeat \"lwarpmk images\" again." )
end -- pagezerowarning
end -- function


function convertepstopdf ()
--
-- Converts EPS files to PDF files.
-- The filenames are arg[argindex] and up.
-- arg[1] is the command "pdftosvg".
--
ignoreconf ()
for i = argindex , #arg do
    if (lfs.attributes(arg[i],"mode")==nil) then
        print ("lwarpmk: File \"" .. arg[i] .. "\" does not exist.")
    else
        print ("lwarpmk: Converting \"" .. arg[i] .. "\"")
        os.execute ( "epstopdf " .. arg[i] )
    end -- if
end -- do
end --function


function convertpdftosvg ()
--
-- Converts PDF files to SVG files.
-- The filenames are arg[argindex] and up.
-- arg[1] is the command "pdftosvg".
--
ignoreconf ()
for i = argindex , #arg do
    if (lfs.attributes(arg[i],"mode")==nil) then
        print ("lwarpmk: File \"" .. arg[i] .. "\" does not exist.")
    else
        print ("lwarpmk: Converting \"" .. arg[i] .. "\"")
        os.execute ( "pdftocairo -svg " .. arg[i] )
    end -- if
end -- do
end --function


-- Force an update and conclude processing:
function updateanddone ()
print ("lwarpmk: Forcing an update of " .. sourcename ..".tex.")
refreshdate ()
print ("lwarpmk: " .. sourcename ..".tex is ready to be recompiled.")
print ("lwarpmk: Done.")
end -- function


-- Start of the main code: --


-- 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
    print ("lwarpmk: Compiling with: " .. printlatexcmd)
    executecheckerror (
        printlatexcmd ,
        "Compile error."
    )
    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(printlatexcmd, "")
        print ("lwarpmk: Done.") ;
    else
        print ("lwarpmk: " .. sourcename .. ".pdf is up to date.") ;
    end
end -- not latexmk


-- lwarpmk print1:

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


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

elseif arg[1] == "printindex" then
loadconf ()
os.execute ( printindexcmd )
print ("lwarpmk: -------")
updateanddone ()


-- lwarpmk 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 .. " " .. sourcename)
updateanddone ()


-- lwarpmk html:

elseif arg[1] == "html" then
loadconf ()
if ( latexmk == "true" ) then
    print ("lwarpmk: Compiling with: " .. HTMLlatexcmd)
    executecheckerror (
        HTMLlatexcmd ,
        "Compile error."
    )
    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(HTMLlatexcmd, "_html")
        pdftohtml ()
        print ("lwarpmk: Done.")
    else
        print ("lwarpmk: " .. homehtmlfilename .. ".html is up to date.")
    end
end -- not latexmk


-- lwarpmk html1:

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


-- lwarpmk pdftohtml:
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 ()
os.execute ( HTMLindexcmd )
print ("lwarpmk: -------")
updateanddone ()


-- lwarpmk htmlglossary:
-- Compile the glossary then touch the source
-- to trigger a recompile of the document.
-- The <sourcename>.xdy file is created by the glossaries package.

elseif arg[1] == "htmlglossary" then
loadconf ()
print ("lwarpmk: Processing the glossary.")
os.execute(glossarycmd .. " " .. sourcename .. "_html")
updateanddone ()


-- lwarpmk limages:
-- Scan the <sourcename>.txt file to create lateximages.

elseif arg[1] == "limages" then
loadconf ()
print ("lwarpmk: Processing images.")
createlateximages ()
print ("lwarpmk: Done.")


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

elseif arg[1] == "again" then
loadconf ()
updateanddone ()


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

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


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

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


-- lwarpmk cleanlimages
-- Remove images from the imagesdirectory.

elseif arg[1] == "cleanlimages" then
loadconf ()
os.execute ( rmname .. " " .. imagesdirectory .. dirslash .. "*" )
print ("lwarpmk: Done.")

-- lwarpmk epstopdf <list of file names>
-- Convert EPS files to PDF using epstopdf
elseif arg[1] == "epstopdf" then
convertepstopdf ()
print ("lwarpmk: Done.")


-- lwarpmk pdftosvg <list of file names>
-- Convert PDF files to SVG using pdftocairo
elseif arg[1] == "pdftosvg" then
convertpdftosvg ()
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 ()


-- Unknown command:

else
printhelp ()
print ("\nlwarpmk: ****** Unknown command \""..arg[1].."\". ******\n")
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 \cs{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 \cs{itemize}, \cs{enumerate}, \cs{description}:
%    \begin{macrocode}
\newcommand*{\LWR@depthlist}{6}
%    \end{macrocode}
% used by \cs{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 \cs{pushclose} and \cs{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:]
% \vspace*{-2\baselineskip}
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4]
% \begin{itemize} 
%    \item{A}
%    \begin{description}
%       \item{B}
%    \end{description}
% \end{itemize}
% \end{Verbatim}
% \vspace{-\baselineskip}
% \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.
% \changes{v0.46}{2018/01/18}{Fix: Stack unnesting.}
%    \begin{macrocode}
\NewDocumentCommand{\pushclose}{m m}
{
\global\let\LWR@closetwelve\LWR@closeeleven
\global\let\LWR@closeeleven\LWR@closeten
\global\let\LWR@closeten\LWR@closenine
\global\let\LWR@closenine\LWR@closeeight
\global\let\LWR@closeeight\LWR@closeseven
\global\let\LWR@closeseven\LWR@closesix
\global\let\LWR@closesix\LWR@closefive
\global\let\LWR@closefive\LWR@closefour
\global\let\LWR@closefour\LWR@closethree
\global\let\LWR@closethree\LWR@closetwo
\global\let\LWR@closetwo\LWR@closeone
\global\let\LWR@closeone#1
\global\let\LWR@closedepthtwelve\LWR@closedeptheleven
\global\let\LWR@closedeptheleven\LWR@closedepthten
\global\let\LWR@closedepthten\LWR@closedepthnine
\global\let\LWR@closedepthnine\LWR@closedeptheight
\global\let\LWR@closedeptheight\LWR@closedepthseven
\global\let\LWR@closedepthseven\LWR@closedepthsix
\global\let\LWR@closedepthsix\LWR@closedepthfive
\global\let\LWR@closedepthfive\LWR@closedepthfour
\global\let\LWR@closedepthfour\LWR@closedepththree
\global\let\LWR@closedepththree\LWR@closedepthtwo
\global\let\LWR@closedepthtwo\LWR@closedepthone
\global\let\LWR@closedepthone#2
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\popclose}

% Pops one action and its depth off the stacks.
% \changes{v0.46}{2018/01/18}{Fix: Stack unnesting.}
%    \begin{macrocode}
\newcommand*{\popclose}
{
\global\let\LWR@closeone\LWR@closetwo
\global\let\LWR@closetwo\LWR@closethree
\global\let\LWR@closethree\LWR@closefour
\global\let\LWR@closefour\LWR@closefive
\global\let\LWR@closefive\LWR@closesix
\global\let\LWR@closesix\LWR@closeseven
\global\let\LWR@closeseven\LWR@closeeight
\global\let\LWR@closeeight\LWR@closenine
\global\let\LWR@closenine\LWR@closeten
\global\let\LWR@closeten\LWR@closeeleven
\global\let\LWR@closeeleven\LWR@closetwelve
\global\let\LWR@closedepthone\LWR@closedepthtwo
\global\let\LWR@closedepthtwo\LWR@closedepththree
\global\let\LWR@closedepththree\LWR@closedepthfour
\global\let\LWR@closedepthfour\LWR@closedepthfive
\global\let\LWR@closedepthfive\LWR@closedepthsix
\global\let\LWR@closedepthsix\LWR@closedepthseven
\global\let\LWR@closedepthseven\LWR@closedeptheight
\global\let\LWR@closedeptheight\LWR@closedepthnine
\global\let\LWR@closedepthnine\LWR@closedepthten
\global\let\LWR@closedepthten\LWR@closedeptheleven
\global\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 \cs{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}
% \changes{v0.66}{2018/12/31}{Fix with \cs{par}.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@setexparray}{m m m}{%
    \begingroup%
    \let\par\relax%
    \xdef\LWR@thisexparrayname{#1#2}%
    \ifstrempty{#3}%
    {\csgdef{\LWR@thisexparrayname}{}}%
    {\csxdef{\LWR@thisexparrayname}{#3}}%
    \endgroup%
}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\LWR@getexparray} \marg{name} \marg{index}
%    \begin{macrocode}
\newcommand*{\LWR@getexparray}[2]{%
    \@nameuse{#1#2}%
}
%    \end{macrocode}
% \end{macro}

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



% \section{Localizing catcodes}
% \label{sec:localizingcatcodes}
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}
%
% Place \cs{StartDefiningTabulars} and
%   \cs{StopDefiningTabulars}
%   \trouble[Misplaced alignment tab character \&]
%       {Misplaced alignment tab character \&>tabular>macros}
%   \trouble{tabular>Misplaced alignment tab character \&>rules}
% before and after defining macros or environments which include
% the tabular |&| character in their definitions.
%
% The catcode of |&| 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}{\StopDefiningTabulars} Place after defining something with |&| in it.
%    \begin{macrocode}
\newcommand{\StopDefiningTabulars}{%
\LWR@traceinfo{StopDefiningTabulars}%
\warpHTMLonly{\catcode`\&=4}%
}
%    \end{macrocode}
% \end{macro}


% \DescribeBoolean{LWR@mathmacro} True if currently defining math macros.
%   Used to disable \SVG\ math hashing and MathJax math contents while
%   defining a macro using inline math.
%   Begin a macro, it is not guaranteed that the contents are static, and so
%   the image must be unique.  The contents also almost certainly will not be
%   parsed correctly by MathJax.
%    \begin{macrocode}
\newbool{LWR@mathmacro}
\boolfalse{LWR@mathmacro}
%    \end{macrocode}

% \begin{macro}{\StartDefiningMath} Place before defining something with |$| in it.
% \changes{v0.57}{2018/05/23}{Added.}
%    \begin{macrocode}
\newcommand{\StartDefiningMath}{%
\LWR@traceinfo{StartDefiningMath}%
\warpHTMLonly{\catcode`\$=\active}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\StopDefiningMath} Place after defining something with |$| in it.
%    \begin{macrocode}
\newcommand{\StopDefiningMath}{%
\LWR@traceinfo{StopDefiningMath}%
\warpHTMLonly{\catcode`\$=3}% math shift
}
%    \end{macrocode}
% \end{macro}

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


% \section{Localizing dynamic math}
% \label{sec:localizingdynamicmath}
% \trouble{SVG image>math incorrect}
% \gindex{SVG>dynamic math}
% \trouble{math>incorrect}
% \trouble{math>dynamic}
% \trouble{MathJax=\brand{MathJax}>errors}
% \gindex{math>dynamic}
% \gindex{dynamic math expressions}
%
% Inline \SVG\ math usually uses a hash of its contents to generate \env{lateximage}s
% which are reusable for multiple instances with the same contents.
% If the contents may change for each use, such as depending on the current
% value of a counter, then \cs{inlinemathother} must be used before the
% inline math expression, and \cs{inlinemathnormal} must be used after.
%
% For MathJax, the inline math expression is usually printed for MathJax to
% interpret.  When marked as dynamic math, the following inline math expression
% will be displayed as an unhashed inline \SVG\ image instead.
%
% For existing code and packages, it may be possible to patch macros after
% they have been defined, using the \pkg{xpatch} package,
% which is pre-loaded by \pkg{lwarp}:
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=lines]
% \xpatchcmd{\macroname}
%     {$math expression$}
%     {\inlinemathother$math expression$\inlinemathnormal}
%     {}
%     {\typeout{Error patching macroname.}}
% \end{Verbatim}
%
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}
%
% \DescribeBoolean{LWR@dynamicmath} True to mark inline math which is dynamic in
% nature, thus should not be hashed for reuse.
% \DescribeDefault{false}
%    \begin{macrocode}
\newbool{LWR@dynamicmath}
\boolfalse{LWR@dynamicmath}
%    \end{macrocode}
%
% \begin{macro}{\inlinemathother} Place before using |$| \dots\ |$| or \cs{(} \dots \cs{)}
% if the contents of the math are not static, depending on counters or dynamic macros.
% \changes{v0.57}{2018/05/23}{Added.}
% \changes{v0.61}{2018/09/20}{Changed name from \cs{StartDynamicMath} to \cs{inlinemathother}.}
%    \begin{macrocode}
\newcommand{\inlinemathother}{%
\LWR@traceinfo{inlinemathother}%
\booltrue{LWR@dynamicmath}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\inlinemathnormal} Place after using |$| \dots\ |$| or \cs{(} \dots \cs{)}
% with dynamic contents.
% \changes{v0.61}{2018/09/20}{Changed name from \cs{StopDynamicMath} to \cs{inlinemathnormal}.}
%    \begin{macrocode}
\newcommand{\inlinemathnormal}{%
\LWR@traceinfo{inlinemathnormal}%
\boolfalse{LWR@dynamicmath}%
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}





% \section{\HTML\ entities}

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

% \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{\LWR@origpound{}x#1}}
%    \end{macrocode}
% \end{macro}

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

% \begin{macro}{\textless}
% \changes{v0.66}{2019/02/07}{Made robust.}
%    \begin{macrocode}
\let\LWR@origtextless\textless
\renewrobustcmd*{\textless}{\HTMLentity{lt}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\textgreater}
% \changes{v0.66}{2019/02/07}{Made robust.}
%    \begin{macrocode}
\let\LWR@origtextgreater\textgreater
\renewrobustcmd*{\textgreater}{\HTMLentity{gt}}
%    \end{macrocode}
% \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.}
% \changes{v0.66}{2019/01/30}{Sanitize underscores.}
%
% Prints the filename for a given section: |\HTMLFilename{}filenumber/name.html|
%    \begin{macrocode}
\newcommand*{\LWR@htmlsectionfilename}[1]{%
\LWR@traceinfo{LWR@htmlsectionfilename A !\detokenize{#1}!}%
%    \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}%
\LWR@sanitize{#1}%
\LWR@traceinfo{about to compare with ??}%
\ifthenelse{\equal{\LWR@sanitized}{??}}%
    {\LWR@traceinfo{found ??}}%
    {\LWR@traceinfo{not found ??}}%
\LWR@traceinfo{about to compare with zero or empty}%
\ifthenelse{%
    \equal{\LWR@sanitized}{0}%
    \OR \equal{\LWR@sanitized}{}%
    \OR \equal{\LWR@sanitized}{??}%
}%
{%
    \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@sanitized}%
    \ifthenelse{%
        \equal{\HTMLFilename}{} \AND
        \equal{\LWR@sanitized}{Index} \OR
        \equal{\LWR@sanitized}{index}%
    }%
    {%
        \LWR@traceinfo{Prefixing the index name with an underscore.}%
        \_\LWR@sanitized.html%
    }%
%    \end{macrocode}
% Otherwise, create a filename with the chosen prefix:
%    \begin{macrocode}
    {%
        \HTMLFilename\LWR@isolate{\LWR@sanitized}.html%
    }%
}%
\LWR@traceinfo{LWR@htmlsectionfilename Z}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@htmlrefsectionfilename} \marg{label}
%
% Prints the filename for the given label
%
% \changes{v0.50}{2018/02/20}{Fix: SVG math in a section name.}
%    \begin{macrocode}
\newcommand*{\LWR@htmlrefsectionfilename}[1]{%
\LWR@traceinfo{LWR@htmlrefsectionfilename: !\detokenize{#1}!}%
%    \end{macrocode}
% \cs{LWR@nullfonts} to allow math in a section name.
%    \begin{macrocode}
\begingroup%
\LWR@nullfonts%
\LWR@htmlsectionfilename{\LWR@htmlfileref{#1}}%
\endgroup%
\LWR@traceinfo{LWR@htmlrefsectionfilename: done}%
}
%    \end{macrocode}
% \end{macro}

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



% \section{Homepage link}

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


% \begin{macro}{\linkhomename}
% Holds the default name for the home link.
%
% \changes{v0.63}{2018/11/29}{Added.}
%    \begin{macrocode}
\newcommand{\linkhomename}{Home}
%    \end{macrocode}
% \end{macro}

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


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

% \begin{macro}{\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}{\linkhomename}{linkhome}%
}
%    \end{macrocode}
% \end{macro}

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


% \codeprint
%    \begin{macrocode}
\begin{warpprint}
%    \end{macrocode}

% \begin{macro}{\LinkHome}
% May be used wherever you wish to place a link back to the homepage.
% For print output, if \pkg{hyperref} is available a hyperlink to the first page
% is used, named by \cs{linkhomename}.
% If \pkg{hyperref} is not available, a pageref is used instead.
%
% \cs{BaseJobname} is included in the link label in case multiple
% documents are cross-referenced.
%
% \changes{v0.63}{2018/11/29}{Fix: Print version.}
% \changes{v0.66}{2019/01/23}{Fix: Document cross-references.}
%    \begin{macrocode}
\AtBeginDocument{
\@ifundefined{hyperref}{
    \newcommand*{\LinkHome}{%
        \linkhomename\ --- page \pageref{\BaseJobname-page-LWRfirstpage}%
    }
}{
    \newcommand*{\LinkHome}{%
        \hyperref[\BaseJobname-page-LWRfirstpage]{\linkhomename}%
    }
}
}

\AfterEndPreamble{\label{\BaseJobname-page-LWRfirstpage}}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpprint}
%    \end{macrocode}



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

% \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{\cs{LWRPrintStack} diagnostic tool}

% Diagnostics tool:
% Prints the \LaTeX\ nesting depth values for the stack levels.
% \cs{LWR@startpars} is used before printing the stack, so that \cs{LWRPrintStack} may
% \watchout
% be called from anywhere in the normal text flow.

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

% \begin{macro}{\LWRPrintStack} Prints the closedepth stack.
% \changes{v0.46}{2018/01/15}{Name changed from \cs{PrintStack}.}
%    \begin{macrocode}
\newcommand*{\LWR@subprintstack}{
\LWR@closedepthone\ \LWR@closedepthtwo\ \LWR@closedepththree\ 
\LWR@closedepthfour\ \LWR@closedepthfive\ \LWR@closedepthsix\ 
\LWR@closedepthseven\ \LWR@closedeptheight\ \LWR@closedepthnine\ 
\LWR@closedepthten\ \LWR@closedeptheleven\ \LWR@closedepthtwelve\ 
}

\newcommand*{\LWRPrintStack}{
\LWR@startpars
\LWR@subprintstack
}
%    \end{macrocode}
% \end{macro}

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

% \codeprint
%    \begin{macrocode}
\begin{warpprint}
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\LWRPrintStack}{}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpprint}
%    \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]{
\LWR@traceinfo{LWR@closeprevious to depth #1, depths are \LWR@subprintstack}%
%    \end{macrocode}
% Close any pending paragraph:
%    \begin{macrocode}
\LWR@stoppars%
%    \end{macrocode}
% Close anything nested deeper than the desired depth.
% First close anything deeper, then at most one of the same level.
% \changes{v0.46}{2018/01/18}{Fix: Stack unnesting.}
%    \begin{macrocode}
\whileboolexpr{test{\ifnumcomp{\LWR@closedepthone}{>}{#1}}}%
{%
    \LWR@traceinfo{LWR@closeprevious: closing out depth \LWR@closedepthone}%
    \LWR@closeoneprevious%
}%
\ifboolexpr{test{\ifnumcomp{\LWR@closedepthone}{=}{#1}}}%
{%
    \LWR@traceinfo{LWR@closeprevious: closing out depth \LWR@closedepthone}%
    \LWR@closeoneprevious%
}{}%
\LWR@traceinfo{LWR@closeprevious: done, depths are \LWR@subprintstack}%
}
%    \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.}
% \changes{v0.46}{2018/01/20}{Fix: Improper \cs{prevdepth}.}
%    \begin{macrocode}
\newcommand{\LWR@forcenewpage}{%
\LWR@traceinfo{LWR@forcenewpage}%
\ifinner\else%
\LWR@stoppars\LWR@orignewpage\LWR@startpars%
\fi%
}
%    \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}
\RenewDocumentCommand{\pagenumbering}{s m}{}
%    \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 tag modifications}

% \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.}
% \changes{v0.45}{2017/12/29}{\pkg{babel-french}: Robust commands.}
%
% Adjust \pkg{babel-french} for \HTML\ spaces.
% So far, this only works for \prog{pdflatex} and \prog{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%
    \renewrobustcmd*{\FBcolonspace}{%
        \begingroup%
        \LWR@FBcancel%
        \LWR@origampersand{}nbsp;%
        \endgroup%
    }%
    \renewrobustcmd*{\FBthinspace}{%
        \begingroup%
        \LWR@FBcancel%
        \LWR@origampersand\LWR@origpound{}x202f;% \,
        \endgroup%
    }%
    \renewrobustcmd*{\FBguillspace}{%
        \begingroup%
        \LWR@FBcancel%
        \LWR@origampersand{}nbsp;% ~,  for \og xyz \fg{}
        \endgroup%
    }%
    \DeclareDocumentCommand{\FBmedkern}{}{%
        \begingroup%
        \LWR@FBcancel%
        \LWR@origampersand\LWR@origpound{}x202f;% \,
        \endgroup%
    }%
    \DeclareDocumentCommand{\FBthickkern}{}{%
        \begingroup%
        \LWR@FBcancel%
        \LWR@origampersand{}nbsp;% ~
        \endgroup%
    }%
    \renewrobustcmd*{~}{\HTMLentity{nbsp}}% was overwritten by babel-french
    \ifFBunicode%
    \else%
        \DeclareTextSymbol{\FBtextellipsis}{LY1}{133}%
        \DeclareTextCommandDefault{\FBtextellipsis}{\textellipsis\xspace}%
    \fi%
}%
}
%    \end{macrocode}


% \subsection{\HTML\ output formatting}
%
% Helps format the output \HTML\ code for human readability.
%
% \begin{macro}{\LWR@indentHTML} Newline and indent the output \HTML\ code.
% \changes{v0.66}{2019/02/01}{Added.}
%    \begin{macrocode}
\newcommand*{\LWR@indentHTML}{%
    \LWR@orignewline\LWR@origrule{2em}{0pt}%
}
%    \end{macrocode}
% \end{macro}


% \subsection{\HTML\ tags}

% \begin{macro}{\LWR@htmltagc} \marg{tag}
% Break ligatures and use upright apostrophes in \HTML\ tags.
%
% \cs{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%
\LWR@isolate{#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 starting}%
\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
\LWR@traceinfo{LWR@nestspan starting: done}%
}% starting env
{% ending env
\LWR@traceinfo{LWR@nestspan ending}%
\ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
{}%
{\addtocounter{LWR@spandepth}{-1}}%
\LWR@traceinfo{LWR@nestspan ending: 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 |#1|#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@htmltag}[1]{%
% \LWR@traceinfo{LWR@htmltagb !\detokenize{#1}!}%
\LWR@htmltagc{#1}%
% \LWR@traceinfo{LWR@htmltagb: done}%
}
%    \end{macrocode}
% \end{macro}

% \subsection{Block tags and comments}

% In the following, \cs{origttfamily} breaks ligatures, which may not be used for \HTML\ codes:
%
% \begin{macro}{\LWR@htmlopencomment}
% \begin{macro}{\LWR@htmlclosecomment}
% \changes{v0.47}{2018/01/25}{Add \cs{mbox} to prevent line breaks.}
% \changes{v0.63}{2018/11/30}{Fix: Break ligature for \pkg{luatexko}.}
%    \begin{macrocode}
\newcommand*{\LWR@htmlopencomment}{%
{%
% \LWR@traceinfo{LWR@htmlopencomment}%
\begingroup%
\LWR@FBcancel%
\ifmmode\else\protect\LWR@origttfamily\fi%
\LWR@print@mbox{\LWR@origtextless{}!-\/-}%
\endgroup%
}%
}

\newcommand*{\LWR@htmlclosecomment}{%
{%
% \LWR@traceinfo{LWR@htmlclosecomment}%
\begingroup%
\LWR@FBcancel%
\ifmmode\else\protect\LWR@origttfamily\fi%
\LWR@print@mbox{-\/-\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@htmlblockcomment}[1]
{\LWR@stoppars\LWR@htmlcomment{#1}\LWR@startpars}
%    \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.
%
% The use of \cs{textquotedbl} instead of |"| provides improved
% compatibility with \pkg{xeCJK}.
%
% \changes{v0.20}{2017/01/17}{Factored code.}
% \changes{v0.34}{2017/08/02}{Moved optional argument in front of mandatory.}
% \changes{v0.63}{2018/11/24}{Fix for \pkg{xeCJK}.}
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@subhtmlelementclass}{m O{} m}{%
\LWR@traceinfo{LWR@subhtmlelementclass !#1!#2!#3!}%
\ifblank{#2}%
{% empty option
    \LWR@htmltag{%
        #1 % space
        class=\textquotedbl#3\textquotedbl\ % space
    }%
}%
{% non-empty option
    \LWR@htmltag{%
        #1\LWR@indentHTML%
        class=\textquotedbl#3\textquotedbl\LWR@indentHTML%
        style=\textquotedbl#2\textquotedbl\LWR@orignewline%
    }%
}%
\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{\HTML{}5 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.}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
%
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\NewDocumentEnvironment{BlockClass}{o m}{}{}%
\end{warpprint}
%    \end{macrocode}
% \end{environment}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
\NewDocumentEnvironment{LWR@print@BlockClass}{o m}{}{}%
\NewDocumentEnvironment{LWR@HTML@BlockClass}{o m}%
{%
    \LWR@origpar%
    \LWR@htmldivclass[#1]{#2}%
}
{\LWR@htmldivclassend{#2}}

\LWR@formattedenv{BlockClass}
\end{warpHTML}
%    \end{macrocode}
% 
% 
% 
% \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".}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
\newcommand{\BlockClassSingle}[2]{#2}
\end{warpall}
%    \end{macrocode}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
\newcommand{\LWR@HTML@BlockClassSingle}[2]{%
\LWR@origpar%
\LWR@htmlelementclassline{div}{#1}{#2}%
}

\LWR@formatted{BlockClassSingle}
\end{warpHTML}
%    \end{macrocode}
%
% 
% \end{macro}


% \begin{macro}{\InlineClass} \parg{WP style} \oarg{style} \marg{class} \marg{text}
%
% High-level interface for inline span classes.
%
% \parg{WP style} is \CSS\ styling to add when formatting for a word processor import.
%
% \oarg{style} is the \CSS\ styling to add when not formatting for a word processor.
%
% \changes{v0.20}{2017/01/03}{Renamed from "inlineclass".}
% \changes{v0.34}{2017/08/02}{Moved optional argument in front of mandatory.}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
% \changes{v0.62}{2018/10/24}{Added optional word-processing style.  Replaces \cs{LWR@HTMLtextstyle}.}
%
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\NewDocumentCommand{\InlineClass}{D{(}{)}{} o m +m}{#4}%
\end{warpprint}
%    \end{macrocode}
% \end{macro}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
\NewDocumentCommand{\LWR@print@InlineClass}{D{(}{)}{} o m +m}{#4}%

\NewDocumentCommand{\LWR@HTML@InlineClass}{D{(}{)}{} o m +m}{%
\ifbool{FormatWP}{%
    \LWR@htmlspanclass[#1]{#3}{#4}%
}{%
    \LWR@htmlspanclass[#2]{#3}{#4}%
}%
}

\LWR@formatted{InlineClass}
\end{warpHTML}
%    \end{macrocode}


% \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}|.
%
% The use of \cs{textquotedbl} instead of |"| provides improved
% compatibility with \pkg{xeCJK}.
%
% \changes{v0.42}{2017/10/26}{Added to factor code.}
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
% \changes{v0.63}{2018/11/24}{Fix for \pkg{xeCJK}.}
%
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\NewDocumentEnvironment{LWR@BlockClassWP}{m m m}{}{}%
\end{warpprint}
%    \end{macrocode}
% \end{environment}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
\NewDocumentEnvironment{LWR@print@LWR@BlockClassWP}{m m m}{}{}%
\NewDocumentEnvironment{LWR@HTML@LWR@BlockClassWP}{m m m}%
{%
\LWR@stoppars%
\ifbool{FormatWP}%
{%
    \addtocounter{LWR@thisautoidWP}{1}%
%    \end{macrocode}
% \changes{v0.65}{2018/12/21}{Fix space between class and id.}
%    \begin{macrocode}
    \LWR@htmltag{%
        div class=\textquotedbl#3\textquotedbl\ % space
        id=\textquotedbl%
            \LWR@print@mbox{autoidWP-\arabic{LWR@thisautoidWP}}%
        \textquotedbl%
        \ifblank{#1}{}{ style=\textquotedbl#1\textquotedbl}%
    }%
}% FormatWP
{% not FormatWP
    \LWR@htmltag{%
        div class=\textquotedbl#3\textquotedbl%
        \ifblank{#2}{}{ style=\textquotedbl#2\textquotedbl}%
    }%
}% not FormatWP
\LWR@startpars%
}
{\LWR@htmldivclassend{#3}}

\LWR@formattedenv{LWR@BlockClassWP}
\end{warpHTML}
%    \end{macrocode}


% \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}{\PN@parnotes@auto} Redefined by \pkg{parnotes} to print
% paragraph notes at the end of each paragraph.
%    \begin{macrocode}
\def\PN@parnotes@auto{}%
%    \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
%    \end{macrocode}
% If \pkg{parnotes} is used, paragraph notes are inserted
% before starting the next paragraph:
% \changes{v0.56}{2018/05/09}{Added support for \pkg{parnotes}.}
%    \begin{macrocode}
        \PN@parnotes@auto%
%    \end{macrocode}
% The opening paragraph tag:
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
        \LWR@htmltagc{\LWR@tagregularparagraph}\LWR@orignewline%
%    \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@br}
%
% Add an \HTML\ break if in a span, and not in a \env{lateximage},
% and not in tabular metadata.  Factored from \cs{LWR@closeparagraph}.
%
% \changes{v0.66}{2019/01/01}{Factored.}
%    \begin{macrocode}
\newcommand*{\LWR@closeparagraph@br}
{%
    \ifboolexpr{
        test {\ifnumcomp{\value{LWR@spandepth}}{>}{0}} and
        test {\ifnumcomp{\value{LWR@lateximagedepth}}{=}{0}} and
        not bool {LWR@intabularmetadata}
    }%
        {\unskip\LWR@htmltagc{br /}}%
        {}%
}
%    \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}
{%
% \LWR@traceinfo{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}
% Add a parbreak if in a span, not in a lateximage,
% and not in table metadata.
%    \begin{macrocode}
    {% no nested par tags
        \LWR@closeparagraph@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.
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
        \leavevmode\LWR@orignewline%
        \LWR@htmltagc{/\LWR@tagregularparagraph}%
        \LWR@orignewline%
%    \end{macrocode}
% No longer doing a 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}%
%    \end{macrocode}
% If \pkg{parnotes} is used, paragraph notes are inserted
% after ending the previous paragraph:
% \changes{v0.56}{2018/05/09}{Added support for \pkg{parnotes}.}
%    \begin{macrocode}
        \PN@parnotes@auto%
    }% end of yes nest par tags
}% end of handling pars
%    \end{macrocode}
% Add a parbreak if in a span, not in a lateximage,
% and not in table metadata.
% \changes{v0.66}{2019/01/01}{Fix: Combined span, \env{tabular}, and \env{lateximage}.}
%    \begin{macrocode}
{% not handling pars
    \LWR@closeparagraph@br%
}% not handling pars
%    \end{macrocode}
% In most cases, finish with a \LaTeX\ \cs{par}, but in the case
% of paragraphs between lines in a tabular fetch the next token instead:
% \changes{v0.46}{2018/01/19}{Fix: Tabular empty lines.}
%    \begin{macrocode}
\ifboolexpr{%
    not bool {LWR@doingapar} and
    test {\ifnumcomp{\value{LWR@tabulardepth}}{>}{0}} and
    test {
        \ifnumcomp{\value{LWR@tabulardepth}}{=}{\value{LWR@tabularpardepth}}
    } and
    bool {LWR@intabularmetadata} and
    not bool {LWR@tableparcell} and
    test {\ifnumcomp{\value{LWR@lateximagedepth}}{=}{0}}
}%
{%
    \LWR@getmynexttoken%
}{%
    \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 \cs{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}%
{%
% \LWR@traceinfo{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:
% \gindex{par=\cs{par}>hooks}
%    \begin{macrocode}
        \PushPreHook{par}{\LWR@openparagraph}%
%    \end{macrocode}
%	At the end of each paragraph, generate closing tag then 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
% \LWR@traceinfo{LWR@startpars: done}%
}
%    \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:
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
        \leavevmode\LWR@orignewline%
        \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{Indentfirst}
%
% \DescribePackage{indentfirst}
% \pkg{indentfirst} redefines \cs{@afterindentfalse} to be \cs{@afterindenttrue}.
% This is reversed \cs{AtBeginDocument} here.
%
% \changes{v0.66}{2019/02/04}{Added support for \pkg{indentfirst}.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}

%    \begin{macrocode}
\AtBeginDocument{
\def\@afterindentfalse{\let\if@afterindent\iffalse}
\@afterindentfalse
}
\let\LWR@afterindent@syntaxhighlight\fi% syntax highlighting
%    \end{macrocode}



%    \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}{}
%    \end{macrocode}
%
%
% \begin{macro}{\HTMLFirstPageTop} \marg{text and logos}
%
% \changes{v0.30}{2017/04/28}{Renamed from \cs{SetFirstPageTop}.}
%
%    \begin{macrocode}
\newcommand{\HTMLFirstPageTop}[1]{%
    \renewcommand{\LWR@firstpagetop}{#1}%
}
%    \end{macrocode}
%
%
% \end{macro}
%
%
% \begin{macro}{\HTMLPageTop} \marg{text and logos}
%
% \changes{v0.30}{2017/04/28}{Renamed from \cs{SetPageTop}.}
%
%    \begin{macrocode}
\newcommand{\HTMLPageTop}[1]{%
    \renewcommand{\LWR@pagetop}{#1}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\HTMLPageBottom} \marg{text and logos}
%
% \changes{v0.30}{2017/04/28}{Renamed from \cs{SetPageBottom}.}
%
%    \begin{macrocode}
\newcommand{\HTMLPageBottom}[1]{%
    \renewcommand{\LWR@pagebottom}{#1}%
}
%    \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}.}
% \changes{v0.45}{2017/12/29}{Improved filenames with underscores.}
%
%    \begin{macrocode}
\newcommand*{\CSSFilename}[1]{%
\renewcommand*{\LWR@currentcss}{#1}%
\@onelevel@sanitize\LWR@currentcss%
}

\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.
% \gindex{HTML>meta tag>title}
% \gindex{title>HTML meta tag}
% \gindex{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.
%
% \gindex{HTML>meta tag>title}
% \gindex{title>HTML meta tag}
% \gindex{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.
%
% \gindex{HTML>meta tag>author}
% \gindex{author>HTML meta tag}
% \gindex{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.
% \trouble[HTML author]{HTMLAuthor=\cs{HTMLAuthor}}
% \trouble{HTML>author}

% \begin{macro}{\HTMLDescription} \marg{New \HTML\ meta description.} \qquad
% Assigns the \HTML\ file's description meta tag.
%
% \gindex{HTML>meta tag>description}
% \gindex{description>HTML meta tag}
% \gindex{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}
%
% \gindex{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 or the section, depending on \progcode{FootnoteDepth},
% 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{3} Determines how deeply
% to place footnotes in the \HTML\ files, similar to |tocdepth|.
% The default of |3| places footnotes before each \cs{subsubsection} or higher.
% See \cref{tab:depthsheadings} for a table of \LaTeX\ section headings.
% \changes{v0.43}{2017/11/08}{Added \progcode{FootnoteDepth}.}
% \changes{v0.52}{2018/03/28}{Changed \progcode{FootnoteDepth} default
%       to \cs{subsbusection}.}
%    \begin{macrocode}
\newcounter{FootnoteDepth}
\setcounter{FootnoteDepth}{3}
%    \end{macrocode}

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



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


% Patch \LaTeX\ footnotes to use a new \cs{box} instead of an insert
% for \pkg{lwarp} footnotes.
% This avoids having the original \cs{footins} appear
% at the bottom of a \env{lateximage}, which is on its own new page.
%    \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{%
    \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 in the footnote even inside a \env{lateximage}:
% \changes{v0.50}{2018/02/20}{Robustify macros.}
%    \begin{macrocode}
    \renewrobustcmd{\textsuperscript}[1]{\LWR@htmlspan{sup}{##1}}%
%    \end{macrocode}
% Use paragraph tags if in a tabular data cell or a \env{lateximage}:
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
    \ifthenelse{%
        \boolean{LWR@doingstartpars} \AND%
        \cnttest{\value{LWR@lateximagedepth}}{=}{0}%
    }%
        {}%
        {\LWR@htmltagc{\LWR@tagregularparagraph}\LWR@orignewline}%
%    \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}
% Paragraph handling:
% \changes{v0.52}{2018/03/28}{Fix: Paragraph handling.}
%    \begin{macrocode}
\LWR@ensuredoingapar%
}%
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\@footnotetext} \marg{text}
%    \begin{macrocode}
\LetLtxMacro\@footnotetext\LWR@footnotetext
%    \end{macrocode}
% \end{macro}
%
%
%
% \subsection{Minipage footnote implementation}
% \label{sec:footnotesminipage}
%
% Patch \LaTeX\ minipage footnotes to use a new \cs{box} instead of an insert
% for \pkg{lwarp} minipage footnotes.
% This avoids having the original \cs{@mpfootins} appear
% at the bottom of a \env{lateximage}, which is on its own new page.
%    \begin{macrocode}
\newbox\LWR@mpfootnotes
%    \end{macrocode}
%
% \begin{macro}{\@mpfootnotetext} \marg{text}
%    \begin{macrocode}
\long\def\@mpfootnotetext#1{%
\LWR@traceinfo{@mpfootnotetext}%
\global\setbox\LWR@mpfootnotes\vbox{%
    \unvbox\LWR@mpfootnotes%
    \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}:
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
    \ifthenelse{%
        \boolean{LWR@doingstartpars} \AND%
        \cnttest{\value{LWR@lateximagedepth}}{=}{0}%
    }%
    {}%
    {\LWR@htmltagc{\LWR@tagregularparagraph}\LWR@orignewline}%
%    \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}
% Paragraph handling:
% \changes{v0.52}{2018/03/28}{Fix: Paragraph handling.}
%    \begin{macrocode}
\LWR@ensuredoingapar%
\LWR@traceinfo{@mpfootnotetext: done}%
}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\thempfootnote} Redefined to remove the \cs{itshape}, which caused
%   an obscure compiling error in some situations.
% \changes{v0.48}{2018/02/11}{Removed \cs{itshape}.}
%    \begin{macrocode}
\AtBeginDocument{
\def\thempfootnote{\@alph\c@mpfootnote}
}
%    \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 \progcode{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{macro}{\LWR@printpendingmpfootnotes}
% Enclose the minipage footnotes in a class, print, then clear.
% \changes{v0.45}{2018/01/10}{Added.}
%    \begin{macrocode}
\newcommand*{\LWR@printpendingmpfootnotes}{%
\ifvoid\LWR@mpfootnotes\else
    \LWR@forcenewpage
    \begin{BlockClass}{footnotes}
    \LWR@print@vspace*{\baselineskip}
    \unvbox\LWR@mpfootnotes
    \setbox\LWR@mpfootnotes=\vbox{}
    \end{BlockClass}
\fi
}
%    \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 \progcode{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 \progcode{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{macro}{\reversemarginpar}
% \changes{v0.45}{2017/12/12}{Added.}
%    \begin{macrocode}
\renewcommand*{\reversemarginpar}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\normalmarginpar}
% \changes{v0.45}{2017/12/12}{Added.}
%    \begin{macrocode}
\renewcommand*{\normalmarginpar}{}
%    \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{macro}{\FilenameLimit}
%   Maximum length of the generated filenames.
%    \begin{macrocode}
\newcommand*{\FilenameLimit}{80}
%    \end{macrocode}
% \end{macro}


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


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

% \begin{macro}{\LWR@thisfilename}
% The currently-active filename or number.
% At first, this is the homepage.
%    \begin{macrocode}
\AtBeginDocument{
\ifbool{FileSectionNames}%
    {\newcommand*{\LWR@thisfilename}{\HomeHTMLFilename}}
    {\newcommand*{\LWR@thisfilename}{0}}
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@thisnewfilename}
% The filename being sanitized.
%    \begin{macrocode}
\newcommand*{\LWR@thisnewfilename}{}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@simplifyname} * \marg{expression} \qquad Simplify \cs{LWR@thisnewfilename}.
%
%   If starred, detokenizes the input expression.
%   If found, changes the expression to a single detokenized dash.
%
% \changes{v0.66}{2019/02/07}{Added.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@simplifyname}{s m}{%
\IfBooleanTF{#1}{%
    \StrSubstitute{\LWR@thisnewfilename}%
        {\detokenize{#2}}%
        {\detokenize{-}}[\LWR@thisnewfilename]%
}{%
    \StrSubstitute{\LWR@thisnewfilename}%
        {#2}%
        {\detokenize{-}}[\LWR@thisnewfilename]%
}
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@simplifycustom}
%   User-defined filename simplifications.
%   Redefine with \cs{newcommand}.
% \changes{v0.67}{2019/02/13}{Added.}
%    \begin{macrocode}
\newcommand*{\LWR@simplifycustom}{}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\FilenameSimplify} * \marg{phrase}
%   Assign a user-defined filename simplification.
%   Appends to \cs{LWR@simplifycustom}.
% \changes{v0.67}{2019/02/13}{Added.}
%    \begin{macrocode}
\NewDocumentCommand{\FilenameSimplify}{s m}{%
\IfBooleanTF{#1}{%
    \appto{\LWR@simplifycustom}{%
        \LWR@simplifyname*{#2}%
    }%
}{%
    \appto{\LWR@simplifycustom}{%
        \LWR@simplifyname{#2}%
    }%
}%
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\LWR@filenamenoblanks} \marg{filename}
%
% Convert blanks into dashes, removes short words,
% store result in \\ |\LWR@thisfilename|.
%
% Also see \cs{LWR@nullfonts} for nullified macros.
%
% \changes{v0.66}{2019/02/07}{Improved file name generation.}
% \changes{v0.67}{2019/02/13}{Improved file name generation.}
%
%    \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}
%
%    \begin{macrocode}
\edef\LWR@thisnewfilename{#1}%
%    \end{macrocode}
% Replaces common macros with hyphens.
% (\cs{\&} is done by \cs{LWR@nullfonts}.)
%    \begin{macrocode}
\RenewDocumentCommand{\LWR@subsingledollar}{s m m m}{}%
\LWR@simplifyname{\_}
\LWR@simplifyname{\#}
\LWR@simplifyname{\textbackslash}
\LWR@simplifyname{\protect}
\LWR@simplifyname{\ }
\LWR@simplifyname{\textless}
\LWR@simplifyname{\textgreater}
%    \end{macrocode}
% \changes{v0.66}{2019/02/06}{Fix: Section names detokenized.}
%    \begin{macrocode}
\edef\LWR@thisnewfilename{\detokenize\expandafter{\LWR@thisnewfilename}}%
%    \end{macrocode}
%    \begin{macrocode}
\LWR@traceinfo{LWR@filenamenoblanks edef: !\LWR@thisnewfilename!}%
\fullexpandarg%
%    \end{macrocode}
% Convert spaces into hyphens:
%    \begin{macrocode}
\LWR@simplifyname*{ }
%    \end{macrocode}
% Convert punctutation into hyphens:
%    \begin{macrocode}
\LWR@simplifyname*{!}
\LWR@simplifyname*{,}
\LWR@simplifyname*{'}
\LWR@simplifyname*{+}
\LWR@simplifyname*{,}
\LWR@simplifyname*{/}
\LWR@simplifyname*{:}
\LWR@simplifyname*{;}
\LWR@simplifyname*{=}
\LWR@simplifyname*{?}
\LWR@simplifyname*{@}
\LWR@simplifyname*{^}
\LWR@simplifyname*{&}
\LWR@simplifyname*{"}
\LWR@simplifyname*{<}
\LWR@simplifyname*{>}
%    \end{macrocode}
% \changes{v0.66}{2019/02/06}{Fix: Section names with macros.}
%    \begin{macrocode}
\LWR@simplifyname{\LWRbackslash}
%    \end{macrocode}
% Braces are removed entirely to avoid extra dashes in the result.
%    \begin{macrocode}
\StrSubstitute{\LWR@thisnewfilename}%
    {\LWRleftbrace}{}[\LWR@thisnewfilename]%
\StrSubstitute{\LWR@thisnewfilename}%
    {\LWRrightbrace}{}[\LWR@thisnewfilename]%
%    \end{macrocode}
% \changes{v0.66}{2019/02/06}{Fix: Section names with percent.}
%    \begin{macrocode}
\LWR@simplifyname{\LWRpercent}
\LWR@simplifyname{\LWRdollar}
%    \end{macrocode}
%    \begin{macrocode}
\LWR@simplifyname*{|}
\LWR@simplifyname*{^}
\LWR@simplifyname*{~}
\LWR@simplifyname*{[}
\LWR@simplifyname*{]}
\LWR@simplifyname*{`}
%    \end{macrocode}
% Convert short words:
%    \begin{macrocode}
\LWR@simplifyname*{-s-}
\LWR@simplifyname*{-S-}
\LWR@simplifyname*{-a-}
\LWR@simplifyname*{-A-}
\LWR@simplifyname*{-an-}
\LWR@simplifyname*{-AN-}
\LWR@simplifyname*{-to-}
\LWR@simplifyname*{-TO-}
\LWR@simplifyname*{-by-}
\LWR@simplifyname*{-BY-}
\LWR@simplifyname*{-of-}
\LWR@simplifyname*{-OF-}
\LWR@simplifyname*{-and-}
\LWR@simplifyname*{-AND-}
\LWR@simplifyname*{-for-}
\LWR@simplifyname*{-FOR-}
\LWR@simplifyname*{-the-}
\LWR@simplifyname*{-THE-}
%    \end{macrocode}
% Convert custom words:
%    \begin{macrocode}
\LWR@simplifycustom%
%    \end{macrocode}
% Convert multiple hyphens:
%    \begin{macrocode}
\LWR@simplifyname*{-----}
\LWR@simplifyname*{----}
\LWR@simplifyname*{---}
\LWR@simplifyname*{--}
%    \end{macrocode}
% If pdf\LaTeX\ and not \optn{utf8} encoding, don't try to convert emdash, endash:
% \changes{v0.52}{2018/04/01}{Fix: \cs{FileDepth} with non-utf8 encoding.}
%    \begin{macrocode}
\ifPDFTeX% pdflatex or dvi latex
\ifdefstring{\inputencodingname}{utf8}{%
\LWR@simplifyname*{—}
%     emdash
\LWR@simplifyname*{–}
%     endash
}{}%
\else% not PDFTeX
\LWR@simplifyname*{—}
\LWR@simplifyname*{–}
\fi%
%    \end{macrocode}
% If starts with a dash, remove the leading dash:
%    \begin{macrocode}
\IfBeginWith{\LWR@thisnewfilename}{\detokenize{-}}{%
    \StrGobbleLeft{\LWR@thisnewfilename}{1}[\LWR@thisnewfilename]%
}{}%
%    \end{macrocode}
% If ends with a dash, remove the trailing dash:
%    \begin{macrocode}
\IfEndWith{\LWR@thisnewfilename}{\detokenize{-}}{%
    \StrGobbleRight{\LWR@thisnewfilename}{1}[\LWR@thisnewfilename]%
}{}%
%    \end{macrocode}
% Limits the length of the filename:
% \changes{v0.66}{2019/02/07}{Limits filename length.}
%    \begin{macrocode}
\StrLeft{\LWR@thisnewfilename}{\FilenameLimit}[\LWR@thisnewfilename]%
%    \end{macrocode}
% Return the global result:
%    \begin{macrocode}
\global\let\LWR@thisfilename\LWR@thisnewfilename%
\endgroup%
\LWR@traceinfo{LWR@filenamenoblanks: result is \LWR@thisfilename}%
}
%    \end{macrocode}
% \end{macro}


% \DescribeCounter{LWR@previousautopagelabel} Remembers which autopage label
% was most recently generated.  Used to avoid duplicates.
%    \begin{macrocode}
\newcounter{LWR@previousautopagelabel}
\setcounter{LWR@previousautopagelabel}{-1}
%    \end{macrocode}


% \DescribeFile{*_html.aux}
% A new entry in the \filenm{*_html.aux} file is used to help
% cross-references:
% \begin{sourceverb}
% \newlabel{autopage-<nnn>}{{<x>}{<y>}}
% \end{sourceverb}
% 
% \begin{macro}{\LWR@newautopagelabel} \marg{pagenumber counter}
% \changes{v0.48}{2018/02/11}{Fix: \TOC, \LOF, \LOT\ links.}
%    \begin{macrocode}
\newcommand*{\LWR@newautopagelabel}[1]{%
\ifnumequal{\value{LWR@previousautopagelabel}}{\value{page}}%
{}% no action if this autopage label has already been defined
{%
    \label{autopage-\arabic{#1}}%
    \setcounter{LWR@previousautopagelabel}{\value{page}}
}%
}
%    \end{macrocode}
% \end{macro}


% \subsection{Customizing \brand{MathJax}}

% \begin{macro}{\LWR@customizedMathJax}
% Additional \brand{MathJax} definitions to be added to the start of each \HTML\ page.
% \changes{v0.52}{2018/03/31}{Added.}
%    \begin{macrocode}
\newcommand*{\LWR@customizedMathJax}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\CustomizeMathJax}
%
% \limitscustomizemathjax
%
% \changes{v0.52}{2018/03/31}{Added.}
%    \begin{macrocode}
\newcommand*{\CustomizeMathJax}[1]{%
    \appto{\LWR@customizedMathJax}{%
        \(#1\)\par
    }%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@customizeMathJax}
% \changes{v0.51}{2018/03/18}{MathJax: Nullifies \cs{ensuremath}.}
% \changes{v0.57}{2018/05/24}{MathJax: Supports \cs{footnote}, \cs{footnotemark}.}
%    \begin{macrocode}
\newcommand{\LWR@customizeMathJax}{%
\ifbool{mathjax}{
%    \end{macrocode}
% ^^A \ifboolexpr{bool{mathjax} and not bool{mathKaTeX}}{
%    \begin{macrocode}
\LWR@stoppars
\LWR@htmlcomment{Nullify \textbackslash{}ensuremath, footnotes for MathJax:}

\(\newcommand\ensuremath[1]{##1}\)

\(\newcommand\footnote[2][]{\text{( Footnote ##1 )}}\)

\(\newcommand\footnotemark[1][]{\text{( Footnote ##1 )}}\)

\LWR@htmlcomment{Additional customizations for MathJax:}

\LWR@customizedMathJax

\LWR@startpars
}{}
}
%    \end{macrocode}
% \end{macro}


% ^^A % \subsection{Customizing Ka\TeX}

% ^^A % \begin{macro}{\LWR@customizedKaTeX}
% ^^A % Additional Ka\TeX\ definitions to be added to the start of each \HTML\ page.
% ^^A % \changes{v0.62}{2018/11/03}{Added.}
% ^^A %    \begin{macrocode}
% ^^A \newcommand*{\LWR@customizedKaTeX}{}
% ^^A %    \end{macrocode}
% ^^A % \end{macro}


% ^^A % \begin{macro}{\CustomizeKaTeX}
% ^^A %
% ^^A % \limitscustomizeKaTeX
% ^^A %
% ^^A % \changes{v0.62}{2018/11/03}{Added.}
% ^^A %    \begin{macrocode}
% ^^A \newcommand*{\CustomizeKaTeX}[1]{%
% ^^A     \appto{\LWR@customizedKaTeX}{%
% ^^A         \(#1\)\par
% ^^A     }%
% ^^A }
% ^^A %    \end{macrocode}
% ^^A % \end{macro}


% ^^A % \begin{macro}{\LWR@customizeKaTeX}
% ^^A % \changes{v0.62}{2018/11/03}{Added.}
% ^^A %    \begin{macrocode}
% ^^A \newcommand{\LWR@customizeKaTeX}{%
% ^^A \ifboolexpr{bool{mathjax} and bool{mathKaTeX}}{
% ^^A \LWR@stoppars
% ^^A \LWR@htmlcomment{Nullify \textbackslash{}ensuremath, footnotes for KaTeX:}
% ^^A 
% ^^A \(\gdef\ensuremath##1{##1}\)
% ^^A 
% ^^A \(\gdef\footnote[##1]##2{\text{( Footnote ##1 )}}\)
% ^^A 
% ^^A \(\gdef\footnotemark[##1]{\text{( Footnote ##1 )}}\)
% ^^A 
% ^^A \LWR@htmlcomment{Additional customizations for KaTeX:}
% ^^A 
% ^^A \LWR@customizedKaTeX
% ^^A 
% ^^A \LWR@startpars
% ^^A }{}
% ^^A }
% ^^A %    \end{macrocode}
% ^^A % \end{macro}


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


% \codeprint
%    \begin{macrocode}
\begin{warpprint}
%    \end{macrocode}

% \begin{macro}{\CustomizeMathJax}
% The print-mode version:
%    \begin{macrocode}
\newcommand*{\CustomizeMathJax}[1]{}
%    \end{macrocode}
% \end{macro}

% ^^A % \begin{macro}{\CustomizeKaTeX}
% ^^A % The print-mode version:
% ^^A %    \begin{macrocode}
% ^^A \newcommand*{\CustomizeKaTeX}[1]{}
% ^^A %    \end{macrocode}
% ^^A % \end{macro}

% \begin{macro}{\FilenameSimplify} * \marg{expression}
% \changes{v0.67}{2019/02/13}{Added.}
%    \begin{macrocode}
\NewDocumentCommand{\FilenameSimplify}{s m}{}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpprint}
%    \end{macrocode}



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

% \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 \progcode{FormatEPUB} or \progcode{FormatWP}: 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]{
\LWR@traceinfo{LWR@newhtmlfile}
%    \end{macrocode}
%
% At the bottom of the ending file:
%
% \changes{v0.65}{2018/12/18}{Improved \CSS\ for page layout.}
%    \begin{macrocode}
\LWR@htmlelementclassend{section}{textbody}
\LWR@htmlelementclassend{div}{bodycontainer}
\LWR@htmlelementclassend{div}{bodyandsidetoc}

\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@traceinfo{LWR@newhtmlfile: about to LWR@orignewpage}
\LWR@orignewpage

\addtocounter{LWR@htmlfilenumber}{1}%
%    \end{macrocode}
%
%
% If using a filename based on section name, create a version without blanks.
% The filename without blanks will be placed into \cs{LWR@thisfilename}.
% Duplicates will be detected using MD5 hashes.
%
% If not using a filename, the file number will be used instead.
%
% \changes{v0.12}{2016/03/13}{Bugfix: \TOC\ with numbered files.}
% \changes{v0.65}{2018/12/21}{Error if duplicate file name.}
%    \begin{macrocode}
\ifbool{FileSectionNames}%
{%
%    \end{macrocode}
% Convert the section name to a filename with blanks and common words removed.
% The resulting filename is in \cs{LWR@thisfilename}.
%    \begin{macrocode}
    \LWR@filenamenoblanks{#1}%
%    \end{macrocode}
% Create a macro name from the MD5 hash of the file name, to detect duplicates:
%    \begin{macrocode}
    \edef\LWR@hashedname{\LWR@mdfive{\LWR@thisfilename}}%
%    \end{macrocode}
% If the macro name is not yet defined, this filename is unique.
%    \begin{macrocode}
    \ifcsundef{LWR@filename\LWR@hashedname}{%
%    \end{macrocode}
% If the filename is unique, create a macro using the hashed name,
% to be used to test for additional duplicates in the future.
%    \begin{macrocode}
        \csdef{LWR@filename\LWR@hashedname}{}%
    }{%
%    \end{macrocode}
% If the filename is not unique, create an error.
%    \begin{macrocode}
        \PackageError{lwarp}
            {
                Section name ``#1'', at the line number listed below,
                generates the filename ``\LWR@thisfilename'',
                which appears to be a duplicate.
                There is a previous section with an identical or similar name.%
            }
            {
                Lwarp sanitizes most symbols and a few common short words
                when generating file names, and this may cause a conflict.
            }
    }
}
%    \end{macrocode}
% If using file numbers instead of names, the name is set to the next file number.
%    \begin{macrocode}
{\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.
%
% \changes{v0.50}{2018/02/20}{Fix: SVG math in a section name.}
%    \begin{macrocode}
\LWR@traceinfo{LWR@newhtmlfile: about to print start file}%
%    \end{macrocode}
% \cs{LWR@nullfonts} to allow math in a section name.
%    \begin{macrocode}
\begingroup%
\LWR@nullfonts%
\LWR@htmlblockcomment{%
|Start file|%
\LWR@htmlsectionfilename{\LWR@thisfilename}|%
}
\endgroup%
%    \end{macrocode}
%
%
% At the top of the starting file:
%    \begin{macrocode}
\LWR@stoppars

%    \end{macrocode}
%
% Start a new file with the given section name:
%    \begin{macrocode}
\LWR@filestart[#1]

%    \end{macrocode}
%
% Track the page numbers:
% \changes{v0.48}{2018/02/11}{Fix: \TOC, \LOF, \LOT\ links.}
%    \begin{macrocode}
\setcounter{LWR@latestautopage}{\value{page}}%
\LWR@newautopagelabel{LWR@latestautopage}%
%    \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}
%
%
% The container for the sidetoc and text body:
%    \begin{macrocode}
\LWR@htmlelementclass{div}{bodyandsidetoc}
%    \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}:
% \changes{v0.65}{2018/12/18}{Improved \CSS\ for page layout.}
%    \begin{macrocode}
\LWR@htmlelementclass{div}{bodycontainer}
\LWR@htmlelementclass{section}{textbody}

%    \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}
%
%
% Keep paragraph tags disabled for now:
%    \begin{macrocode}
\LWR@stoppars

%    \end{macrocode}
%
% If using \brand{MathJax},
% disable \cs{ensuremath} by printing a nullified
% definition at the start of each file, and add further customizations:
% \changes{v0.51}{2018/03/18}{MathJax: Nullifies \cs{ensuremath}.}
%    \begin{macrocode}
\LWR@customizeMathJax
%    \end{macrocode}
%
% ^^A % Likewise for Ka\TeX:
% ^^A % \changes{v0.62}{2018/11/03}{KaTeX: Nullifies \cs{ensuremath}.}
% ^^A %    \begin{macrocode}
% ^^A \LWR@customizeKaTeX
% ^^A %    \end{macrocode}
%
%    \begin{macrocode}
\LWR@traceinfo{LWR@newhtmlfile: done}
}
%    \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
% \prog{pdflatex} to generate characters and \prog{pdftotext} to read them.
% If extra symbols appear in the text,
% \trouble[accents in filenames]{filename>accents}
% \trouble{sectioning>accents}
% \gindex{filename>accent in}
% \gindex{accents>in section \& file names}
% it may be that \prog{pdflatex} is actually producing a symbol over or under a
% character, resulting in \prog{pdftotext} picking up the accent symbol separately.
%
% \XeLaTeX{} and \LuaLaTeX{} directly support accented section and file names.
% \gindex{accents>in section \& file names}
% \gindex{Unicode>file \& section names}
% \gindex{UTF-8>file \& section names}
% \gindex{Xe\LaTeX>file \& section names}
% \gindex{Lua\LaTeX>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 \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.
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
% \changes{v0.63}{2018/11/24}{Fix for \pkg{xeCJK}.}
%    \begin{macrocode}
\newcommand*{\LWR@createautosec}[1]{%
\LWR@htmltag{%
    #1 % space
    id=\textquotedbl\LWR@print@mbox{autosec-\arabic{page}}\textquotedbl%
}%
}
%    \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.
%
% \cs{LWR@stoppars} must be executed first.
% \watchout
%    \begin{macrocode}
\NewDocumentCommand{\LWR@pushoneclose}{m m}{%
\LWR@traceinfo{LWR@pushoneclose #1}%
    \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.
%
% \cs{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\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}
%
%
% \begin{macro}{\@partcntformat} \marg{sectiontype}
%
% \cs{let} to \cs{@seccntformat} by default, but may be redefined
% by \pkg{ctex}.
%
% \changes{v0.62}{2018/11/17}{Added for \pkg{ctex}.}
%
%    \begin{macrocode}
\let\@partcntformat\@seccntformat
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@partnameformat}
% Prints ``Part'' for part sections.
%
% Nullified by \pkg{ctex}.
%
% \changes{v0.62}{2018/11/17}{Added for \pkg{ctex}.}
%    \begin{macrocode}
\newcommand*{\@partnameformat}{\LWR@isolate{\partname}~}%
%    \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}{\ctr{LWR@currentautosec}: Added.}
% \changes{v0.66}{2019/01/28}{\ctr{LWR@currentautosec}: Fix for \LOF, \LOT float in home page.}
%    \begin{macrocode}
\newcounter{LWR@currentautosec}
\setcounter{LWR@currentautosec}{1}
%    \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: starting}%
\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}%
\IfBooleanT{#1}{\LWR@traceinfo{LWR@section: starred}}%
\ifbool{LWR@forcinghtmlpage}{\LWR@traceinfo{LWR@section: forcinghtmlpage}}{}%
\ifthenelse{%
    \(%
        \(\NOT\equal{#1}{\BooleanTrue}\)\OR%
        \(\cnttest{\@nameuse{LWR@depth#4}}{=}{\LWR@depthpart}\)\OR%
        \(\boolean{LWR@forcinghtmlpage}\)%
    \)%
    \AND%
    \cnttest{\@nameuse{LWR@depth#4}}{<=}{\value{FileDepth}}%
    \AND%
    \(%
        \NOT\boolean{CombineHigherDepths}\OR%
        \cnttest{\@nameuse{LWR@depth#4}}{<=}{\value{LWR@prevFileDepth}}%
    \)%
    \AND%
%    \end{macrocode}
% \changes{v0.43}{2017/10/31}{Fix: Expansion in comparison.}
%    \begin{macrocode}
    \(% phantomsection
        \NOT\isempty{#3}%
        \OR%
        \(\NOT\equal{#1}{\BooleanTrue}\)%
    \)%
}%
%    \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, about to LWR@orignewpage}%
    \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''
% Footnotes may be used in section names, which would also appear in the
% \HTML\ section opening comments, so the short \TOC\ entry is used if possible,
% and a limited opening comment is made if the sectional unit is starred.
% \changes{v0.43}{2017/10/31}{Fix: Nullify fonts inside \HTML\ comment.}
% \changes{v0.52}{2018/03/28}{Fix: Footnote numbering: Limited \HTML\ comment if starred.}
% \changes{v0.52}{2018/03/28}{Fix: Footnote numbering: Use short \TOC\ entry
%                                       for HTMLDebug comments.}
%    \begin{macrocode}
\ifbool{HTMLDebugComments}{%
    \begingroup%
    \LWR@nullfonts%
    \IfBooleanTF{#1}% starred
    {\LWR@htmlcomment{Opening #4*}}%
    {%
        \IfNoValueTF{#2}% short TOC
            {\LWR@htmlcomment{Opening #4 ``#3''}}%
            {\LWR@htmlcomment{Opening #4 ``#2''}}%
    }\LWR@orignewline%
    \endgroup%
}{}
%    \end{macrocode}
% For inline sections paragraph and subparagraph, start a new paragraph now:
%    \begin{macrocode}
\ifthenelse{%
    \cnttest{\@nameuse{LWR@depth#4}}{>=}{\LWR@depthparagraph}%
}%
    {\LWR@startpars}%
    {}%
%    \end{macrocode}
% Create the opening tag with an autosec:
%    \begin{macrocode}
\LWR@traceinfo{LWR@section: about to LWR@createautosec}%
\LWR@createautosec{\@nameuse{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}%
{%
    \LWR@traceinfo{LWR@section: starred}%
%    \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}{\LWR@isolate{#2}}{\LWR@isolate{#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{\@nameuse{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:
% \changes{v0.64}{2018/12/07}{Support for \pkg{ujarticle and related.}}
%    \begin{macrocode}
            \LWR@traceinfo{LWR@section: about to addcontentsline}%
            \addcontentsline{toc}{#4}%
            {%
                \protect\numberline{%
                    \@nameuse{pre#4name}%
                    \@nameuse{the#4}%
                    \@nameuse{post#4name}%
                }%
                {%
                    \ignorespaces%
                    \IfValueTF{#2}{\LWR@isolate{#2}}{\LWR@isolate{#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}{\LWR@isolate{#2}}{\LWR@isolate{#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}{\LWR@isolate{#2}}{\LWR@isolate{#3}}%
        }%
    }%
%    \end{macrocode}
% For part, print ``Part'':
%    \begin{macrocode}
    \ifbool{LWR@mainmatter}%
    {%
        \ifthenelse{%
            \(\cnttest{\@nameuse{LWR@depth#4}}{<=}%
                {\value{secnumdepth}}\) \AND%
            \(\cnttest{\@nameuse{LWR@depth#4}}{=}{\LWR@depthpart}\)%
        }%
            {\@partnameformat}%
            {}%
%    \end{macrocode}
% Print the section number:
%    \begin{macrocode}
        \LWR@traceinfo{LWR@section: about to print section number}%
        \ifthenelse{%
            \cnttest{\@nameuse{LWR@depth#4}}{<=}{\value{secnumdepth}}%
        }%
            {%
                \ifstrequal{#4}{part}%
                {\protect\LWR@sectionnumber{\@partcntformat{#4}}}%
                {%
                    \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}
\LWR@traceinfo{LWR@section: about to print the section name}%
\LWR@isolate{#3}%
%    \end{macrocode}
% Close the heading tag, such as /H2:
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
\LWR@traceinfo{LWR@section: about to close the heading tag}%
\LWR@htmltag{\@nameuse{LWR@tag#4end}}%
\LWR@orignewline%
%    \end{macrocode}
% Generate a \LaTeX{} label:
% \changes{v0.43}{2017/11/01}{Fix: Math in section name.}
% \changes{v0.48}{2018/02/11}{Fix: \TOC, \LOF, \LOT\ links.}
% \changes{v0.66}{2019/01/28}{Fix: \TOC, \LOF, \LOT\ links.}
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
\LWR@traceinfo{LWR@section: about to create the LaTeX label}%
\setcounter{LWR@latestautopage}{\value{page}}%
\LWR@newautopagelabel{LWR@currentautosec}\LWR@orignewline%
%    \end{macrocode}
% Start paragraph handing unless is an inline paragraph or subparagraph:
%    \begin{macrocode}
\ifthenelse{%
    \cnttest{\@nameuse{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{\@nameuse{LWR@depth#4}}{=}{\LWR@depthpart}%
}%
    {% not starred
        \setcounter{LWR@prevFileDepth}{\@nameuse{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{Pre- and post- sectioning names}

% \begin{macro}{\prepartname}
% \begin{macro}{\postpartname}
%
% Usually null, but is used by \pkg{uj*} and \pkg{ut*} Japanese classes.
%    \begin{macrocode}
\providecommand*{\prepartname}{}
\providecommand*{\postpartname}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}

% \begin{macro}{\prechaptername}
% \begin{macro}{\postchaptername}
%
% Usually null, but is used by \pkg{uj*} and \pkg{ut*} Japanese classes.
%    \begin{macrocode}
\providecommand*{\prechaptername}{}
\providecommand*{\postchaptername}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}

% \begin{macro}{\presectionname}
% \begin{macro}{\postsectionname}
%
% Always null, but provided here for algorithmic simplicity in \cs{LWR@section}.
%    \begin{macrocode}
\providecommand*{\presectionname}{}
\let\postsectionname\presectionname

\let\presubsectionname\presectionname
\let\postsubsectionname\postsectionname

\let\presubsubsectionname\presectionname
\let\postsubsubsectionname\postsectionname

\let\preparagraphname\presectionname
\let\postparagraphname\postsectionname

\let\presubparagraphname\presectionname
\let\postsubparagraphname\postsectionname
%    \end{macrocode}
% \end{macro}
% \end{macro}


% \subsection{\cs{section} and friends}

% \begin{macro}{\part} * \oarg{TOC name} \marg{name}
%
% \changes{v0.38}{2017/08/21}{Fix with \pkg{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} \oarg{heading 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}.}
% \changes{v0.45}{2017/12/04}{Add optional heading title for \pkg{memoir}.}
%    \begin{macrocode}
\let\@printcites\relax% for quotchap package

\newcommand{\chapter@preamble}{}% for koma-script

\@ifundefined{chapter}
{}
{%
\DeclareDocumentCommand{\chapter}{s o o m}{%
\IfValueTF{#2}{
\LWR@traceinfo{chapter #2}%
}{
\LWR@traceinfo{chapter #4}%
}
\LWR@maybeprintpendingfootnotes{\LWR@depthchapter}%
\LWR@stoppars%

\LWR@startnewdepth{\LWR@depthchapter}{\LWR@printclosechapter}%

\LWR@section{#1}{#2}{#4}{chapter}%

\@printcites% for quotchap package

\chapter@preamble% for koma-script
\renewcommand{\chapter@preamble}{}%
}
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\section} * \oarg{TOC name} \oarg{heading name} \marg{name}
% \changes{v0.45}{2017/12/04}{Add optional heading title for \pkg{memoir}.}
%    \begin{macrocode}
\DeclareDocumentCommand{\section}{s o o m}{%
\LWR@traceinfo{section: starting}%
\LWR@maybeprintpendingfootnotes{\LWR@depthsection}%
\LWR@stoppars%

\LWR@startnewdepth{\LWR@depthsection}{\LWR@printclosesection}%

\LWR@section{#1}{#2}{#4}{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.
% \gindex{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{macro}{\theHTMLTitleSeparator}
% May be used inside \cs{theHTMLTitleSection} to separate the
% website's overall \HTML\ title and the particular page's
% section name.
% \changes{v0.52}{2018/04/01}{Fix: \cs{FileDepth} with non-utf8 encoding.}
% \changes{v0.62}{2018/11/02}{Refactored.}
% \changes{v0.64}{2018/12/07}{Added \pkg{utarticle} and related.}
%    \begin{macrocode}
\ifPDFTeX% pdflatex or dvi latex
    \ifdefstring{\inputencodingname}{utf8}{%
        \newcommand*{\theHTMLTitleSeparator}{ — }% EMdash
    }{%
        \newcommand*{\theHTMLTitleSeparator}{ - }% hyphen
    }%
\else%
    \ifpTeX
        \newcommand*{\theHTMLTitleSeparator}{ - }% hyphen
    \else
        \newcommand*{\theHTMLTitleSeparator}{ — }% EMdash
    \fi%
\fi%
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\HTMLTitleBeforeSection}
% Sets the \HTML\ page's meta \attribute{title} tag to
% show the website title before the section name.
%    \begin{macrocode}
\newcommand*{\HTMLTitleBeforeSection}{%
    \def\theHTMLTitleSection{%
        \theHTMLTitle\theHTMLTitleSeparator\theHTMLSection%
    }%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\HTMLTitleAfterSection}
% Sets the \HTML\ page's meta \attribute{title} tag to
% show the section name before the website title.
%    \begin{macrocode}
\newcommand*{\HTMLTitleAfterSection}{%
    \def\theHTMLTitleSection{%
        \theHTMLSection\theHTMLTitleSeparator\theHTMLTitle%
    }%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\theHTMLTitleSection}
% Forms the \HTML\ page's meta \attribute{title} tag.
% The default is to show the website title before the section name.
% \changes{v0.62}{2018/11/02}{Added.}
%    \begin{macrocode}
\HTMLTitleBeforeSection
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\theHTMLSection}
% The section name is passed to \cs{LWR@filestart},
% which then sets \cs{theHTMLSection} for use
% inside \cs{theHTMLTitleSection} to create an
% \HTML\ meta \attribute{title} tag.
% \changes{v0.62}{2018/11/02}{Added.}
%    \begin{macrocode}
\newcommand*{\theHTMLSection}{}
%    \end{macrocode}
% \end{macro}

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



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


% \begin{macro}{\LWR@filestart} \oarg{sectionname} \qquad
% 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 !#1!}%
%    \end{macrocode}
% Locally temporarily disable direct-formatting commands:
%    \begin{macrocode}
\begingroup%
\LWR@nullfonts%
%    \end{macrocode}
% Save the section name for use while creating the
% \HTML\ meta \attribute{title} tag:
%    \begin{macrocode}
\edef\theHTMLSection{#1}%
%    \end{macrocode}
% Create the page's \HTML\ header:
%    \begin{macrocode}
\LWR@htmltag{!DOCTYPE html}\LWR@orignewline
%    \end{macrocode}
% The language is user-adjustable:
%    \begin{macrocode}
\LWR@htmltag{%
    html lang=\LWR@orig@textquotedbl\LWR@currentHTMLLanguage\LWR@orig@textquotedbl%
}\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=\LWR@orig@textquotedbl{}UTF-8\LWR@orig@textquotedbl\ /%
}\LWR@orignewline
%    \end{macrocode}
%
% Author:
% \changes{v0.44}{2017/11/18}{Fix \cs{HTMLAuthor}.}
%    \begin{macrocode}
\ifthenelse{\equal{\theHTMLAuthor}{}}%
    {}%
    {%
        \LWR@htmltag{%
            meta name=\LWR@orig@textquotedbl{}author\LWR@orig@textquotedbl\ % space
            content=\LWR@orig@textquotedbl\theHTMLAuthor\LWR@orig@textquotedbl\ /%
        }\LWR@orignewline%
    }%
%    \end{macrocode}
%
% \pkg{lwarp} is the generator:
% \gindex{HTML>meta tag>generator}
% \gindex{generator>HTML meta tag}
% \gindex{meta tag, HTML>generator}
%    \begin{macrocode}
\LWR@htmltag{%
    meta % space
    name=\LWR@orig@textquotedbl{}generator\LWR@orig@textquotedbl\ % space
    content=\LWR@orig@textquotedbl{}LaTeX lwarp package\LWR@orig@textquotedbl\ /%
}\LWR@orignewline%
%    \end{macrocode}
% If there is a description, add it now:
%    \begin{macrocode}
\ifdefempty{\LWR@currentHTMLDescription}{}{%
    \LWR@htmltag{%
        meta name=\LWR@orig@textquotedbl{}description\LWR@orig@textquotedbl\ % space
        content=\LWR@orig@textquotedbl\LWR@currentHTMLDescription\LWR@orig@textquotedbl\ /%
    }\LWR@orignewline
}%
%    \end{macrocode}
% Mobile-friendly viewport:
% \gindex{HTML>meta tag>viewport}
% \gindex{viewport>HTML meta tag}
% \gindex{meta tag, HTML>viewport}
%    \begin{macrocode}
\LWR@htmltag{%
    meta % space
    name=\LWR@orig@textquotedbl{}viewport\LWR@orig@textquotedbl\ % space
    content=\LWR@orig@textquotedbl{}width=device-width, initial-scale=1.0\LWR@orig@textquotedbl\ /%
}\LWR@orignewline
%    \end{macrocode}
% IE patch:
% \changes{v0.63}{2018/11/30}{Fix: Break ligature for \pkg{luatexko}.}
%    \begin{macrocode}
\LWR@htmltag{!-\/-[if lt IE 9]}\LWR@orignewline
\LWR@htmltag{%
    script % space
    src=\LWR@orig@textquotedbl{}%
        http://html5shiv.googlecode.com/svn/trunk/html5.js%
    \LWR@orig@textquotedbl%
}%
\LWR@htmltag{/script}\LWR@orignewline
\LWR@htmltag{![endif]-\/-}\LWR@orignewline
%    \end{macrocode}
% The page's title, if there is one.  
% A section name is also added if given.
% \changes{v0.44}{2017/11/18}{Add \cs{HTMLTitle}.}
% \changes{v0.62}{2018/11/02}{Refactored.}
%    \begin{macrocode}
\ifthenelse{\equal{\theHTMLTitle}{}}%
    {}%
    {%
        \LWR@htmltag{title}%
        \ifdefempty{\theHTMLSection}%
            {\theHTMLTitle}%
            {\theHTMLTitleSection}%
        \LWR@htmltag{/title}\LWR@orignewline%
    }%
%    \end{macrocode}
% The page's stylesheet:
%    \begin{macrocode}
\LWR@htmltag{%
    link % space
    rel=\LWR@orig@textquotedbl{}stylesheet\LWR@orig@textquotedbl\ % space
    type=\LWR@orig@textquotedbl{}text/css\LWR@orig@textquotedbl\ % space
    href=\LWR@orig@textquotedbl\LWR@currentcss\LWR@orig@textquotedbl\ /%
}%
\LWR@orignewline
%    \end{macrocode}
% Optional \brand{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}%
%    \end{macrocode}
% ^^A     \ifbool{mathKaTeX}{%
% ^^A         \verbatiminput{lwarp_KaTeX.txt}%
% ^^A     }{%
%    \begin{macrocode}
        \verbatiminput{lwarp_mathjax.txt}%
%    \end{macrocode}
% ^^A     }%
%    \begin{macrocode}
    \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}
% Executed at the beginning of the entire document.
%
% The use of \cs{textquotedbl} instead of |"| improves compatibility with \pkg{xeCJK}.
%
% \changes{v0.19}{2016/06/01}{Enabled \textbackslash\textbackslash{} equal to \cs{newline}.}
% \changes{v0.21}{2017/02/22}{Changed \filenm{lateximages} to a \filenm{.txt} file.}
% \changes{v0.28}{2017/04/09}{\progcode{FormatWordProcessor} forces single-file output.}
% \changes{v0.63}{2018/11/24}{Fixes for \pkg{xeCJK}.}
%    \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}
% No black box for overfull lines:
% \changes{v0.55}{2018/04/24}{Fix: Overfull boxes in \env{lateximage}s.}
%    \begin{macrocode}
\overfullrule=0pt
%    \end{macrocode}
% Reduce chance of line overflow when \HTML\ tags are added:
%    \begin{macrocode}
\LWR@print@footnotesize%
%    \end{macrocode}
% In \PDF\ output, don't allow line breaks to interfere with \HTML\ tags:
%    \begin{macrocode}
\LWR@print@raggedright%
\LetLtxMacro{\\}{\LWR@endofline}%
%    \end{macrocode}
% Spread the lines for \prog{pdftotext} to read them well:
%    \begin{macrocode}
\linespread{1.3}%
%    \end{macrocode}
% For \prog{pdftotext} to reliably identify paragraph splits:
%    \begin{macrocode}
\setlength{\parindent}{0pt}
\setlength{\parskip}{2ex}
%    \end{macrocode}
%
% For the \env{lateximage} record file:
%    \begin{macrocode}
\immediate\openout\LWR@lateximagesfile=\BaseJobname-images.txt
%    \end{macrocode}
%
% Removes space around the caption in the \HTML:
% \changes{v0.48}{2018/02/13}{Adjusted space around captions.}
%    \begin{macrocode}
\setlength{\belowcaptionskip}{0ex}
\setlength{\abovecaptionskip}{0ex}
%    \end{macrocode}
% Redefine the plain page style to be empty when used by index pages:
%    \begin{macrocode}
\renewcommand{\ps@plain}{}
%    \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}}
%
% 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}.
% \gindex{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}
\LetLtxMacro\TeX\LWR@TeX
\LetLtxMacro\LaTeX\LWR@LaTeX
\LetLtxMacro\LuaTeX\LWR@LuaTeX
\LetLtxMacro\LuaLaTeX\LWR@LuaLaTeX
\LetLtxMacro\XeTeX\LWR@XeTeX
\LetLtxMacro\XeLaTeX\LWR@XeLaTeX
\LetLtxMacro\ConTeXt\LWR@ConTeXt
%    \end{macrocode}
% Not yet started any paragraph handling:
%    \begin{macrocode}
\global\boolfalse{LWR@doingapar}
\global\boolfalse{LWR@doingstartpars}
%    \end{macrocode}
% Document and page settings:
% \changes{v0.45}{2017/12/08}{Fix: Lateximages on incorrect pages with Mathjax.}
%    \begin{macrocode}
\mainmatter
\LWR@origpagenumbering{arabic}
%    \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
%    \end{macrocode}
% \changes{v0.65}{2018/12/18}{Improved \CSS\ for page layout.}
%    \begin{macrocode}
\LWR@htmlelementclass{div}{bodywithoutsidetoc}
\LWR@htmlelementclass{div}{bodycontainer}
\LWR@traceinfo{LWR@lwarpStart: Generating textbody.}
\LWR@htmlelementclass{section}{textbody}
%    \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}
%
% Required for \cs{nameref} to work with \SVG\ math:
% \changes{v0.47}{2018/01/25}{Fix for \SVG\ math in \cs{nameref}.}
%    \begin{macrocode}
\immediate\write\@mainaux{\catcode`\string$\active}%
\LetLtxMacro\LWR@syntaxhighlightone$% balance for editor syntax highlighting
%    \end{macrocode}
%
% Allow \HTML\ paragraphs to begin:
%    \begin{macrocode}
\LWR@startpars
%    \end{macrocode}
%
% If using \brand{MathJax},
% disable \cs{ensuremath} by printing a nullified
% definition at the start of each file, and add further customizations:
% \changes{v0.51}{2018/03/18}{MathJax: Nullifies \cs{ensuremath}.}
%    \begin{macrocode}
\LWR@customizeMathJax
%    \end{macrocode}
%
% ^^A % Likewise for Ka\TeX:
% ^^A % \changes{v0.62}{2018/11/03}{KaTeX: Nullifies \cs{ensuremath}.}
% ^^A %    \begin{macrocode}
% ^^A \LWR@customizeKaTeX
% ^^A %    \end{macrocode}
%
%
% First autopage label in case a figure occurs early.
% \changes{v0.66}{2019/01/28}{Fix: \TOC, \LOF, \LOT\ links.}
%    \begin{macrocode}
\setcounter{LWR@latestautopage}{\value{page}}%
\LWR@newautopagelabel{LWR@currentautosec}%
%    \end{macrocode}
%
%    \begin{macrocode}
\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\@nameuse{tf@#2}
    \immediate\openout \@nameuse{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 \progcode{FormatEPUB} or \progcode{FormatWP}, 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:
% \changes{v0.65}{2018/12/18}{Improved \CSS\ for page layout.}
%    \begin{macrocode}
\LWR@htmlelementclassend{section}{textbody}
\LWR@htmlelementclassend{div}{bodycontainer}
\LWR@htmlelementclassend{div}{bodyandsidetoc}
%    \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
% \trouble[\cs{theauthor}, \pkg{authblk}]{theauthor=\cs{theauthor} and \pkg{authblk}}
% \trouble{authblk=\pkg{authblk}>theauthor=\cs{theauthor}}
% 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
% \trouble[\cs{thanks}]{title>thanks=\cs{thanks}}
% \trouble{footnote>title}
% \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.
% \trouble[\cs{theauthor}, \pkg{authblk}]{theauthor=\cs{theauthor} and \pkg{authblk}}
% \trouble{authblk=\pkg{authblk}>theauthor=\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
% \trouble[affiliations]{author>affiliation}
% \trouble{title>affiliation}
% \trouble{affiliation}
% 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{\cs{if@titlepage}}
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}
%
% \begin{macro}{\if@titlepage}
% Some classes do not provide \cs{if@titlepage}.
% In this case, provide it and force it |false|.
%    \begin{macrocode}
\ifcsvoid{@titlepagefalse}{
    \newif\if@titlepage
    \@titlepagefalse
}{}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}
%
%
% \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.
%
% \changes{v0.49}{2018/02/18}{Fix: Adapts to classes which already provide.}
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
\providerobustcmd{\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}.
% Provided even for \pkg{memoir} class, since it is used by \cs{maketitle}.
%
% \changes{v0.39}{2017/09/02}{Clear pending footnotes.}
% \changes{v0.39}{2017/09/03}{Removed minipages.}
%    \begin{macrocode}
\DeclareDocumentEnvironment{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 \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.
%
% \cs{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}
\@ifclassloaded{memoir}
{
\newcommand{\LWR@setfootnoteseries}{%
    \renewcommand\thefootnote{\@arabic\c@footnote}%
}
}{% not memoir
\if@titlepage
\newcommand{\LWR@setfootnoteseries}{%
    \renewcommand\thefootnote{\@arabic\c@footnote}%
}
\else
\newcommand{\LWR@setfootnoteseries}{%
    \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
}
\fi
}% not memoir
%    \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}~%
%    \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 \prog{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 \cs{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 \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}%
%    \end{macrocode}
% For \pkg{IEEEtran} class:
% \changes{v0.48}{2018/02/04}{Fix: Errors with \pkg{IEEEtran} class.}
%    \begin{macrocode}
    \renewcommand*{\cr}{}%
    \renewcommand*{\crcr}{}%
    \renewcommand*{\noalign}{}%
%    \end{macrocode}
%    \begin{macrocode}
        \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 \cs{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}}
% \gindex{subtitle=\cs{subtitle}}%
% \gindex{published=\cs{published}}
% \gindex{titlepage>subtitle=\cs{subtitle} and \cs{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.
%
% If \pkg{titling} is loaded, \cs{AddSubtitlePublished} creates a number
% of additional macros, and also assigns some of the \pkg{titling} hooks.
% If \pkg{titling} is not loaded, \cs{AddSubtitlePublished} creates null macros.
%
% Do not use \cs{AddSubtitlePublished} if the user has patched the \pkg{titling}
% \trouble[\pkg{titling} hooks]{titling=\pkg{titling}>hooks}
% \trouble{AddSubtitlePublished=\cs{AddSubtitlePublished}}
% 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}
\newcommand*{\AddSubtitlePublished}{%
\@ifpackageloaded{titling}{% yes titling package
    \newcommand{\@published}{}%
    \newcommand{\published}[1]{\gdef\@published{##1}}%
    \renewcommand*{\maketitlehooka}{\printpublished}%
    \newcommand*{\printpublished}{%
        \warpprintonly{\begin{center}\unskip}%
        \begin{BlockClass}{published}%
        \warpprintonly{\large\itshape}%
        \@published%
        \end{BlockClass}%
        \warpprintonly{\end{center}}%
    }%
    \newcommand{\@subtitle}{}%
    \newcommand{\subtitle}[1]{\gdef\@subtitle{##1}}%
    \renewcommand*{\maketitlehookb}{\printsubtitle}%
    \newcommand*{\printsubtitle}{%
        \warpprintonly{\begin{center}\unskip}%
        \begin{BlockClass}{subtitle}%
        \warpprintonly{\Large\itshape}%
        \@subtitle%
        \end{BlockClass}%
        \warpprintonly{\end{center}}%
    }%
}% yes titling package
{% no titling package
    \newcommand{\published}[1]{}%
    \newcommand*{\printpublished}{}%
    \newcommand{\subtitle}{}%
    \newcommand*{\printsubtitle}%
}% no titling package
}% \AddSubtitlePublished
%    \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}
%
% Some classes allow an optional name, so it is allowed here.
% \begin{environment}{abstract}
% \changes{v0.48}{2018/02/05}{Allow optional name.}
%    \begin{macrocode}
\DeclareDocumentEnvironment{abstract}{O{\abstractname}}
{
\LWR@forcenewpage
\BlockClass{abstract}
\BlockClassSingle{abstracttitle}{#1}
}
{
\endBlockClass
}
%    \end{macrocode}
% \end{environment}

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






% \section{Quote and verse}

% \subsection{Attributions}

% \begin{macro}{\attribution}
% For use with quote, quotation, verse:
%
% Ex: |"A quotation." \attribution{\textsc{Author Name}\\\textsl{Book Title}}|
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
\newcommand{\attribution}[1]{%
    \begin{BlockClass}{attribution}
    #1
    \end{BlockClass}
}
\end{warpHTML}
%    \end{macrocode}
% \codeprint
%    \begin{macrocode}
\begin{warpprint}
\newcommand{\attribution}[1]{
    \begin{flushright}
    \unskip
    #1
    \end{flushright}%
}
\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
%
% \subsubsection{\LaTeX\ core \env{verse} environment}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
% \begin{environment}{verse}
% \changes{v0.54}{2018/04/08}{Fix: Line spacing.}
%    \begin{macrocode}
\renewenvironment{verse}
               {\let\\\newline% lwarp
                \list{}{\itemsep      \z@
                        \itemindent   -1.5em%
                        \listparindent\itemindent
                        \rightmargin  \leftmargin
                        \advance\leftmargin 1.5em}%
                \item\relax}
               {\endlist}
%    \end{macrocode}
% \end{environment}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}
%
% \subsubsection{\pkg{verse} and \pkg{memoir}}
%
% The following lengths are used by \pkg{verse} and \pkg{memoir}.
% They 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 \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{1: style}
%       \marg{2: negative \cs{baselineskip} \cs{vspace}}
%       \marg{3: class}
%
% Encloses a verbatim environment with the given \CSS\ class.
%
% The use of \cs{textquotedbl} instead of |"| improves compatibility with \pkg{xeCJK}.
%
% \changes{v0.51}{2018/03/17}{Adds vertical offset.}
% \changes{v0.63}{2018/11/24}{Fix for \pkg{xeCJK}.}
%    \begin{macrocode}
\newcommand*{\LWR@atbeginverbatim}[3][]
{%
%    \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 \brand{MathJax} script.
%    \begin{macrocode}
\ifbool{LWR@verbtags}{%
    \LWR@htmltag{pre class=\textquotedbl#3\textquotedbl%
        \ifthenelse{\equal{#1}{}}{}{ style=\textquotedbl#1\textquotedbl}%
    }%
    \LWR@orignewline% pre
    \leavevmode\unskip\LWR@print@vspace*{-#2\baselineskip}%
}{}%
%    \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.
% \changes{v0.50}{2018/03/02}{Improved column alignment.}
%    \begin{macrocode}
\begingroup%
%    \end{macrocode}
% \changes{v0.50}{2018/03/02}{Improved column alignment.}
% \changes{v0.54}{2018/04/06}{Improved column alignment.}
%    \begin{macrocode}
% \LWR@print@normalsize%
\LWR@origttfamily%
\LWR@print@small%
%    \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}
\LWR@select@print@hspace%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@afterendverbatim}
%       \marg{negative \cs{baselineskip} \cs{vspace}}
%
%       Finishes enclosing a verbatim environment.
% \changes{v0.54}{2018/04/07}{Added vspace argument.}
%    \begin{macrocode}
\newcommand*{\LWR@afterendverbatim}[1]{%
\endgroup%
\par%
%    \end{macrocode}
% At the end of the environment, close the |pre|:
%    \begin{macrocode}
\ifbool{LWR@verbtags}{%
    \LWR@print@vspace*{-#1\baselineskip}%
    \noindent\LWR@htmltag{/pre}\LWR@orignewline% 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{2.5}{Verbatim}%
\LWRV@origverbatim@input{#1}{#2}%
\LWR@afterendverbatim{1.5}%
}
%    \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{2.5}{verbatim}%
}
\AfterEndEnvironment{verbatim}{%
    \LWR@afterendverbatim{1}%
}
}
%    \end{macrocode}
% \end{environment}


% \begin{environment}{tabbing}
%
% \limitstabbing
%
% \changes{v0.42}{2017/10/13}{Added.}
% \changes{v0.52}{2018/03/27}{Fix to allow inside \env{lateximage}.}
% \changes{v0.58}{2018/06/07}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\newcommand*{\LWR@HTML@tabbing}{%
\LWR@forcenewpage%
\LWR@atbeginverbatim{3}{tabbing}%
\LWR@print@tabbing%
}

\newcommand*{\LWR@HTML@endtabbing}{%
    \LWR@print@endtabbing%
    \LWR@afterendverbatim{1}%
}

\LWR@formatted{tabbing}
\LWR@formatted{endtabbing}
%    \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}
\trivlist
\item[\InlineClass{theoremlabel}{#1\ #2\ }]\itshape
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@opargbegintheorem} \marg{name} \marg{number} \marg{oparg}
%    \begin{macrocode}
\renewcommand{\@opargbegintheorem}[3]{%
\LWR@forcenewpage
\BlockClass{theoremcontents}
\trivlist
\item[\InlineClass{theoremlabel}{#1\ #2\ (#3)\ }]\itshape
}
%    \end{macrocode}
% \end{macro}
% \begin{macro}{\@endtheorem}
%    \begin{macrocode}
\renewcommand*{\@endtheorem}{%
\endtrivlist
\endBlockClass% theoremcontents
}
%    \end{macrocode}
% \end{macro}

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



% \section{Lists}
%
% \limitslists
%
% ^^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}
% \gindex{item>empty}%
% \gindex{list>empty item}%
% \trouble{list>empty item}%
% 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}
%
%
%
% \DescribeMacro{\makelabel}
% \limitsmakelabel
%
% \changes{v0.34}{2017/07/27}{Lists refactored to remove \pkg{enumitem} requirement.}
%
% \subsection{List environment}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}


% \begin{macro}{\LWR@printcloselist}
% May be locally redefined by \env{enumerate} or \env{description}.
%    \begin{macrocode}
\newcommand*{\LWR@printcloselist}{\LWR@printcloseitemize}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@printopenlist}
% May be locally redefined by \env{enumerate} or \env{description}.
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\newcommand*{\LWR@printopenlist}{ul style="\LWR@print@mbox{list-style-type:none}"}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\@mklab}
% Removes \PDF\ spacing.
% \changes{v0.45}{2018/01/11}{Modified for \HTML.}
%    \begin{macrocode}
\AtBeginDocument{
\def\@mklab#1{%
%     \hfil %
    #1}
\let\makelabel\@mklab
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\@donoparitem}
% Modified for \HTML\ output by replacing \TeX\ boxes with plain text.
% Also removes \PDF\ spacing.
% \changes{v0.45}{2018/01/11}{Modified for \HTML.}
%    \begin{macrocode}
\def\@donoparitem{%
  \@noparitemfalse
%   \global\setbox\@labels\hbox{\hskip -\leftmargin
%                                \unhbox\@labels
%                                 \hskip \leftmargin}%
%   \if@minipage\else
%     \@tempskipa\lastskip
%     \vskip -\lastskip
%     \advance\@tempskipa\@outerparskip
%     \advance\@tempskipa -\parskip
%     \vskip\@tempskipa
%   \fi
}
%    \end{macrocode}
% \end{macro}
%
%
%
%
% \begin{macro}{\@item}
% Modified for \HTML\ output by replacing \TeX\ boxes with plain text.
% Also removes \PDF\ spacing.
% \changes{v0.45}{2018/01/11}{Modified for \HTML.}
% \changes{v0.48}{2018/02/02}{Honors \cs{makelabel}.}
%    \begin{macrocode}
\def\LWR@HTML@item[#1]{%
\LWR@traceinfo{@item}
  \if@noparitem
    \@donoparitem
  \else
%     \if@inlabel
%       \indent
        \par
%     \fi
    \ifhmode
%       \unskip\unskip
        \par
    \fi
    \if@newlist
      \if@nobreak
        \@nbitem
      \else
%         \addpenalty\@beginparpenalty
%         \addvspace\@topsep
%         \addvspace{-\parskip}%
      \fi
    \else
%       \addpenalty\@itempenalty
%       \addvspace\itemsep
    \fi
    \global\@inlabeltrue
  \fi
%   \everypar{%
    \@minipagefalse
    \global\@newlistfalse
%    \end{macrocode}
%    \begin{macrocode}
%     \if@inlabel
%       \global\@inlabelfalse
%    \end{macrocode}
%    \begin{macrocode}
%       {\setbox\z@\lastbox
%        \ifvoid\z@
%          \kern-\itemindent
%        \fi}%
%    \end{macrocode}
%
%    \begin{macrocode}
%       \box\@labels
%       \penalty\z@
%     \fi
%    \end{macrocode}
%    \begin{macrocode}
%     \if@nobreak
%       \@nobreakfalse
%       \clubpenalty \@M
%     \else
%       \clubpenalty \@clubpenalty
%       \everypar{}%
%     \fi}%
%    \end{macrocode}
%    \begin{macrocode}
  \if@noitemarg
    \@noitemargfalse
    \if@nmbrlist
%    \end{macrocode}
%    \begin{macrocode}
      \refstepcounter\@listctr
    \fi
  \fi
%    \end{macrocode}
% \changes{v0.51}{2018/03/17}{Restored list label space.}
%    \begin{macrocode}
    \makelabel{#1} % extra space
%   \sbox\@tempboxa{\makelabel{#1}%
%   \global\setbox\@labels\hbox{%
%     \unhbox\@labels
%     \hskip \itemindent
%     \hskip -\labelwidth
%     \hskip -\labelsep
%     \ifdim \wd\@tempboxa >\labelwidth
%       \box\@tempboxa
%    \end{macrocode}
%    \begin{macrocode}
%     \else
%       \hbox to\labelwidth {\unhbox\@tempboxa}%
%     \fi
%     \hskip \labelsep}%
  \ignorespaces%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\@nbitem}
%    \begin{macrocode}
\def\@nbitem{%
%   \@tempskipa\@outerparskip
%   \advance\@tempskipa -\parskip
%   \addvspace\@tempskipa
}
%    \end{macrocode}
% \end{macro}
%


% \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{macro}{\LWR@nulllistfills} Nullifies various \TeX\ fill commands,
% in case they are used inside \cs{makelabel}.
% Problems are caused when these are nullified all the time.
%    \begin{macrocode}
\newcommand*{\LWR@nulllistfills}{%
\renewcommand*{\hss}{}%
\renewcommand*{\llap}[1]{##1}%
\renewcommand*{\rlap}[1]{##1}%
\renewcommand*{\hfil}{}%
\renewcommand*{\hfilneg}{}%
\renewcommand*{\hfill}{}%
}
%    \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@traceinfo{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}%
\LWR@nulllistfills%
}
%    \end{macrocode}
% \changes{v0.46}{2018/01/21}{Fix: Stack unnesting.}
%    \begin{macrocode}
\newcommand*{\LWR@listend}{%
\LWR@traceinfo{LWR@listend}%
\LWR@stoppars%
\LWR@closeprevious{\LWR@depthlist}%
\LWR@startpars%
}
%    \end{macrocode}
% \end{environment}


% \subsection{Itemize}

% \begin{macro}{\LWR@itemizeitem} \oarg{label}
%
% Handles \cs{item} inside an itemize or enumerate.
%
% See \cs{LWR@openparagraph} where extra \cs{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}
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\newcommand*{\LWR@itemizestart}{%
\renewcommand*{\LWR@printcloselist}{\LWR@printcloseitemize}
\renewcommand*{\LWR@printopenlist}{ul style="\LWR@print@mbox{list-style-type:none}"}
\let\item\LWR@itemizeitem%
\LWR@nulllistfills%
}
%    \end{macrocode}
% \end{environment}



% \subsection{Enumerate}

% An \HTML\ unordered list is used with customized \LaTeX-generated labels.

% \begin{environment}{enumerate} \oarg{options}
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\newcommand*{\LWR@enumeratestart}{%
\renewcommand*{\LWR@printcloselist}{\LWR@printcloseitemize}
\renewcommand*{\LWR@printopenlist}{ul style="\LWR@print@mbox{list-style-type:none}"}
\let\item\LWR@itemizeitem%
\LWR@nulllistfills%
}
%    \end{macrocode}
% \end{environment}


% \subsection{Description}

% \begin{macro}{\LWR@descitem} \oarg{label}
% Handles an \cs{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}
\LWR@select@html@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}
\LWR@select@html@hspace%
%    \end{macrocode}
%    \begin{macrocode}
\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%
\LWR@nulllistfills%
}
%    \end{macrocode}
% \end{environment}


% \subsection{Patching the lists}

% \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}{%
    \LetLtxMacro\item\LWR@listitem%
    \LetLtxMacro\@item\LWR@HTML@item%
    \renewcommand*{\@trivlist}{%
        \LWR@traceinfo{@trivlist start}%
        \LWR@liststart%
        \LWR@orig@trivlist%
        \LWR@traceinfo{@trivlist done}%
    }%
    \renewcommand*{\trivlist}{%
        \LWR@traceinfo{trivlist}%
        \LWR@origtrivlist%
    }%
    \renewcommand*{\endtrivlist}{%
        \LWR@traceinfo{endtrivlist start}%
        \LWR@origendtrivlist\LWR@listend%
        \LWR@traceinfo{endtrivlist done}%
    }%
    \renewcommand*{\itemize}{%
        \LWR@itemizestart\LWR@origitemize%
    }%
    \renewcommand*{\enumerate}{%
        \LWR@enumeratestart\LWR@origenumerate%
    }%
    \renewcommand*{\description}{%
        \LWR@descriptionstart\LWR@origdescription%
    }%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@restoreoriglists} Restores the original \env{trivlist} environment.
%    \begin{macrocode}
\newcommand*{\LWR@restoreoriglists}{%
\LWR@traceinfo{LWR@restoreoriglists}%
\LetLtxMacro\item\LWR@origitem%
\LetLtxMacro\@item\LWR@orig@item%
\let\@trivlist\LWR@orig@trivlist%
\let\trivlist\LWR@origtrivlist%
\let\endtrivlist\LWR@origendtrivlist%
\LetLtxMacro\itemize\LWR@origitemize%
\LetLtxMacro\enditemize\LWR@endorigitemize%
\LetLtxMacro\enumerate\LWR@origenumerate%
\LetLtxMacro\endenumerate\LWR@endorigenumerate%
\LetLtxMacro\description\LWR@origdescription%
\LetLtxMacro\enddescription\LWR@endorigdescription%
\let\@mklab\LWR@orig@mklab%
\let\makelabel\LWR@origmakelabel%
\let\@donoparitem\LWR@orig@donoparitem%
\let\@nbitem\LWR@orig@nbitem%
}
%    \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 of the \LaTeX\ core
% and the various tabular-related packages.
%
%
% \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 \progcode{\&} to localize catcode changes.}
% \changes{v0.33}{2017/07/10}{Add: Tabular at and bang columns now have their
%	own \HTML\ columns.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
% \subsection{Temporary package-related macros}
%
% These macros are temporary placeholders for macros defined by various
% packages.  If the relevent package is not loaded, these placeholders are used instead.
%
%
% \subsubsection{\pkg{arydshln}}
%
% Emualated by the original \LaTeX\ non-dashed versions.
% \changes{v0.56}{2018/05/04}{\pkg{arydshln}: Added.}
%    \begin{macrocode}
\LetLtxMacro\hdashline\hline
\LetLtxMacro\cdashline\cline
\LetLtxMacro\firsthdashline\hline
\LetLtxMacro\lasthdashline\hline
%    \end{macrocode}
%
%
% \subsection{Token lookahead}

% Used by \cs{LWR@futurenonspacelet} to look at the next token.

% \begin{macro}{\LWR@mynexttoken}
%    \begin{macrocode}
\newcommand\LWR@mynexttoken\relax
%    \end{macrocode}
% \end{macro}

% \cs{futurelet} copies the next token then executes a function to analyze

% \cs{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 \cs{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{Tabular variables}

% \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.
% \changes{v0.60}{2018/09/17}{\env{tabular}: Improved memory management: Global boolean.}
%    \begin{macrocode}
\newbool{LWR@tabularcelladded}
\boolfalse{LWR@tabularcelladded}
%    \end{macrocode}

% \DescribeCounter{LWR@hlines}
% Number of \cs{hline}s or \cs{midrule}s above the next row.
%    \begin{macrocode}
\newcounter{LWR@hlines}
%    \end{macrocode}

% \DescribeCounter{LWR@hdashedlines}
% Number of \pkg{arydshln} dashed lines above the next row.
%    \begin{macrocode}
\newcounter{LWR@hdashedlines}
%    \end{macrocode}

% \DescribeBoolean{LWR@doingtbrule}
% True if the next row will have a top/bottom rule above it.
% \changes{v0.60}{2018/09/17}{\env{tabular}: Improved memory management: Global boolean.}
%    \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}


% \DescribeCounter{LWR@tabularDepth}
% Tracks whether |&| is being used inside a \env{tabular}.
%    \begin{macrocode}
\newcounter{LWR@tabulardepth}
\setcounter{LWR@tabulardepth}{0}
%    \end{macrocode}
%
% \DescribeCounter{LWR@tabularpardepth}
% Tracks whether should look ahead at the next token
%   when encountering a \cs{par} while processing tabular contents.
%
% When |LWR@tabularpardepth| is deeper than |LWR@tabulardepth| then
% \pkg{lwarp} has started looking at the contents of the |tabular|, and thus
% any \cs{par}s encountered must be followed by another token lookahead.
% \changes{v0.46}{2018/01/18}{\ctr{LWR@tabularpardepth} added.}
%    \begin{macrocode}
\newcounter{LWR@tabularpardepth}
\setcounter{LWR@tabularpardepth}{0}
%    \end{macrocode}
%
%
%    \begin{macrocode}
\newcommand*{\LWR@colsresult}{}%temp storage for column format results
\newcommand*{\LWR@pposition}{}
\newcommand*{\LWR@pleft}{}
\newcommand*{\LWR@pright}{}
%    \end{macrocode}


% \DescribeObject{LWR@tablecolspec} Holds the parsed column specification,
% of total width |LWR@tabletotalLaTeXcols|, not counting |@| and |!| columns.
%
% Will contain a string such as |llrrccpc|, exactly one letter per \LaTeX\ table column,
% without |@|, |!|, |>|, |<|, or the vertical bar.
% \changes{v0.60}{2018/09/17}{\env{tabular}: Improved memory management: Not using \pkg{xstring}.}


% \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.
%    \begin{macrocode}
\newcounter{LWR@tablecolspecindex}
%    \end{macrocode}

% \DescribeCounter{LWR@tableLaTeXcolindex}
% 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@tableLaTeXcolindex}
%    \end{macrocode}

% \DescribeCounter{LWR@tabletotalLaTeXcols}
% 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@tabletotalLaTeXcols|.)
%    \begin{macrocode}
\newcounter{LWR@tabletotalLaTeXcols}
%    \end{macrocode}

% \DescribeCounter{LWR@tabletotalLaTeXcolsnext}
% Holds the next \LaTeX\ table column index while parsing,
% equal to one more than |LWR@tabletotalLaTeXcols|.
%    \begin{macrocode}
\newcounter{LWR@tabletotalLaTeXcolsnext}
%    \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{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@tableLaTeXcolindex}}%
    \LWR@printatbang{bang}{\arabic{LWR@tableLaTeXcolindex}}%
}%
}
%    \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 \progcode{\protect\textgreater} for \cs{bottomrule}.}
% \changes{v0.61}{2018/09/23}{Fix: Par tags in \env{tabular}.}
%
%    \begin{macrocode}
\newcommand*{\LWR@closetabledatacell}{%
\LWR@stoppars%
\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 \progcode{\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@tableLaTeXcolindex}}}%
%    \end{macrocode}
% Close paragraphs:
%    \begin{macrocode}
        \ifbool{LWR@tableparcell}{\LWR@stoppars}{}%
        \global\boolfalse{LWR@tableparcell}%
%    \end{macrocode}
%
% Close the table data cell.
%
% Close any color \element{div}s.
% \changes{v0.48}{2018/02/06}{\pkg{colortbl}: Added.}
%    \begin{macrocode}
        \whileboolexpr{test {\ifnumcomp{\value{LWR@cellcolordepth}}{>}{0}}}{%
            \LWR@htmltag{/div}\LWR@orignewline%
            \addtocounter{LWR@cellcolordepth}{-1}%
        }%
%    \end{macrocode}
% 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}
% Color control.  Column is set by |>{}| for each cell, so it must be cleared here.
% \changes{v0.48}{2018/02/06}{\pkg{colortbl}: Added.}
%    \begin{macrocode}
\gdef\LWR@cellHTMLcolor{}
\gdef\LWR@columnHTMLcolor{}
\setcounter{LWR@cellcolordepth}{0}
}
%    \end{macrocode}
% \end{macro}
%
% 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{Handling \progcode{\&}}
%
% \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@tableLaTeXcolindex}{1}%
%    \end{macrocode}
% Have not yet added data in this column:
%    \begin{macrocode}
    \global\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%
    test{\ifnumcomp{\value{LWR@hlines}}{>}{0}} or%
    test{\ifnumcomp{\value{LWR@hdashedlines}}{>}{0}} or%
    bool{LWR@startedrow}%
}{%
%    \end{macrocode}
% To temporarily turn off |LWR@exitingtabular| so that
% table data tags will still be generated:
%
% If generating a final row for the \cs{bottomrule} borders,
% turn off the |@|, |!|, |<|, and |>| column output:
%    \begin{macrocode}
\ifbool{LWR@exitingtabular}{%
    \global\booltrue{LWR@tabularmutemods}%
}{%
    \global\boolfalse{LWR@tabularmutemods}%
}%
%    \end{macrocode}
% Locally 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@tableLaTeXcolindex}}{<}{\value{LWR@tabletotalLaTeXcols}}
    } or %
    (%
        bool{LWR@intabularmetadata} and%
        not bool{LWR@tabularcelladded} and%
        test {
            \ifnumcomp{\value{LWR@tableLaTeXcolindex}}{=}{\value{LWR@tabletotalLaTeXcols}}
        }%
    )%
}%
{%
    \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@tableLaTeXcolindex}{1}%
    \global\boolfalse{LWR@tabularcelladded}%
    \global\booltrue{LWR@emptyatbang}%
%    \end{macrocode}
% Starts the next cell:
%    \begin{macrocode}
    \ifnumcomp{\value{LWR@tableLaTeXcolindex}}{<}{\value{LWR@tabletotalLaTeXcols}}%
        {\LWR@getmynexttoken}%
        {}%
}%
%    \end{macrocode}
% Reenable the original |LWR@exitingtabular| to close the entire table:
%    \begin{macrocode}
\ifbool{LWR@tabularmutemods}{%
    \global\booltrue{LWR@exitingtabular}%
}{%
    \global\boolfalse{LWR@exitingtabular}%
}%
\global\boolfalse{LWR@tabularmutemods}%
%    \end{macrocode}
%    \begin{macrocode}
\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}{%
%    \end{macrocode}
% Finish the row:
%    \begin{macrocode}
\ifnumcomp{\value{LWR@tableLaTeXcolindex}}{<}{\value{LWR@tabletotalLaTeXcols}}%
    {\LWR@tabularfinishrow}%
    {\LWR@closetabledatacell}%
\LWR@htmltag{/tr}\LWR@orignewline%
%    \end{macrocode}
% \pkg{xcolor} row color support:
%    \begin{macrocode}
\@rowc@lors%
%    \end{macrocode}
% No longer inside a data cell:
%    \begin{macrocode}
\global\booltrue{LWR@intabularmetadata}%
%    \end{macrocode}
% Not yet started a table row:
%    \begin{macrocode}
\global\boolfalse{LWR@startedrow}%
%    \end{macrocode}
% Additional setup:
%    \begin{macrocode}
\setcounter{LWR@hlines}{0}%
\setcounter{LWR@hdashedlines}{0}%
\global\boolfalse{LWR@doingtbrule}%
\global\boolfalse{LWR@doingcmidrule}%
\LWR@clearmidrules%
\gdef\LWR@rowHTMLcolor{}%
%    \end{macrocode}
% Start at first column:
%    \begin{macrocode}
\setcounter{LWR@tableLaTeXcolindex}{1}%
%    \end{macrocode}
% Have not yet added data in this column:
%    \begin{macrocode}
\global\boolfalse{LWR@tabularcelladded}%
%    \end{macrocode}
% Allow \TeX\ to flush the pending paragraph.
% Not doing so causes a slowdown for very large tables.
% \changes{v0.60}{2018/09/17}{Fix: Slowdown for long tables.}
%    \begin{macrocode}
\LWR@stoppars
\LWR@origpar
%    \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{Looking ahead in the column specifications}
%
% \begin{macro}{\LWR@columnspeclookahead} \marg{offset}
%
% Looks |offset| tokens ahead in the column specification,
% setting \cs{LWR@strresulttwo}.
%
% The |w| column alignment will be seen as a single unit such as |{c}|.
%    \begin{macrocode}
\newcommand*{\LWR@columnspeclookahead}[1]{%
\setcounter{LWR@tempcountone}{\value{LWR@tablecolspecindex}}%
\addtocounter{LWR@tempcountone}{#1}%
\fullexpandarg%
\StrChar{\LWR@origcolspec}{\arabic{LWR@tempcountone}}[\LWR@strresulttwo]%
%    \end{macrocode}
% Get the contents of the first group in \cs{LWR@strresulttwo}:
%    \begin{macrocode}
\exploregroups%
\StrChar{\LWR@strresulttwo}{1}[\LWR@strresulttwo]%
\noexploregroups%
}
%    \end{macrocode}
% \end{macro}


% \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 \progcode{@}.}
%
%    \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@tabletotalLaTeXcols}}{=}{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@tabletotalLaTeXcols}}{\LWR@colparameter}%
    \LWR@traceinfo{at \arabic{LWR@tabletotalLaTeXcols}: %
    \LWR@getexparray{LWR@colatspec}{\arabic{LWR@tabletotalLaTeXcols}}}%
}%
\let\LWR@colparameter\relax%
\global\booltrue{LWR@validtablecol}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@parsebangcolumn}
% Handles |!{text}| columns.
%
% \changes{v0.22}{2017/02/28}{Added tabular \progcode{!!} 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@tabletotalLaTeXcols}}{=}{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@tabletotalLaTeXcols}}{\LWR@colparameter}%
    \LWR@traceinfo{bang \arabic{LWR@tabletotalLaTeXcols}: \LWR@colparameter!}%
}%
\let\LWR@colparameter\relax%
\global\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@tabletotalLaTeXcolsnext}}{\LWR@colparameter}%
\let\LWR@colparameter\relax%
\global\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@tabletotalLaTeXcols}}{\LWR@colparameter}%
\let\LWR@colparameter\relax%
\global\booltrue{LWR@validtablecol}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@parsebarcolumn} \qquad Handles vertical rules.
%
% \changes{v0.41}{2017/10/07}{Added vertical rules.}
% \changes{v0.56}{2018/04/30}{Adds support for double vertical rules.}
%
%    \begin{macrocode}
\newcommand*{\LWR@parsebarcolumn}{%
\LWR@traceinfo{LWR@parsebarcolumn}%
%    \end{macrocode}
% Remember the bar at this position:
%    \begin{macrocode}
\ifnumcomp{\value{LWR@tabletotalLaTeXcols}}{=}{0}%
{% left edge of the table:
    \edef\LWR@tempone{\LWR@getexparray{LWR@colbarspec}{leftedge}}%
    \ifdefstring{\LWR@tempone}{tvertbarl}%
    {\LWR@setexparray{LWR@colbarspec}{leftedge}{tvertbarldouble}}%
    {\LWR@setexparray{LWR@colbarspec}{leftedge}{tvertbarl}}%
}%
{% not at the left edge:
    \edef\LWR@tempone{%
        \LWR@getexparray{LWR@colbarspec}{\arabic{LWR@tabletotalLaTeXcols}}%
    }%
    \ifdefstring{\LWR@tempone}{tvertbarr}%
    {%
        \LWR@setexparray{LWR@colbarspec}%
            {\arabic{LWR@tabletotalLaTeXcols}}{tvertbarrdouble}%
    }%
    {%
        \LWR@setexparray{LWR@colbarspec}%
            {\arabic{LWR@tabletotalLaTeXcols}}{tvertbarr}%
    }%
}%
\global\booltrue{LWR@validtablecol}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@parsecoloncolumn} \qquad Handles vertical rules.
%
% \changes{v0.56}{2018/05/04}{\pkg{arydshln}: Added.}
%    \begin{macrocode}
\newcommand*{\LWR@parsecoloncolumn}{%
\LWR@traceinfo{LWR@parsecoloncolumn}%
%    \end{macrocode}
% Remember the bar at this position:
%    \begin{macrocode}
\ifnumcomp{\value{LWR@tabletotalLaTeXcols}}{=}{0}%
{% left edge of the table:
    \edef\LWR@tempone{\LWR@getexparray{LWR@colbarspec}{leftedge}}%
    \ifdefstring{\LWR@tempone}{tvertbarldash}%
    {\LWR@setexparray{LWR@colbarspec}{leftedge}{tvertbarldoubledash}}%
    {\LWR@setexparray{LWR@colbarspec}{leftedge}{tvertbarldash}}%
}%
{% not at the left edge:
    \edef\LWR@tempone{%
        \LWR@getexparray{LWR@colbarspec}{\arabic{LWR@tabletotalLaTeXcols}}%
    }%
    \ifdefstring{\LWR@tempone}{tvertbarrdash}%
    {\LWR@setexparray{LWR@colbarspec}%
        {\arabic{LWR@tabletotalLaTeXcols}}{tvertbarrdoubledash}}%
    {\LWR@setexparray{LWR@colbarspec}%
        {\arabic{LWR@tabletotalLaTeXcols}}{tvertbarrdash}}%
}%
\global\booltrue{LWR@validtablecol}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@parsesemicoloncolumn} \qquad Handles vertical rules.
%
% \changes{v0.56}{2018/05/04}{\pkg{arydshln}: Added.}
%    \begin{macrocode}
\newcommand*{\LWR@parsesemicoloncolumn}{%
%    \end{macrocode}
% Treat |;| as a |:| column:
%    \begin{macrocode}
\LWR@parsecoloncolumn%
%    \end{macrocode}
% Skip the following width token:
%    \begin{macrocode}
\addtocounter{LWR@tablecolspecindex}{1}%
}
%    \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]{%
\addtocounter{LWR@tabletotalLaTeXcols}{1}%
\addtocounter{LWR@tabletotalLaTeXcolsnext}{1}%
%    \end{macrocode}
% \changes{v0.60}{2018/09/17}{\env{tabular}: Improved memory management: Not using \pkg{xstring}.}
%    \begin{macrocode}
\LWR@setexparray{LWR@tablecolspec}{\arabic{LWR@tabletotalLaTeXcols}}{#1}%
%    \end{macrocode}
%    \begin{macrocode}
\LWR@traceinfo{normal column \arabic{LWR@tabletotalLaTeXcols}: #1}%
\LWR@setexparray{LWR@colatspec}{\arabic{LWR@tabletotalLaTeXcolsnext}}{}%
\LWR@setexparray{LWR@colbangspec}{\arabic{LWR@tabletotalLaTeXcolsnext}}{}%
\LWR@setexparray{LWR@colbeforespec}{\arabic{LWR@tabletotalLaTeXcolsnext}}{}%
\LWR@setexparray{LWR@colafterspec}{\arabic{LWR@tabletotalLaTeXcolsnext}}{}%
\LWR@setexparray{LWR@colbarspec}{\arabic{LWR@tabletotalLaTeXcolsnext}}{}%
\global\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 `w' columns}
%
% \begin{macro}{\LWR@parsewcolumn}
% The width will be ignored.
%    \begin{macrocode}
\newcommand*{\LWR@parsewcolumn}{%
%    \end{macrocode}
%    \begin{macrocode}
\LWR@columnspeclookahead{1}%
\expandafter\LWR@parsenormalcolumn\expandafter{\LWR@strresulttwo}%
%    \end{macrocode}
% Skips the following width and alignment tokens:
%    \begin{macrocode}
\addtocounter{LWR@tablecolspecindex}{2}%
}
%    \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 \progcode{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.
% \trouble[tabular baselines]{tabular>baselines}
% \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}}
% \gindex{tabular>baseline}\gindex{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}}
% \gindex{tabular>HTML colummn conversion}
% \gindex{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'.  Ignores optional argument.  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}
%
%
% \DescribeBoolean{LWR@opttablecol} True if found a table column optional argument.
%    \begin{macrocode}
\newbool{LWR@opttablecol}
%    \end{macrocode}
%
%
%
% \begin{macro}{\LWR@parsetablecols} \marg{colspecs}
%
% Scans the column specification left to right.
%
% Builds \cs{LWR@tablecolspec} with the final specification,
% one \LaTeX\ column per entry.  The final number of \LaTeX\ columns in each row is
% stored in |LWR@tabletotalLaTeXcols|,
% which is the number of |&| and |\\| in each line, but
% which does not include |@|, |!|, |<|, |>| specifications in the count.
%
% \changes{v0.22}{2017/02/28}{Unknown table column types become \progcode{l}.
%	Added tabular \progcode{D}, \progcode{!!}, \progcode{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}%
%    \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}
%
% The parsed column spec data array, |LWR@tablecolspec|,
% will be overwritten with new values.
%
% Total number of columns found so far.
% Also pre-initialize the first several columns of specs:
%    \begin{macrocode}
\setcounter{LWR@tabletotalLaTeXcols}{0}%
\setcounter{LWR@tabletotalLaTeXcolsnext}{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}
\expandarg%
\StrLen{\LWR@origcolspec}[\LWR@strresult]%
\fullexpandarg%
\LWR@traceinfo{original column spec length: \LWR@strresult}%
\setcounter{LWR@tablecolspecwidth}{\LWR@strresult}%
%    \end{macrocode}
% Haven't seen any optional arguments so far
%    \begin{macrocode}
\global\boolfalse{LWR@opttablecol}%
%    \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}
\global\boolfalse{LWR@validtablecol}%
%    \end{macrocode}
%
% Skip over any optional arguments, such as \pkg{siunitx} |S| column:
% \changes{v0.48}{2018/02/04}{Fix: Ignore optional tabular column arguments.}
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{[}{\global\booltrue{LWR@opttablecol}}{}%
%    \end{macrocode}
%
% Throw away anything found inside the optional argument:
%    \begin{macrocode}
\ifbool{LWR@opttablecol}%
{}% inside an optional argument
{% not an optional tabular argument
%    \end{macrocode}
% Not inside an optional argument, so consider the column type:
%    \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}}{}%
%    \end{macrocode}
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{S}{\LWR@parsenormalcolumn{c}}{}%
\IfStrEq{\LWR@strresult}{s}{\LWR@parsenormalcolumn{c}}{}%
%    \end{macrocode}
%    \begin{macrocode}
\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}{:}{\LWR@parsecoloncolumn}{}%
\IfStrEq{\LWR@strresult}{;}{\LWR@parsesemicoloncolumn}{}%
%    \end{macrocode}
%    \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}
% \changes{v0.56}{2018/05/10}{Added \pkg{array} \texttt{W} column.}
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{w}{\LWR@parsewcolumn}{}%
\IfStrEq{\LWR@strresult}{W}{\LWR@parsewcolumn}{}%
%    \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|'':
% \begin{Verbatim}[tabsize=4,gobble=2]
%   \newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
% \end{Verbatim}
% \vspace{-\baselineskip}
% \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}%
}%
}% not an optional column argument
%    \end{macrocode}
% If read the closing bracket, no longer inside the optional argument:
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{]}{\global\boolfalse{LWR@opttablecol}}{}%
%    \end{macrocode}
% Move to the next character:
%    \begin{macrocode}
\addtocounter{LWR@tablecolspecindex}{1}%
}% whiledo
}%
%    \end{macrocode}
% \end{macro}


% \subsection{\pkg{colortbl} and \pkg{xparse} tabular color support}
%
% \changes{v0.48}{2018/02/06}{\pkg{colortbl}: Added.}
% \changes{v0.49}{2018/02/17}{\pkg{xcolor}: Added tabular row colors.}
%
% These macros provide a minimal emulation of some \pkg{colortbl} macros
% which might appear between table cells.
% If \pkg{colortbl} is loaded, these macros will be replaced with
% functional versions.
%
% For each of the \HTML\ colors below, the text for the \HTML\ color is
% set if requested, but the macro is empty if none has been set.
%
% \begin{macro}{\rownum}
% Reserve a counter register.
%    \begin{macrocode}
 \@ifundefined{rownum}{\newcount\rownum}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@rowcolors} Emulated in case \pkg{xcolor} is not used.
%    \begin{macrocode}
\newcommand*{\@rowcolors}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@rowc@lors} Emulated in case \pkg{xcolor} is not used.
%    \begin{macrocode}
\newcommand*{\@rowc@lors}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LWR@xcolorrowHTMLcolor} Emulated \pkg{xcolor} row color.
%    \begin{macrocode}
\newcommand*{\LWR@xcolorrowHTMLcolor}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LWR@columnHTMLcolor} \HTML style code for the column color.
%    \begin{macrocode}
\def\LWR@columnHTMLcolor{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LWR@rowHTMLcolor} \HTML style code for the row color.
%    \begin{macrocode}
\def\LWR@rowHTMLcolor{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LWR@cellHTMLcolor} \HTML style code for the cell color.
%    \begin{macrocode}
\def\LWR@cellHTMLcolor{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LWR@ruleHTMLcolor} \HTML style code for the cell color.
%    \begin{macrocode}
\newcommand*{\LWR@ruleHTMLcolor}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\rowcolor} \oarg{model} \marg{color} \oarg{left overhang} \oarg{right overhang}
% Print version.  The \HTML\ version is in \pkg{lwarp-colortbl}.
% Used before starting a tabular data cell, thus \cs{LWR@getmynexttoken}.
%    \begin{macrocode}
\newcommand*{\rowcolor}{\LWR@getmynexttoken}%
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\arrayrulecolor} \oarg{model} \marg{color}
% \begin{macro}{\arrayrulecolornexttoken} \oarg{model} \marg{color}
%
% Print versions for use outside and inside a \env{tabular}:
%    \begin{macrocode}
\newcommand{\arrayrulecolor}[2][named]{}
\newcommand{\arrayrulecolornexttoken}[2][named]{\LWR@getmynexttoken}
%    \end{macrocode}
% \end{macro}
% \end{macro}

% \begin{macro}{\doublerulesepcolor} \oarg{model} \marg{color}
% \begin{macro}{\doublerulesepcolornexttoken} \oarg{model} \marg{color}
%
% Print versions for use inside and outside a \env{tabular}:
%    \begin{macrocode}
\newcommand{\doublerulesepcolor}[2][named]{}
\newcommand{\doublerulesepcolornexttoken}[2][named]{\LWR@getmynexttoken}
%    \end{macrocode}
% \end{macro}
% \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}%
    \ifboolexpr{%
        test{\ifnumcomp{\value{LWR@hlines}}{>}{0}} or%
        test{\ifnumcomp{\value{LWR@hdashedlines}}{>}{0}}%
    }%
    {%
        \LWR@htmltag{tr class="hline" }%
        \LWR@orignewline%
    }%
    {% not doing hline
        \ifbool{LWR@doingtbrule}%
        {%
            \ifdefvoid{\LWR@ruleHTMLcolor}{%
                \LWR@htmltag{tr class="tbrule"}%
            }{%
                \LWR@htmltag{%
                    tr class="tbrule" % space
                    style="border-top: 1px solid % space
                        \LWR@origpound\LWR@ruleHTMLcolor "%
                }%
            }%
            \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]{%
\LWR@traceinfo{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
\LWR@traceinfo{LWR@printbartag done}%
}
%    \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}
\xdef\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@addcdashline%
        \LWR@addtabularrulecolors%
        \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@tableLaTeXcolindex}}{=}{1}{%
    \LWR@printbartag{leftedge}%
}{}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@tabularleftedge}
%    \begin{macrocode}
\newcommand*{\LWR@tabularleftedge}{%
\ifnumcomp{\value{LWR@tableLaTeXcolindex}}{=}{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 and color.
%
% \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 \progcode{\protect\textless} for \cs{bottomrule}.}
%
%    \begin{macrocode}
\newcommand*{\LWR@tabledatasinglecolumntag}%
{%
\LWR@traceinfo{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 \cs{LWR@strresult}:
% \changes{v0.60}{2018/09/17}{\env{tabular}: Improved memory management: Not using \pkg{xstring}.}
%    \begin{macrocode}
        \xdef\LWR@strresult{%
            \LWR@getexparray{LWR@tablecolspec}{\arabic{LWR@tableLaTeXcolindex}}%
        }%
%    \end{macrocode}
% print the start of a new table data cell:
%    \begin{macrocode}
\LWR@traceinfo{LWR@tabledatasinglecolumntag: about to print td tag}%
        \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@tableLaTeXcolindex}}%
        "%
%    \end{macrocode}
% Add styles for rules, alignment:
% \changes{v0.42}{2017/10/26}{If \progcode{FormatWP} add cell alignment.}
%    \begin{macrocode}
        \LWR@tdstartstyles%
        \LWR@addcmidrulewidth%
        \LWR@addcdashline%
%    \end{macrocode}
% \changes{v0.60}{2018/09/17}{\env{tabular}: Improved memory management: Not using \pkg{xstring}.}
%    \begin{macrocode}
        \xdef\LWR@thiscolspec{%
            \LWR@getexparray{LWR@tablecolspec}{\arabic{LWR@tableLaTeXcolindex}}%
        }% 
        \LWR@addformatwpalignment{\LWR@thiscolspec}%
%    \end{macrocode}
% Add styles for cell and rule colors:
% \changes{v0.48}{2018/02/08}{\pkg{colortbl}: Added.}
%    \begin{macrocode}
        \LWR@addtabularrowcolor%
        \LWR@addtabularrulecolors%
%    \end{macrocode}
%    \begin{macrocode}
        \LWR@tdendstyles%
        }% HTML td
        \LWR@traceinfo{LWR@tabledatasinglecolumntag: done printing td tag}%
%    \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@traceinfo{LWR@tabledatasinglecolumntag: about to LWR@startpars}%
            \global\booltrue{LWR@tableparcell}%
            \LWR@startpars%
            \LWR@traceinfo{LWR@tabledatasinglecolumntag: done with LWR@startpars}%
        }% 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@tableLaTeXcolindex}}%
        }%
        \global\boolfalse{LWR@intabularmetadata}%
    }% not exiting tabular
}{}% in tabular metadata
\LWR@traceinfo{LWR@tabledatasinglecolumntag: done}%
}%
%    \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.

% \DescribeObject{LWR@cdashlines}|LWR@cdashlines| is a data array
% (\cref{sec:dataarray}) of columns each containing a |Y|
% if an \pkg{arydshln} package "cdashed line" should be
% created for this 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@trimrules| markers for this line.
%
% \changes{v0.41}{2017/09/28}{Add: \cs{cmidrule} trims.}
% \changes{v0.60}{2018/09/17}{\env{tabular}: Fix for midrules.}
%    \begin{macrocode}
\newcommand*{\LWR@clearmidrules}
{%
\setcounter{LWR@midrulecounter}{1}%
\whileboolexpr{%
    not test{%
        \ifnumcomp{\value{LWR@midrulecounter}}{>}%
            {\value{LWR@tabletotalLaTeXcols}}%
    }%
}%
{%
    \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}}{}%
    \LWR@setexparray{LWR@cdashlines}{\arabic{LWR@midrulecounter}}{N}%
    \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}}{}%
\global\booltrue{LWR@doingcmidrule}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@docmidrule} \oarg{width} \parg{trim} \marg{leftcolumn-rightcolumn}
%
% Marks |LWR@midrules| array elements to be a non-zero width 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}



% \begin{macro}{\LWR@subcdashline} \marg{leftcolumn} \marg{rightcolumn}
%
% Marks |LWR@cdashlines| data array elements to be |Y| from
% left to right columns.
%
% |LWR@doingcmidrule| is set to force an empty row at the end of the tabular
% to create the rule.
%
%    \begin{macrocode}
\newcommand*{\LWR@subcdashline}[2]{%
\setcounter{LWR@midrulecounter}{#1}%
\whileboolexpr{%
    not test {%
        \ifnumcomp{\value{LWR@midrulecounter}}{>}{#2}%
    }%
}%
{%
    \LWR@setexparray{LWR@cdashlines}{\arabic{LWR@midrulecounter}}{Y}%
    \addtocounter{LWR@midrulecounter}{1}%
}% whiledo
\global\booltrue{LWR@doingcmidrule}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@docdashline} \marg{leftcolumn-rightcolumn}
%
% Marks |LWR@cdashlines| data array elements to be |Y| from
% left to right columns.
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@docdashline}
    {>{\SplitArgument{1}{-}}m}%
    {%
        \LWR@subcdashline#1%
    }
%    \end{macrocode}
% \end{macro}



% Used to compute margins, tabular trims, column offsets:
%    \begin{macrocode}
\newlength{\LWR@templengthone}
\newlength{\LWR@templengthtwo}
\newlength{\LWR@templengththree}
\newcounter{LWR@tempcountone}
%    \end{macrocode}


% Used to add a style to a table data cell:
%    \begin{macrocode}
\newbool{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@tableLaTeXcolindex}}%
}%
\ifdimcomp{\LWR@templengthone}{>}{0pt}%
{%
%    \end{macrocode}
% Print the class with 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@tableLaTeXcolindex}}}%
{\LWR@getexparray{LWR@trimrrules}{\arabic{LWR@tableLaTeXcolindex}}}%
}
%    \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 \progcode{FormatWP} force explicit border.}
%
%    \begin{macrocode}
\newcommand{\LWR@addrulewidth}[2]{%
%    \end{macrocode}
% Only add a custom width if |thiswidth| is different than the |defaultwidth|,
% or if a color is being used:
%    \begin{macrocode}
\ifboolexpr{%
    test{\ifdimcomp{#1}{=}{0pt}} or
    (
        ( test{\ifdimcomp{#1}{=}{#2}} and not bool{FormatWP} )
        and ( test {\ifdefvoid{\LWR@ruleHTMLcolor}} )
    )
}%
{}% default width and color
{% custom width and/or color
%    \end{macrocode}
% Ensure that the width is wide enough to display in the browser:
%    \begin{macrocode}
    \LWR@forceminwidth{#1}%
%    \end{macrocode}
% Begin adding another style:
%    \begin{macrocode}
    \LWR@tdaddstyle%
%    \end{macrocode}
% The style itself:
%    \begin{macrocode}
    border-top:\LWR@printlength{\LWR@atleastonept} solid %
%    \end{macrocode}
% If default gray, the darkness of the color depends on the thickness of the rule:
%    \begin{macrocode}
    \ifdefvoid{\LWR@ruleHTMLcolor}{%
        \ifdimcomp{#1}{<}{\LWR@lightrulewidth}%
        {\LWR@origpound{}A0A0A0}%
        {% lightrule or heaver
            \ifdimcomp{#1}{<}{\LWR@heavyrulewidth}%
            {\LWR@origpound{}808080}%
            {black}%
        }% lightrule or heavier
    }{%
        \LWR@origpound\LWR@ruleHTMLcolor%
    }
}% custom width and/or color
}
%    \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@addcdashline}
%
% Must be placed between \cs{LWR@tdstartstyles} and \cs{LWR@tdendstyles}.
%
% \changes{v0.56}{2018/05/04}{\pkg{arydshln}: Added.}
%    \begin{macrocode}
\newcommand{\LWR@addcdashline}{%
\edef\LWR@tempone{%
    \LWR@getexparray{LWR@cdashlines}{\arabic{LWR@tableLaTeXcolindex}}%
}%
\ifdefstring{\LWR@tempone}{Y}{%
    \LWR@tdaddstyle%
    border-top: 1pt dashed %
    \ifdefvoid{\LWR@ruleHTMLcolor}%
        {black}%
        {\LWR@origpound\LWR@ruleHTMLcolor}%
}{}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@WPcell} \marg{text-align} \marg{vertical-align}
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\newcommand*{\LWR@WPcell}[2]{%
\LWR@tdaddstyle%
\LWR@print@mbox{text-align:#1}; \LWR@print@mbox{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 \progcode{FormatWP} add explicit style
%   for cell alignment.}
% \changes{v0.44}{2017/11/08}{Fix for multicolumn alignment if \progcode{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{Cell colors}

% \changes{v0.48}{2018/02/06}{\pkg{colortbl}: Added.}
%
% \begin{macro}{\LWR@addtabularrowcolor} Adds a cell's row color style, if needed.
%
% No color is added for the final row of empty cells which finishes each \env{tabular}.
%
%    \begin{macrocode}
\newcommand*{\LWR@addtabularrowcolor}{%
\ifbool{LWR@tabularmutemods}{}{%
    \ifdefvoid{\LWR@rowHTMLcolor}{%
        \ifdefvoid{\LWR@xcolorrowHTMLcolor}{}%
        {% xcolor row color
            \LWR@tdaddstyle%
            background:\LWR@origpound\LWR@xcolorrowHTMLcolor%
        }%
    }%
    {% explicit row color
        \LWR@tdaddstyle%
        background:\LWR@origpound\LWR@rowHTMLcolor%
    }%
}%
}
%    \end{macrocode}
% \end{macro}


%
% \begin{macro}{\LWR@addtabularhrulecolor} Adds a cell's horizontal rule color style, if needed.
% \changes{v0.48}{2018/02/08}{\pkg{colortbl}: Added.}
% \changes{v0.56}{2018/04/30}{Adds support for double \cs{hline}s and \cs{midrule}s.}
% \changes{v0.56}{2018/05/02}{Adds support for \pkg{arydshln} dashed rules.}
%    \begin{macrocode}
\newcommand*{\LWR@addtabularhrulecolor}{%
%    \end{macrocode}
% If either form of horizontal rule is requested:
%    \begin{macrocode}
\ifboolexpr{%
    test{\ifnumcomp{\value{LWR@hlines}}{>}{0}} or%
    test{\ifnumcomp{\value{LWR@hdashedlines}}{>}{0}} or%
    bool{LWR@doingtbrule}%
}{%
%    \end{macrocode}
% If there is a no custom color:
%    \begin{macrocode}
    \ifdefvoid{\LWR@ruleHTMLcolor}%
    {%
        \ifnumcomp{\value{LWR@hlines}}{>}{1}%
        {%
            \LWR@tdaddstyle%
            border-top: 4px double%
        }{% else
        \ifnumcomp{\value{LWR@hdashedlines}}{>}{1}%
        {%
            \LWR@tdaddstyle%
            border-top: 2px dashed%
        }{% else
        \ifnumcomp{\value{LWR@hdashedlines}}{=}{1}%
        {%
            \LWR@tdaddstyle%
            border-top: 1px dashed%
        }{}}}%
%    \end{macrocode}
% If no color and not doubled or dashed, then add nothing, since
% a simpler rule is the default.
%    \begin{macrocode}
    }%
%    \end{macrocode}
% If there is a custom color:
%    \begin{macrocode}
    {%
        \ifnumcomp{\value{LWR@hlines}}{>}{1}%
        {%
            \LWR@tdaddstyle%
            border-top: 4px double \LWR@origpound\LWR@ruleHTMLcolor%
        }{% else
        \ifnumcomp{\value{LWR@hdashedlines}}{>}{1}%
        {%
            \LWR@tdaddstyle%
            border-top: 2px dashed \LWR@origpound\LWR@ruleHTMLcolor%
        }{% else
        \ifnumcomp{\value{LWR@hdashedlines}}{=}{1}%
        {%
            \LWR@tdaddstyle%
            border-top: 1px dashed \LWR@origpound\LWR@ruleHTMLcolor%
        }{% else
            \LWR@tdaddstyle%
            border-top: 1px solid \LWR@origpound\LWR@ruleHTMLcolor%
        }}}%
    }%
}{}%
}
%    \end{macrocode}
% \end{macro}


%
% \begin{macro}{\LWR@addtabularrulecolors} Adds a cell's rule color styles, if needed.
% \changes{v0.48}{2018/02/08}{\pkg{colortbl}: Added.}
% \changes{v0.56}{2018/04/30}{Adds support for double vertical rules.}
% \changes{v0.56}{2018/05/05}{Adds support for dashed vertical rules.}
%
% No color is added for the final row of empty cells which finishes each \env{tabular}.
%
%    \begin{macrocode}
\newcommand*{\LWR@addtabularrulecolors}{%
%    \end{macrocode}
% Custom horizonal rule color:
%    \begin{macrocode}
\LWR@addtabularhrulecolor%
%    \end{macrocode}
% No vertical rules if finishing the \env{tabular} with a row of empty cells:
%    \begin{macrocode}
\ifbool{LWR@tabularmutemods}{}{%
%    \end{macrocode}
% If at the leftmost cell, possibly add a leftmost vertical rule:
%    \begin{macrocode}
    \ifnumequal{\value{LWR@tableLaTeXcolindex}}{1}{%
%    \end{macrocode}
% Fetch the left edge's vertical bar specification:
%    \begin{macrocode}
        \edef\LWR@tempone{\LWR@getexparray{LWR@colbarspec}{leftedge}}%
%    \end{macrocode}
% Add a custom style if a vertical bar was requested:
%    \begin{macrocode}
        \ifdefstring{\LWR@tempone}{tvertbarl}{%
                \LWR@tdaddstyle%
                border-left: 1px solid % space
                    \LWR@vertruleHTMLcolor%
        }{}%
        \ifdefstring{\LWR@tempone}{tvertbarldouble}{%
                \LWR@tdaddstyle%
                border-left: 4px double % space
                    \LWR@vertruleHTMLcolor%
        }{}%
        \ifdefstring{\LWR@tempone}{tvertbarldash}{%
                \LWR@tdaddstyle%
                border-left: 1px dashed % space
                    \LWR@vertruleHTMLcolor%
        }{}%
        \ifdefstring{\LWR@tempone}{tvertbarldoubledash}{%
                \LWR@tdaddstyle%
                border-left: 2px dashed % space
                    \LWR@vertruleHTMLcolor%
        }{}%
    }{}%
%    \end{macrocode}
% Possibly add a right vertical rule for this cell:
%    \begin{macrocode}
    \edef\LWR@tempone{%
        \LWR@getexparray{LWR@colbarspec}{\arabic{LWR@tableLaTeXcolindex}}%
    }%
    \ifdefstring{\LWR@tempone}{tvertbarr}{%
%    \end{macrocode}
% Add a custom style if a vertical bar was requested:
%    \begin{macrocode}
            \LWR@tdaddstyle%
            border-right: 1px solid \LWR@vertruleHTMLcolor%
    }{}%
    \ifdefstring{\LWR@tempone}{tvertbarrdouble}{%
            \LWR@tdaddstyle%
            border-right: 4px double \LWR@vertruleHTMLcolor%
    }{}%
    \ifdefstring{\LWR@tempone}{tvertbarrdash}{%
            \LWR@tdaddstyle%
            border-right: 1px dashed \LWR@vertruleHTMLcolor%
    }{}%
    \ifdefstring{\LWR@tempone}{tvertbarrdoubledash}{%
            \LWR@tdaddstyle%
            border-right: 2px dashed \LWR@vertruleHTMLcolor%
    }{}%
}%
}
%    \end{macrocode}
% \end{macro}


% \DescribeCounter{LWR@cellcolordepth}
% Counts how many cell color \element{div}s were added to the current tabular data cell.
%    \begin{macrocode}
\newcounter{LWR@cellcolordepth}
%    \end{macrocode}


% \begin{macro}{\LWR@subaddtabularcellcolor} \marg{\HTML\ color}
%    \begin{macrocode}
\newcommand*{\LWR@subaddtabularcellcolor}[1]{%
\LWR@htmltag{div class="cellcolor" style="%
    background:\LWR@origpound{}{}#1 %
" }%
\addtocounter{LWR@cellcolordepth}{1}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@addtabularcellcolor} Adds a cell color style, if needed.
% \changes{v0.49}{2018/02/18}{\pkg{xcolor}: Added tabular row colors.}
%    \begin{macrocode}
\newcommand*{\LWR@addtabularcellcolor}{%
\ifdefvoid{\LWR@cellHTMLcolor}%
{%
    \ifdefvoid{\LWR@rowHTMLcolor}%
    {%
        \ifdefvoid{\LWR@xcolorrowHTMLcolor}%
        {%
            \ifdefvoid{\LWR@columnHTMLcolor}%
            {}%
            {\LWR@subaddtabularcellcolor{\LWR@columnHTMLcolor}}%
        }%
        {\LWR@subaddtabularcellcolor{\LWR@xcolorrowHTMLcolor}}%
    }%
    {\LWR@subaddtabularcellcolor{\LWR@rowHTMLcolor}}%
}%
{\LWR@subaddtabularcellcolor{\LWR@cellHTMLcolor}}%
}
%    \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}
\newcounter{LWR@mcolvertbarsl}
\newcounter{LWR@mcolvertbarsr}
\newcounter{LWR@mcolvertbarsldash}
\newcounter{LWR@mcolvertbarsrdash}
\newbool{LWR@mcolvertbaronleft}%
%    \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}{}%
%    \end{macrocode}
% \changes{v0.56}{2018/05/10}{Added \pkg{array} \texttt{W} column.}
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{w}{w}{}%
\IfStrEq{\LWR@strresult}{W}{W}{}%
%    \end{macrocode}
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{S}{c}{}%
\IfStrEq{\LWR@strresult}{s}{c}{}%
%    \end{macrocode}
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{X}{p}{}%
%    \end{macrocode}
% \changes{v0.43}{2017/11/07}{Added vertical rules.}
% \changes{v0.56}{2018/04/30}{Adds support for double vertical rules.}
% \changes{v0.56}{2018/05/05}{Adds support for dashed vertical rules.}
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{|}%
{%
    \ifbool{LWR@mcolvertbaronleft}%
        {\addtocounter{LWR@mcolvertbarsl}{1}}% left edge
        {\addtocounter{LWR@mcolvertbarsr}{1}}% not left edge
}%
{%
    \IfStrEq{\LWR@strresult}{:}%
    {%
        \ifbool{LWR@mcolvertbaronleft}%
            {\addtocounter{LWR@mcolvertbarsldash}{1}}% left edge
            {\addtocounter{LWR@mcolvertbarsrdash}{1}}% not left edge
    }%
    {%
        \IfStrEq{\LWR@strresult}{;}%
        {%
            \ifbool{LWR@mcolvertbaronleft}%
                {\addtocounter{LWR@mcolvertbarsldash}{1}}% left edge
                {\addtocounter{LWR@mcolvertbarsrdash}{1}}% not left edge
        }%
        {\boolfalse{LWR@mcolvertbaronleft}}%
    }%
}%
\LWR@traceinfo{lwr@printmccoltype done}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@multicolpartext} \marg{num parameters}
% Print the data with paragraph tags, advance to bypass the given number of parameters.
% \changes{v0.56}{2018/05/12}{Fix: \cs{multicolumn} parameters.}
%    \begin{macrocode}
\newcommand*{\LWR@multicolpartext}[1]{%
\LWR@startpars%
\LWR@multicoltext%
\addtocounter{LWR@tablemulticolspos}{#1}%
\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}
\global\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}
\global\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 \progcode{D}, \progcode{!!},
%	and \progcode{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}
\global\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%
}{}%
%    \end{macrocode}
% \changes{v0.56}{2018/05/12}{Fix: \cs{multicolumn} parameters.}
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{p}{\LWR@multicolpartext{0}}{}%
\IfStrEq{\LWR@strresult}{m}{\LWR@multicolpartext{0}}{}%
\IfStrEq{\LWR@strresult}{b}{\LWR@multicolpartext{0}}{}%
\IfStrEq{\LWR@strresult}{P}{\LWR@multicolpartext{0}}{}%
\IfStrEq{\LWR@strresult}{M}{\LWR@multicolpartext{0}}{}%
\IfStrEq{\LWR@strresult}{B}{\LWR@multicolpartext{0}}{}%
%    \end{macrocode}
% \changes{v0.56}{2018/05/10}{Added \pkg{array} \texttt{W} column.}
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{w}{\LWR@multicolpartext{3}}{}%
\IfStrEq{\LWR@strresult}{W}{\LWR@multicolpartext{3}}{}%
%    \end{macrocode}
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{S}{\LWR@multicoltext}{}%
\IfStrEq{\LWR@strresult}{s}{\LWR@multicoltext}{}%
%    \end{macrocode}
%    \begin{macrocode}
\IfStrEq{\LWR@strresult}{X}{\LWR@multicolpartext{0}}{}%
\IfStrEq{\LWR@strresult}{|}{\LWR@multicolskip}{}%
\IfStrEq{\LWR@strresult}{:}{\LWR@multicolskip}{}%
\IfStrEq{\LWR@strresult}{;}{%
    \LWR@multicolskip%
    \addtocounter{LWR@tablemulticolspos}{1}% skip parameter
}{}%
\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{macro}{\LWR@addmulticolvertrulecolor}
% \changes{v0.56}{2018/04/30}{Adds support for double vertical rules.}
% \changes{v0.56}{2018/05/05}{Adds support for dashed vertical rules.}
%    \begin{macrocode}
\newcommand*{\LWR@addmulticolvertrulecolor}{%
%    \end{macrocode}
% No vertical rules if finishing the \env{tabular} with a row of empty cells:
%    \begin{macrocode}
\ifbool{LWR@tabularmutemods}{}{%
%    \end{macrocode}
% Left side:
%    \begin{macrocode}
    \ifnumcomp{\value{LWR@mcolvertbarsl}}{=}{1}{%
        \LWR@tdaddstyle%
        border-left: 1px solid \LWR@vertruleHTMLcolor%
    }{}%
    \ifnumcomp{\value{LWR@mcolvertbarsl}}{>}{1}{%
        \LWR@tdaddstyle%
        border-left: 4px double \LWR@vertruleHTMLcolor%
    }{}%
    \ifnumcomp{\value{LWR@mcolvertbarsldash}}{=}{1}{%
        \LWR@tdaddstyle%
        border-left: 1px dashed \LWR@vertruleHTMLcolor%
    }{}%
    \ifnumcomp{\value{LWR@mcolvertbarsldash}}{>}{1}{%
        \LWR@tdaddstyle%
        border-left: 2px dashed \LWR@vertruleHTMLcolor%
    }{}%
%    \end{macrocode}
% Right side:
%    \begin{macrocode}
    \ifnumcomp{\value{LWR@mcolvertbarsr}}{=}{1}{%
        \LWR@tdaddstyle%
        border-right: 1px solid \LWR@vertruleHTMLcolor%
    }{}%
    \ifnumcomp{\value{LWR@mcolvertbarsr}}{>}{1}{%
        \LWR@tdaddstyle%
        border-right: 4px double \LWR@vertruleHTMLcolor%
    }{}%
    \ifnumcomp{\value{LWR@mcolvertbarsrdash}}{=}{1}{%
        \LWR@tdaddstyle%
        border-right: 1px dashed \LWR@vertruleHTMLcolor%
    }{}%
    \ifnumcomp{\value{LWR@mcolvertbarsrdash}}{>}{1}{%
        \LWR@tdaddstyle%
        border-right: 2px dashed \LWR@vertruleHTMLcolor%
    }{}%
}%
}
%    \end{macrocode}
% \end{macro}


%    \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 \optn{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%
\global\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@tableLaTeXcolindex}}%
\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}
% 
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\IfValueT{#1}{% vpos?
\ifstrequal{#1}{b}{style="\LWR@print@mbox{vertical-align:bottom}" }{}%
\ifstrequal{#1}{t}{style="\LWR@print@mbox{vertical-align:top}" }{}%
}% vpos?
}% rows?
%    \end{macrocode}
% 
%    \begin{macrocode}
 class="td%
%    \end{macrocode}
% Print the column type and vertical bars:
%    \begin{macrocode}
\setcounter{LWR@mcolvertbarsl}{0}%
\setcounter{LWR@mcolvertbarsr}{0}%
\setcounter{LWR@mcolvertbarsldash}{0}%
\setcounter{LWR@mcolvertbarsrdash}{0}%
\booltrue{LWR@mcolvertbaronleft}%
\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@tableLaTeXcolindex}}}%
{\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.}
% \changes{v0.56}{2018/04/30}{Adds support for double vertical rules.}
% \changes{v0.56}{2018/05/05}{Adds support for dashed vertical rules.}
%    \begin{macrocode}
\ifnumcomp{\value{LWR@mcolvertbarsl}}{=}{1}{ tvertbarl}{}%
\ifnumcomp{\value{LWR@mcolvertbarsl}}{>}{1}{ tvertbarldouble}{}%
\ifnumcomp{\value{LWR@mcolvertbarsr}}{=}{1}{ tvertbarr}{}%
\ifnumcomp{\value{LWR@mcolvertbarsr}}{>}{1}{ tvertbarrdouble}{}%
\ifnumcomp{\value{LWR@mcolvertbarsldash}}{=}{1}{ tvertbarldash}{}%
\ifnumcomp{\value{LWR@mcolvertbarsldash}}{>}{1}{ tvertbarldoubledash}{}%
\ifnumcomp{\value{LWR@mcolvertbarsrdash}}{=}{1}{ tvertbarrdash}{}%
\ifnumcomp{\value{LWR@mcolvertbarsrdash}}{>}{1}{ tvertbarrdoubledash}{}%
%    \end{macrocode}
% Close the class tag's opening quote:
"% NOT A TYPO
%    \begin{macrocode}
%
%    \end{macrocode}
% \changes{v0.42}{2017/10/26}{If \progcode{FormatWP} add cell alignment.}
%    \begin{macrocode}
\LWR@tdstartstyles%
%    \end{macrocode}
% \changes{v0.49}{2018/02/18}{\pkg{xcolor}: Added tabular row colors.}
%    \begin{macrocode}
\LWR@addtabularrowcolor%
%    \end{macrocode}
%    \begin{macrocode}
\LWR@addcmidrulewidth%
\LWR@addcdashline%
\LWR@addtabularhrulecolor%
\LWR@addmulticolvertrulecolor%
\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@tableLaTeXcolindex}}{#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@tableLaTeXcolindex}{#1}%
\addtocounter{LWR@tableLaTeXcolindex}{-1}%
%    \end{macrocode}
% Skip any trailing |@| or |!| columns for this cell:
%    \begin{macrocode}
\global\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@tabletotalLaTeXcols}}
%    \end{macrocode}
% Create the multicolumn tag:
%    \begin{macrocode}
\LWR@domulticolumn{\arabic{LWR@tabletotalLaTeXcols}}%
    {\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%
    \LWR@isolate{#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{%
                \@nameuse{p@\LTcaptype}\@nameuse{the\LTcaptype}%
            }%
        }%
    }{}%
%    \end{macrocode}
% Create an \HTML\ caption.  Afterwards, maybe make a LOT entry.
%    \begin{macrocode}
    \LWR@figcaption%
    \LWR@isolate{\@nameuse{fnum@\LTcaptype}}%
    \CaptionSeparator%
    \LWR@isolate{#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%
            {\@nameuse{ext@\LTcaptype}}%
            {\LTcaptype}%
            {%
                \protect\numberline%
                {\LWR@isolate{\@nameuse{p@\LTcaptype}}\@nameuse{the\LTcaptype}}%
                {\ignorespaces \LWR@isolate{#3}\protect\relax}%
            }%
        }% end of No TOC entry
%    \end{macrocode}
% The optional caption has text enclosed:
%    \begin{macrocode}
        {% yes TOC entry
            \addcontentsline%
            {\@nameuse{ext@\LTcaptype}}%
            {\LTcaptype}%
            {%
                \protect\numberline%
                {\LWR@isolate{\@nameuse{p@\LTcaptype}}\@nameuse{the\LTcaptype}}%
                {\ignorespaces \LWR@isolate{#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}
\global\booltrue{LWR@skipatbang}%
}% end of \LWR@domulticolumn

\addtocounter{LWR@tableLaTeXcolindex}{\arabic{LWR@tabletotalLaTeXcols}}
\addtocounter{LWR@tableLaTeXcolindex}{-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{Multirow if not loaded}
%
% A default defintion in case \pkg{multirow} is not loaded.
% This is used during table parsing.
%    \begin{macrocode}
\begin{warpHTML}
\newcommand{\multirow}[2][c]{}
\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}.}
% \changes{v0.57}{2018/06/01}{Improved print/\HTML\ output selection.}
%
% \cs{AtBeginDocument} to adjust after the user may have loaded \pkg{multirow},
% which requires several tests to determine which version is loaded
% and thus which options are available.
%    \begin{macrocode}
\AtBeginDocument{
%    \end{macrocode}
%
% |\@ifundefined{@xmultirow}| determines if \pkg{multirow} was never loaded.
%
% Null action if not loaded:
%    \begin{macrocode}
\@ifundefined{@xmultirow}
{
\DeclareExpandableDocumentCommand{\LWR@print@multicolumnrow}%
    {+m +m +O{c} +m +O{0} +m +O{0pt} +m}%
    {}%
}% 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.
%
% The print version:
%    \begin{macrocode}
\@ifpackageloaded{multirow}{% v2.0 or newer
\@ifpackagelater{multirow}{2016/09/01}% 2016/09/27 for v2.0
{% v2.0+:
\DeclareExpandableDocumentCommand{\LWR@print@multicolumnrow}%
    {+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@print@multicolumnrow}%
    {+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 \optn{vposn} option.
%
%    \begin{macrocode}
{% v1.6 or older did not \ProvidePackage
\DeclareExpandableDocumentCommand{\LWR@print@multicolumnrow}%
    {+m +m +O{c} +m +O{0} +m +O{0pt} +m}%
    {\multicolumn{#1}{#2}{\@xmultirow{#4}[#5]{#6}[#7]{#8}}}%
}

}% \@ifundefined{@xmultirow}

\providecommand*{\multicolumnrow}{\LWR@print@multicolumnrow}

}% AtBeginDocument
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}
%
%
%
% \subsection{Utility macros inside a table}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
% Used to prevent opening a tabular data cell if the following token is
% one which does not create tabular data:
%    \begin{macrocode}
\newcommand*{\LWR@donothing}{}
%    \end{macrocode}
%
% In case \pkg{array} is not loaded:
% \changes{v0.58}{2018/06/21}{\pkg{memoir}: Fix for \cs{firsthlline}, \cs{lasthline}.}
%    \begin{macrocode}
\let\firsthline\relax
\let\lasthline\relax
\newcommand*{\firsthline}{}
\newcommand*{\lasthline}{}
%    \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 \cs{hline}, \cs{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}
\global\let\LWR@mynextaction\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}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
% Look for other things which would not start a table cell:
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\multicolumn}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
\ifdefequal{\LWR@mynexttoken}{\multirow}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
\ifdefequal{\LWR@mynexttoken}{\multicolumnrow}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
\ifdefequal{\LWR@mynexttoken}{\noalign}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
% If an \cs{mrowcell}, this is a cell to be skipped over:
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\mrowcell}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
% If an \cs{mcolrowcell}, this is a cell to be skipped over:
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\mcolrowcell}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\TabularMacro}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\hline}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\firsthline}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\lasthline}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\toprule}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\midrule}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\cmidrule}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
% \changes{v0.56}{2018/05/02}{Fix: \cs{morecmidrules}}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\morecmidrules}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\specialrule}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\cline}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\bottomrule}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\rowcolor}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\arrayrulecolor}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\doublerulesepcolor}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\warpprintonly}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\warpHTMLonly}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\ldelim}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\rdelim}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
% For \pkg{arydshln}:
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\hdashline}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\cdashline}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\firsthdashline}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\lasthdashline}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
% Ignore an empty line between rows:
% \changes{v0.45}{2017/12/06}{Fix: Empty line between rows.}
%    \begin{macrocode}
\ifdefequal{\LWR@mynexttoken}{\par}%
    {\global\let\LWR@mynextaction\LWR@donothing}{}%
%    \end{macrocode}
%
% No action for an \cs{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}
\LWR@traceinfo{LWR@tabledatacolumntag: about to do mynext}%
\LWR@mynextaction%
\LWR@traceinfo{LWR@tabledatacolumntag: done}%
}
%    \end{macrocode}
% \end{macro}

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


% \subsection{\cs{mrowcell}}

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

% \begin{macro}{\mrowcell}
% The user must insert \cs{mrowcell} into any \cs{multirow} cells which must be skipped.
% This command has no action during print output.
% \trouble[multirow cells]{tabular>multirow=\cs{multirow}}
%    \begin{macrocode}
\newcommand*{\mrowcell}{}
%    \end{macrocode}

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


% \subsection{\cs{mcolrowcell}}

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

% \begin{macro}{\mcolrowcell}
% The user must insert \cs{mcolrowcell} into any \cs{multicolumnrow} cells
% which must be skipped.
% This command has no action during print output.
% \trouble[multirow cells]{tabular>multirow=\cs{multirow}}
% \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{\HTML\ \env{tabular} environment}

% \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.
% They are pre-deleted in case \pkg{memoir} has already loaded \pkg{booktabs}.
%
% \changes{v0.34}{2017/08/08}{\pkg{booktabs}: Works inside \env{lateximage}.}
% \changes{v0.58}{2018/06/21}{\pkg{memoir}: Fix for \pkg{booktabs}.}
%    \begin{macrocode}
\LetLtxMacro\toprule\relax
\LetLtxMacro\midrule\relax
\LetLtxMacro\cmidrule\cline
\LetLtxMacro\bottomrule\relax
\LetLtxMacro\addlinespace\relax
\LetLtxMacro\morecmidrules\relax
\LetLtxMacro\specialrule\relax

\newcommand*{\toprule}[1][]{\hline}
\newcommand*{\midrule}[1][]{\hline}
\LetLtxMacro\cmidrule\cline
\newcommand*{\bottomrule}[1][]{\hline}
\newcommand*{\addlinespace}[1][]{}
\newcommand*{\morecmidrules}{}
\newcommand*{\specialrule}[3]{\hline}
%    \end{macrocode}
%
%
% \begin{macro}{\noalign} \marg{text}
% Redefined for use inside \env{tabular}.
% \changes{v0.49}{2018/02/18}{Fix: \cs{noalign} inside \env{tabular}.}
%    \begin{macrocode}
\LetLtxMacro\LWR@orignoalign\noalign

\newcommand{\LWR@tabularnoalign}[1]{%
\begingroup%
\global\advance\rownum\m@ne%
\renewcommand*{\LWR@xcolorrowHTMLcolor}{}%
\multicolumn{\value{LWR@tabletotalLaTeXcols}}{l}{#1} \\
\endgroup%
% \@rowc@lors%
\LWR@getmynexttoken%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LWR@HTMLhline}
% 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 \progcode{FormatWP} force explicit border.}
%
%    \begin{macrocode}
\AtBeginDocument{
\@ifpackageloaded{lwarp-tabls}
{
\newcommand*{\LWR@HTMLhline}[1][]{%
    \ifbool{FormatWP}%
    {\LWR@docmidrule{1-\arabic{LWR@tabletotalLaTeXcols}}}%
    {\addtocounter{LWR@hlines}{1}}%
    \LWR@getmynexttoken}%
}
{
\newcommand*{\LWR@HTMLhline}{%
    \ifbool{FormatWP}%
    {\LWR@docmidrule{1-\arabic{LWR@tabletotalLaTeXcols}}}%
    {\addtocounter{LWR@hlines}{1}}%
    \LWR@getmynexttoken}%
}
}% AtBeginDocument
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@HTMLcline} \marg{columns}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTMLcline}{m}%
{\LWR@docmidrule{#1}\LWR@getmynexttoken}%
%    \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 \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}{tabular} |<direction>| \oarg{vertposition} \marg{colspecs}
%
% The |<direction>| is from \pkg{plext} for Japanese documents, and is ignored.
%
% \changes{v0.34}{2017/08/08}{\pkg{booktabs}: Works inside \env{lateximage}.}
% \changes{v0.36}{2017/08/16}{Fix for \pkg{babel-french}.}
% \changes{v0.65}{2018/12/15}{Added support for \pkg{plext}.}
% \changes{v0.65}{2018/12/16}{Fix: \env{tabular*}.}
%
%    \begin{macrocode}
\StartDefiningTabulars

\NewDocumentCommand{\LWR@HTML@@tabular}{d<> o m}
{%
\LWR@traceinfo{LWR@HTML@@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}
\setcounter{LWR@hlines}{0}%
\setcounter{LWR@hdashedlines}{0}%
\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 \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@traceinfo{LWR@@tabular: About to LWR@forecenewpage.}%
\LWR@forcenewpage
\LWR@htmlblocktag{table}%
%    \end{macrocode}
% Parse the table columns:
%    \begin{macrocode}
\LWR@parsetablecols{#3}%
%    \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@tableLaTeXcolindex}{1}%
%    \end{macrocode}
% Have not yet added data in this column:
%    \begin{macrocode}
\global\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 adjust for \pkg{colortbl}.
% \changes{v0.48}{2018/02/06}{\pkg{colortbl}: Added.}
%    \begin{macrocode}
\LetLtxMacro\arrayrulecolor\arrayrulecolornexttoken%
\LetLtxMacro\doublerulesepcolor\doublerulesepcolornexttoken%
\gdef\LWR@columnHTMLcolor{}%
\gdef\LWR@rowHTMLcolor{}%
\gdef\LWR@cellHTMLcolor{}%
\@rowcolors%
%    \end{macrocode}
%
% The vertical rules are set to the color active at the start of the tabular.
% \cs{arrayrulecolor} will then affect horizontal rules inside the tabular,
% but not the vertical rules.
% \changes{v0.65}{2018/12/19}{Fix: Rule color.}
%    \begin{macrocode}
\ifdefvoid{\LWR@ruleHTMLcolor}%
    {\edef\LWR@vertruleHTMLcolor{black}}%
    {\edef\LWR@vertruleHTMLcolor{\LWR@origpound\LWR@ruleHTMLcolor}}%
%    \end{macrocode}
%
% Tracking the depth of cell color \element{div}s:
%    \begin{macrocode}
\setcounter{LWR@cellcolordepth}{0}%
%    \end{macrocode}
%
% The following may appear before a data cell is created,
% so after doing their actions, we look ahead with \cs{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@@HTML@tabular: redefining macros}%
\LetLtxMacro\noalign\LWR@tabularnoalign%
\LetLtxMacro\hline\LWR@HTMLhline%
\LetLtxMacro\cline\LWR@HTMLcline%
%    \end{macrocode}
%    \begin{macrocode}
\DeclareDocumentCommand{\hdashline}{o}{%
    \ifbool{FormatWP}%
        {\LWR@docdashline{1-\arabic{LWR@tabletotalLaTeXcols}}}%
        {\addtocounter{LWR@hdashedlines}{1}}%
    \LWR@getmynexttoken%
}%
%    \end{macrocode}
%    \begin{macrocode}
\DeclareDocumentCommand{\cdashline}{m}{%
    \LWR@docdashline{##1}\LWR@getmynexttoken%
}%
%    \end{macrocode}
%    \begin{macrocode}
\DeclareDocumentCommand{\firsthdashline}{o}{%
    \ifbool{FormatWP}%
        {\LWR@docdashline{1-\arabic{LWR@tabletotalLaTeXcols}}}%
        {\addtocounter{LWR@hdashedlines}{1}}%
    \LWR@getmynexttoken%
}%
%    \end{macrocode}
%    \begin{macrocode}
\DeclareDocumentCommand{\lasthdashline}{o}{%
    \ifbool{FormatWP}%
        {\LWR@docdashline{1-\arabic{LWR@tabletotalLaTeXcols}}}%
        {\addtocounter{LWR@hdashedlines}{1}}%
    \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 \cs{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}
% Locally force any minipages to be fullwidth, until the end of the \env{tabular}:
% \changes{v0.66}{2018/12/31}{Fix: Minipages inside \env{tabular}.}
%    \begin{macrocode}
\booltrue{LWR@forceminipagefullwidth}
%    \end{macrocode}
% Nest one level deeper of tabular paragraph handling:
% \changes{v0.46}{2018/01/18}{Fix: Tabular empty lines.}
%    \begin{macrocode}
\addtocounter{LWR@tabularpardepth}{1}%
%    \end{macrocode}
% Look ahead for a possible table data cell:
%    \begin{macrocode}
\LWR@traceinfo{LWR@@HTML@tabular: about to LWR@getmynexttoken}%
\LWR@getmynexttoken%
}%
%    \end{macrocode}
%
%
%
% Ending the environment:
%    \begin{macrocode}
\newcommand*{\LWR@HTML@endtabular}
{%
\LWR@traceinfo{LWR@HTML@endtabular}%
%    \end{macrocode}
% Unnest one level of tabular paragraph handling:
% \changes{v0.46}{2018/01/18}{Fix: Tabular empty lines.}
%    \begin{macrocode}
\addtocounter{LWR@tabularpardepth}{-1}%
\ifboolexpr{%
    test {%
        \ifnumcomp{\value{LWR@tableLaTeXcolindex}}{<}{\value{LWR@tabletotalLaTeXcols}}
    } or %
    (%
        bool{LWR@intabularmetadata} and%
        not bool{LWR@tabularcelladded} and%
        test {%
            \ifnumcomp{\value{LWR@tableLaTeXcolindex}}{=}{\value{LWR@tabletotalLaTeXcols}}%
        }%
    )%
}%
{%
    \LWR@tabularfinishrow%
}%
{%
    \LWR@closetabledatacell%
}%
\LWR@htmlblocktag{/tr}%
%    \end{macrocode}
% \pkg{xcolor} row color support:
%    \begin{macrocode}
\@rowc@lors%
%    \end{macrocode}
%    \begin{macrocode}
\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}%
\StopDefiningTabulars%
\LWR@traceinfo{LWR@HTML@endtabular finished}%
}

\csletcs{LWR@HTML@endtabular*}{LWR@HTML@endtabular}

\StopDefiningTabulars
%    \end{macrocode}
%
% \pkg{siunitx} may redefine \env{tabular}, so set the following later:
%    \begin{macrocode}
\AtBeginDocument{
    \LetLtxMacro\LWR@origendtabular\endtabular
    \csletcs{LWR@origendtabular*}{endtabular*}
    \LWR@formatted{@tabular}
    \LWR@formatted{endtabular}
    \LWR@formatted{endtabular*}
}
%    \end{macrocode}
% \end{environment}

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



% \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.
%
% \DescribeFile{*_html.aux}
% A new entry in \filenm{*_html.aux} is used to remember section name, file, and
% lateximage depth and number for each label:
% \begin{sourceverb}
% \newlabel{<labelname>@lwarp}{{<section name>}{<filename>}
%                                   {<limagedepth>}{<limagenumber>}}
% \end{sourceverb}
%
% \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}),
%		and another \filenm{.aux} entry (\cref{sec:lwarplabelsetup}).
%   \item [\cs{newlabel}:] Unchanged.  When the |.aux| file is read, sets \cs{r@<label>@lwarp}.
%   \item [\cs{r@<label>@lwarp}:] Set to |{{section_name}{file_name}{depth}{number}}|:
%		\begin{description}
%		\item [\cs{LWR@nameref}:] The section name for this label.
%		\item [\cs{LWR@htmlfileref}:] The filenumber or name for this label.
%		\item [\cs{LWR@lateximagedepthref}:] The |lateximagedepth| for this label.
%		\item [\cs{LWR@lateximagenumberref}:] 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{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{New \pkg{lwarp} labels.}
% \label{sec:lwarplabelsetup}
%
% \DescribeFile{*_html.aux}
% A new entry in \filenm{*_html.aux} is used to remember section name, file, and
% lateximage depth and number for each label:
% \begin{sourceverb}
% \newlabel{<labelname>@lwarp}{{<section name>}{<filename>}
%                                   {<limagedepth>}{<limagenumber>}}
% \end{sourceverb}
%
%
% See: \\
% \href{http://tex.stackexchange.com/questions/57194/extract-section-number-from-equation-reference}
%    {\ttfamily http://tex.stackexchange.com/questions/57194/ \\
%		\fqquad\ extract-section-number-from-equation-reference}
%
%
% \begin{macro}{\LWR@setref} \marg{args list} \marg{selector} \marg{label}
%
% \cs{@setref} without the \cs{null} (\cs{hbox}), and without the
% warning messages.
% Each caused problems with \pkg{lwarp} references.
% The regular reference will cause the warning.
%
% \changes{v0.66}{2019/01/30}{No longer use \pkg{zref}.}
%    \begin{macrocode}
\def\LWR@setref#1#2#3{%
  \ifx#1\relax%
    ??%
  \else%
   \expandafter#2#1%
  \fi}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@nameref} \marg{label}
% Returns the section name for this label:
% \changes{v0.66}{2019/01/27}{No longer use \pkg{zref}.}
%    \begin{macrocode}
\newcommand*{\LWR@nameref}[1]{%
    \expandafter\LWR@setref\csname r@#1@lwarp\endcsname\LWR@firstoffour{#1}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@htmlfileref} \marg{label}
% Returns the file number or name for this label:
% \changes{v0.24}{2017/03/13}{Fix: Index links while \cs{tracinglwarp}.}
% \changes{v0.66}{2019/01/27}{No longer use \pkg{zref}.}
%    \begin{macrocode}
\newcommand*{\LWR@htmlfileref}[1]{%
    \expandafter\LWR@setref\csname r@#1@lwarp\endcsname\LWR@secondoffour{#1}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@lateximagedepthref} \marg{label}
% Returns the |lateximagedepth| for this label:
% \changes{v0.66}{2019/01/27}{No longer use \pkg{zref}.}
%    \begin{macrocode}
\newcommand*{\LWR@lateximagedepthref}[1]{%
    \expandafter\LWR@setref\csname r@#1@lwarp\endcsname\LWR@thirdoffour{#1}%
}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\LWR@lateximagenumberref} \marg{label}
% Returns the |lateximagenumber| for this label:
% \changes{v0.66}{2019/01/27}{No longer use \pkg{zref}.}
%    \begin{macrocode}
\newcommand*{\LWR@lateximagenumberref}[1]{%
    \expandafter\LWR@setref\csname r@#1@lwarp\endcsname\LWR@fourthoffour{#1}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@lwarplabel} \marg{label}
% Sanitize the name and then creates the label:
% \changes{v0.66}{2019/01/27}{No longer use \pkg{zref}.}
%    \begin{macrocode}
\newcommand*{\LWR@lwarplabel}[1]{%
\LWR@traceinfo{LWR@lwarplabel !#1!}%
\LWR@setlatestname{\@currentlabelname}%
    \@bsphack%
    \protected@write\@auxout{}%
        {\string\newlabel{#1@lwarp}{%
            {\@currentlabelname}%
            {\ifbool{FileSectionNames}{\LWR@thisfilename}{\arabic{LWR@htmlfilenumber}}}%
            {\arabic{LWR@lateximagedepth}}%
            {\arabic{LWR@lateximagenumber}}%
        }}%
    \@esphack%
}
%    \end{macrocode}
% \end{macro}
%



% \subsection{Labels}
% \label{sec:labels}


% \begin{macro}{\LWR@sublabel} \marg{label} \quad
% Creates an \HTML\ id tag.
%
% \cs{detokenize} is used to allow underscores in the labels.
% \changes{v0.45}{2017/12/29}{Fix: Labels with underscores.}
%    \begin{macrocode}
\newcommand*{\LWR@sublabel}[1]{%
\LWR@traceinfo{LWR@sublabel !#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:
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
% (To be factored\dots)
%    \begin{macrocode}
    \LWR@sanitize{#1}%
    \ifbool{LWR@doingstartpars}%
    {% pars allowed
        \ifbool{LWR@doingapar}%
        {% par started
            \LWR@htmltag{a \LWR@print@mbox{id="\LWR@sanitized"}}\LWR@htmltag{/a}%
        }% par started
        {% par not started
            \LWR@stoppars%
            \LWR@htmltag{a \LWR@print@mbox{id="\LWR@sanitized"}}\LWR@htmltag{/a}%
            \LWR@startpars%
        }% par not started
    }% pars allowed
    {% pars not allowed
        \LWR@htmltag{a \LWR@print@mbox{id="\LWR@sanitized"}}\LWR@htmltag{/a}%
    }% pars not allowed
}% not lateximage
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@new@label} \parg{bookmark} \marg{label} \oarg{type}
%
% \cs{label} during \HTML\ output when not in \SVG\ math mode,
% removing extra spaces around the label, as done by a regular \LaTeX\ \cs{label}.
%
% The is also used during a \env{lateximage}, including \SVG\ math, since
% the special label handling is required, but \cs{LWR@sublabel} does not
% generate \HTML\ tags inside a \env{lateximage}.
%
% \pkg{clevereref} later encases this to add its own cross-referencing.
%
% The optional \meta{bookmark} is per the \pkg{memoir} class, and is ignored.
%
% The optional \meta{type} is per the \pkg{ntheorem} package, and is ignored.
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@new@label}{d() m o}{%
\LWR@traceinfo{LWR@new@label: starting}%
\LWR@traceinfo{LWR@new@label: !#2!}%
% \@bsphack%
%    \end{macrocode}
% Create a traditional \LaTeX\ label, as modified by \pkg{cleveref}:
%    \begin{macrocode}
\LWR@orig@label{#2}%
%    \end{macrocode}
% Create a special label which holds the section number,
% |LWR@htmlfilenumber|, |LWR@lateximagedepth|, and |LWR@lateximagenumber|:
%    \begin{macrocode}
\LWR@traceinfo{LWR@new@label: filesectionnames is \ifbool{FileSectionNames}{true}{false}}%
\LWR@traceinfo{LWR@new@label: LWR@thisfilename is !\LWR@thisfilename!}%
\LWR@traceinfo{LWR@new@label: LWR@htmlfilenumber is \arabic{LWR@htmlfilenumber}}%
\LWR@lwarplabel{#2}%
\LWR@sublabel{#2}%
% \@esphack%
\LWR@traceinfo{LWR@new@label: done}%
}
%    \end{macrocode}
% \end{macro}



% \subsection{References}
% \label{sec:references}

% \begin{macro}{\LWR@startref} \marg{label} \quad
% (Common code for \cs{ref} and \cs{nameref}.)
%
% Open an \HTML\ tag reference to a filename, \# character, and a label.
%
% \changes{v0.28}{2017/04/13}{Removed space.}
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
% \changes{v0.66}{2019/01/27}{No longer use \pkg{zref}.}
%
%    \begin{macrocode}
\newcommand*{\LWR@startref}[1]
{%
\LWR@sanitize{#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@print@mbox{\LWR@htmlrefsectionfilename{#1}}%
\LWR@traceinfo{LWR@startref C}%
\LWR@origpound%
%    \end{macrocode}
% Create the destination id:
%
% See if |LWR@lateximagedepth| is unknown:
%    \begin{macrocode}
\LWR@traceinfo{LWR@startref D: !#1!}%
\ifcsundef{r@#1@lwarp}%
%    \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}
{%
    \ifthenelse{\cnttest{\LWR@lateximagedepthref{#1}}{>}{0}}%
        {%
            \LWR@ImagesName\LWR@lateximagenumberref{#1}%
        }%
        {%
            \LWR@traceinfo{LWR@startref D3}%
%    \end{macrocode}
% \cs{detokenize} is used to allow underscores in the labels:
% \changes{v0.45}{2017/12/01}{Fix: Labels with underscores.}
%    \begin{macrocode}
            \LWR@print@mbox{\LWR@sanitized}%
        }%
}%
\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@print@ref{#2}%
\LWR@htmltag{/a}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\ref} * \marg{label} \quad
%   \cs{ref} is redefined to \cs{LWR@HTML@ref},
%   except inside the text part of a \cs{hyperref},
%   where it is redefined to \cs{LWR@ref@ignorestar}.
% \begin{macro}{\LWR@HTML@ref} * \marg{label}
%   Create an internal document reference link,
%   or without a link if starred per \pkg{hyperref}.
%
% \changes{v0.58}{2018/06/07}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@ref}{s m}{%
\LWR@traceinfo{LWR@HTML@ref !#2!}%
\IfBooleanTF{#1}%
{\LWR@print@ref{#2}}%
{\LWR@subnewref{#2}{#2}}%
}

\LWR@formatted{ref}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\LWR@ref@ignorestar} * \marg{label} \quad
%   For use inside \cs{hyperref}.  Ignores the star, then uses the original \cs{ref}.
%
% \changes{v0.57}{2018/06/05}{\pkg{subcaption}: Fix: \cs{subref}.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@ref@ignorestar}{s m}{%
    \LWR@print@ref{#2}%
}
%    \end{macrocode}
% \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@new@pageref}{s m}{%
\IfBooleanTF{#1}%
{(\pagerefPageFor\LWR@print@ref{#2})}%
{(\cpageref{#2})}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\nameref} \marg{label}
%
% \changes{v0.43}{2017/10/31}{Made robust.}
%    \begin{macrocode}
\newrobustcmd*{\nameref}[1]{%
\LWR@traceinfo{nameref}%
\LWR@startref{#1}%
\LWR@traceinfo{nameref B}%
\LWR@nameref{#1}%
\LWR@traceinfo{nameref C}%
\LWR@htmltag{/a}%
\LWR@traceinfo{nameref: done}%
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\Nameref} \marg{label}
% In print, adds the page number.  In \HTML, does not.
%    \begin{macrocode}
\LetLtxMacro\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.
%
%    \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}



% Emulates \pkg{hyperref}:
% \begin{macro}{\@currentHref} Added to support \pkg{backref}.
% \changes{v0.45}{2018/01/14}{Added.}
%    \begin{macrocode}
\AtBeginDocument{
\def\@currentHref{%
autopage-\theLWR@currentautosec%
}
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\LWR@subhyperref} \marg{URL}
%
% Starts a link for \cs{LWR@hrefb}.
% A group must have been opened first, with nullified catcodes.
% The text name is printed afterwards, after the group is closed and catcodes restored.
%
% \changes{v0.18}{2016/04/14}{Improved \HTML\ output linebreaks.}
% \changes{v0.45}{2017/12/29}{Improved URLs with underscores.}
% \changes{v0.57}{2018/06/05}{Fix: Text catcodes.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@subhyperref}{m}{%
\LWR@traceinfo{LWR@subhyperref !#1!}%
\LWR@sanitize{#1}%
\LWR@htmltag{%
    a href="\LWR@sanitized" % space
    target="\_{}blank" % space
}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@subhyperreftext} \marg{text}
%
% Finishes the hyperref for \cs{LWR@hrefb}.  Catcodes must have been restored already.
% To be used after \cs{LWR@subhyperref}, and after its group has been closed.
%
% \changes{v0.57}{2018/06/05}{Fix: Text catcodes.}
%    \begin{macrocode}
\newcommand{\LWR@subhyperreftext}[1]{%
#1%
\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.}
% \changes{v0.45}{2017/12/29}{Improved URLs with underscores.}
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@subhyperrefclass}{m +m m}{%
\LWR@htmltag{%
    a % space
    href="\begingroup\@sanitize#1\endgroup" % space
    class="#3" % space
}\LWR@orignewline%
#2\LWR@orignewline%
\LWR@htmltag{/a}%
\LWR@ensuredoingapar%
}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\href} \oarg{options} \marg{URL}
%
% Create a link with accompanying text:
%
% \changes{v0.43}{2017/10/31}{Made robust.}
% \changes{v0.49}{2018/02/18}{Fix: Adapt to classes.}
% \changes{v0.52}{2018/03/26}{Fix: \progcode{\#}, \progcode{\%}, \progcode{\&}, \progcode{\~}, \progcode{\_} in \URL.}
% \changes{v0.57}{2018/06/05}{Fix: Text catcodes.}
%    \begin{macrocode}
\DeclareDocumentCommand{\LWR@hrefb}{O{} m}{%
\LWR@ensuredoingapar%
\LWR@subhyperref{#2}%
\endgroup% restore catcodes
\LWR@subhyperreftext%
}

\newrobustcmd*{\href}{%
\begingroup%
\catcode`\#=12%
\catcode`\%=12%
\catcode`\&=12%
\catcode`\~=12%
\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.}
% \changes{v0.45}{2017/12/29}{Fix: Underscore in \URL.}
% \changes{v0.52}{2018/03/26}{Fix: \progcode{\#}, \progcode{\%}, \progcode{\&}, \progcode{\~}, \progcode{\_} in \URL.}
%    \begin{macrocode}
\newcommand*{\LWR@nolinkurlb}[1]{%
\LWR@ensuredoingapar%
\def\LWR@templink{#1}%
\@onelevel@sanitize\LWR@templink%
\LWR@templink%
\endgroup%
}

\newrobustcmd*{\nolinkurl}{%
\begingroup%
\catcode`\#=12%
\catcode`\%=12%
\catcode`\&=12%
\catcode`\~=12%
\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.}
% \changes{v0.45}{2017/12/29}{Improved URLs with underscores.}
% \changes{v0.49}{2018/02/18}{Fix: Adapt to classes.}
% \changes{v0.52}{2018/03/26}{Fix: \progcode{\#}, \progcode{\%}, \progcode{\&}, \progcode{\~}, \progcode{\_} in \URL.}
%    \begin{macrocode}
\DeclareDocumentCommand{\LWR@urlb}{m}{%
\LWR@ensuredoingapar%
\def\LWR@templink{#1}%
\@onelevel@sanitize\LWR@templink%
\href{\LWR@templink}{\LWR@templink}%
\endgroup%
}

\newrobustcmd*{\url}{%
\begingroup%
\catcode`\#=12%
\catcode`\%=12%
\catcode`\&=12%
\catcode`\~=12%
\catcode`\_=12%
\LWR@urlb%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@subinlineimage} \oarg{alttag} \marg{class}
%	\marg{filename} \marg{extension} \marg{style}
%
% \changes{v0.18}{2016/05/18}{Suppress extra space.}
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
\newcommand*{\LWR@subinlineimage}[5][]{%
\ifblank{#1}%
{%
    \LWR@htmltag{img \LWR@indentHTML
        src="#3.#4" \LWR@indentHTML
        alt="#3" \LWR@indentHTML
        style="#5" \LWR@indentHTML
        class="#2" \LWR@orignewline
    }%
}%
{%
    \LWR@htmltag{img \LWR@indentHTML
        src="#3.#4" \LWR@indentHTML
        alt="#1" \LWR@indentHTML
        style="#5" \LWR@indentHTML
        class="#2" \LWR@orignewline
    }%
}%
}
%    \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 \progcode{<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 |\begin{figure}|
% \item [\cs{end<type>}:] Ends the float environment. |\endfigure| or |\end{figure}|
% \item [\cs{tf@<ext>}:] The \LaTeX{} file identifier for the output file.
% \item [\progcode{LWR@have<type>}:] A boolean remembering whether a \cs{listof} was
%	requested for a float of this type.
% \item [File with extension \filenm{lo<f,t,a-z>}:] An output file containing
%	the commands to build the
%	\cs{listof<type>} ``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 environment}

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


% \begin{macro}{\LWR@floatbegin} \marg{type} \oarg{placement} \qquad
% 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@print@raggedright%
%    \end{macrocode}
% Open an \HTML\ |figure| tag.
% The figure is assigned a \attribute{class} equal to its type,
% and another class according to the \pkg{float} package style, if used.
% Note that \cs{csuse} returns an empty string if \cs{LWR@floatstyle@<type>}
% is not defined.
% \changes{v0.42}{2017/10/26}{If \progcode{FormatWP} add a text frame.}
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
% \changes{v0.56}{2018/05/14}{Adds a \element{class} per \pkg{float} package style.}
%    \begin{macrocode}
\LWR@htmltag{%
    figure id="\LWR@print@mbox{autoid-\arabic{LWR@thisautoid}}" % space
    class="#1 \@nameuse{LWR@floatstyle@#1}"%
}%
\ifbool{FormatWP}{%
    \LWR@orignewline%
    \LWR@BlockClassWP{}{}{wp#1}%
}{}%
%    \end{macrocode}
% Update the caption type:
%    \begin{macrocode}
\renewcommand*{\@captype}{#1}%
\caption@settype{#1}%
%    \end{macrocode}
% Mark the float for a word processor conversion:
%    \begin{macrocode}
\LWR@startpars%
\ifboolexpr{bool{FormatWP} and bool{WPMarkFloats}}{%

=== begin #1 ===

}{}%
%    \end{macrocode}
% Look for \cs{centering}, etc:
% \changes{v0.54}{2018/04/19}{Honor \cs{centering}, etc. in floats.}
% \changes{v0.55}{2018/04/24}{Fix: Float optional args.}
%    \begin{macrocode}
\LWR@futurenonspacelet\LWR@mynexttoken\LWR@floatalignment%
}
%    \end{macrocode}
% \end{macro}
%
% For \pkg{koma-script}.  The following does not work for tables.
% \changes{v0.55}{2018/04/25}{Fix: \cs{centering}, etc. for \pkg{koma-script}.}
%    \begin{macrocode}
\AtBeginDocument{
\@ifpackageloaded{tocbasic}{
\appto\figure@atbegin{%
\LWR@futurenonspacelet\LWR@mynexttoken\LWR@floatalignment%
}
}{}
}
%    \end{macrocode}
%
%
%
% \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}{%
%    \end{macrocode}
% If saw a \cs{centering}, finish the \env{center} environment:
% \changes{v0.54}{2018/04/19}{Honor \cs{centering}, etc. in floats.}
%    \begin{macrocode}
\LWR@endfloatalignment%
%    \end{macrocode}
% Mark the float end for a word processor conversion:
%    \begin{macrocode}
\ifboolexpr{bool{FormatWP} and bool{WPMarkFloats}}{%

=== end ===

}{}%
\LWR@stoppars%
%    \end{macrocode}
% Close an \HTML\ |figure| tag:
% \changes{v0.42}{2017/10/26}{If \progcode{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}


% \subsection{Float tracking}
%
% \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}

% \DescribeCounter{LWR@thisautoidWP}
% A sequential counter for all word processor conversion \element{div}s.
% This is used to convince \brand{LibreOffice} to form a frame around this element.
% \changes{v0.45}{2017/12/09}{Separate \ctr{LWR@thisautoidWP} for word processor \element{div}s.}
%    \begin{macrocode}
\newcounter{LWR@thisautoidWP}
%    \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@newautoidanchor}
% Adds a new \element{autoid} anchor.
% \changes{v0.45}{2017/12/07}{Fix: No anchor if frozen autoid.}
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
% \changes{v0.51}{2018/03/16}{Fix: No autoid is inside a \env{lateximage}.}
%    \begin{macrocode}
\newcommand*{\LWR@newautoidanchor}{%
\ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
{}%
{
    \ifbool{LWR@freezethisautoid}{}{%
        \addtocounter{LWR@thisautoid}{1}%
        \LWR@htmltag{a id="\LWR@print@mbox{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}

% \begin{macro}{\LWR@floatalignmentname}
% Set to |center|, |flushleft|, or |flushright| if saw
% \cs{centering}, \cs{raggedright}, or \cs{raggedleft}.
%    \begin{macrocode}
\newcommand*{\LWR@floatalignmentname}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@floatalignment}
% If sees a \cs{centering}, \cs{raggedleft}, or \cs{raggedright},
% creates a \env{center}, \env{flushright}, or \env{flushleft} environment.
% \changes{v0.54}{2018/04/19}{Honor \cs{centering}, etc. in floats.}
%    \begin{macrocode}
\newcommand*{\LWR@floatalignment}{%
\ifdefstrequal{\LWR@mynexttoken}{\centering}{%
    \center%
    \renewcommand*{\LWR@floatalignmentname}{center}%
}{}%
\ifdefstrequal{\LWR@mynexttoken}{\raggedright}{%
    \flushleft%
    \renewcommand*{\LWR@floatalignmentname}{flushleft}%
}{}%
\ifdefstrequal{\LWR@mynexttoken}{\raggedleft}{%
    \flushright%
    \renewcommand*{\LWR@floatalignmentname}{flushright}%
}{}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@endfloatalignment}
% Closes an environment from \cs{LWR@floatalignment}.
% \changes{v0.54}{2018/04/19}{Honor \cs{centering}, etc. in floats.}
%    \begin{macrocode}
\newcommand*{\LWR@endfloatalignment}{%
\ifdefvoid{\LWR@floatalignmentname}{}{\@nameuse{end\LWR@floatalignmentname}}%
\renewcommand*{\LWR@floatalignmentname}{}%
}
%    \end{macrocode}
% \end{macro}


% \subsection{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]{%
    \LWR@traceinfo{@makecaption}%
    \LWR@isolate{#1}\CaptionSeparator\LWR@isolate{#2}%
    \LWR@traceinfo{@makecaption: done}%
}%
}
%    \end{macrocode}
% \end{macro}


% \subsection{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|, |.lot| file is read.
%    \begin{macrocode}
\newcounter{LWR@nextautoid}
\newcounter{LWR@nextautopage}
%    \end{macrocode}
%
%
%
% \begin{macro}{\LWRsetnextfloat} \marg{autopage} \marg{float autoid}
%
% \DescribeFile{*_html.lof}
% \DescribeFile{*_html.lot}
% This is written to the \filenm{*_html.lof} or \filenm{*_html.lot} file
% just before each float's usual entry.
% The |autopage| and the float's |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}
%
% An \HTML\ \element{figcaption} is not allowed in places where
% \LaTeX\ does allow a figure caption, such as inside a \env{longtable}
% where the tabular has already started, or inside a \env{center} environment.
% Therefore, a \element{div} of class \attribute{figurecaption} is used
% instead.
% \changes{v0.42}{2017/10/20}{If \progcode{FormatWP} forces italic captions.}
% \changes{v0.65}{2018/12/21}{Uses \element{figurecaption} instead of \element{figcaption}.}
%    \begin{macrocode}
\newenvironment*{LWR@figcaption}
    {
        \ifbool{FormatWP}{%
            \BlockClass[font-style:italic]{figurecaption}
%             \LWR@print@vspace*{\baselineskip}
        }{
            \BlockClass{figurecaption}
        }%
    }
    {\endBlockClass}
%    \end{macrocode}
% \end{environment}
%
%
% \begin{macro}{\LWR@HTML@caption@begin} \marg{type}
%
% Low-level code to create \HTML\ tags for captions.
%
% The print versions are from the \pkg{caption} package.
%
% \changes{v0.47}{2018/01/28}{Fix: Argument passed to \cs{LWR@origcaption@begin}.}
% \changes{v0.58}{2018/06/07}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\newcommand*{\LWR@HTML@caption@begin}[1]
{
\LWR@traceinfo{LWR@HTML@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}
\@setpar{\LWR@closeparagraph\@@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@traceinfo{LWR@HTML@caption@begin: about to LWR@origcaption@begin}%
\LWR@print@caption@begin{#1}%
\LWR@traceinfo{LWR@HTML@caption@begin: done}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@HTML@caption@end}
% Low-level patches to create \HTML\ tags for captions.
% \changes{v0.58}{2018/06/07}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\newcommand*{\LWR@HTML@caption@end}
{%
\LWR@traceinfo{LWR@HTML@caption@end}%
\LWR@print@caption@end%
%    \end{macrocode}
% Closing tag:
%    \begin{macrocode}
\endLWR@figcaption%
\endgroup%
% \leavevmode% avoid bad space factor (0) error
\LWR@traceinfo{LWR@HTML@caption@end: done}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\caption@begin}
% \begin{macro}{\caption@end}
% Low-level patches to create \HTML\ tags for captions.
% These are assigned \cs{AtBeginDocument} so that other packages
% which modify captions will have already been loaded before saving the
% print-mode version.
%    \begin{macrocode}
\AtBeginDocument{
\LWR@formatted{caption@begin}
\LWR@formatted{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.
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\let\LWR@origcaptionlistentry\captionlistentry

\renewcommand*{\captionlistentry}{%
\LWR@ensuredoingapar%
\LWR@origcaptionlistentry%
}

\def\LWR@LTcaptionlistentry{%
\LWR@ensuredoingapar%
\LWR@htmltag{a id="\LWR@print@mbox{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}.}
%f
%    \begin{macrocode}
\let\LWR@origaddcontentsline\addcontentsline

\renewcommand*{\addcontentsline}[3]{%
\ifstrequal{#1}{toc}{}{% not TOC
%    \end{macrocode}
% \changes{v0.51}{2018/03/11}{No anchor ID if inside \SVG\ image.}
%    \begin{macrocode}
\ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
    {}%
    {\LWR@newautoidanchor}%
%    \end{macrocode}
% \changes{v0.51}{2018/03/11}{Add missing support for float mechanism if necessary.}
%    \begin{macrocode}
    \ifcsvoid{ext@#2}{\csdef{ext@#2}{#1}}{}%
%    \end{macrocode}
%    \begin{macrocode}
    \addtocontents{\@nameuse{ext@#2}}{%
        \protect\LWRsetnextfloat%
        {\arabic{LWR@latestautopage}}%
        {\arabic{LWR@thisautoid}}%
    }%
}% not TOC
\LWR@origaddcontentsline{#1}{#2}{#3}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \DescribePackage{capt-of}
% \DescribePackage{caption} Either package provides \cs{captionof}, which
% is later patched at the beginning of the document.
%
% \begin{macro}{\captionof}
% Patched to handle paragraph tags.
%    \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/sidetoc}
% \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 side\TOC\ may be referred to again in each \HTML\ page.
%    \begin{macrocode}
\newcommand*{\LWR@myshorttoc}[1]{%
\LWR@traceinfo{LWR@myshorttoc: #1}%
\LWR@ensuredoingapar%
%    \end{macrocode}
% Only if the file exists:
%    \begin{macrocode}
\IfFileExists{\jobname.#1}{%
\LWR@traceinfo{LWR@myshorttoc: loading}%
%    \end{macrocode}
%
% Many of the commands in the file will have |@| characters in them, so |@|
% \watchout
% must be made a regular letter.
%    \begin{macrocode}
\begingroup%
\makeatletter%
%    \end{macrocode}
% Read in the \TOC\ file:
%    \begin{macrocode}
\@input{\jobname.#1}%
\endgroup%
}%
{}%
\LWR@traceinfo{LWR@myshorttoc: done}%
}
%    \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}
%
%
% \DescribeBoolean{LWR@copiedsidetoc} Used to only copy the
% \TOC\ file to the sidetoc a single time.
%
% (\pkg{listings} and perhaps other packages would re-use \cs{tableofcontents}
% for their own purposes, causing the sidetoc to be copied more than once, and
% thus end up empty.)
% \changes{v0.45}{2017/12/09}{Fix: Empty sidetoc.}
%    \begin{macrocode}
\newbool{LWR@copiedsidetoc}
\boolfalse{LWR@copiedsidetoc}
%    \end{macrocode}
%
%
%
% \begin{macro}{\tableofcontents}
% Patch \cs{tableofcontents}, etc. to print footnotes first.
% \pkg{newfloat} uses \cs{listoffigures} for all future float types.
% \changes{v0.45}{2017/12/07}{Fix: Patch \cs{AtBeginDocument}.}
% \changes{v0.45}{2017/12/09}{Fix: Empty sidetoc.}
%    \begin{macrocode}
\AtBeginDocument{
\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 \progcode{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}
    \ifbool{LWR@copiedsidetoc}{}{%
        \LWR@copyfile{\jobname.toc}{\jobname.sidetoc}%
        \booltrue{LWR@copiedsidetoc}%
    }%
    \LWR@printpendingfootnotes
    \LWR@origtableofcontents
}
}% \tableofcontents
}% AtBeginDocument
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\listoffigures}
% \changes{v0.42}{2017/10/18}{Added boolean \progcode{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 \progcode{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.
%
% \changes{v0.57}{2018/05/26}{Fix: Provide \cs{l@name} if not defined.}
% \changes{v0.61}{2018/09/26}{Fix: \pkg{newfloat} lists.}
%    \begin{macrocode}
\NewDocumentCommand{\listof}{m +m}{%
\@ifundefined{l@#1}{%
    \csdef{l@#1}##1##2{\hypertocfloat{1}{#1}{\@nameuse{ext@#1}}{##1}{##2}}%
}{}%
\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.\@nameuse{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 side\TOC:
%
% \begin{docsidebar}[CSS related to side\TOC:]
% \vspace*{-\baselineskip}
% \begin{description}[parsep=0ex]
% \vspace*{-\baselineskip}
% \item [|div.sidetoccontainer|:] The entire side\TOC.
% \item [|div.sidetoctitle|:] The title.
% \item [|div.sidetoccontents|:] The table of contents.
% \end{description}
% \vspace*{-\baselineskip}
% \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{div}{sidetoccontainer}
\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}
\ifcsvoid{thetitle}{}{\InlineClass{sidetocthetitle}{\thetitle}\par}
\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}
\LWR@htmlelementclassend{div}{sidetoccontainer}
}
%    \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 opens.
%
% \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}{%
\LWR@traceinfo{hypertoc !#1!#2!#3!#4!}%
%    \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 the name,
% of the given \HTML\ class.
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
        \LWR@subhyperrefclass{%
            \LWR@htmlrefsectionfilename{autopage-#4}%
                \LWR@origpound\LWR@print@mbox{autosec-#4}%
        }{#3}{toc#2}%
        \LWR@stoppars%
    }%
    {}%
\LWR@traceinfo{hypertoc done}%
}
%    \end{macrocode}
% \end{macro}

% \DescribeCounter{lofdepth} \TOC\ depth for figures.
%    \begin{macrocode}
\@ifclassloaded{memoir}{}{
\newcounter{lofdepth}
\setcounter{lofdepth}{1}
}
%    \end{macrocode}

% \DescribeCounter{lotdepth} \TOC\ depth for tables.
%    \begin{macrocode}
\@ifclassloaded{memoir}{}{
\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 \progcode{lofdepth}, \progcode{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.
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
        \LWR@subhyperrefclass{%
        \LWR@htmlrefsectionfilename{autopage-\arabic{LWR@nextautopage}}%
        \LWR@origpound\LWR@print@mbox{autoid-\arabic{LWR@nextautoid}}}%
        {#4}{toc#2}%
        \LWR@stoppars%
    }%
    {}%
}
%    \end{macrocode}
% \end{macro}

% Automatically called by \cs{contentsline}:
% \begin{macro}{\l@part} \marg{name} \marg{page}
%
% Uses \cs{DeclareDocumentCommand} in case the class does not happen to have a \cs{part}.
% \changes{v0.48}{2018/02/03}{Adapts to classes without \cs{part}.}
%    \begin{macrocode}
\DeclareDocumentCommand{\l@part}{m m}{\hypertoc{-1}{part}{#1}{#2}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\l@chapter} \marg{name} \marg{page}
%
% Uses \cs{DeclareDocumentCommand} in case the class does not happen to have a \cs{chapter}.
% \changes{v0.62}{2018/11/17}{Don't define if no \cs{chapter}.
%   Fix for \pkg{algorithm2e}.}
%    \begin{macrocode}
\@ifundefined{chapter}
{}
{
\DeclareDocumentCommand{\l@chapter}{m m}
    {\hypertoc{0}{chapter}{#1}{#2}}
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\l@section} \marg{name} \marg{page}
%    \begin{macrocode}
\renewcommand{\l@section}[2]{\hypertoc{1}{section}{#1}{#2}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\l@subsection} \marg{name} \marg{page}
%    \begin{macrocode}
\renewcommand{\l@subsection}[2]{\hypertoc{2}{subsection}{#1}{#2}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\l@subsubsection} \marg{name} \marg{page}
%    \begin{macrocode}
\renewcommand{\l@subsubsection}[2]{\hypertoc{3}{subsubsection}{#1}{#2}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\l@paragraph} \marg{name} \marg{page}
%    \begin{macrocode}
\renewcommand{\l@paragraph}[2]{\hypertoc{4}{paragraph}{#1}{#2}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\l@subparagraph} \marg{name} \marg{page}
%    \begin{macrocode}
\renewcommand{\l@subparagraph}[2]{\hypertoc{5}{subparagraph}{#1}{#2}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\l@figure} \marg{name} \marg{page}
%    \begin{macrocode}
\renewcommand{\l@figure}[2]{\hypertocfloat{1}{figure}{lof}{#1}{#2}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\l@table} \marg{name} \marg{page}
%    \begin{macrocode}
\renewcommand{\l@table}[2]{\hypertocfloat{1}{table}{lot}{#1}{#2}}
%    \end{macrocode}
% \end{macro}

%    \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/\\
%		\fqquad\ 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{environment}{theindex}
%    \begin{macrocode}
\@ifundefined{chapter}
{\newcommand*{\LWR@indexsection}[1]{\section*{#1}}}
{\newcommand*{\LWR@indexsection}[1]{\chapter*{#1}}}

\AtBeginDocument{
\renewenvironment*{theindex}{%
    \LWR@indexsection{\indexname}%
    \let\item\LWR@indexitem%
    \let\subitem\LWR@indexsubitem%
    \let\subsubitem\LWR@indexsubsubitem%
}{}
}% AtBeginDocument
%    \end{macrocode}
% \end{environment}


% \begin{macro}{\LWR@indexitem} \oarg{index key} \qquad
% The optional argument is added to support \pkg{repeatindex}.
%
% \changes{v0.58}{2018/06/21}{Accepts optional arg for \pkg{repeatindex}.}
%    \begin{macrocode}
\newcommand{\LWR@indexitem}[1][\@empty]{

\InlineClass{indexitem}{}#1%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@indexsubitem}
%    \begin{macrocode}
\newcommand{\LWR@indexsubitem}{

\InlineClass{indexsubitem}{}
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@indexsubsubitem}
%    \begin{macrocode}
\newcommand{\LWR@indexsubsubitem}{

\InlineClass{indexsubsubitem}{}
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\@wrindex} \marg{term} \qquad
% Redefined to write the |LWR@autoindex| counter instead of |page|.
% \changes{v0.28}{2017/04/13}{Improved indexing.}
%    \begin{macrocode}
\def\LWR@wrindex#1{%
\addtocounter{LWR@autoindex}{1}%
\LWR@new@label{LWRindex-\arabic{LWR@autoindex}}%
\protected@write\@indexfile{}%
{\string\indexentry{#1}{\arabic{LWR@autoindex}}}%
\endgroup
\@esphack}

\AtBeginDocument{
\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@new@label{LWRglossary-\theLWR@autoglossary}%
\protected@write\@glossaryfile{}%
{\string\glossaryentry{#1}{\theLWR@autoglossary}}%
\endgroup
\@esphack}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@indexnameref} \marg{LWR@autoindex}
%
% Creates a hyperlink based on the given entry's autoindex.
%    \begin{macrocode}
\newcommand*{\LWR@indexnameref}[1]{\nameref{LWRindex-#1}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@doindexentry} \marg{LWR@autoindex, or macros.}
%
% Creates a hyperlink, or handles \cs{see}, \cs{textbf}, etc.
%
% \changes{v0.58}{2018/06/17}{Adds support for \cs{see}, \cs{seealso}, \cs{emph}, \cs{textbf}, etc.}
%    \begin{macrocode}
\newrobustcmd{\LWR@doindexentry}[1]{%
\IfInteger{#1}%
    {\LWR@indexnameref{#1}}%
    {#1}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@hyperindexrefnullified}
% Handles macros commonly seen inside an \cs{index} entry.
% Each macro is redefined to create and format a link to its entry.
%
% To handle additional macros:
% \trouble[index formatting]{index>formatting}
% \gindex{index>formatting}
% \begin{sourcedisplay}
% \cs{appto}\cs{LWR@hyperindexrefnullified}\{\dots\}
% \end{sourcedisplay}
%
% \changes{v0.58}{2018/06/17}{Adds support for \cs{see}, \cs{seealso}, \cs{emph}, \cs{textbf}, etc.}
% \changes{v0.61}{2018/09/27}{Made robust,}
% \changes{v0.65}{2018/12/09}{Added \cs{textsi}.}
%    \begin{macrocode}
\newcommand{\LWR@hyperindexrefnullified}{%
\renewrobustcmd{\emph}[1]{\LWR@HTML@emph{\LWR@doindexentry{##1}}}%
\renewrobustcmd{\textbf}[1]{\LWR@HTML@textbf{\LWR@doindexentry{##1}}}%
\renewrobustcmd{\textrm}[1]{\LWR@HTML@textrm{\LWR@doindexentry{##1}}}%
\renewrobustcmd{\textsf}[1]{\LWR@HTML@textsf{\LWR@doindexentry{##1}}}%
\renewrobustcmd{\texttt}[1]{\LWR@HTML@texttt{\LWR@doindexentry{##1}}}%
\renewrobustcmd{\textup}[1]{\LWR@HTML@textup{\LWR@doindexentry{##1}}}%
\renewrobustcmd{\textsc}[1]{\LWR@HTML@textsc{\LWR@doindexentry{##1}}}%
\renewrobustcmd{\textsi}[1]{\LWR@HTML@textsi{\LWR@doindexentry{##1}}}%
\renewrobustcmd{\textit}[1]{\LWR@HTML@textit{\LWR@doindexentry{##1}}}%
\renewrobustcmd{\textsl}[1]{\LWR@HTML@textsl{\LWR@doindexentry{##1}}}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\hyperindexref} \marg{LWR@autoindex}
%
% |\hyperindexref{LWR@autoindex}| is inserted into |*.ind| by
% the \pkg{makeindex} style file \filenm{lwarp.ist} or
% the \pkg{xindy} style file \filenm{lwarp.xdy}.
%
% \changes{v0.20}{2016/12/19}{Print mode provided in case \pkg{hyperref} not used.}
% \changes{v0.28}{2017/04/13}{Improved indexing.}
% \changes{v0.58}{2018/06/17}{Adds support for \cs{see}, \cs{seealso}, \cs{emph}, \cs{textbf}, etc.}
% \changes{v0.66}{2019/02/05}{Fix: Long index entries.}
%    \begin{macrocode}
\newcommand{\hyperindexref}[1]{%
%    \end{macrocode}
% In long index lines with numerous entries,
% \prog{makeindex} can insert a newline before the page number,
% resulting in an extra space before the first digit.
% If the first character is a space, remove it first.
% ^^A Or use the trimspaces package.
%    \begin{macrocode}
\def\LWR@tempone{#1}%
\IfBeginWith{\LWR@tempone}{ }{%
    \StrGobbleLeft{\LWR@tempone}{1}[\LWR@tempone]%
}{}%
%    \end{macrocode}
% If a numeric entry, create a link.
% If not numeric, such as \cs{see}, use the entry as-is.
% \cs{emph}, \cs{textit}, etc. have been redefined above to create and
% format the entry.
%    \begin{macrocode}
\IfInteger{\LWR@tempone}%
    {\LWR@indexnameref{\LWR@tempone}}%
    {%
        \begingroup%
        \LWR@hyperindexrefnullified
        #1%
        \endgroup%
    }%
}
%    \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{Bibliography presentation}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
% \begin{macro}{\bibliography} \marg{filenames}
%
% Modified to use the base jobname instead of the |_html| jobname.
% \changes{v0.48}{2018/02/04}{Fix: \cs{BaseJobname} for bibliography.}
%    \begin{macrocode}
\def\bibliography#1{%
    \if@filesw
    \immediate\write\@auxout{\string\bibdata{#1}}%
    \fi
%     \@input@{\jobname.bbl}% original
    \begingroup%
    \@input@{\BaseJobname.bbl}% lwarp
    \endgroup%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\@biblabel} \marg{text-refnumber}
%
% \changes{v0.48}{2018/02/04}{Improved bibliography label.}
%    \begin{macrocode}
\renewcommand{\@biblabel}[1]{[#1]\quad}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{environment}{thebibliography}
% To emphasize document titles in the bibliography,
% the following redefines \cs{em} inside \env{thebibliography}
% to gather everything until the next closing brace,
% then display these tokens with \cs{textit}.
%
% {
%   \footnotesize
%   \textit{Adapted from |embracedef.sty|, which is by \textup{\textsc{Takayuki YATO}}:} \\
%   \fqquad\url{https://gist.github.com/zr-tex8r/b72555e3e7ad2f0a37f1}
% }
%
% \changes{v0.45}{2018/01/13}{Patched to emphasize titles.}
%    \begin{macrocode}
\AtBeginDocument{
\AtBeginEnvironment{thebibliography}{
\providecommand*{\LWR@newem}[1]{\textit{#1}}

\renewrobustcmd{\em}{%
  \begingroup
    \gdef\LWR@em@after{\LWR@em@finish\LWR@newem}%
    \afterassignment\LWR@em@after
    \toks@\bgroup
}

\def\LWR@em@finish#1{%
    \xdef\LWR@em@after{\noexpand#1{\the\toks@}}%
  \endgroup
  \LWR@em@after\egroup
}
}% \AtBeginEnvironment{thebibliography}
}% \AtBeginDocument
%    \end{macrocode}
% \end{environment}

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



% \section{Restoring original formatting}
%
% \begin{macro}{\LWR@restoreorigformatting}
% Used to temporarily restore
% the print-mode meaning of a number of formatting, graphics, and symbols-related
% macros while generating \SVG\ math or a \env{lateximage}.
%
% Must be used inside a group.
%
% Sets \cs{LWR@formatting} to |print| until the end of the group.
%
% 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}.}

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

%    \begin{macrocode}
\newcommand*{\LWR@restoreorigformatting}{%
\LWR@traceinfo{LWR@restoreorigformatting}%
%    \end{macrocode}
% Numerous macros change their print/\HTML\ meaning depending on \cs{LWR@formatting}:
%    \begin{macrocode}
\renewcommand*{\LWR@formatting}{print}%
\linespread{1}%
%    \end{macrocode}
%
%    \begin{macrocode}
\let\par\LWR@origpar%
%    \end{macrocode}
%
%    \begin{macrocode}
\LWR@select@print@hspace%
%    \end{macrocode}
%
% \changes{v0.48}{2018/02/04}{Fix: Spacing in \SVG\ math, \env{lateximage}, \tikz.}
%    \begin{macrocode}
\LetLtxMacro\hfil\LWR@orighfil%
\let\hss\LWR@orighss%
\let\llap\LWR@origllap%
\let\rlap\LWR@origrlap%
\let\hfilneg\LWR@orighfilneg%
%    \end{macrocode}
%    \begin{macrocode}
\let\,\LWR@origcomma% disable HTML short unbreakable space
\let\thinspace\LWR@origthinspace% disable HTML short unbreakable space
\let\negthinspace\LWR@orignegthinspace% disable HTML negative short unbreakable space
\let\textellipsis\LWR@origtextellipsis%
\let\textless\LWR@origtextless%
\let\textgreater\LWR@origtextgreater%
\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%
%    \end{macrocode}
% \changes{v0.65}{2018/12/10}{Added \cs{sishape}.}
%    \begin{macrocode}
\LetLtxMacro\sishape\LWR@origsishape%
%    \end{macrocode}
%    \begin{macrocode}
\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%
%    \end{macrocode}
%
% \cs{endtabular} must be restored to its original,
% instead of relying on \pkg{lwarp}'s \cs{LWR@formatted} mechanism:
% \changes{v0.65}{2018/12/16}{Fix: \env{tabular*}.}
%    \begin{macrocode}
\LetLtxMacro\endtabular\LWR@origendtabular%
\csletcs{endtabular*}{LWR@origendtabular*}%
%    \end{macrocode}
%    \begin{macrocode}
\LetLtxMacro\noalign\LWR@orignoalign%
\LetLtxMacro\hline\LWR@orighline%
%    \end{macrocode}
%    \begin{macrocode}
\let\newline\LWR@orignewline%
\LetLtxMacro\includegraphics\LWR@origincludegraphics%
\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%
%
\LWR@restoreorigaccents%
\LWR@restoreoriglists%
%
\LWR@FBcancel%
}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
%
%
% \section{Math}
% \label{sec:math}
%
%
%
% \subsection{Limitations}
%
% \limitsmath
%
% \subsubsection{Catcode changes}
% \limitsmathcatcode
%
% \subsubsection{Complicated inline math objects}
% \limitsmathinline
%
% \subsubsection{Complicated display math objects}
%
% \limitsmathdisplay


% \subsection{\HTML\ \attribute{alt} tag names}
%
% Redefinable names for the \HTML\ \attribute{alt} tags,
% for translation according to the reader's native language.
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \begin{macro}{\mathimagename} The \HTML\ \attribute{alt} tag for
%   an \SVG\ math image. \\
% \DescribeDefault{``math image''}
% \changes{v0.57}{2018/05/22}{Added.}
%    \begin{macrocode}
\newcommand*{\mathimagename}{math image}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\packagediagramname} Appended to the \env{lateximage}
%       \HTML\ \attribute{alt} tag for the images generated by many packages.
% \DescribeDefault{``diagram''}
% \changes{v0.57}{2018/05/22}{Added.}
%    \begin{macrocode}
\newcommand*{\packagediagramname}{diagram}
%    \end{macrocode}
% \end{macro}

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


% \subsection{Inline and display math}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \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}


% \DescribeBoolean{LWR@indisplaymathimage}
% True if processing display math for \SVG\ output.
% Inside a \env{lateximage}, display math is only set to print-mode output
% if |LWR@indisplaymathimage| is false.
% Used to avoid nullifying display math before it has been completed.
%    \begin{macrocode}
\newbool{LWR@indisplaymathimage}
%    \end{macrocode}


% \DescribeBoolean{LWR@xfakebold}
% True if \pkg{xfakebold} \cs{setBold} is in use.
% \changes{v0.67}{2019/02/17}{\pkg{xfakebold}: Added support.}
%    \begin{macrocode}
\newbool{LWR@xfakebold}
\boolfalse{LWR@xfakebold}
%    \end{macrocode}

% \begin{macro}{\LWR@orig@setBold}
% Redefined by \pkg{lwarp-xfakebold}.
%    \begin{macrocode}
\newcommand*{\LWR@orig@setBold}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@orig@unsetBold}
% Redefined by \pkg{lwarp-xfakebold}.
%    \begin{macrocode}
\newcommand*{\LWR@orig@unsetBold}{}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@applyxfakebold}
% Redefined by \pkg{lwarp-xfakebold}.
%    \begin{macrocode}
\newcommand*{\LWR@applyxfakebold}{}
%    \end{macrocode}
% \end{macro}


% \DescribeMacro{\$}
%	Plain dollar signs appearing in the \HTML\ output may be interpreted
%	by \brand{MathJax} to be math shifts.
%	For a plain text dollar |\$|, use an \HTML\ entity to avoid
%	it being interpreted by \brand{MathJax}, unless are inside a lateximage,
%	in which case it will not be seen by \brand{MathJax}.
% \changes{v0.19}{2016/06/08}{Avoids \brand{MathJax}.}
% \changes{v0.26}{2017/03/30}{Dollar span avoided in a lateximage.}
% \changes{v0.51}{2018/03/23}{\HTML\ entity used for text dollar.}
%    \begin{macrocode}
\let\LWR@origtextdollar\$

\renewcommand*{\$}{%
\ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
{\LWR@origtextdollar}%
{\HTMLentity{dollar}}%
}
%    \end{macrocode}


% \DescribeFile{lwarp_baseline_marker.png}
% \DescribeFile{lwarp_baseline_marker.eps}
% A marker to be used to help \prog{pdfcrop} identify the inline math baseline
% and width.  If either \pkg{graphicx} or \pkg{graphics} is loaded, this marker is
% placed at the lower left and lower right corners of the inline math.
% \prog{pdfcrop} is then able to identify the width of the image, and also
% the height of an image such as a horizontal dash which does not
% otherwise touch the baseline.
%
% A marker with alpha or opacity of 0\% is not registered by \prog{pdfcrop}, so
% the marker is a small square block of 1\% alpha, which seems to work while still being
% effectively invisible in the final SVG image.
%
% If \pkg{graphicx} is loaded, this marker is sized as a tiny 1\,sp square.
% If \pkg{graphics} is loaded, this marker is used at its default size of around
% .25\,pt.
% If neither graphics package is loaded, the marker is replaced by a 10\,sp horizontal
% space, and there is no assistance for determining baseline or width of the inline
% math image.
% The best results are obtained when using \pkg{graphicx}.
%
% \begin{macro}{\LWR@addbaselinemarker} Places a small marker in an \SVG\ inline image.
% If \pkg{graphics} or \pkg{graphicx} are loaded, the marker is a mostly transparent
% image.
% If neither is loaded, no marker is used.
% \changes{v0.51}{2018/03/16}{Improved \SVG\ math baseline.}
% \changes{v0.52}{2018/03/24}{Warnings if \filenm{lwarp_baseline_marker.png} is not present
%               or if graphicx/s not loaded.}
% \changes{v0.59}{2018/09/02}{Uses \filenm{.eps} if \DVI\ \prog{latex}.}
%    \begin{macrocode}
\AtBeginDocument{

\ifpdf
    \newcommand*{\LWR@baselinename}{lwarp_baseline_marker.png}
\else
    \ifXeTeX
        \newcommand*{\LWR@baselinename}{lwarp_baseline_marker.png}
    \else
        \newcommand*{\LWR@baselinename}{lwarp_baseline_marker.eps}
    \fi
\fi

\IfFileExists{\LWR@baselinename}%
{
    \@ifpackageloaded{graphicx}{
        \newcommand*{\LWR@addbaselinemarker}{%
            \LWR@origincludegraphics{\LWR@baselinename}%
        }
    }{
        \@ifpackageloaded{graphics}{
            \newcommand*{\LWR@addbaselinemarker}{%
                \LWR@origincludegraphics{\LWR@baselinename}%
            }
        }{
            \PackageWarning{lwarp}{Load graphicx or graphics
                for improved SVG math baselines,}
            \newcommand*{\LWR@addbaselinemarker}{}
        }
    }
}{% lwarp_baseline_marker.png or .eps is not present
    \PackageWarning{lwarp}{File \LWR@baselinename\space is not installed alongside
        the lwarp-*.sty files, so SVG math baselines may not be accurate,}
    \newcommand*{\LWR@addbaselinemarker}{}
}

}% AtBeginDocument
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@subsingledollar} * \marg{2: alt text} \marg{3: add'l hashing}
%                                               \marg{4: math expression}
%
% For inline math.
% Uses MathJax, or for \SVG\ math the image is measured and ajusted to the baseline
% of the \HTML\ output, and placed inside a \env{lateximage}.
%
% \describehashing
%
% \changes{v0.19}{2016/05/25}{\brand{MathJax} support.}
% \changes{v0.42}{2017/10/26}{If \progcode{FormatWP} print LaTeX expression.}
% \changes{v0.47}{2018/01/24}{Added \SVG\ math image baseline adjust and em sizing.}
% \changes{v0.50}{2018/02/23}{Fix: Use \env{lateximage} even if MathJax.}
% \changes{v0.50}{2018/02/24}{Improved \SVG\ math \attribute{alt} tags.}
%    \begin{macrocode}
\newlength{\LWR@singledollarwidth}
\newlength{\LWR@singledollarheight}
\newlength{\LWR@singledollardepth}

\newsavebox{\LWR@singledollarbox}

\NewDocumentCommand{\LWR@subsingledollar}{s m m m}{%
\LWR@traceinfo{LWR@subsingledollar}%
%    \end{macrocode}
%    \begin{macrocode}
\ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
{%
\LWR@traceinfo{LWR@subsingledollar: already in a lateximage}%
    #4% contents
}%
{% not in a lateximage
\begingroup%
%    \end{macrocode}
% Support for \pkg{xfakebold}:
% \changes{v0.67}{2019/02/17}{\pkg{xfakebold}: Added support.}
%    \begin{macrocode}
\LWR@applyxfakebold%
%    \end{macrocode}
% MathJax cannot parse the often complicated \TeX\ expressions which
% appear in the various uses of \cs{ensuredmath}.
% \cs{ensuremath} forces the \attribute{alt} tag to ``|(math image)|'', as
% translated according to \cs{mathimagename}.
% If this is the case, force the use of a \env{lateximage} even if MathJax.
% Likewise for \pkg{siunitx} if |parse-numbers=false|.
%
% If MathJax, or if formatting math for a word processor, and not \cs{ensuredmath},
% and not a dynamic math expression, print the math expression:
% \changes{v0.51}{2018/03/11}{Fix: \cs{ensuredmath} inside \SVG\ image.}
% \changes{v0.57}{2018/05/23}{Fix: Dynamic inline math expressions.}
%    \begin{macrocode}
\ifboolexpr{%
    (
        bool{mathjax} or
        ( bool{FormatWP} and bool{WPMarkMath} )
    ) and
    ( not test { \ifstrequal {#2} {(\mathimagename)} } ) and % from \ensuredmath
    ( not bool{LWR@dynamicmath} )
}%
%    \end{macrocode}
% For \brand{MathJax}, print the math between |\(| and |\)|:
%    \begin{macrocode}
{%
    \LWR@traceinfo{LWR@subsingledollar: Mathjax}%
    {\textbackslash(\LWR@HTMLsanitize{#4}\textbackslash)}%
}% mathjax
%    \end{macrocode}
% For SVG, print the math inside a \env{lateximage},
% with an \element{alt} tag of the \LaTeX\ code,
% and a \CSS\ style to control the baseline adjustment.
%    \begin{macrocode}
{% not mathjax
\LWR@traceinfo{LWR@subsingledollar: NOT mathjax, or is ensuremath, or is dynamic}%
%    \end{macrocode}
% Measure the depth, width, and height of the math image:
% \changes{v0.51}{2018/03/04}{Fix: SVG math with enclosed \env{lateximage}.}
%    \begin{macrocode}
    \begingroup%
%    \end{macrocode}
% Temporarily disable formatting while measuring the image parameters:
%    \begin{macrocode}
    \LWR@restoreorigformatting%
    \RenewDocumentEnvironment{lateximage}{s o o o}{}{}% inside group
    \LWR@print@normalsize%
%    \end{macrocode}
% Temporarily set font for the \HTML\ \PDF\ output:
% \changes{v0.51}{2018/03/14}{Fix: Honors text font around \SVG\ math.}
%    \begin{macrocode}
    \LWR@traceinfo{Using font family \LWR@f@family}%
    \@nameuse{LWR@orig\LWR@f@family family}%
    \LWR@traceinfo{Using font series \LWR@f@series}%
    \@nameuse{LWR@orig\LWR@f@series series}%
    \LWR@traceinfo{Using font shape \LWR@f@shape}%
    \@nameuse{LWR@orig\LWR@f@shape shape}%
%    \end{macrocode}
% |lateximagedepth| must be nested to avoid generating paragraph tags.
% \AmS\ math modifies the \cs{text} macro such that \cs{addtocounter} does not
% always occur as expected.  Lower-level code is used instead.
%    \begin{macrocode}
    \global\advance\c@LWR@lateximagedepth 1\relax%
%    \end{macrocode}
% Typeset and save the contents, depending on how they were generated:
% \begin{description}
% \item [SVG math:] \cs{LWR@origensuredmath} is part of argument \#4.
% \item [SVG math \cs{ensuremath}:] \cs{LWR@origensuredmath} is part of argument \#4.
% \item [SVG dynamic math:] \cs{LWR@origensuredmath} is part of argument \#4.
% \item [Mathjax:] Argument \#4 is the contents of the math expression
%   without \cs{LWR@origensuredmath}.  This case is handled above.
% \item [Mathjax \cs{ensuremath}:] \cs{LWR@origensuredmath} is part of argument \#4.
% \item [Mathjax dynamic math:]  Argument \#4 is the contents of the math expression
%   without \cs{LWR@origensuredmath}, so \cs{LWR@origensuredmath} is added below.\
% \item [\cs{ifmmode}:] Included ``just in case''.
% \end{description}
%
% \changes{v0.51}{2018/03/07}{Fix: \env{lateximage} inside \AmS\ \cs{text}.}
% \changes{v0.51}{2018/03/12}{Typeset \SVG\ math only once during measurement.}
% \changes{v0.57}{2018/05/23}{Fix: Dynamic inline math expressions.}
%    \begin{macrocode}
    \ifmmode%
        \global\sbox{\LWR@singledollarbox}{#4}%
    \else%
        \ifbool{LWR@dynamicmath}{%
            \ifbool{mathjax}{%
                \global\sbox{\LWR@singledollarbox}{\LWR@origensuredmath{#4}}%
            }{%
                \global\sbox{\LWR@singledollarbox}{#4}%
            }%
        }{%
            \global\sbox{\LWR@singledollarbox}{#4}%
        }%
    \fi%
%    \end{macrocode}
% Add a small and almost transparent marker at the depth of the image.
%
% A math minus sign has the same depth as a plus, even though it does not draw
% anything below the baseline.  This means that \prog{pdfcrop} would crop the image
% without depth.  The marker below the baseline is seen by \prog{pdfcrop}
% and preserves the depth.
% \changes{v0.51}{2018/03/16}{Improved \SVG\ math baseline.}
%    \begin{macrocode}
    \global\sbox{\LWR@singledollarbox}{%
        \usebox{\LWR@singledollarbox}%
        \raisebox{-\dp\LWR@singledollarbox}{%
            \LWR@addbaselinemarker%
        }%
    }%
%    \end{macrocode}
% More low-level code to undo the counter change.
%    \begin{macrocode}
    \global\advance\c@LWR@lateximagedepth -1\relax% Due to AmS \text macro.
%    \end{macrocode}
% Measure the depth:
% \changes{v0.52}{2018/03/24}{Added user-adjustable \SVG\ math font scaling.}
%    \begin{macrocode}
    \setlength{\LWR@singledollardepth}{%
        \LateximageFontScale\dp\LWR@singledollarbox%
    }%
%    \end{macrocode}
% Make the length a global change:
%    \begin{macrocode}
    \global\LWR@singledollardepth=\LWR@singledollardepth%
%    \end{macrocode}
% Likewise for width:
%    \begin{macrocode}
    \setlength{\LWR@singledollarwidth}{%
        \LateximageFontScale\wd\LWR@singledollarbox%
    }%
    \global\LWR@singledollarwidth=\LWR@singledollarwidth%
%    \end{macrocode}
% Likewise for total height:
%    \begin{macrocode}
    \setlength{\LWR@singledollarheight}{%
        \LateximageFontScale\ht\LWR@singledollarbox%
    }%
    \addtolength{\LWR@singledollarheight}{%
        \LateximageFontScale\dp\LWR@singledollarbox%
    }%
    \global\LWR@singledollarheight=\LWR@singledollarheight%
%    \end{macrocode}
%    \begin{macrocode}
    \endgroup%
%    \end{macrocode}
%
% Set a style for the the height or width.
% The |em| unit is used so that the math scales according to the
% user's selected font size.
%
% Start with the greater of the width or the height, biased towards the width:
%    \begin{macrocode}
    \ifdimgreater{\LWR@singledollarwidth}{.7\LWR@singledollarheight}{%
        \def\LWR@singledollarstyle{%
            width:\LWR@convertto{em}{\the\LWR@singledollarwidth} em%
        }%
    }{%
        \def\LWR@singledollarstyle{%
            height:\LWR@convertto{em}{\the\LWR@singledollarheight} em%
        }%
    }%
%    \end{macrocode}
% If a very narrow width, use the height.
%    \begin{macrocode}
    \ifdimless{\LWR@singledollarwidth}{.2em}%
    {%
        \def\LWR@singledollarstyle{%
            height:\LWR@convertto{em}{\the\LWR@singledollarheight} em%
        }%
    }%
    {}%
%    \end{macrocode}
% If very wide and short, use the width:
%    \begin{macrocode}
    \ifdimless{\LWR@singledollarheight}{.2em}%
    {%
        \def\LWR@singledollarstyle{%
            width:\LWR@convertto{em}{\the\LWR@singledollarwidth} em%
        }%
    }%
    {}%
%    \end{macrocode}
% If there is significant text depth, add the depth to the style.
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
    \ifdimgreater{\LWR@singledollardepth}{0.05ex}{%
        \def\LWR@singledollardepthstyle{%
            \ ; % extra space
            \LWR@print@mbox{%
                vertical-align:-\LWR@convertto{em}{\the\LWR@singledollardepth} em%
            } % extra space
        }%
    }{%
        \def\LWR@singledollardepthstyle{}%
    }%
%    \end{macrocode}
% Create the \env{lateximage} using the alternate tag and the computed
% size and depth.
% The star causes \env{lateximage} to use an MD5 hash as the filename.
% When hashing, also include the current font and color in the hash.
% \changes{v0.50}{2018/02/22}{MD5 hash avoids duplicate \SVG\ math.}
% \changes{v0.57}{2018/05/23}{Fix: Dynamic inline math expressions.}
%    \begin{macrocode}
    \ifbool{LWR@dynamicmath}{%
        \LWR@traceinfo{subsingledollar: dynamic}%
        \begin{lateximage}% no hashing
            [(\mathimagename)]% alt tag
            []% no add'l hashing
            [\LWR@singledollarstyle \LWR@singledollardepthstyle]% CSS
    }{%
        \LWR@traceinfo{subsingledollar: static}%
        \IfValueTF{#1}{%
            \LWR@findcurrenttextcolor% sets \LWR@tempcolor
%    \end{macrocode}
% Support for \pkg{xfakebold}:
% \changes{v0.67}{2019/02/17}{\pkg{xfakebold}: Added support.}
%    \begin{macrocode}
            \ifbool{LWR@xfakebold}%
                {\def\LWR@tempone{Y}}%
                {\def\LWR@tempone{N}}%
%    \end{macrocode}
%    \begin{macrocode}
            \begin{lateximage}*% use hashing
                [#2]% alt
                [% addl' hashing
                    #3%
                    FM\LWR@f@family%
                    SR\LWR@f@series%
                    SH\LWR@f@shape%
                    CL\LWR@tempcolor%
                    FB\LWR@tempone% xfakebold
                ]%
                [\LWR@singledollarstyle \LWR@singledollardepthstyle]% CSS
        }{%
            \begin{lateximage}% no hashing
                [#2]% alt
                []% no add'l hashing
                [\LWR@singledollarstyle \LWR@singledollardepthstyle]% CSS
        }%
    }%
%    \end{macrocode}
% Place small and almost transparent markers on the baseline
% at the left and right edges of the image.
% These markers are seen by \prog{pdfcrop},
% and force vertically-centered objects such as a dash
% to be raised off the baseline in the cropped image,
% and also force the total width and left \Slash right margins to be correct.
% (Except that in some fonts a character may exceed the bounding box, and thus
% may appear wider than expected when converted to an image.)
% \changes{v0.51}{2018/03/10}{SVG math baseline improved with invisible rule at corner.}
%    \begin{macrocode}
    \LWR@addbaselinemarker%
%    \end{macrocode}
% Support for \pkg{xfakebold}:
% \changes{v0.67}{2019/02/17}{\pkg{xfakebold}: Added support.}
%    \begin{macrocode}
    \LWR@applyxfakebold%
%    \end{macrocode}
% Typeset the contents:
%    \begin{macrocode}
    \usebox{\LWR@singledollarbox}%
%    \end{macrocode}
% The closing baseline marker:
%    \begin{macrocode}
    \LWR@addbaselinemarker%
%    \end{macrocode}
%    \begin{macrocode}
    \end{lateximage}%
%
}% not mathjax
\endgroup%
}% not in a lateximage
\LWR@traceinfo{LWR@subsingledollar: done}%
}
%    \end{macrocode}
% \end{macro}


%    \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 \brand{MathJax}:
%    \begin{macrocode}
\begingroup
\catcode`\$=\active%
\protected\gdef${\@ifnextchar$\LWR@doubledollar\LWR@singledollar}%
%    \end{macrocode}

% Used by \pkg{chemformula} to escape single-dollar math:
%    \begin{macrocode}
\protected\gdef\LWR@newsingledollar{\@ifnextchar$\LWR@doubledollar\LWR@singledollar}%
%    \end{macrocode}


% \begin{macro}{\LWR@doubledollar}
%
% \changes{v0.42}{2017/10/16}{Improved \cs{ensuremath}.}
%
% Redefine the double dollar sign to place math inside a \env{lateximage}, or use \brand{MathJax}:
%    \begin{macrocode}
\protected\gdef\LWR@doubledollar$#1$${%
%    \end{macrocode}
% If \brand{MathJax} or formatting for a word processor, print the \LaTeX\ expression:
% \changes{v0.19}{2016/05/25}{\brand{MathJax} support.}
% \changes{v0.42}{2017/10/26}{If \progcode{FormatWP} print LaTeX expression.}
%    \begin{macrocode}
\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
%    \end{macrocode}
% For \brand{MathJax}, print the math between |\[| and |\]|:
% \changes{v0.42}{2017/10/16}{Improved line spacing with mathjax.}
%    \begin{macrocode}
{

    \textbackslash[%
    \LWR@HTMLsanitize{#1}%
    \textbackslash]

}% mathjax
%    \end{macrocode}
% For SVG, print the math inside a \env{lateximage},
%   with an \element{alt} tag of the \LaTeX\ code:
% \changes{v0.50}{2018/02/24}{Improved \SVG\ math \attribute{alt} tags.}
% \changes{v0.50}{2018/03/02}{Improved \SVG\ math display.}
% \changes{v0.51}{2018/03/11}{Fix: \cs{addcontentsline} inside \SVG\ math.  Provides an autoid anchor.}
%    \begin{macrocode}
{% not mathjax
    \begin{BlockClass}{displaymath}%
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}%
    [%
        \textbackslash{[} % extra space
        \LWR@HTMLsanitize{#1} % extra space
        \textbackslash{]}%
    ]%
%    \end{macrocode}
% Support for \pkg{xfakebold}:
% \changes{v0.67}{2019/02/17}{\pkg{xfakebold}: Added support.}
%    \begin{macrocode}
    \LWR@applyxfakebold%
%    \end{macrocode}
%    \begin{macrocode}
    \LWR@origdollar\LWR@origdollar#1\LWR@origdollar\LWR@origdollar%
    \end{lateximage}%
    \end{BlockClass}%
}% not mathjax
}%
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\LWR@singledollar} \marg{alt text} \marg{math expression}
%    \begin{macrocode}
\protected\gdef\LWR@singledollar#1${%
\ifbool{mathjax}{%
    \LWR@subsingledollar*%
    {% alt tag
        \textbackslash( %
        \LWR@HTMLsanitize{#1} % extra space
        \textbackslash)%
    }%
    {singledollar}% add'l hashing
    {#1}% contents
}{% not mathjax
    \LWR@subsingledollar*%
    {% alt tag
        \textbackslash( %
        \LWR@HTMLsanitize{#1} % extra space
        \textbackslash)%
    }%
    {singledollar}% add'l hashing
    {\LWR@origensuredmath{#1}}% contents
}% not mathjax
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\(}
% \begin{macro}{\[}
% Redefine to the above dollar macros.
%    \begin{macrocode}
\AtBeginDocument{
\protected\gdef\(#1\){$#1$}
\protected\gdef\[#1\]{$$#1$$}
}

\endgroup
%    \end{macrocode}
% \changes{v0.59}{2018/08/23}{Fix with \cs{displaymathnormal}.}
%    \begin{macrocode}
\AtBeginDocument{
\LetLtxMacro\LWR@openbracketnormal\[
\LetLtxMacro\LWR@closebracketnormal\]
}
%    \end{macrocode}
% \end{macro}
% \end{macro}


% \begin{macro}{\@ensuredmath} \marg{expression}
%
% If MathJax, a \env{lateximage} is used, since \cs{ensuremath} is
% often used for complex \TeX\ expressions which MathJax may not render.
% If \SVG\ math, a hashed file is used with a simple \attribute{alt} tag, but
% additional hashing provided by the contents.
%
% \changes{v0.51}{2018/02/24}{Hashes \cs{ensuremath}.}
% \changes{v0.42}{2017/10/16}{Improved \cs{ensuremath}.}
% \changes{v0.50}{2018/02/23}{Fix: Use \env{lateximage} even if MathJax.}
% \changes{v0.50}{2018/02/24}{Improved \SVG\ math \attribute{alt} tags.}
% \changes{v0.52}{2018/03/25}{Improved hashing expansion.}
%    \begin{macrocode}
\LetLtxMacro\LWR@origensuredmath\@ensuredmath

\renewcommand{\@ensuredmath}[1]{%
\ifbool{mathjax}{%
    \LWR@subsingledollar*{(\mathimagename)}{%
           \protect\LWR@HTMLsanitize{\detokenize\expandafter{#1}}%
    }{\relax%
        \LWR@origensuredmath{#1}%
    }%
}{% SVG math
%    \end{macrocode}
% If already inside a \env{lateximage} in math mode, continue as-is.
%    \begin{macrocode}
\ifmmode%
    \LWR@origensuredmath{#1}%
\else%
%    \end{macrocode}
% Create an inline math \env{lateximage} with a simple \attribute{alt} tag
% and additional hashing according to the contents.
%    \begin{macrocode}
    \ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
    {\LWR@origensuredmath{#1}}%
    {%
        \LWR@subsingledollar*{(\mathimagename)}{%
           \protect\LWR@HTMLsanitize{\detokenize\expandafter{#1}}%
        }{%
            \LWR@origensuredmath{#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}{LWR@displaymathnormal}
% Set math mode then typeset the body of what was between the begin/end.
% See the \pkg{environ} package for \cs{BODY}.
%    \begin{macrocode}
\NewEnviron{LWR@displaymathnormal}{\expandafter\[\BODY\]\@ignoretrue}
%    \end{macrocode}
% \end{environment}


% Set the default displaymath to the normal version:
%    \begin{macrocode}
\LetLtxMacro\[\LWR@openbracketnormal%
\LetLtxMacro\]\LWR@closebracketnormal%
\LetLtxMacro\displaymath\LWR@displaymathnormal%
\LetLtxMacro\enddisplaymath\endLWR@displaymathnormal%
%    \end{macrocode}
%
%
% \begin{environment}{LWR@displaymathother}
% A version of \env{displaymath} which can handle complicated objects,
% but does not supply \brand{MathJax} or \HTML\ \attribute{alt} tags.
% \changes{v0.51}{2018/03/21}{Processing for complicated display math.}
%    \begin{macrocode}
\newenvironment{LWR@displaymathother}
{%
    \begin{BlockClass}{displaymath}%
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}%
    [(display math)]%
    \LWR@origdollar\LWR@origdollar%
}
{%
    \LWR@origdollar\LWR@origdollar%
    \end{lateximage}%
    \end{BlockClass}%
}
%    \end{macrocode}
% \end{environment}
%
%
% \begin{environment}{LWR@equationother}
% A version of \env{displaymath} which can handle complicated objects,
% but does not supply \brand{MathJax} or \HTML\ \attribute{alt} tags.
% \changes{v0.51}{2018/03/21}{Processing for complicated display math.}
%    \begin{macrocode}
\newenvironment{LWR@equationother}
{%
    \begin{BlockClass}{displaymathnumbered}%
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}%
    [(display math)]%
    \LWR@origequation%
}
{%
    \LWR@origendequation%
    \end{lateximage}%
    \end{BlockClass}%
}
%    \end{macrocode}
% \end{environment}


% \subsection{\brand{MathJax} support}
% \changes{v0.19}{2016/05/25}{\brand{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 \brand{MathJax} equation format
% and number for the following equations.
%
% These \brand{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}
% \brand{MathJax} doesn't allow setting the equation number to 1:
%    \begin{macrocode}
\ifthenelse{\cnttest{\value{equation}}>0}
{
%    \end{macrocode}
% Tell \brand{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 \brand{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
\@nameuse{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}
\@nameuse{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 \brand{MathJax} instance.
% The contents are printed to \HTML\ output, not interpreted by \LaTeX.
%    \begin{macrocode}
\NewDocumentCommand{\LWR@addmathjax}{m +m}{%
%    \end{macrocode}
% Enclose the \brand{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 \brand{MathJax} environment:
%    \begin{macrocode}
\textbackslash{}end\{#1\}
\LWR@orignewline
}
%    \end{macrocode}
% \end{macro}


% \subsection{Equation environment}
%
% Remember existing \env{equation} environment:
%    \begin{macrocode}
\AtBeginDocument{
\let\LWR@origequation\equation
\let\LWR@origendequation\endequation
\csletcs{LWR@origequation*}{equation*}
\csletcs{LWR@origendequation*}{endequation*}
}
%    \end{macrocode}
%
%
% \begin{macro}{\LWR@doequation} \marg{env contents} \marg{env name}
%
% \changes{v0.19}{2016/05/25}{\brand{MathJax} support.}
% \changes{v0.52}{2018/03/28}{Fix: \env{equation*} with \env{split}.}
%
% 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 \brand{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 \brand{MathJax} script.
%    \begin{macrocode}
\newcommand*{\LWR@doequation}[2]{%

%    \end{macrocode}
% If |mathjax| or |FormatWP|, print the \LaTeX\ expression:
% \changes{v0.42}{2017/10/26}{If \progcode{FormatWP} print LaTeX expression.}
%    \begin{macrocode}
\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
%    \end{macrocode}
% \brand{MathJax} output:
%    \begin{macrocode}
{
%    \end{macrocode}
% Print commands to syncronize \brand{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{#2}{#1}
}
%    \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:
% \changes{v0.50}{2018/03/02}{Improved \SVG\ math display.}
% \changes{v0.51}{2018/03/11}{Fix: \cs{addcontentsline} inside \SVG\ math.  Provides an autoid anchor.}
% \changes{v0.52}{2018/03/31}{Fix: \env{equation*} now based on \env{equation} instead of \env{displaymath}.}
%    \begin{macrocode}
    \ifstrequal{#2}{equation*}{%
        \begin{BlockClass}{displaymath}%
    }{%
        \begin{BlockClass}{displaymathnumbered}%
    }%
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[%
        \ifstrequal{#2}{equation*}{%
            \ifdefequal{\LWR@equationtag}{\theequation}{%
%                                   no tag was given
            }{%
                (\LWR@equationtag) % tag was given
            }%
        }{%
            (\LWR@equationtag) % automatic numbering
        }%
        \textbackslash{begin\{#2\}} % extra space
        \LWR@HTMLsanitizeexpand{\detokenize\expandafter{#1}} % extra space
        \textbackslash{end\{#2\}}%
    ]% alt tag
%    \end{macrocode}
% Support for \pkg{xfakebold}:
% \changes{v0.67}{2019/02/17}{\pkg{xfakebold}: Added support.}
%    \begin{macrocode}
    \LWR@applyxfakebold%
%    \end{macrocode}
% Create the actual \LaTeX-formatted equation inside
% the |lateximage| using the contents of the environment.
%    \begin{macrocode}
    \@nameuse{LWR@orig#2}%
    #1% contents collected by \collect@body
    \@nameuse{LWR@origend#2}%
    \end{lateximage}%
    \end{BlockClass}%
}% not mathjax
}
%    \end{macrocode}
%
%
% After the environment, if \brand{MathJax}, print the math to the \HTML\ output
% for \brand{MathJax} processing:
%    \begin{macrocode}
\newcommand*{\LWR@doendequation}[1]{%
    \ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
    {%
        \LWR@addmathjax{#1}{\BODY}%
    }{}%

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


% Remove existing \env{equation} environment:
%    \begin{macrocode}
\AtBeginDocument{
\let\equation\relax
\let\endequation\relax
\csletcs{equation*}{relax}
\csletcs{endequation*}{relax}
}
%    \end{macrocode}


% \begin{environment}{equation}
% 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}.
%    \begin{macrocode}
\AtBeginDocument{
\NewEnviron{equation}%
{\LWR@doequation{\BODY}{equation}}%
[\LWR@doendequation{equation}]

\LetLtxMacro\LWR@equationnormal\equation
\LetLtxMacro\endLWR@equationnormal\endequation
}
%    \end{macrocode}
% \end{environment}


% \begin{environment}{equation*}
%    \begin{macrocode}
\AtBeginDocument{
\NewEnviron{equation*}%
{\LWR@doequation{\BODY}{equation*}}%
[\LWR@doendequation{equation*}]

\csletcs{LWR@equationnormalstar}{equation*}
\csletcs{LWR@endequationnormalstar}{endequation*}
}
%    \end{macrocode}
% \end{environment}


% Remember the ``less'' version of \env{equation}, which uses \brand{MathJax}
% and \attribute{alt} tags, but does not support complicated contents such as
% some \tikz\ expressions.
%    \begin{macrocode}
\AtBeginDocument{
\LetLtxMacro\LWR@equationless\equation
\LetLtxMacro\endLWR@equationless\endequation
\csletcs{LWR@equationlessstar}{equation*}
\csletcs{LWR@endequationlessstar}{endequation*}
}
%    \end{macrocode}


% \subsection{\cs{displaymathnormal} and \cs{displaymathother}}
%
% \limitsmathdisplay
%
% \begin{macro}{\displaymathnormal} Use when display math environments have simple
% math which is to sent to \brand{MathJax} or included in \HTML\ \attribute{alt} tags.
% \margintag{simple math objects}
% \changes{v0.51}{2018/03/21}{Processing for complicated display math.}
%    \begin{macrocode}
\newcommand*{\displaymathnormal}{%
\ifbool{LWR@origmathjax}{\booltrue{mathjax}}{\boolfalse{mathjax}}%
\LetLtxMacro\[\LWR@openbracketnormal%
\LetLtxMacro\]\LWR@closebracketnormal%
\LetLtxMacro\displaymath\LWR@displaymathnormal%
\LetLtxMacro\enddisplaymath\endLWR@displaymathnormal%
\LetLtxMacro\equation\LWR@equationnormal%
\LetLtxMacro\endequation\endLWR@equationnormal%
\csletcs{equation*}{LWR@equationnormalstar}%
\csletcs{endequation*}{LWR@endequationnormalstar}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\displaymathother} Use when display math environments have complicated
% objects which will not work with MathJax or should not be
% included in \HTML\ \attribute{alt} tags. \margintag{complicated math objects}
% Complicated contents are more likely to compile correctly.
% \changes{v0.51}{2018/03/21}{Processing for complicated display math.}
%    \begin{macrocode}
\newcommand*{\displaymathother}{%
\boolfalse{mathjax}%
\LetLtxMacro\displaymath\LWR@displaymathother%
\LetLtxMacro\enddisplaymath\endLWR@displaymathother%
\LetLtxMacro\[\LWR@displaymathother%
\LetLtxMacro\]\endLWR@displaymathother%
\LetLtxMacro\equation\LWR@equationother%
\LetLtxMacro\endequation\endLWR@equationother%
\csletcs{equation*}{displaymath}%
\csletcs{endequation*}{enddisplaymath}%
}
%    \end{macrocode}
% \end{macro}

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


% \codeprint
%    \begin{macrocode}
\begin{warpprint}
%    \end{macrocode}

% Print-mode versions:
%    \begin{macrocode}
\newcommand*{\displaymathnormal}{}
\newcommand*{\displaymathother}{}
%    \end{macrocode}

%    \begin{macrocode}
\end{warpprint}
%    \end{macrocode}


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


% \subsection{AMS Math environments}
% \changes{v0.19}{2016/05/25}{\brand{MathJax} support added.}
%
% \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}
% \gindex{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@htmlmathlabelb #1}%
%    \end{macrocode}
% If |mathjax| or |FormatWP|, print the \LaTeX\ expression:
% \changes{v0.42}{2017/10/26}{If \progcode{FormatWP} print LaTeX expression.}
%    \begin{macrocode}
\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{%
%    \end{macrocode}
% 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}{\brand{MathJax} support added.}
% \changes{v0.33}{2017/06/20}{Fix: Incorrectly-inline math environments.}
% \changes{v0.34}{2017/07/29}{Fix: Added the \env{eqnarray} environments.}
%
% The \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 \brand{MathJax}: Each environment is syched with \LaTeX's equation numbers,
% typeset with \LaTeX\ inside an \HTML\ comment, then
% printed to \HTML\ output for \brand{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 \progcode{FormatWP} print LaTeX expression.}
%    \begin{macrocode}
\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{%
%    \end{macrocode}
%
% If \brand{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 \brand{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 \brand{MathJax} to interpret:
%    \begin{macrocode}
        \LWR@addmathjax{eqnarray}{\BODY}
    }%
    {% not LWR@numbereqnarray
%    \end{macrocode}
%
% If not numbering equations, just create the contents for \brand{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.}
% \changes{v0.50}{2018/03/02}{Improved \SVG\ math display.}
% \changes{v0.51}{2018/03/11}{Fix: \cs{addcontentsline} inside \SVG\ math.  Provides an autoid anchor.}
%    \begin{macrocode}
        \begin{BlockClass}{displaymathnumbered}%
        \LWR@newautoidanchor%
        \booltrue{LWR@indisplaymathimage}%
        \begin{lateximage}[(\LWR@startingequationtag--\LWR@equationtag)
            \LWR@addmathjax{eqnarray}{\BODY}]
%    \end{macrocode}
% Support for \pkg{xfakebold}:
% \changes{v0.67}{2019/02/17}{\pkg{xfakebold}: Added support.}
%    \begin{macrocode}
        \LWR@applyxfakebold%
%    \end{macrocode}
% Create the image contents using an actual \env{eqnarray}:
%    \begin{macrocode}
        \LWR@origeqnarray
        \BODY
        \LWR@origendeqnarray
        \end{lateximage}
        \end{BlockClass}
    }%
    {% not LWR@numbereqnarray
%    \end{macrocode}
% If not numbered, do the same, but an extra \cs{nonumber} seems to be required:
% \changes{v0.50}{2018/03/02}{Improved \SVG\ math display.}
% \changes{v0.51}{2018/03/11}{Fix: \cs{addcontentsline} inside \SVG\ math.  Provides an autoid anchor.}
%    \begin{macrocode}
        \begin{BlockClass}{displaymath}
        \LWR@newautoidanchor%
        \booltrue{LWR@indisplaymathimage}%
        \begin{lateximage}[\LWR@addmathjax{eqnarray*}{\BODY}]
%    \end{macrocode}
% Support for \pkg{xfakebold}:
% \changes{v0.67}{2019/02/17}{\pkg{xfakebold}: Added support.}
%    \begin{macrocode}
        \LWR@applyxfakebold%
%    \end{macrocode}
%    \begin{macrocode}
        \LWR@origeqnarray
        \BODY
        \nonumber
        \LWR@origendeqnarray
        \end{lateximage}
        \end{BlockClass}
    }% 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}
%
%
%    \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 \prog{lwarpmk} to extract the \env{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 \prog{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.
%
% The \HTML\ \attribute{alt} tag is set to the \LaTeX\ source for \SVG\ math,
% \margintag{\HTML\ \attribute{alt} tag}
% some chemistry expressions, and perhaps some other expressions which make sense
% for text copy/paste.  In some other cases, the \attribute{alt} tag is set
% according to the package name.
%
% \describemathimagename
%
% \describepackagediagramname
%
% \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 \cs{lateximage} inside of \cs{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 |<project>-images.txt|.
%    \begin{macrocode}
\newcounter{LWR@LIpage}
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% \subsection{Font size}
% \label{sec:mathfontscale}
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \begin{macro}{\LateximageFontSizeName}
% Declares how large to write text in \cs{lateximage}s.  The |.svg| file text size
% should blend well with the surrounding \HTML\ text size.
%
% \emph{Do not include the leading backslash in the name.}
% \trouble[no backslash]{LateximageFontSizeName=\cs{LateximageFontSizeName}}
%
% \changes{v0.19}{2016/05/29}{Add: User-adjustable math/lateximage font size.}
% \changes{v0.54}{2018/04/16}{Defaults to \progcode{normalsize}.}
%    \begin{macrocode}
\newcommand*{\LateximageFontSizeName}{normalsize}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LateximageFontScale}
% \changes{v0.52}{2018/03/24}{Added user-adjustable \SVG\ math font scaling.}
% Declares how large to scale inline \SVG\ math images.  The |.svg| file text size
% should blend well with the surrounding \HTML\ text size.
% The default is .75, but it may be redefined as needed depending on the
% \HTML\ font.
%
%    \begin{macrocode}
\newcommand*{\LateximageFontScale}{.75}
%    \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
% |&|, |<|, or |>|, which should not be allowed
% inside an \HTML\ \element{alt} tag, so must convert them to \HTML\ entities.
%
% Two versions follow, depending on expansion needs.
% There may be a better way\dots
%
% \changes{v0.36}{2017/08/16}{Fix for \pkg{babel-french}.}
% \changes{v0.51}{2018/03/07}{Fix: Escapes double quotes.}
%    \begin{macrocode}
\newrobustcmd{\LWR@HTMLsanitize}[1]{%
%    \end{macrocode}
% Cancel French \pkg{babel} character handling,
% and fully expand the strings:
%    \begin{macrocode}
\begingroup%
\LWR@FBcancel%
\fullexpandarg%
%    \end{macrocode}
% The |&|, |<|, and |>| may be interpreted by the browser:
%    \begin{macrocode}
\protect\StrSubstitute{\detokenize{#1}}%
{\detokenize{&}}{\detokenize{&amp;}}[\LWR@strresult]%
%    \end{macrocode}
%    \begin{macrocode}
\protect\StrSubstitute{\detokenize\expandafter{\LWR@strresult}}%
{\detokenize{<}}{\detokenize{&lt;}}[\LWR@strresult]%
%    \end{macrocode}
%    \begin{macrocode}
\protect\StrSubstitute{\detokenize\expandafter{\LWR@strresult}}%
{\detokenize{>}}{\detokenize{&gt;}}[\LWR@strresult]%
%    \end{macrocode}
% The double quote occasionally causes problems.
%    \begin{macrocode}
\protect\StrSubstitute{\detokenize\expandafter{\LWR@strresult}}%
{\detokenize{"}}{\detokenize{&quot;}}[\LWR@strresult]%
%    \end{macrocode}
% MathJax allows expressions to be defined with \cs{newcommand}.
% These expressions would appear with |##| for each argument,
% and each must be changed to a single |#|.
% This must be done after all the above changes.
% Attempting another conversion after this causes an error upon further expansion.
%    \begin{macrocode}
\protect\StrSubstitute{\detokenize\expandafter{\LWR@strresult}}%
{\detokenize{##}}{\LWR@origpound}[\LWR@strresult]%
%    \end{macrocode}
%    \begin{macrocode}
\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 \pkg{babel-french}.}
% \changes{v0.51}{2018/03/07}{Fix: Escapes double quotes.}
%    \begin{macrocode}
\newrobustcmd{\LWR@HTMLsanitizeexpand}[1]{%
%    \end{macrocode}
% Cancel French \pkg{babel} character handling,
% and fully expand the strings:
%    \begin{macrocode}
\begingroup%
\LWR@FBcancel%
\fullexpandarg%
%    \end{macrocode}
% The difference between this and \cs{LWR@HTMLsanitize} (without ``expand'')
% is the following \cs{expandafter}:
%    \begin{macrocode}
\protect\StrSubstitute{\detokenize\expandafter{#1}}%
{\detokenize{&}}{\detokenize{&amp;}}[\LWR@strresult]%
%    \end{macrocode}
%    \begin{macrocode}
\protect\StrSubstitute{\detokenize\expandafter{\LWR@strresult}}%
{\detokenize{<}}{\detokenize{&lt;}}[\LWR@strresult]%
%    \end{macrocode}
%    \begin{macrocode}
\protect\StrSubstitute{\detokenize\expandafter{\LWR@strresult}}%
{\detokenize{>}}{\detokenize{&gt;}}[\LWR@strresult]%
%    \end{macrocode}
%    \begin{macrocode}
\protect\StrSubstitute{\detokenize\expandafter{\LWR@strresult}}%
{\detokenize{"}}{\detokenize{&quot;}}[\LWR@strresult]%
%    \end{macrocode}
% \cs{LWR@HTMLsanitizeexpand} is not used for defining new MathJax macros,
% so the |##| conversion is not needed here.
%    \begin{macrocode}
\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.
%
% This is reset by \env{lateximage},
% may be temporarily overwritten by \cs{tag} calling \cs{LWR@remembertag}.
%    \begin{macrocode}
\newcommand*{\LWR@equationtag}{}
%    \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}

%    \begin{macrocode}
}% not mathjax
}% AtBeginDocument
%    \end{macrocode}


% \subsection{\HTML\ \attribute{alt} tags}

% \begin{macro}{\LWR@amsmathbody} \marg{envname} \qquad
%   For use inside the optional argument to a \env{lateximage}
%   to add the contents of a AMS math environment to the \element{alt} tag.
%
% \changes{v0.42}{2017/10/12}{Fix: Numbering and naming AMS math environments.}
%
%    \begin{macrocode}
\newcommand*{\LWR@amsmathbody}[1]
{%
\textbackslash\{begin\}\{#1\} % extra space
\LWR@HTMLsanitizeexpand{\detokenize\expandafter{\the\@envbody}}%
\textbackslash\{end\}\{#1\}%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\LWR@amsmathbodynumbered} \marg{envname} \qquad
%   For use inside the optional argument to a \env{lateximage}
%   to add the contents of a AMS math environment to the \attribute{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)} % extra space
\LWR@amsmathbody{#1} % extra space
}
%    \end{macrocode}
% \end{macro}


% \subsection{\env{lateximage} environment}

% \begin{environment}{lateximage} * \oarg{2: \element{alt} tag}
%                                       \oarg{3: add'l hashing} \oarg{4: \CSS\ style}
%
% Typesets the contents and then renders the result as an \SVG\ file.
% Star causes the image to be hashed for reuse.
%
% The optional \element{alt} tag is included in the \HTML\ code for use with copy/paste.
%
% \describehashing
%
% \DescribeFile{*_html.aux}
% A new label is placed into the file \filenm{*_html.aux}:
% \begin{sourceverb}
% \newlabel{LWRlateximage-<BaseJobname>-<number>}{{<x>}{<y>}}
% \end{sourceverb}
% This is used to find the image in the \PDF\ file, according to its name.
%
% \DescribeFile{*-images.txt}
% A list of images to generate is created in \filenm{<jobname>-images.txt}.
% Each line has three pipe-delimited fields,
% containing the \PDF\ page number from \filenm{<jobname>_html.pdf}, where the image
% is located, a boolean indicating whether the image is hashed, and
% the filename of the image.
%
%
% \changes{v0.18}{2016/05/18}{Suppress 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}.}
% \changes{v0.47}{2018/01/24}{Added \CSS\ style option.}
% \changes{v0.51}{2018/03/07}{Added additional hashing option.}
% \changes{v0.66}{2019/01/27}{Adds \cs{BaseJobname} for multiple projects.}
%
%    \begin{macrocode}
\catcode`\$=\active%

\NewDocumentEnvironment{lateximage}{s O{(image)} O{} O{}}
{%
\LWR@traceinfo{lateximage: starting on \jobname.pdf page \arabic{page}}%
\LWR@traceinfo{lateximage: entering depth is \arabic{LWR@lateximagedepth}}%
%    \end{macrocode}
% Nested |lateximage|s remain one large |lateximage|:
%    \begin{macrocode}
\ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
%    \end{macrocode}
% If nesting inside an already-existing lateximage, simply record one more level.
% \AmS\ packages redefine \cs{addtocounter} to do nothing if inside a \cs{text},
% so lower-level \TeX\ macros are used for tracking nested \env{lateximage}s.
% \changes{v0.51}{2018/03/07}{Fix: \env{lateximage} inside \AmS\ \cs{text}.}
%    \begin{macrocode}
{%
%     \addtocounter{LWR@lateximagedepth}{1}%
    \global\advance\c@LWR@lateximagedepth 1\relax% Due to AmS \text macro.
}%
%    \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}
\LWR@traceinfo{lateximage: starting outer-most lateximage}%
    \setcounter{LWR@startingequation}{\value{equation}}%
    \addtocounter{LWR@startingequation}{1}%
    \booltrue{LWR@isstartingequation}%
    \let\LWR@startingequationtag\theLWR@startingequation%
%    \end{macrocode}
% The default equation tag, unless overwritten by \cs{tag}:
%    \begin{macrocode}
    \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.
% \cs{setcounterpageref} assigns |LWR@LIpage| to the page number for
% the reference |LWRlateximage-BaseJobname-XXX|:
%    \begin{macrocode}
    \setcounterpageref{LWR@LIpage}{%
        LWRlateximage-\BaseJobname-\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 \prog{pdftotext} translation
% of the image's page, and also will hold the link to the |.svg| file:
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
    \LWR@htmltag{span\LWR@indentHTML%
        id="lateximage-\BaseJobname-\arabic{LWR@lateximagenumber}"\LWR@indentHTML
        class="lateximagesource"\LWR@orignewline
    }%
%    \end{macrocode}
% Write instructions to the |<ImagesDirectory>.txt| file:
% \changes{v0.50}{2018/02/22}{MD5 hash avoids duplicate \SVG\ math.}
%    \begin{macrocode}
    \LWR@traceinfo{lateximage: about to write to \BaseJobname-images.txt}%
    \IfBooleanTF{#1}% starred
    {% hash
        \LWR@traceinfo{lateximage: hash true, adding %
            !\detokenize\expandafter{#2}!\detokenize\expandafter{#3}!}%
%    \end{macrocode}
% Compute and save the hashed file name for later use:
% \changes{v0.52}{2018/03/25}{Fix for hash expansion.}
%    \begin{macrocode}
        \edef\LWR@hashedname{%
            \LWR@mdfive{\detokenize\expandafter{#2}-!-#3}%
        }%
        \LWR@traceinfo{lateximage: hash is \LWR@hashedname}%
%    \end{macrocode}
% Write the page, hashing, and hashed name:
%    \begin{macrocode}
        \immediate\write\LWR@lateximagesfile{%
            |\arabic{LWR@LIpage}|true|\LWR@hashedname|%
        }%
    }% hash
    {% no hash
%    \end{macrocode}
% No hash, so write the page, no hashing, and the image number:
%    \begin{macrocode}
        \LWR@traceinfo{lateximage: hash false}%
        \immediate\write\LWR@lateximagesfile{%
            |\arabic{LWR@LIpage}|false|\LWR@ImagesName\arabic{LWR@externalfilecnt}|%
        }%
    }% no hash
%    \end{macrocode}
% Place an open comment tag.
% This will hide any traces of the lateximage \PDF\ page which were picked up by
% \prog{pdftotext}.
%    \begin{macrocode}
    \LWR@traceinfo{lateximage: about to create open comment}%
    \LWR@htmlopencomment%
%    \end{macrocode}
% One level deeper.  At this outer-most \env{lateximage}, it is known
% that this is not being used inside an \AmS\ \cs{text}, since the outer-most
% level will never be in math mode.
%    \begin{macrocode}
     \addtocounter{LWR@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@print@minipage{6in}%
    \@nameuse{LWR@print@\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}%
    \LetLtxMacro\@footnotetext\LWR@footnotetext%
%    \end{macrocode}
% Create the |LWRlateximage<number>| label:
%    \begin{macrocode}
    \LWR@traceinfo{lateximage: about to create label}%
    \LWR@orig@label{LWRlateximage-\BaseJobname-\arabic{LWR@lateximagenumber}}%
    \LWR@traceinfo{lateximage: finished creating the label}%
%    \end{macrocode}
% Enable print-mode math functions:
% \changes{v0.50}{2018/02/20}{Fix: SVG math in a section name.}
%    \begin{macrocode}
    \LetLtxMacro$\LWR@origdollar%
    \catcode`\$=3% math shift
    \LetLtxMacro\(\LWR@origopenparen%
    \LetLtxMacro\)\LWR@origcloseparen%
%    \end{macrocode}
% Only enable print-mode display math if are not already inside display math:
% \changes{v0.51}{2018/03/21}{Processing for complicated display math.}
%    \begin{macrocode}
    \ifbool{LWR@indisplaymathimage}{}{% not in display math
        \LetLtxMacro\[\LWR@origopenbracket%
        \LetLtxMacro\]\LWR@origclosebracket%
        \let\equation\LWR@origequation%
        \let\endequation\LWR@origendequation%
        \csletcs{equation*}{LWR@origequation*}%
        \csletcs{endequation*}{LWR@origendequation*}%
    }% not in display math
%    \end{macrocode}
% For \pkg{chemformula}:
%    \begin{macrocode}
    \LetLtxMacro\LWR@newsingledollar$%
    \LetLtxMacro\LWR@newsingledollar$% syntax highlighting
%    \end{macrocode}
%    \begin{macrocode}
}% 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 lateximage}%
%    \end{macrocode}
% Nested more than one deep?
%    \begin{macrocode}
\LWR@traceinfo{lateximage: internal depth was \arabic{LWR@lateximagedepth}}%
\ifnumcomp{\value{LWR@lateximagedepth}}{>}{1}%
%    \end{macrocode}
% If nesting inside an already existing lateximage, simply record one less level.
% Uses a lower-level \TeX\ macro due to \AmS\ \cs{text} change of \cs{addtocounter}.
%    \begin{macrocode}
{%
    \LWR@traceinfo{lateximage: unnesting}%
    \global\advance\c@LWR@lateximagedepth -1\relax%
}%
%    \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@traceinfo{lateximage: ending outer-most lateximage}%
    \endLWR@print@minipage%
    \LWR@orignewpage%
    \LWR@print@scriptsize%
%    \end{macrocode}
% Close the \HTML\ comment which encapsulated any traces of the lateximage picked up by \prog{pdftotext}:
%    \begin{macrocode}
    \LWR@print@vspace*{.5\baselineskip}%
    \LWR@htmlclosecomment%
    \LWR@traceinfo{lateximage: The page after the image is \arabic{page}}%
%    \end{macrocode}
% Create a link to the lateximage, allowing its natural height:
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
% \changes{v0.50}{2018/02/22}{MD5 hash avoids duplicate \SVG\ math.}
%    \begin{macrocode}
    \IfBooleanTF{#1}% starred
    {% hash
        \LWR@subinlineimage[#2]{lateximage}%
        {%
            \LWR@ImagesDirectory\OSPathSymbol%
            \LWR@print@mbox{\LWR@hashedname}%
        }{svg}{#4}%
    }% hash
    {% no hash
        \LWR@subinlineimage[#2]{lateximage}%
        {%
            \LWR@ImagesDirectory\OSPathSymbol%
            \LWR@print@mbox{\LWR@ImagesName\theLWR@externalfilecnt}%
        }{svg}{#4}%
    }% no hash
%    \end{macrocode}
% Be sure that are doing a paragraph:
%    \begin{macrocode}
    \LWR@ensuredoingapar%
%    \end{macrocode}
% Close the \HTML\ span which has the \prog{pdftotext} comment and also the link to the |.svg| image:
%    \begin{macrocode}
    \LWR@htmltag{/span}%
    \ifbool{HTMLDebugComments}{%
        \LWR@htmlcomment{End of lateximage}%
    }{}%
%    \end{macrocode}
% Undo one lateximage level.
% This is not inside an \AmS\ \cs{text}, so regular \cs{addtocounter} may be used here.
%    \begin{macrocode}
    \addtocounter{LWR@lateximagedepth}{-1}%
}% end of outer-most lateximage
\LWR@traceinfo{lateximage: exiting depth is \arabic{LWR@lateximagedepth}}%
\LWR@traceinfo{lateximage: done}%
}%
\catcode`\$=3% math shift
\end{warpHTML}
%    \end{macrocode}
% \end{environment}

% \codeprint
%    \begin{macrocode}
\begin{warpprint}
%    \end{macrocode}

% \begin{environment}{lateximage} \oarg{\element{alt} tag} \oarg{\CSS\ style}
%
% \env{varwidth} is used to create a box of the natural width of its contents.
%
% \changes{v0.48}{2018/02/02}{Print mode boxed to natural width.}
%    \begin{macrocode}
\NewDocumentEnvironment{lateximage}{s o o o}
    {\begin{varwidth}[b]{\linewidth}}
    {\end{varwidth}}
%    \end{macrocode}
% \end{environment}

%    \begin{macrocode}
\end{warpprint}
%    \end{macrocode}




% \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 \progcode{FormatWP} use explicit \attribute{text-align}.}
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\renewenvironment*{center}
{
\LWR@forcenewpage
\ifbool{FormatWP}
{\BlockClass[\LWR@print@mbox{text-align:center}]{center}}
{\BlockClass{center}}
}
{\endBlockClass}
%    \end{macrocode}
% \end{environment}


% \begin{environment}{flushright}
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\renewenvironment*{flushright}
{
\LWR@forcenewpage
\ifbool{FormatWP}
{\BlockClass[\LWR@print@mbox{text-align:right}]{flushright}}
{\BlockClass{flushright}}
}
{\endBlockClass}
%    \end{macrocode}
% \end{environment}

% \begin{environment}{flushleft}
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\renewenvironment*{flushleft}
{
\LWR@forcenewpage
\ifbool{FormatWP}
{\BlockClass[\LWR@print@mbox{text-align:left}]{flushleft}}
{\BlockClass{flushleft}}
}
{\endBlockClass}
%    \end{macrocode}
% \end{environment}


% \cs{centering}, \cs{raggedleft}, and \cs{raggedright} usually have no effect
% on the \HTML\ output, but they may be used to compare with the next token
% to identify their use at the start of a float.  See \cs{LWR@floatalignment}.

% \begin{macro}{\centering}
% \changes{v0.54}{2018/04/19}{Added debug comment.}
%    \begin{macrocode}
\newcommand*{\LWR@HTML@centering}{%
\ifbool{HTMLDebugComments}{%
    \LWR@htmlcomment{centering}%
}{}%
}
\LWR@formatted{centering}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\raggedleft}
% \changes{v0.54}{2018/04/19}{Added debug comment.}
%    \begin{macrocode}
\newcommand*{\LWR@HTML@raggedleft}{%
\ifbool{HTMLDebugComments}{%
    \LWR@htmlcomment{raggedleft}%
}{}%
}
\LWR@formatted{raggedleft}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\raggedright}
% \changes{v0.54}{2018/04/19}{Added debug comment.}
%    \begin{macrocode}
\newcommand*{\LWR@HTML@raggedright}{%
\ifbool{HTMLDebugComments}{%
    \LWR@htmlcomment{raggedright}%
}{}%
}
\LWR@formatted{raggedright}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\leftline} \marg{text}
% \changes{v0.48}{2018/02/03}{Added.}
%    \begin{macrocode}
\renewcommand{\leftline}[1]{\begin{flushleft}#1\end{flushleft}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\centerline} \marg{text}
% \changes{v0.48}{2018/02/03}{Added.}
%    \begin{macrocode}
\renewcommand{\centerline}[1]{\begin{center}#1\end{center}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\rightline} \marg{text}
% \changes{v0.48}{2018/02/03}{Added.}
%    \begin{macrocode}
\renewcommand{\rightline}[1]{\begin{flushright}#1\end{flushright}}
%    \end{macrocode}
% \end{macro}


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






% ^^A *preloaded
% \section{Preloaded packages}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
% If the given package was loaded before or by \pkg{lwarp},
% load the \pkg{lwarp} version as well.
% \begin{macro}{\LWR@PreloadedPackage} \marg{packagename}
% \changes{v0.62}{2018/11/17}{Added.}
% \changes{v0.65}{2018/12/21}{\cs{AtBeginDocument} to avoid option clashes.}
%    \begin{macrocode}
\newcommand*{\LWR@PreloadedPackage}[1]{%
    \@ifpackageloaded{#1}%
        {%
            \AtBeginDocument{
                \LWR@origRequirePackage{lwarp-#1}%
            }
        }%
        {}%
}
%    \end{macrocode}
% \end{macro}
%
% If \pkg{textcomp} was loaded before \pkg{lwarp},
% perhaps as part of the font-related packages,
% explicitly load the lwarp patches now:
%    \begin{macrocode}
\LWR@PreloadedPackage{textcomp}
%    \end{macrocode}

% If \pkg{xunicode} was loaded before \pkg{lwarp},
% perhaps as part of the font-related packages,
% explicitly load the lwarp patches now:
%    \begin{macrocode}
\LWR@PreloadedPackage{xunicode}
%    \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}
\LWR@PreloadedPackage{graphics}
\LWR@PreloadedPackage{graphicx}
%    \end{macrocode}

% \pkg{ulem} may be preloaded by \pkg{ctex}, \pkg{ctexart}, and related classes.
%    \begin{macrocode}
\LWR@PreloadedPackage{ulem}
%    \end{macrocode}

% \pkg{xetexko-vertical} may be preloaded by \pkg{xetexko}.
%    \begin{macrocode}
\LWR@PreloadedPackage{xetexko-vertical}
%    \end{macrocode}

% \pkg{geometry} is preloaded by \pkg{lwarp}, and perhaps by various classes.
%    \begin{macrocode}
\LWR@PreloadedPackage{geometry}
%    \end{macrocode}

% \pkg{plext} is preloaded by some CJK classes.
%    \begin{macrocode}
\LWR@PreloadedPackage{plext}
%    \end{macrocode}

% \pkg{stfloats} is preloaded by \pkg{ltj*} classes.
%    \begin{macrocode}
\LWR@PreloadedPackage{stfloats}
%    \end{macrocode}

% \pkg{lltjext} is preloaded by \pkg{ltj*} classes.
%    \begin{macrocode}
\LWR@PreloadedPackage{lltjext}
%    \end{macrocode}

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






% \section{\pkg{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:
% \changes{v0.50}{2018/02/24}{\pkg{siunitx}: Improved units.}
%    \begin{macrocode}
\newrobustcmd{\LWR@siunitx@textcelsius}{\HTMLentity{deg}C}
\newrobustcmd{\LWR@siunitx@textdegree}{\HTMLentity{deg}}
\newrobustcmd{\LWR@siunitx@textprime}{\HTMLunicode{2032}}
\newrobustcmd{\LWR@siunitx@textdblprime}{\HTMLunicode{2033}}
\newrobustcmd{\LWR@siunitx@textplanckbar}{\text{\textit{\HTMLunicode{0127}}}}

\appto\LWR@restoreorigformatting{%
\renewrobustcmd{\LWR@siunitx@textcelsius}{\text{\ensuremath{^\circ}C}}%
\renewrobustcmd{\LWR@siunitx@textdegree}{\text{\ensuremath{^\circ}}}%
\renewrobustcmd{\LWR@siunitx@textprime}{\text{\ensuremath{^\prime}}}%
\renewrobustcmd{\LWR@siunitx@textdblprime}{\text{\ensuremath{^{\prime\prime}}}}%
\renewrobustcmd{\LWR@siunitx@textplanckbar}{\text{\ensuremath{\hbar}}}%
}

\PassOptionsToPackage{
    detect-mode=true,
    per-mode=symbol,	% fraction is not seen by pdftotext
    text-celsius = {\LWR@siunitx@textcelsius},
    text-degree = {\LWR@siunitx@textdegree},
    text-arcminute = {\LWR@siunitx@textprime} ,
    text-arcsecond = {\LWR@siunitx@textdblprime} ,
}{siunitx}
%    \end{macrocode}

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





% \section{Graphics print-mode modifications}
%
% \gindex{image>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:
% \changes{v0.65}{2018/12/19}{\pkg{graphics}: Added \cs{includegraphics} \attribute{alt} key.}
%    \begin{macrocode}
\begin{warpprint}
\define@key{Gin}{class}{}
\define@key{Gin}{alt}{}
%    \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{\pkg{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}
%
%
% \textred{After \pkg{xparse} may have been loaded \dots}
%    \begin{macrocode}
\AtBeginDocument{
%    \end{macrocode}
% \textred{\dots\ and \emph{only} if \pkg{xcolor} was loaded:}
%    \begin{macrocode}
\@ifpackageloaded{xcolor}{
\LWR@traceinfo{patching xcolor}
%    \end{macrocode}
%
%
% The print version:
% \begin{macro}{\colorboxBlock}
% \cs{colorboxBlock} is the same as \cs{colorbox}:
%    \begin{macrocode}
\LetLtxMacro\colorboxBlock\colorbox
%    \end{macrocode}
% \end{macro}
%
%
%
% The original definition is reused by the new versions:
%    \begin{macrocode}
\LetLtxMacro\LWR@orig@print@fcolorbox\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}

\NewDocumentCommand{\LWR@print@fcolorbox}{o m o m +m}{%
\LWR@traceinfo{LWR@print@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}.
%
% The current color is remembered, then set to the frame, then the current
% color is used for the contents.
% \changes{v0.62}{2018/10/18}{Fix: No longer requires \pkg{xifthen}.}
%    \begin{macrocode}
\ifstrequal{#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}%
    {\LWR@orig@print@fcolorbox[#1]{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
    {\LWR@orig@print@fcolorbox[#1]{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
}%
{% no value #1
    \IfValueTF{#3}%
    {\LWR@orig@print@fcolorbox{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
    {\LWR@orig@print@fcolorbox{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
}% no value #1
}% #4 not none
\LWR@traceinfo{LWR@print@fcolorbox done}%
}

\renewcommand*{\fcolorbox}{\LWR@print@fcolorbox}
%    \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}
\newcommand*{\LWR@print@fcolorboxBlock}{\LWR@print@fcolorbox}
\newcommand*{\fcolorboxBlock}{\LWR@print@fcolorboxBlock}
%    \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{LWR@print@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}.
%
% The current color is remembered, then set to the frame, then the current
% color is used for the contents.
% \changes{v0.62}{2018/10/18}{Fix: No longer requires \pkg{xifthen}.}
%    \begin{macrocode}
\ifstrequal{#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}%
    {\LWR@orig@print@fcolorbox[#1]{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
    {\LWR@orig@print@fcolorbox[#1]{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
    }%
    {% no value #1
    \IfValueTF{#3}%
    {\LWR@orig@print@fcolorbox{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
    {\LWR@orig@print@fcolorbox{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
    }% no value #1
}% #4 not none
\LWR@traceinfo{*** finished end fcolorminipage}%
}

\newenvironment*{fcolorminipage}
    {\LWR@print@fcolorminipage}
    {\endLWR@print@fcolorminipage}
%    \end{macrocode}
% \end{environment}

%    \begin{macrocode}
\LWR@traceinfo{xcolor patches done}
}{}% xcolor loaded
}% AtBeginDocument
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpall}
%    \end{macrocode}



% \section{\pkg{chemmacros} environments}
% \label{sec:chemmacrosprintenvs}
%
% \cs{makepolymerdelims} and redox reactions must be enclosed in a \env{lateximage}
% during \HTML\ output.
% These environments are provided here in print mode, and in the \pkg{chemmacros}
% code in \HTML\ mode, as a high-level semantic syntax which automatically embeds the
% contents in a \env{lateximage} with an appropriate \attribute{alt} tag.
%
% \codeprint
%
%    \begin{macrocode}
\begin{warpprint}
%    \end{macrocode}

%    \begin{macrocode}
\AtBeginDocument{
\@ifpackageloaded{chemmacros}{
%    \end{macrocode}
%
% \begin{noindenvironment}{polymerdelims}
%    \begin{macrocode}
\DeclareDocumentEnvironment{polymerdelims}{}
    {}{}
%    \end{macrocode}
% \end{noindenvironment}

% \begin{noindenvironment}{redoxreaction} \marg{space above} \marg{space below}
%
% For print output, extra space is include above and below the image, and
% a \env{lateximage} is not necessary.
% This extra space must be enforced, even inside a float, so zero-width rules are used.
%
% For the \HTML\ version, see \cref{sec:chemmacroshtmlenvs}.
%    \begin{macrocode}
\DeclareDocumentEnvironment{redoxreaction}{m m}
    {\rule{0pt}{#1}}{\rule[-#2]{0pt}{#2}}
%    \end{macrocode}
% \end{noindenvironment}
%
%    \begin{macrocode}
}{}% chemmacros
}% AtBeginDocument
%    \end{macrocode}

%    \begin{macrocode}
\end{warpprint}
%    \end{macrocode}




% \section{\pkg{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}.  Print-mode versions are not required
% since they all come down to \cs{ref} eventually, and \cs{ref} has a print-mode
% version.
% \end{flushleft}
%    \begin{macrocode}
\AfterEndPreamble{
\LWR@traceinfo{Patching cleveref.}
%    \end{macrocode}

% \begin{macro}{\@@@setcref} \marg{kindofref} \marg{label}
%
% \cs{@templabel} becomes the section number.
%
% \changes{v0.48}{2018/02/10}{Fix for new v0.21 of \pkg{cleveref}.}
%    \begin{macrocode}
\def\LWR@orig@@@setcref#1#2{\cref@getlabel{#2}{\@templabel}#1{\@templabel}{}{}}%

\ifdefequal{\@@setcref}{\LWR@orig@@@setcref}{% before v0.21
    \renewcommand*{\@@setcref}[2]{#1{\ref{#2}}{}{}}
}{
    \ifdefequal{\@@@setcref}{\LWR@orig@@@setcref}{% as of v0.21
        \renewcommand*{\@@@setcref}[2]{#1{\ref{#2}}{}{}}
    }{
        \PackageWarning{lwarp-cleveref}{
            Unknown version of cleveref.
            \protect\cref\space will fail.
        }%
    }
}
%    \end{macrocode}
% \end{macro}

%\begin{macro}{\@@@setcrefrange} \marg{text} \marg{label} \marg{label}
% \changes{v0.48}{2018/02/10}{Fix for new v0.21 of \pkg{cleveref}.}
%    \begin{macrocode}
\def\LWR@orig@@@setcrefrange#1#2#3{%
  \cref@getlabel{#2}{\@labela}%
  \cref@getlabel{#3}{\@labelb}%
  #1{\@labela}{\@labelb}{}{}{}{}}%

\ifdefequal{\@@setcrefrange}{\LWR@orig@@@setcrefrange}{
    \renewcommand{\@@setcrefrange}[3]{%
        #1{\ref{#2}}{\ref{#3}}{}{}{}{}%
    }
}{
    \ifdefequal{\@@@setcrefrange}{\LWR@orig@@@setcrefrange}{
        \renewcommand{\@@@setcrefrange}[3]{%
            #1{\ref{#2}}{\ref{#3}}{}{}{}{}%
        }
    }{
        \PackageWarning{lwarp-cleveref}{
            Unknown version of cleveref.
            \protect\crefrange\space will fail.
        }
    }
}

%    \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''
%
% \changes{v0.48}{2018/02/10}{Fix for new v0.21 of \pkg{cleveref}.}
%    \begin{macrocode}
\def\LWR@orig@@setcpageref#1#2{% before v0.21
  \cref@getpageref{#2}{\@temppage}#1{\@temppage}{}{}}%

\def\LWR@orig@@@setcpageref#1#2{% as of v0.21
  \cpageref@getlabel{#2}{\@temppage}#1{\@temppage}{}{}}%

\ifdefequal{\@@setcpageref}{\LWR@orig@@setcpageref}{
    \renewcommand*{\@@setcpageref}[2]{%
        #1{\cpagerefFor\ \cref{#2}}{}{}%
    }
}{
    \ifdefequal{\@@@setcpageref}{\LWR@orig@@@setcpageref}{
        \renewcommand*{\@@@setcpageref}[2]{%
            #1{\cpagerefFor\ \cref{#2}}{}{}%
        }
    }
    {
        \PackageWarning{lwarp-cleveref}{
            Unknown version of cleveref.
            \protect\cpageref\space will fail.
        }
    }
}
%    \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}
\def\LWR@orig@@setcpagerefrange#1#2#3{% before v0.21
  \cref@getpageref{#2}{\@pagea}%
  \cref@getpageref{#3}{\@pageb}%
  #1{\@pagea}{\@pageb}{}{}{}{}}%

\def\LWR@orig@@@setcpagerefrange#1#2#3{% as of v0.21
  \cpageref@getlabel{#2}{\@pagea}%
  \cpageref@getlabel{#3}{\@pageb}%
  #1{\@pagea}{\@pageb}{}{}{}{}}%

\ifdefequal{\@@setcpagerefrange}{\LWR@orig@@setcpagerefrange}{
    \renewcommand*{\@@setcpagerefrange}[3]{%
        #1{\cpagerefFor\ \cref{#2}}{\cref{#3}}{}{}{}{}%
    }
}{
    \ifdefequal{\@@@setcpagerefrange}{\LWR@orig@@@setcpagerefrange}{
        \renewcommand*{\@@@setcpagerefrange}[3]{%
            #1{\cpagerefFor\ \cref{#2}}{\cref{#3}}{}{}{}{}%
        }
    }
    {
        \PackageWarning{lwarp-cleveref}{
            Unknown version of cleveref.
            \protect\cpagerefrange\space will fail.
        }
    }
}

}% AfterEndPreamble
%    \end{macrocode}


%
% Remember and patch some label-related defintions.
% These will be further encased and patched by other packages later.
%
% \cs{label} and \cs{pageref} do NOT change their behavior according to
% print or \HTML\ output, and thus do not use the \cs{LWR@formatted} system.
%
%    \begin{macrocode}
\LetLtxMacro\LWR@orig@label\label
\RenewDocumentCommand{\label}{}{\LWR@new@label}

\LetLtxMacro\LWR@orig@pageref\pageref
\RenewDocumentCommand{\pageref}{}{\LWR@new@pageref}
\end{warpHTML}
%    \end{macrocode}



% \section{\env{picture} environment}
% \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.}
% \changes{v0.59}{2018/09/05}{Added an \attribute{alt} tag.}
%    \begin{macrocode}
\BeforeBeginEnvironment{picture}{\begin{lateximage}[(picture)]}

\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}
%
%
% \DescribeBoolean{LWR@minipagefullwidth} Should the next minipage
% have no \HTML\ |width|?
%    \begin{macrocode}
\newbool{LWR@minipagefullwidth}
\boolfalse{LWR@minipagefullwidth}
%    \end{macrocode}
%
%
% \DescribeBoolean{LWR@forceminipagefullwidth} Should the next minipage
% have no \HTML\ |width|?  Used to force full width for all minipages
% in an environment such as \env{tabular} or \env{multicols},
% where the actual width depends on the browser width.
% Controlled by \cs{useminipagewidths} and \cs{ignoreminipagewidths}.
%    \begin{macrocode}
\newbool{LWR@forceminipagefullwidth}
\boolfalse{LWR@forceminipagefullwidth}
%    \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.}
% \changes{v0.66}{2018/12/28}{Made \cs{global}.}
%
% \codehtml
%
%    \begin{macrocode}
\newcommand*{\minipagefullwidth}{\global\booltrue{LWR@minipagefullwidth}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\UseMinipageWidths} Locally requests that minipage widths be
%   honored.
% \changes{v0.66}{2018/12/31}{Added,}
%    \begin{macrocode}
\newcommand*{\UseMinipageWidths}{\boolfalse{LWR@forceminipagefullwidth}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\IgnoreMinipageWidths} Locally requests that minipage widths be
%   honored.
% \changes{v0.66}{2018/12/31}{Added,}
%    \begin{macrocode}
\newcommand*{\IgnoreMinipageWidths}{\booltrue{LWR@forceminipagefullwidth}}
\end{warpHTML}
%    \end{macrocode}
% \end{macro}
%
%
% \codeprint
%
%    \begin{macrocode}
\begin{warpprint}
\newcommand*{\minipagefullwidth}{}
\newcommand*{\UseMinipageWidths}{}
\newcommand*{\IgnoreMinipageWidths}{}
\end{warpprint}
%    \end{macrocode}
%
%
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%
%
%
% \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.}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
% \changes{v0.65}{2018/12/17}{Refactored to later allow Japanese \textless{}t/y\textgreater{} argument.}
%
% The vertical positions may be 'c', 't', or 'b'.
% The inner position may also be 's'.
%
% When using \cs{linewidth}, \cs{textwidth}, or \cs{textheight}, these are scaled proportionally to a
% 6\texttimes{}9 inch text area.
%
%    \begin{macrocode}
\NewDocumentEnvironment{LWR@HTML@sub@minipage}{m m m m}
{%
\LWR@traceinfo{minipage}%
%    \end{macrocode}
%
% Temporarily open a group, in which width and height is
% computed based on a virtual page size instead of
% the extra-large \PDF\ page used during \HTML\ tag generation.
%
% The following used to be an actual \LaTeX\ minipage.
% \changes{v0.45}{2017/12/01}{Fix: Improper \cs{prevdepth}.}
%    \begin{macrocode}
\begingroup
%    \end{macrocode}
% Compute width, adjusted for frames:
%    \begin{macrocode}
\setlength{\LWR@minipagewidth}{#4}%
\ifthenelse{\cnttest{\value{LWR@minipagedepth}}{=}{0}}{%
%    \end{macrocode}
% Only create a new page if not yet nested:
%    \begin{macrocode}
    \LWR@orignewpage%
%    \end{macrocode}
% Adjust virtual page size:
%    \begin{macrocode}
    \addtolength{\LWR@minipagewidth}{3em}% room for frames
    \setlength{\linewidth}{6in}%
    \setlength{\textwidth}{6in}%
    \setlength{\textheight}{9in}%
}{}%
\LWR@traceinfo{computed width is \LWR@printlength{\LWR@minipagewidth}}%
%    \end{macrocode}
% Compute height:
%    \begin{macrocode}
\setlength{\LWR@minipageheight}{\textheight}% default unless specified
\ifblank{#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 virtual 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 \progcode{FormatWP} add a text frame.}
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\ifbool{FormatWP}{%

\addtocounter{LWR@thisautoidWP}{1}%
\LWR@htmltag{%
    div id="\LWR@print@mbox{autoidWP-\arabic{LWR@thisautoidWP}}" %
    class="wpminipage"%
}%

}{}%
%    \end{macrocode}
% Create the \element{div} tag with optional alignment style:
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\LWR@traceinfo{minipage: creating div class}%
\LWR@htmltag{div class="minipage" style="%
\ifthenelse{\equal{#1}{t}}{\LWR@print@mbox{vertical-align:bottom} ; }{}%
\ifthenelse{\equal{#1}{c}}{\LWR@print@mbox{vertical-align:middle} ; }{}%
\ifthenelse{\equal{#1}{b}}{\LWR@print@mbox{vertical-align:top} ; }{}%
\ifthenelse{\equal{#3}{t}}{\LWR@print@mbox{justify-content:flex-start} ; }{}%
\ifthenelse{\equal{#3}{c}}{\LWR@print@mbox{justify-content:center} ; }{}%
\ifthenelse{\equal{#3}{b}}{\LWR@print@mbox{justify-content:flex-end} ; }{}%
\ifthenelse{\equal{#3}{s}}{\LWR@print@mbox{justify-content:space-between} ; }{}%
%    \end{macrocode}
% Print the width and optional height styles:
% \changes{v0.66}{2018/12/31}{Honor \cs{LWR@forceminipagefullwidth}.}
%    \begin{macrocode}
\LWR@traceinfo{minipage: about to print the width of \LWR@printlength{\LWR@minipagewidth}}%
\ifbool{LWR@minipagefullwidth}%
{\global\boolfalse{LWR@minipagefullwidth}}%
{%
    \ifbool{LWR@forceminipagefullwidth}%
        {}%
        {%
            \ifthenelse{\lengthtest{#4}=\linewidth}%
                {}%
                {width:\LWR@printlength{\LWR@minipagewidth} ; }%
        }%
}%
\LWR@traceinfo{minipage: about to print the height}%
\ifblank{#2}{}{height:\LWR@printlength{\LWR@minipageheight} ; }%
"}%
%    \end{macrocode}
% Finish with an empty line to start the contents on a new line.
%    \begin{macrocode}

% The preceding empty line is required.
%    \end{macrocode}
% Set the user-accessible line and text width and height values
% inside the virtual minipage.
% These do not affect the actual size of the \PDF\ output,
% but are used by any reference to \cs{linewidth}, etc.
% inside the virtual minipage being created here.
%    \begin{macrocode}
\setlength{\linewidth}{#4}% the original width
\setlength{\textwidth}{6in}%
\setlength{\textheight}{9in}%
%    \end{macrocode}
% \cs{raggedright} cancels hyphenation, which will be done by \HTML\ instead.
%    \begin{macrocode}
\LWR@print@raggedright%
%    \end{macrocode}
% Set minipage footnotes:
%    \begin{macrocode}
\def\@mpfn{mpfootnote}%
\def\thempfn{\thempfootnote}\c@mpfootnote\z@%
\let\@footnotetext\@mpfootnotetext%
%    \end{macrocode}
% Resume paragraph tag handling for the contents of the minipage:
% \changes{v0.42}{2017/10/18}{Added boolean \progcode{WPMarkMinipages}.}
%    \begin{macrocode}
\LWR@startpars%
\ifboolexpr{bool{FormatWP} and bool{WPMarkMinipages}}{%

=== begin minipage ===

}{}%
\LWR@traceinfo{minipage: finished starting the minipage}%
}% finished \minipage
{% \endminipage
%    \end{macrocode}
% Print pending minipage footnotes:
% \changes{v0.45}{2017/12/01}{Fix: Improper \cs{prevdepth}.}
%    \begin{macrocode}
\LWR@printpendingmpfootnotes%
%    \end{macrocode}
% End the environment with closing tag:
% \changes{v0.42}{2017/10/18}{Added boolean \progcode{WPMarkMinipages}.}
%    \begin{macrocode}
\ifboolexpr{bool{FormatWP} and bool{WPMarkMinipages}}{%

=== end minipage ===

}{}%
\LWR@stoppars%
%    \end{macrocode}
% The following used to be an actual \LaTeX\ minipage.
% \changes{v0.45}{2017/12/01}{Fix: Improper \cs{prevdepth}.}
%    \begin{macrocode}
\endgroup%

\ifbool{FormatWP}{%

\LWR@htmlelementend{div}%

}{}%
\LWR@htmldivclassend{minipage}%

\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}%
\LWR@traceinfo{LWR@minipage: done}%
}

\NewDocumentEnvironment{LWR@HTML@minipage}{O{t} O{} O{t} m}
    {\LWR@HTML@sub@minipage{#1}{#2}{#3}{#4}}
    {\endLWR@HTML@sub@minipage}

\LWR@formattedenv{minipage}
%    \end{macrocode}
% \end{environment}
%
%
% \subsection{\cs{parbox}, \cs{mbox}, \cs{makebox}, \cs{framebox}, \cs{fbox}, \cs{raisebox}}
%
% \codehtml
%
% \null
%
% \begin{macro}{\parbox} \oarg{pos} \oarg{height} \oarg{inner-pos} \marg{width} \marg{text}
%
% A parbox uses the minipage code:
%
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@parbox}{O{t} O{} O{t} m +m}
{
\LWR@traceinfo{parbox of width #4}%
\begin{minipage}[#1][#2][#3]{#4}%
#5
\end{minipage}%
}

\LWR@formatted{parbox}
%    \end{macrocode}
% \end{macro}
%
%
%
% \begin{macro}{\mbox} \marg{text}
%   \qquad Nullified for \HTML.
% \changes{v0.48}{2018/02/04}{Nullified for \HTML.}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\newcommand*{\LWR@HTML@mbox}[1]{#1}

\LWR@formatted{mbox}
%    \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.}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@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}.
% \changes{v0.47}{2018/01/26}{Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
    \InlineClass[%
        \LWR@print@mbox{display:inline-block} ; %
        \LWR@print@mbox{text-align}:\LWR@align\ ; %
        width:\LWR@printlength{\LWR@tempwidth}%
    ]%
    {makebox}%
%    \end{macrocode}
% \changes{v0.46}{2018/01/19}{Fix: Lateximage in a \cs{makebox}.}
% ^^A Now prints directly instead of inside a \mbox.
%    \begin{macrocode}
    {#4}%
    }% scope
}%
%    \end{macrocode}
% Without a width argument, the text is simply used inline:
% \changes{v0.46}{2018/01/19}{Fix: Lateximage in a \cs{makebox}.}
% ^^A Now prints directly instead of inside a \mbox.
%    \begin{macrocode}
{#4}% no width
}

\LWR@formatted{makebox}
%    \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.}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
%
%    \begin{macrocode}
\LetLtxMacro\LWR@origframebox\framebox

\NewDocumentCommand{\LWR@HTML@framebox}{o o m}{%
\fbox{\makebox[#1][#2]{#3}}%
}

\LWR@formatted{framebox}
%    \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@fboxstyle}
% Prints the \HTML\ attributes for a black border and padding.
%
% \cs{LWR@forceminwidth} must be used first in order to set the border width.
%
% \changes{v0.66}{2019/02/04}{Use current text color.}
% 
%    \begin{macrocode}
\newcommand*{\LWR@fboxstyle}{%
\LWR@findcurrenttextcolor%
border:\LWR@printlength{\LWR@atleastonept} solid \LWR@origpound\LWR@tempcolor ; %
padding:\LWR@printlength{\fboxsep} ; %
color:\LWR@origpound\LWR@tempcolor%
}
%    \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}.}
% \changes{v0.66}{2019/02/02}{Fix: Removed extra space.}
%
% Create a new \HTML\ version, but don't use it until after \pkg{xcolor}
% may have loaded:
%    \begin{macrocode}
\newcommand{\LWR@HTML@fbox}[1]{%
\LWR@traceinfo{HTML fbox}%
\LWR@forceminwidth{\fboxrule}%
\InlineClass[%
\LWR@fboxstyle%
]{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{\LWR@formatted{fbox}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\fboxBlock} \marg{text}
% Creates a framed \HTML\ \element{div} of the text.
%
% First, a print-mode version.
% This is newly defined for print mode, so it is defined inside \env{warpall}.
%
% \codeall
%    \begin{macrocode}
\end{warpHTML}
\begin{warpall}
\let\fboxBlock\fbox
\end{warpall}
\begin{warpHTML}
%    \end{macrocode}
% \codehtml
%
% Next, an \HTML\ version:
% \changes{v0.34}{2017/07/31}{Added.}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
%
%    \begin{macrocode}
\newcommand{\LWR@HTML@fboxBlock}[1]{%
\LWR@forceminwidth{\fboxrule}%
\begin{BlockClass}[%
\LWR@fboxstyle%
]{fboxBlock}
#1
\end{BlockClass}
}

\LWR@formatted{fboxBlock}

\end{warpHTML}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{environment}{fminipage} \oarg{align} \oarg{height} \oarg{align} \marg{width}
%
% Creates a framed \HTML\ \element{div} around its contents.
% \changes{v0.34}{2017/07/31}{Added.}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
%
% Print version:
% \codeall \\
%
%    \begin{macrocode}
\begin{warpall}

\newsavebox{\LWR@fminipagebox}

\NewDocumentEnvironment{LWR@print@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%
}

\LetLtxMacro\fminipage\LWR@print@fminipage
\LetLtxMacro\endfminipage\endLWR@print@fminipage
% \newenvironment{fminipage}{\LWR@print@fminipage}{\endLWR@print@fminipage}

\end{warpall}
%    \end{macrocode}

% \HTML\ version:
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}

\NewDocumentEnvironment{LWR@HTML@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}}%
%    \end{macrocode}
% \changes{v0.62}{2018/11/11}{Fix: Horiz white space.}
%    \begin{macrocode}
\LWR@stoppars%
%    \end{macrocode}
%    \begin{macrocode}
\begin{BlockClass}[%
\LWR@fboxstyle ; %
\IfValueT{#2}{height:\LWR@printlength{\LWR@tempheight} ; }%
width:\LWR@printlength{\LWR@tempwidth}%
]{fminipage}%
}
{%
\end{BlockClass}%
%    \end{macrocode}
% Prevent paragraph tags around horizontal white space
% until the start of the next paragraph:
% \changes{v0.62}{2018/11/11}{Fix: Horiz white space.}
%    \begin{macrocode}
\global\booltrue{LWR@minipagethispar}%
\LWR@traceinfo{fminipage done}%
}

\LWR@formattedenv{fminipage}
%    \end{macrocode}
% \end{environment}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
%
%
% \begin{macro}{\raisebox} \marg{raiselen} \oarg{height} \oarg{depth} \marg{text}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\begin{warpHTML}

\NewDocumentCommand{\LWR@HTML@raisebox}{m o o m}{%
#4%
}

\LWR@formatted{raisebox}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpHTML}
%    \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 \progcode{FormatWP}, use explicit styles for
%   \cs{textsc}, etc.}
% \changes{v0.62}{2018/11/11}{\cs{textbf} and related: Improved font detection.}

% \begin{macro}{\emph} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTML@emph}[1]{%
    {%
        \itshape%
        \LWR@htmlspan{em}{#1}%
    }%
}
\LWR@formatted{emph}

\DeclareRobustCommand{\LWR@null@emph}[1]{#1}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\textmd} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTML@textmd}[1]{%
    {%
        \mdseries%
        \InlineClass(font-weight:normal){textmd}{#1}%
    }%
}
\LWR@formatted{textmd}

\DeclareRobustCommand{\LWR@null@textmd}[1]{#1}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\textbf} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTML@textbf}[1]{%
    {%
        \bfseries%
        \LWR@htmlspan{b}{#1}%
    }%
}
\LWR@formatted{textbf}

\DeclareRobustCommand{\LWR@null@textbf}[1]{#1}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\textrm} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTML@textrm}[1]{%
    {%
        \rmfamily%
        \InlineClass(font-family:serif){textrm}{#1}%
    }%
}
\LWR@formatted{textrm}

\DeclareRobustCommand{\LWR@null@textrm}[1]{#1}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\textsf} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTML@textsf}[1]{%
    {%
        \sffamily%
        \InlineClass(font-family:sans){textsf}{#1}%
    }%
}
\LWR@formatted{textsf}

\DeclareRobustCommand{\LWR@null@textsf}[1]{#1}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\texttt} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTML@texttt}[1]{%
    {%
        \ttfamily%
        \LWR@htmlspan{kbd}{#1}%
    }%
}
\LWR@formatted{texttt}

\DeclareRobustCommand{\LWR@null@texttt}[1]{#1}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\textup} \marg{text}
% \changes{v0.28}{2017/04/13}{Fixed span class.}
% \changes{v0.62}{2018/11/11}{Fixed WP span class.}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTML@textup}[1]{%
    {%
        \upshape%
        \InlineClass(font-style:normal){textup}{#1}%
    }%
}
\LWR@formatted{textup}

\DeclareRobustCommand{\LWR@null@textup}[1]{#1}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\textit} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTML@textit}[1]{%
    {%
        \itshape%
        \LWR@htmlspan{i}{#1}%
    }%
}
\LWR@formatted{textit}

\DeclareRobustCommand{\LWR@null@textit}[1]{#1}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\textsc} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTML@textsc}[1]{%
    {%
        \scshape%
        \InlineClass(
            font-variant: small-caps ;
            font-variant-numeric: oldstyle-nums ;
        ){textsc}{#1}%
    }%
}
\LWR@formatted{textsc}

\DeclareRobustCommand{\LWR@null@textsc}[1]{#1}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\textsi} \marg{text}
% \changes{v0.65}{2018/12/09}{Added.}
%    \begin{macrocode}
\@ifundefined{textsi}{
    \LetLtxMacro\LWR@print@textsi\LWR@print@textsc
}{}

\DeclareRobustCommand{\LWR@HTML@textsi}[1]{%
    {%
        \sishape%
        \InlineClass(
            font-style: italic; 
            font-variant: small-caps ;
            font-variant-numeric: oldstyle-nums ;
        ){textsi}{#1}%
    }%
}
\LWR@formatted{textsi}

\DeclareRobustCommand{\LWR@null@textsi}[1]{#1}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\textsl} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTML@textsl}[1]{%
    {%
        \slshape%
        \InlineClass(font-style:oblique){textsl}{#1}%
    }%
}
\LWR@formatted{textsl}

\DeclareRobustCommand{\LWR@null@textsl}[1]{#1}
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\textnormal} \marg{text}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@HTML@textnormal}[1]{\textmd{\textrm{\textup{#1}}}}
\LWR@formatted{textnormal}

\DeclareRobustCommand{\LWR@null@textnormal}[1]{#1}
%    \end{macrocode}
% \end{macro}


%    \begin{macrocode}
\DeclareRobustCommand{\LWR@null@rmfamily}{}
\DeclareRobustCommand{\LWR@null@sffamily}{}
\DeclareRobustCommand{\LWR@null@ttfamily}{}
\DeclareRobustCommand{\LWR@null@bfseries}{}
\DeclareRobustCommand{\LWR@null@mdseries}{}
\DeclareRobustCommand{\LWR@null@upshape}{}
\DeclareRobustCommand{\LWR@null@slshape}{}
\DeclareRobustCommand{\LWR@null@scshape}{}
\DeclareRobustCommand{\LWR@null@itshape}{}
\DeclareRobustCommand{\LWR@null@normalfont}{}
%    \end{macrocode}
%
% \changes{v0.62}{2018/11/17}{Fix for \cs{em}.}
%    \begin{macrocode}
\DeclareRobustCommand{\LWR@null@em}{}
%    \end{macrocode}


% \begin{macro}{\LWR@nullfonts} Removes formatting during filename operations,
%       file references, and \HTML\ comments.
%
% \textred{Use only inside a group.}\watchout
%
% The following are \emph{not} made robust,
%   since they must be expanded to their nullified versions.
%
% \changes{v0.34}{2017/08/05}{Improved font control.}
% \changes{v0.36}{2017/08/15}{Fix: Filenames while using \brand{MathJax}.}
% \changes{v0.40}{2017/09/21}{Fix: Long arguments for expandable command.}
% \changes{v0.43}{2017/10/31}{Fix: Nullify dollar inside filesnames.}
% \changes{v0.48}{2018/02/04}{Fix: \cs{newline} in title.}
% \changes{v0.65}{2018/12/09}{Added \cs{textsi}.}
%    \begin{macrocode}
\catcode`\$=\active% redefining $ below
\catcode`\_=12% redefining \_ below
\newcommand*{\LWR@nullfonts}{%
\LetLtxMacro\emph\LWR@null@emph%
\LetLtxMacro\textmd\LWR@null@textmd%
\LetLtxMacro\textbf\LWR@null@textbf%
\LetLtxMacro\textrm\LWR@null@textrm%
\LetLtxMacro\textsf\LWR@null@textsf%
\LetLtxMacro\texttt\LWR@null@texttt%
\LetLtxMacro\textup\LWR@null@textup%
\LetLtxMacro\textit\LWR@null@textit%
\LetLtxMacro\textsc\LWR@null@textsc%
\LetLtxMacro\textsi\LWR@null@textsi%
\LetLtxMacro\textsl\LWR@null@textsl%
\LetLtxMacro\textnormal\LWR@null@textnormal%
\LetLtxMacro\rmfamily\LWR@null@rmfamily%
\LetLtxMacro\sffamily\LWR@null@sffamily%
\LetLtxMacro\ttfamily\LWR@null@ttfamily%
\LetLtxMacro\bfseries\LWR@null@bfseries%
\LetLtxMacro\mdseries\LWR@null@mdseries%
\LetLtxMacro\upshape\LWR@null@upshape%
\LetLtxMacro\slshape\LWR@null@slshape%
\LetLtxMacro\scshape\LWR@null@scshape%
%    \end{macrocode}
% \changes{v0.65}{2018/12/10}{Added \cs{sishape}.}
%    \begin{macrocode}
\LetLtxMacro\sishape\LWR@null@sishape%
%    \end{macrocode}
%    \begin{macrocode}
\LetLtxMacro\itshape\LWR@null@itshape%
\LetLtxMacro\normalfont\LWR@null@normalfont%
\LetLtxMacro\em\LWR@null@em%
%    \end{macrocode}
% Various built-in symbols.
% \changes{v0.67}{2019/02/13}{Add'l symbols.}
%    \begin{macrocode}
\renewcommand*{\$}{-}%
\renewcommand*{\%}{-}%
\renewcommand*{\_}{-}%
\renewcommand*{\}}{-}%
\renewcommand*{\{}{-}%
\renewcommand*{\&}{and}%
\renewcommand*{\#}{-}%
\renewcommand*{\,}{-}%
\renewcommand*{~}{-}%
\renewcommand*{\^}[1]{-}%
\renewcommand*{\~}[1]{-}%
\renewcommand*{\newline}{-}%
\renewcommand*{\textasciicircum}{-}%
\renewcommand*{\textasciitilde}{-}%
\renewcommand*{\textasteriskcentered}{-}%
\renewcommand*{\textbackslash}{-}%
\renewcommand*{\textbar}{-}%
\renewcommand*{\textbardbl}{-}%
\renewcommand*{\textbigcircle}{-}%
\renewcommand*{\textbraceleft}{-}%
\renewcommand*{\textbraceright}{-}%
\renewcommand*{\textbullet}{-}%
\renewcommand*{\textcopyright}{-}%
\renewcommand*{\textdagger}{-}%
\renewcommand*{\textdaggerdbl}{-}%
\renewcommand*{\textdollar}{-}%
\renewcommand*{\textellipsis}{-}%
\renewcommand*{\textemdash}{-}%
\renewcommand*{\textendash}{-}%
\renewcommand*{\textexclamdown}{-}%
\renewcommand*{\textgreater}{-}%
\renewcommand*{\textless}{-}%
\renewcommand*{\textordfeminine}{-}%
\renewcommand*{\textordmasculine}{-}%
\renewcommand*{\textparagraph}{-}%
\renewcommand*{\textperiodcentered}{-}%
\renewcommand*{\textpertenthousand}{-}%
\renewcommand*{\textperthousand}{-}%
\renewcommand*{\textquestiondown}{-}%
\renewcommand*{\textquotedblleft}{-}%
\renewcommand*{\textquotedblright}{-}%
\renewcommand*{\textquoteleft}{-}%
\renewcommand*{\textquoteright}{-}%
\renewcommand*{\textregistered}{-}%
\renewcommand*{\textsection}{-}%
\renewcommand*{\textsterling}{-}%
\renewcommand*{\texttrademark}{-}%
\renewcommand*{\textunderscore}{-}%
\renewcommand*{\textvisiblespace}{-}%
\renewcommand*{\copyright}{-}%
\renewcommand*{\dag}{-}%
\renewcommand*{\ddag}{-}%
\renewcommand*{\dots}{-}%
\renewcommand*{\P}{-}%
\renewcommand*{\pounds}{-}%
\renewcommand*{\S}{-}%
\renewcommand*{\aa}{a}%
\renewcommand*{\AA}{A}%
\renewcommand*{\AE}{AE}%
\renewcommand*{\ae}{ae}%
\renewcommand*{\dh}{d}%
\renewcommand*{\DH}{D}%
\renewcommand*{\DJ}{D}%
\renewcommand*{\dj}{d}%
\renewcommand*{\IJ}{IJ}%
\renewcommand*{\ij}{ij}%
\renewcommand*{\L}{L}%
\renewcommand*{\l}{l}%
\renewcommand*{\NG}{NG}%
\renewcommand*{\ng}{ng}%
\renewcommand*{\O}{O}%
\renewcommand*{\o}{o}%
\renewcommand*{\oe}{oe}%
\renewcommand*{\OE}{OE}%
\renewcommand*{\ss}{ss}%
\renewcommand*{\SS}{SS}%
\renewcommand*{\th}{th}%
\renewcommand*{\TH}{TH}%
\renewcommand*{\guillemotleft}{}%
\renewcommand*{\guilsinglleft}{}%
\renewcommand*{\quotedblbase}{}%
\renewcommand*{\textquotedbl}{}%
\renewcommand*{\guillemotright}{}%
\renewcommand*{\guilsinglright}{}%
\renewcommand*{\quotesinglbase}{}%
%    \end{macrocode}
%    \begin{macrocode}
\renewcommand*{\HTMLunicode}[1]{}%
\renewcommand*{\HTMLentity}[1]{}%
%    \end{macrocode}
%    \begin{macrocode}
\renewcommand{\textsuperscript}[1]{##1}%
\renewcommand{\textsubscript}[1]{##1}%
%    \end{macrocode}
% \changes{v0.50}{2018/02/20}{Fix: \cs{underline} in sectioning file name.}
%    \begin{macrocode}
\renewcommand{\underline}[1]{##1}%
%    \end{macrocode}
%    \begin{macrocode}
\RenewDocumentCommand{\LWR@htmlspanclass}{o m +m}{##3}%
\DeclareExpandableDocumentCommand{\InlineClass}{D{(}{)}{} o m +m}{##4}%
%    \end{macrocode}
% Nullify math macros.
% \changes{v0.55}{2018/04/24}{Removed extraneous space which appeared in file links.}
%    \begin{macrocode}
\def\(##1\){}%
\def\[##1\]{}%
\RenewDocumentCommand{\LWR@subsingledollar}{s m m m}{}%
\protected\def$##1${}%
%    \end{macrocode}
% Nullify logos:
% \changes{v0.66}{2019/02/01}{Logos.}
%    \begin{macrocode}
\renewcommand*{\TeX}{TeX}%
\renewcommand*{\LaTeX}{LaTeX}%
\renewcommand*{\LaTeXe}{LaTeX2e}%
\renewcommand*{\LuaTeX}{LuaTeX}%
\renewcommand*{\LuaLaTeX}{LuaLaTeX}%
\renewcommand*{\XeTeX}{XeTeX}%
\renewcommand*{\XeLaTeX}{XeLaTeX}%
\renewcommand*{\ConTeXt}{ConTeXt}%
\renewcommand*{\BibTeX}{BibTeX}%
\renewcommand*{\MakeIndex}{MakeIndex}%
\renewcommand*{\AmS}{AmS}%
\renewcommand*{\MiKTeX}{MiKTeX}%
\renewcommand*{\LyX}{LyX}%
%    \end{macrocode}
% Use the simpler form with \cs{texorpdfstring}:
% \changes{v0.52}{2018/03/31}{Fix: \cs{texorpdfstring} in section names.}
%    \begin{macrocode}
\let\texorpdfstring\relax%
\newcommand{\texorpdfstring}[2]{##2}%
}
\catcode`\$=3%
\catcode`\_=8%
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\FilenameNullify} \marg{redefinitions}
%
% Adds more nullifying definitions for filename generation.
%
% \changes{v0.67}{2019/02/13}{Added.}
%    \begin{macrocode}
\newcommand*{\FilenameNullify}[1]{%
    \appto{\LWR@nullfonts}{#1}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \changes{v0.48}{2018/02/02}{Improved font control.}

% Remembers the current font family, series, and shape.
%    \begin{macrocode}
\newcommand*{\LWR@f@family}{rm}
\newcommand*{\LWR@f@series}{md}
\newcommand*{\LWR@f@shape}{up}
%    \end{macrocode}


% \begin{macro}{\LWR@textcurrentfont} \marg{text}
%
% Prints the text with the current font choices.
% Avoids nesting repeated font selections.
%
% \changes{v0.48}{2018/02/02}{Added.  Improves font control.}
% \changes{v0.56}{2018/04/27}{Added \attribute{span.textbf}, etc.}
% \changes{v0.62}{2018/11/15}{Tracks depth to avoid nesting repeated font changes.}
%    \begin{macrocode}
\newcounter{LWR@textcurrentfontdepth}
\setcounter{LWR@textcurrentfontdepth}{0}

\newcommand*{\LWR@textcurrentfont}[1]{%
    \ifnumcomp{\value{LWR@textcurrentfontdepth}}{>}{0}%
        {%
            \addtocounter{LWR@textcurrentfontdepth}{1}%
            #1%
            \addtocounter{LWR@textcurrentfontdepth}{-1}%
        }%
        {%
            \addtocounter{LWR@textcurrentfontdepth}{1}%
            \InlineClass{%
                    text\LWR@f@family\LWR@origtilde{}%
                    text\LWR@f@series\LWR@origtilde{}%
                    text\LWR@f@shape%
                }%
                {#1}%
            \addtocounter{LWR@textcurrentfontdepth}{-1}%
        }%
}
%    \end{macrocode}
% \end{macro}

% \begin{environment}{LWR@blocktextcurrentfont}
%
% Prints the contents with the current font choices.
%
% \changes{v0.56}{2018/05/09}{Added \attribute{div.textbf}, etc.}
%    \begin{macrocode}
\newenvironment*{LWR@blocktextcurrentfont}{%
\BlockClass{%
        text\LWR@f@family\LWR@origtilde{}%
        text\LWR@f@series\LWR@origtilde{}%
        text\LWR@f@shape%
    }%
}{\endBlockClass}
%    \end{macrocode}
% \end{environment}


% \changes{v0.48}{2018/02/02}{Improved font control.}
% \changes{v0.50}{2018/02/20}{Robustify macros.}
%
% \begin{macro}{\mdseries}
%    \begin{macrocode}
\renewrobustcmd*{\mdseries}{\renewcommand*{\LWR@f@series}{md}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\bfseries}
%    \begin{macrocode}
\renewrobustcmd*{\bfseries}{\renewcommand*{\LWR@f@series}{bf}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\rmfamily}
%    \begin{macrocode}
\renewrobustcmd*{\rmfamily}{\renewcommand*{\LWR@f@family}{rm}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\sffamily}
%    \begin{macrocode}
\renewrobustcmd*{\sffamily}{\renewcommand*{\LWR@f@family}{sf}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\ttfamily}
%    \begin{macrocode}
\renewrobustcmd*{\ttfamily}{\renewcommand*{\LWR@f@family}{tt}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\upshape}
%    \begin{macrocode}
\renewrobustcmd*{\upshape}{\renewcommand*{\LWR@f@shape}{up}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\itshape}
%    \begin{macrocode}
\renewrobustcmd*{\itshape}{\renewcommand*{\LWR@f@shape}{it}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\scshape}
%    \begin{macrocode}
\renewrobustcmd*{\scshape}{\renewcommand*{\LWR@f@shape}{sc}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\sishape}
% \changes{v0.65}{2018/12/10}{Added \cs{sishape}.}
%    \begin{macrocode}
\@ifundefined{sishape}{
    \newrobustcmd*{\sishape}{\renewcommand*{\LWR@f@shape}{si}}
}{
    \renewrobustcmd*{\sishape}{\renewcommand*{\LWR@f@shape}{si}}
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\slshape}
% \changes{v0.62}{2018/11/11}{Added.}
%    \begin{macrocode}
\renewrobustcmd*{\slshape}{\renewcommand*{\LWR@f@shape}{sl}}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\normalfont}
%    \begin{macrocode}
\renewrobustcmd*{\normalfont}{\rmfamily\mdseries\upshape}
%    \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}
% \changes{v0.50}{2018/02/20}{Robustify macros.}
%    \begin{macrocode}
\renewrobustcmd{\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}
% \changes{v0.50}{2018/02/20}{Robustify macros.}
%    \begin{macrocode}
\AtBeginDocument{
\renewrobustcmd{\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 \progcode{FormatWP}, use explicit styles for
%   \cs{underline}, etc.}
%    \begin{macrocode}
\renewcommand{\underline}[1]{%
    \InlineClass%
        (text-decoration:underline; text-decoration-skip: auto)%
        {underline}{#1}%
}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@overline} \marg{text}
% \changes{v0.50}{2018/02/21}{Added.}
%    \begin{macrocode}
\newcommand{\LWR@overline}[1]{%
    \InlineClass%
        (text-decoration:overline; text-decoration-skip: auto)%
        {overline}{#1}%
}
%    \end{macrocode}
% \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@tempcolor}
% \begin{macro}{\LWR@tempcolortwo}
% The color converted to \HTML\ colorspace.
%    \begin{macrocode}
\newcommand*{\LWR@tempcolor}{}
\newcommand*{\LWR@tempcolortwo}{}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\LWR@findcurrenttextcolor}
% \changes{v0.51}{2018/03/14}{Added \cs{LWR@findcurrenttextcolor} when no \pkg{xcolor}.}
% Sets \cs{LWR@tempcolor} to the current color.
% \changes{v0.66}{2019/02/04}{Fix: Color if \pkg{xcolor} not loaded.}
%    \begin{macrocode}
\newcommand*{\LWR@findcurrenttextcolor}{%
\renewcommand{\LWR@tempcolor}{000000}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\LWR@textcurrentcolor} \marg{text}
% Like \cs{textcolor} but uses the current \cs{color} instead.
% \changes{v0.51}{2018/03/11}{\pkg{xcolor}: \cs{LWR@textcurrentcolor} if \pkg{xcolor} not loaded.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@textcurrentcolor}{m}{%
    \renewcommand*{\LWR@currenttextcolor}{black}%
    #1%
}
%    \end{macrocode}
% \end{macro}


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



% \codeprint
%    \begin{macrocode}
\begin{warpprint}
%    \end{macrocode}

% \begin{macro}{\LWR@textcurrentfont} \marg{text}
%
% Prints the text with the current font choices.
%
% \changes{v0.62}{2018/11/11}{Added print version.}
%    \begin{macrocode}
\newcommand*{\LWR@textcurrentfont}[1]{#1}
%    \end{macrocode}
% \end{macro}

% \begin{environment}{LWR@blocktextcurrentfont}
%
% Prints the contents with the current font choices.
%
% \changes{v0.62}{2018/11/11}{Added print version.}
%    \begin{macrocode}
\newenvironment*{LWR@blocktextcurrentfont}{}{}
%    \end{macrocode}
% \end{environment}

% \begin{macro}{\FilenameNullify} \marg{macros to nullify}
% \changes{v0.67}{2019/02/13}{Added.}
%    \begin{macrocode}
\newcommand*{\FilenameNullify}[1]{}
%    \end{macrocode}
% \end{macro}

%    \begin{macrocode}
\end{warpprint}
%    \end{macrocode}



% \section{Skips, spaces, font sizes}

% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
% \cs{,} and \cs{thinspace} may be redefined by other packages, so
% are redefined \cs{AtBeginDocument} here.
%
% Direct-formatting space commands become \HTML\ entities:
%
% \changes{v0.45}{2017/12/29}{Improved: Robust \cs{\,}, \cs{~}, and \cs{textellipsis} commands.}
% \changes{v0.56}{2018/05/09}{Added \cs{thinspace}.}
% \changes{v0.61}{2018/09/23}{Spaces redefined \cs{AtBeginDocument}.}
%    \begin{macrocode}
\AtBeginDocument{
\renewrobustcmd*{\,}{\HTMLunicode{202f}}	% HTML thin non-breakable space
\renewrobustcmd*{\thinspace}{\HTMLunicode{202f}}    % HTML thin non-breakable space
\renewrobustcmd*{\negthinspace}{\HTMLunicode{202f}}    % HTML thin non-breakable space
\renewrobustcmd*{~}{\HTMLentity{nbsp}}
\renewrobustcmd*{\textellipsis}{\HTMLunicode{2026}}
}
%    \end{macrocode}
%
% Direct-formatting font sizes are ignored:
%
% \changes{v0.58}{2018/06/07}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\newrobustcmd*{\LWR@HTML@normalsize}{}
\LWR@formatted{normalsize}

\newrobustcmd*{\LWR@HTML@small}{}
\LWR@formatted{small}

\newrobustcmd*{\LWR@HTML@footnotesize}{}
\LWR@formatted{footnotesize}

\newrobustcmd*{\LWR@HTML@scriptsize}{}
\LWR@formatted{scriptsize}

\newrobustcmd*{\LWR@HTML@tiny}{}
\LWR@formatted{tiny}

\newrobustcmd*{\LWR@HTML@large}{}
\LWR@formatted{large}

\newrobustcmd*{\LWR@HTML@Large}{}
\LWR@formatted{Large}

\newrobustcmd*{\LWR@HTML@LARGE}{}
\LWR@formatted{LARGE}

\newrobustcmd*{\LWR@HTML@huge}{}
\LWR@formatted{huge}

\newrobustcmd*{\LWR@HTML@Huge}{}
\LWR@formatted{Huge}
%    \end{macrocode}
%
% \changes{v0.49}{2018/02/18}{Fix: Adapt to classes.}
%    \begin{macrocode}
\DeclareDocumentCommand{\onecolumn}{}{}

\DeclareDocumentCommand{\twocolumn}{O{}}{

#1

}
%    \end{macrocode}


% \begin{macro}{\hfill}
% \changes{v0.20}{2016/12/12}{Inserts a \cs{qquad}.}
% \changes{v0.58}{2018/06/07}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\newcommand*{\LWR@HTML@hfill}{\qquad}
\LWR@formatted{hfill}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\hrulefill}
% \changes{v0.20}{2017/01/19}{Inserts a short rule.}
% \changes{v0.58}{2018/06/07}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\newcommand*{\LWR@HTML@hrulefill}{\rule{1in}{1pt}}
\LWR@formatted{hrulefill}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\dotfill}
% \changes{v0.20}{2017/01/19}{Inserts an ellipsis.}
% \changes{v0.58}{2018/06/07}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\newcommand*{\LWR@HTML@dotfill}{\dots}
\LWR@formatted{dotfill}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\newpage}
% \changes{v0.45}{2018/01/12}{Added.}
%    \begin{macrocode}
\renewcommand*{\newpage}{

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


% \begin{macro}{\newline}
% Uses the \HTML\ \element{br /} element.
% \changes{v0.50}{2018/02/20}{Robustify macros.}
%    \begin{macrocode}
\newrobustcmd*{\LWR@newlinebr}{\unskip\LWR@htmltag{br /}\LWR@orignewline}%
\LetLtxMacro\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{0pt}}
{%
\newline%
%    \end{macrocode}
% \changes{v0.62}{2018/10/14}{Extra space if optional arg.}
%    \begin{macrocode}
\setlength{\LWR@templengthone}{#2}%
\ifdimgreater{\LWR@templengthone}{0pt}{\newline}{}%
}
%    \end{macrocode}
% \end{macro}





% \begin{macro}{\LWR@minipagestartpars}
% \changes{v0.19}{2016/05/31}{Suppresses paragraph tags between minipages.}
% \gindex{minipage>horizontal space between}
% \gindex{space>horizontal>between minipages}
% \gindex{horizontal space>between minipages}
% \trouble{minipage>horizontal space between}
% 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
% suppresses 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 suppressed 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 suppress 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.
% Uses |2003 EM SPACE| to pass validation.
% \changes{v0.64}{2018/12/08}{Made robust.}
% \changes{v0.65}{2018/12/22}{Changed to Unicode EM SPACE.}
%    \begin{macrocode}
\renewrobustcmd*{\quad}{%
\LWR@minipagestoppars%
\HTMLunicode{2003}%
\LWR@minipagestartpars%
}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\qquad}
% Handles special minipage \& horizontal space interactions.
% \changes{v0.64}{2018/12/08}{Made robust.}
%    \begin{macrocode}
\renewrobustcmd*{\qquad}{\quad\quad}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\enskip}
% Handles special minipage \& horizontal space interactions.
% \changes{v0.64}{2018/12/08}{Made robust.}
% \changes{v0.65}{2018/12/22}{Changed to Unicode EN SPACE.}
%    \begin{macrocode}
\renewrobustcmd*{\enskip}{%
\LWR@minipagestoppars%
\HTMLunicode{2002}%
\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@select@html@hspace}
%
% \begin{macro}{\hspace} * \marg{length} * \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}
\newcommand{\LWR@select@html@hspace}{%
\RenewDocumentCommand{\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}
    {%
        \LWR@htmltagc{%
            span style="width:\LWR@printlength{\LWR@tempwidth};  % extra space
                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 \progcode{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}
% \end{macro}
%
% \begin{macro}{\LWR@select@html@nohspace}
%
% \begin{macro}{\hspace} * \marg{length}
%
% Used to disable \cs{hspace} while creating |description| \cs{item}s.
%    \begin{macrocode}
\newcommand{\LWR@select@html@nohspace}{%
    \RenewDocumentCommand{\hspace}{s m}{}%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}

% \begin{macro}{\LWR@select@print@hspace}
%    \begin{macrocode}
\newcommand*{\LWR@select@print@hspace}{%
    \renewrobustcmd\hspace{\@ifstar\@hspacer\@hspace}%
}
%    \end{macrocode}
% \end{macro}


%
%
% \begin{macro}{\hspace} * \marg{length}
%
% Handles special minipage \& horizontal space interactions.
%    \begin{macrocode}
\LWR@select@html@hspace
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@vspace} * \marg{length} Nullified vspace.
%
% \changes{v0.33}{2017/06/21}{Add: \cs{vspace} nullified.}
% \changes{v0.50}{2018/02/20}{Robustify macros.}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
%
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@vspace}{s m}{}

\LWR@formatted{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}{\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}
\newcommand*{\LWR@HTML@rule}[3][]{%
%    \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.
% \changes{v0.57}{2018/06/02}{Fix: Colored rules.}
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
    \LWR@findcurrenttextcolor%
    \LWR@htmltagc{%
    span\LWR@indentHTML%
    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:\LWR@printlength{\LWR@tempwidth} ; %
    height:\LWR@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}
    \ifblank{#1}%
    {}%
    {%
        \setlength{\LWR@tempraise}{0pt-#1}%
        \setlength{\LWR@tempraise}{\LWR@tempraise*2}%
        \LWR@indentHTML%
        -ms-transform: translate(0pt,\LWR@printlength{\LWR@tempraise}); %
        \LWR@indentHTML%
        -webkit-transform: translate(0pt,\LWR@printlength{\LWR@tempraise}); %
        \LWR@indentHTML%
        transform: translate(0pt,\LWR@printlength{\LWR@tempraise}); %
        \LWR@indentHTML%
    }%
%    \end{macrocode}
% Display inline-block to place the span inline with the text:
%    \begin{macrocode}
    display:inline-block;"\LWR@orignewline%
    }%
%    \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 \progcode{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
}

\LWR@formatted{rule}
%    \end{macrocode}
% \end{macro}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}




% \section{\cs{phantomsection}}

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

% \begin{macro}{\phantomsection}
% Emulate the \pkg{hyperref} \cs{phantomsection} command,
% often used to insert the bibliography into the table of contents.
% Ignores \cs{ForceHTMLTOC}.
% \changes{v0.55}{2018/04/26}{Fix: \cs{ForceHTMLTOC} with \cs{phantomsection}.}
%    \begin{macrocode}
\DeclareDocumentCommand{\phantomsection}{}{%
\begingroup%
\boolfalse{LWR@forcinghtmltoc}%
\section*{}%
\endgroup%
}
%    \end{macrocode}
% \end{macro}


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





% \section{\cs{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 \cs{let} in \cs{LWR@LwarpStart}.
%
% For \CSS\ conversions, see: \\
% \url{http://edward.oconnor.cx/2007/08/tex-poshlet} \\
% \url{http://nitens.org/taraborelli/texlogo} \\
% and the spacing described in the \pkg{metafont} package documentation.
%
%
%
% \subsection{\HTML\ logos}
%
% \changes{v0.62}{2018/10/23}{Logos: CSS instead of \element{sup}, \element{sub}.}
% \changes{v0.62}{2018/10/23}{Logos: Improved CSS.}
% \changes{v0.62}{2018/10/23}{Logos: Made robust.}
%
% \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 \progcode{FormatWP} use explicit style.}
%    \begin{macrocode}
\LetLtxMacro\LWR@origTeX\TeX

\newrobustcmd*{\LWR@TeX}
{%
    \InlineClass{latexlogofont}%
    {%
        \InlineClass{latexlogo}%
        {%
            T%
            \InlineClass{latexlogosub}{e}%
            X%
        }%
    }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LaTeX}
% \changes{v0.42}{2017/10/20}{If \progcode{FormatWP} use explicit style.}
% \begin{macro}{\LaTeXe} \LaTeX, \LaTeXe
%    \begin{macrocode}
\LetLtxMacro\LWR@origLaTeX\LaTeX

\newrobustcmd*{\LWR@LaTeX}
{%
    \InlineClass{latexlogofont}%
    {%
        \InlineClass{latexlogo}%
        {%
            L%
            \InlineClass{latexlogosup}{a}%
            T%
            \InlineClass{latexlogosub}{e}%
            X%
        }%
    }%
}

\LetLtxMacro\LWR@origLaTeXe\LaTeXe

\renewrobustcmd*{\LaTeXe}
{%
    \LaTeX%
    \InlineClass{latexlogofont}{%
        \InlineClass{latexlogotwoe}{%
            2%
            \InlineClass{latexlogotwoesub}{\HTMLunicode{03B5}}%
        }%
    }%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\LuaTeX}
% \begin{macro}{\LuaLaTeX} \LuaTeX, \LuaLaTeX
%    \begin{macrocode}
\newrobustcmd*{\LWR@LuaTeX}{\InlineClass{latexlogofont}{Lua}\TeX}
\newrobustcmd*{\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}
\newrobustcmd*{\Xe}
    {%
        X%
        \InlineClass{xelatexlogosub}{\HTMLunicode{18e}}%
    }

\newrobustcmd*{\LWR@XeTeX}{\InlineClass{xelatexlogo}{\Xe}\TeX}

\newrobustcmd*{\LWR@XeLaTeX}{\InlineClass{xelatexlogo}{\Xe}\LaTeX}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \begin{macro}{\ConTeXt} \ConTeXt
%    \begin{macrocode}
\newrobustcmd*{\LWR@ConTeXt}
{\InlineClass{latexlogofont}{Con}\TeX{}%
\InlineClass{latexlogofont}{t}}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\BibTeX}
% \begin{macro}{\MakeIndex} \BibTeX, \MakeIndex
%    \begin{macrocode}
\providerobustcmd*{\BibTeX}
{\InlineClass{latexlogofont}{B\textsc{ib}}\TeX}

\newrobustcmd*{\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%
            \InlineClass{latexlogosub}{M}%
            S%
        }%
    }%
}%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{macro}{\MiKTeX} \MiKTeX
%    \begin{macrocode}
\newrobustcmd*{\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}
\newrobustcmd*{\LyX}{\InlineClass{lyxlogo}{LyX}}
%    \end{macrocode}
% \end{macro}
%
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
%
%
% \subsection{Print logos}
%
% \changes{v0.62}{2018/10/23}{Logos: Fix for \XeTeX\ logo if \pkg{graphics} is not loaded.}
%
% \codeprint
%    \begin{macrocode}
\begin{warpprint}

\newrobustcmd*{\XeTeXrevE}
    {\hspace{-.1667em}\raisebox{-.5ex}{E}\hspace{-.125em}}

\AtBeginDocument{
\@ifpackageloaded{graphics}{
    \renewrobustcmd*{\XeTeXrevE}
        {\hspace{-.1667em}\raisebox{-.5ex}{\reflectbox{E}}\hspace{-.125em}}
}{
    \PackageWarning{lwarp}{Load graphicx or graphics
        for improved XeTeX logo}
}
}

\providerobustcmd*{\XeTeX}{\mbox{X\XeTeXrevE\TeX}}
\providerobustcmd*{\XeLaTeX}{\mbox{X\XeTeXrevE\LaTeX}}
\providerobustcmd*{\AmS}{%
    \leavevmode\hbox{$\mathcal A\kern-.2em\lower.376ex%
    \hbox{$\mathcal M$}\kern-.2em\mathcal S$}%
}
\newrobustcmd*{\LyX}{\textsf{LyX}}
\providerobustcmd*{\LuaTeX}{\mbox{Lua\TeX}}
\providerobustcmd*{\LuaLaTeX}{\mbox{Lua\LaTeX}}
\providerobustcmd*{\BibTeX}{\mbox{B\textsc{ib}\TeX}}
\providerobustcmd*{\MakeIndex}{\mbox{\textit{MakeIndex}}}
\providerobustcmd*{\ConTeXt}{\mbox{Con\TeX{}t}}
\providerobustcmd*{\MiKTeX}{\mbox{MiK\TeX}}
\end{warpprint}
%    \end{macrocode}


% \section{\cs{AtBeginDocument}, \cs{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}




% \section{Loading \brand{Koma-script} class patches}
%
% 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{Loading \brand{Memoir} class patches}
%
% Load patches to \pkg{memoir}.
%
% \changes{v0.45}{2017/12/03}{\pkg{memoir}: Added.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%    \begin{macrocode}
\@ifclassloaded{memoir}{\RequirePackage{lwarp-patch-memoir}}{}
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}



% \section{\pkg{ut*} class patches}
%
% Load patches to \pkg{uj*} and \pkg{ut*} classes, as well as \pkg{ltj*} classes.
%
% \changes{v0.64}{2018/12/07}{\pkg{ujarticle} and related: Improved \cs{today}.}
% \changes{v0.64}{2018/12/07}{Added \pkg{utarticle} and related.}
% \changes{v0.65}{2018/12/15}{Fix for \cs{rensuji}.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\LWR@patchujtclasses}{
%    \end{macrocode}
%
% \pkg{uj/t} does not use \cs{partname}
%    \begin{macrocode}
    \def\@partnameformat{}
%    \end{macrocode}
%    \begin{macrocode}
    \def\@partcntformat##1{%
        \prepartname%
        \csname the##1\endcsname%
        \postpartname%
        \quad%
    }
    \@ifundefined{chapter}{}{
        \def\@chapcntformat##1{%
            \prechaptername%
            \csname the##1\endcsname%
            \postchaptername%
            \quad%
        }
    }
%    \end{macrocode}
% Use decimal points instead of centered dots:
%    \begin{macrocode}
    \renewcommand{\thepart}{\@Roman\c@part}
    \@ifundefined{chapter}{
        \renewcommand{\thesection}{\@arabic\c@section}
    }{
        \renewcommand{\thechapter}{\@arabic\c@chapter}
        \renewcommand{\thesection}{\thechapter.\@arabic\c@section}
    }
    \renewcommand{\thesubsection}{\thesection.\@arabic\c@subsection}
    \renewcommand{\thesubsubsection}{%
    \thesubsection.\@arabic\c@subsubsection}
    \renewcommand{\theparagraph}{%
    \thesubsubsection.\@arabic\c@paragraph}
    \renewcommand{\thesubparagraph}{%
    \theparagraph.\@arabic\c@subparagraph}
    \@ifundefined{chapter}{
        \renewcommand{\thefigure}{\@arabic\c@figure}
        \renewcommand{\thetable}{\@arabic\c@table}
    }{
        \renewcommand{\thefigure}{%
        \ifnum\c@chapter>\z@\thechapter.\fi\@arabic\c@figure}
        \renewcommand{\thetable}{%
        \ifnum\c@chapter>\z@\thechapter.\fi\@arabic\c@table}
    }
}

\@ifclassloaded{ujarticle}{\LWR@patchujtclasses}{}
\@ifclassloaded{ujbook}{\LWR@patchujtclasses}{}
\@ifclassloaded{ujreport}{\LWR@patchujtclasses}{}
\@ifclassloaded{utarticle}{\LWR@patchujtclasses}{}
\@ifclassloaded{utbook}{\LWR@patchujtclasses}{}
\@ifclassloaded{utreport}{\LWR@patchujtclasses}{}
\@ifclassloaded{ltjarticle}{\LWR@patchujtclasses}{}
\@ifclassloaded{ltjbook}{\LWR@patchujtclasses}{}
\@ifclassloaded{ltjreport}{\LWR@patchujtclasses}{}
\@ifclassloaded{ltjsarticle}{\LWR@patchujtclasses}{}
\@ifclassloaded{ltjsbook}{\LWR@patchujtclasses}{}
\@ifclassloaded{ltjsreport}{\LWR@patchujtclasses}{}
\@ifclassloaded{ltjskiyou}{\LWR@patchujtclasses}{}
\@ifclassloaded{ltjspf}{\LWR@patchujtclasses}{}
\@ifclassloaded{ltjtarticle}{\LWR@patchujtclasses}{}
\@ifclassloaded{ltjtbook}{\LWR@patchujtclasses}{}
\@ifclassloaded{ltjtreport}{\LWR@patchujtclasses}{}
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}


% ^^A *ctex
% \section{C\TeX\ patches}
%
% Patches for \pkg{ctex} and related classes,
% which are loaded before \pkg{lwarp}.
%
% All C\TeX\ classes and the \pkg{ctex} package seem to
% load \pkg{ctexpatch}, so its presence is used to
% decide whether to have \pkg{lwarp} patch C\TeX.
%
% \changes{v0.62}{2018/11/17}{\pkg{ctexpatch}: Added patch.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
% \cs{AtBeginDocument} in case the user set |FileSectionNames| in the preamble.
%
%    \begin{macrocode}
\AtBeginDocument{
    \@ifpackageloaded{ctexpatch}{%
        \def\@partcntformat#1{%
            \LWR@isolate{\CTEX@partname}~%
            \CTEX@part@aftername%
        }%

        \def\@partnameformat{}

        \def\@chapcntformat#1{%
            \LWR@isolate{\CTEX@chaptername}~%
            \CTEX@chapter@aftername%
        }%
    }{}
}
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
%
%
% ^^A *kotexutf
% \section{\pkg{kotexutf} patches}
%
% Patch for \pkg{kotexutf}, which is loaded before \pkg{lwarp}.
%
% \pkg{kotexutf}'s \cs{@setref} was conflicting with \pkg{lwarp}'s
% cross references.
%
% \changes{v0.66}{2019/01/29}{\pkg{kotexutf}: Patch for references.}
%
% \codehtml
%    \begin{macrocode}
\begin{warpHTML}
%    \end{macrocode}
%
% If \pkg{kotexutf}'s version of \cs{@setref} is detected,
% it is reverted to the original.
%    \begin{macrocode}
\AtBeginDocument{
\@ifpackageloaded{kotexutf}{%
    \def\LWR@kotexutf@setref#1#2#3{%
        \@setref@dhucs@orig{#1}{#2}{#3}%
      \ifx#1\relax\else
        \bgroup
        \dhucs@make@cjkchar@null
        \edef\@temp{\expandafter#2#1}\global\josatoks\expandafter{\@temp}%
        \egroup
      \fi%
    }%

    \ifdefequal{\@setref}{\LWR@kotexutf@setref}{
        \let\@setref\@setref@dhucs@orig
    }{}
}{}
}
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
%
% \iffalse
%</package>
% \fi
%
%
%
%
%
%
%
%
% \changes{v0.20}{2016/12/12}{Code factored into independent \filenm{lwarp_html} files.}
%
% ^^A 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
%
%
%
% \changes{v0.66}{2018/12/29}{Package dates added where possible.}
%
%
% \iffalse
%<*2in1>
% \fi
%
% \part{lwarp-2in1.sty}
%
% \section{2in1}
%
% \DescribePackage{2in1}
% \pkg{2in1} is ignored.
%
% \changes{v0.62}{2018/10/16}{\pkg{2in1}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{2in1}
%    \end{macrocode}
%
% \iffalse
%</2in1>
% \fi
%
%
%
%
% \iffalse
%<*2up>
% \fi
%
% \part{lwarp-2up.sty}
%
% \section{2up}
%
% \DescribePackage{2up}
% \pkg{2up} is ignored.
%
% \changes{v0.60}{2018/09/18}{\pkg{2up}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{2up}[2010/05/15]
%    \end{macrocode}
%
%    \begin{macrocode}
\def\source#1#2#3{}
\def\target#1#2#3{}
\def\targetlayout#1{}
\newdimen\pageseplength
\newdimen\pagesepwidth
\newdimen\pagesepoffset
\def\twoupemptypage{}
\def\twoupclearpage{}
\def\twoupeject{}
\def\twouparticle{}
\def\twoupplain{}
\def\twouplegaltarget{}
\def\twouplandscape{}
\def\TwoupWrites{}
%    \end{macrocode}
%
% \iffalse
%</2up>
% \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}[2004/04/15]
%    \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}[1994/08/30]
%    \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
%
% \pkg{memoir} provides an \env{abstract} environment even though it
% is not an \pkg{article} or \pkg{report} class.
% Meanwhile, \pkg{lwarp} loads \pkg{book} to
% emulate \pkg{memoir}, but \pkg{book} does not have an \env{abstract}
% environment, so when the \pkg{abstract} package is loaded for emulation there
% is no pre-existing \env{abstract} to redefine, which would cause an error.
% Thus, a null \env{abstract} is provide here:
%    \begin{macrocode}
\ProvideDocumentEnvironment{abstract}{}{}{}
%    \end{macrocode}
%
% Accept all options for \pkg{lwarp-abstract}:
%    \begin{macrocode}
\LWR@ProvidesPackagePass{abstract}[2009/06/08]
%    \end{macrocode}


%    \begin{macrocode}
\AtBeginDocument{
\BeforeBeginEnvironment{abstract}{
\LWR@forcenewpage
\BlockClass{abstract}
}
\AfterEndEnvironment{abstract}{\endBlockClass}
}

\renewcommand{\@bsrunintitle}{%
\hspace*{\abstitleskip}%
{\abstractnamefont%
\InlineClass{abstractrunintitle}{\abstractname}%
\@bslabeldelim}%
}

\@ifclassloaded{memoir}
{
  \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
    }
}{% not memoir
\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
}% not memoir
%    \end{macrocode}

% \iffalse
%</abstract>
% \fi
%
%
%
%
%
% \iffalse
%<*academicons>
% \fi
%
% \part{lwarp-academicons.sty}
%
% \section{academicons}
%
% \credits{Diogo A. B. Fernandes}
%
% \DescribePackage{academicons}
% \pkg{academicons} is patched for use by \pkg{lwarp}.
%
% If \cs{aiicon} is used, the name of the icon is used in the \attribute{alt} tag.
% Otherwise, for each of the individual icon macros, a generic \attribute{alt} tag is used.
%
% \changes{v0.67}{2019/02/23}{\pkg{academicons}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{academicons}[2018/06/27]
%    \end{macrocode}
%
%    \begin{macrocode}
\LetLtxMacro\LWR@orig@symbol\symbol

\let\LWR@academicons@orig@AI\AI

\newcommand*{\LWR@academicons@symbol}[1]{%
    \begin{lateximage}*[(academicon)][academicons#1]%
    \begingroup%
    \LWR@academicons@orig@AI%
    \LWR@orig@symbol{#1}%
    \endgroup%
    \end{lateximage}%
}

\renewcommand*{\AI}{%
    \LetLtxMacro\symbol\LWR@academicons@symbol%
}

\renewcommand*{\aiicon}[1]
{%
    \begin{lateximage}*[(#1 icon)][academicons#1]%
    \AI\csname aiicon@#1\endcsname%
    \end{lateximage}%
}
%    \end{macrocode}
%
% \iffalse
%</academicons>
% \fi
%
%
%
%
%
% \iffalse
%<*accsupp>
% \fi
%
% \part{lwarp-accsupp.sty}
%
% \section{accsupp}
%
% \DescribePackage{accsupp}
% \pkg{accsupp} is ignored.
%
% \changes{v0.59}{2018/07/25}{\pkg{accsupp}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{accsupp}[2018/03/28]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\BeginAccSupp}[1]{}
\newcommand*{\EndAccSupp}[1]{}
%    \end{macrocode}
%
% \iffalse
%</accsupp>
% \fi
%
%
%
% \iffalse
%<*acro>
% \fi
%
% \part{lwarp-acro.sty}

% \section{acro}
%
% \credits{Clemens Niederberger}
%
% \DescribePackage{acro}
% \pkg{acro} is patched for use by \pkg{lwarp}.
%
% \changes{v0.48}{2018/02/02}{\pkg{acro}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{acro}[2017/01/30]
%    \end{macrocode}


% \cs{DeclareAcronym} is used in the preamble,
% where \pkg{lwarp} has not yet made the dollar active,
% so temporarily enable \pkg{lwarp} math catcode just for this
% definition:
%    \begin{macrocode}
\ExplSyntaxOn
\NewDocumentCommand \LWR@DeclareAcronym {mm}
{
    \acro_declare_acronym:nn {#1} {#2}
    \catcode`\$=3% lwarp
}
\ExplSyntaxOff

\RenewDocumentCommand{\DeclareAcronym}{}{
    \catcode`\$=\active% lwarp
    \LWR@DeclareAcronym
}
%    \end{macrocode}

% Modified to activate the current font:
%    \begin{macrocode}
\ExplSyntaxOn
\cs_gset_protected:Npn \acro_write_short:nn #1#2
  {
    \mode_if_horizontal:F { \leavevmode }
    \group_begin:
      \bool_if:NTF \l__acro_custom_format_bool
        { \l__acro_custom_format_tl }
        { \l__acro_short_format_tl }
      {\LWR@textcurrentfont{#2}}% lwarp
    \group_end:
  }

\cs_gset_protected:Npn \acro_write_alt:nn #1#2
  {
    \mode_if_horizontal:F { \leavevmode }
    \group_begin:
      \bool_if:NTF \l__acro_custom_format_bool
        { \l__acro_custom_format_tl }
        { \l__acro_alt_format_tl }
      {\LWR@textcurrentfont{#2}}% lwarp
    \group_end:
  }

\cs_gset_protected:Npn \acro_write_long:nn #1#2
  {
    \mode_if_horizontal:F { \leavevmode }
    \group_begin:
      \bool_if:NTF \l__acro_custom_long_format_bool
        { \l__acro_custom_long_format_tl }
        { \use:n }
      {
        \use:x
          {
            \exp_not:n {#1}
            {
              \bool_if:NTF \l__acro_first_upper_bool
                { \exp_not:N \__acro_first_upper_case:n { \exp_not:n {
                    \LWR@textcurrentfont{#2}% lwarp
                } } }
                { \exp_not:n {\LWR@textcurrentfont{#2}} }% lwarp
            }
          }
      }
    \group_end:
  }
\ExplSyntaxOff
%    \end{macrocode}

% \iffalse
%</acro>
% \fi
%
%
%
%
% \iffalse
%<*acronym>
% \fi
%
% \part{lwarp-acronym.sty}

% \section{acronym}
%
% \credits{Tobias Oetiker}
%
% \DescribePackage{acronym}
% \pkg{acronym} is patched for use by \pkg{lwarp}.
%
% \cs{acresetall} does not work with \pkg{cleveref},
% \trouble[multiply-defined labels]{multiply-defined labels>acronym=\pkg{acronym}}
% \trouble{acronym=\pkg{acronym}>multiply-defined labels}
% causing multiply-defined labels.
% \pkg{lwarp} patches \pkg{acronym} for \HTML, but not for print mode.
%
% \changes{v0.48}{2018/02/02}{\pkg{acronym}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{acronym}[2015/03/21]
%    \end{macrocode}

% Uses \cs{textit} instead of \cs{itshape}:
%    \begin{macrocode}
\renewcommand{\acfia}[1]{%
  {\textit{\AC@acl{#1}}} (\ifAC@starred\acs*{#1}\else\acs{#1}\fi)}
%    \end{macrocode}


% Removes the mbox to allow math inside:
%    \begin{macrocode}
\renewcommand*\AC@acs[1]{%
%     \mbox{
 \expandafter\AC@get\csname fn@#1\endcsname\@firstoftwo{#1}}
% }
%    \end{macrocode}

% Fix for acronym labels in the captions of floats.
% \changes{v0.66}{2019/01/28}{\pkg{acronym}: Fix for acronym in caption.}
%    \begin{macrocode}
\renewcommand{\@starttoc}[1]{
\LWR@htmlelementclass{nav}{#1}
\LetLtxMacro\@verridelabel\@gobble
\LWR@orig@starttoc{#1}
\LWR@htmlelementclassend{nav}{#1}
}
%    \end{macrocode}


% Modified for \pkg{cleveref} and \pkg{lwarp}:
% \changes{v0.66}{2019/01/27}{\pkg{acronym}: No longer uses \pkg{zref}.}
%    \begin{macrocode}
\renewcommand*\AC@und@newl@bel[3]{%
    \@ifundefined{#1@#3}%
    {%
        \global\expandafter\let\csname#2@#3\endcsname\@nnil
        \global\expandafter\let\csname#2@#3@lwarp\endcsname\@nnil% lwarp
        \global\expandafter\let\csname#2@#3@cref\endcsname\@nnil% lwarp
    }%
    {%
        \global\expandafter\let\csname#1@#3\endcsname\relax
        \global\expandafter\let\csname#1@#3@lwarp\endcsname\relax% lwarp
        \global\expandafter\let\csname#1@#3@cref\endcsname\relax% lwarp
    }%
}%
%    \end{macrocode}

% \iffalse
%</acronym>
% \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}[2012/01/20]
%    \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}
% Create the \element{div} with the given margin and class:
% \changes{v0.47}{2018/01/26}{\pkg{adjmulticol}: Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\BlockClass[%
\LWR@print@mbox{margin-left:\LWR@printlength{\LWR@templengthone}} ; %
\LWR@print@mbox{margin-right:\LWR@printlength{\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.}
% \changes{v0.64}{2018/12/06}{\pkg{addlines}: Updated to v0.3.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{addlines}[2018/12/05]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand\addlines{\@ifstar\addlines@a\addlines@a}
\newcommand\addlines@a[1][1]{}
\let\addline\addlines
\newcommand\removelines{\@ifstar\removelines@a\removelines@a}
\newcommand\removelines@a[1][1]{}
\let\removeline\removelines
\newcommand\squeezepage[1][0]{}
%    \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}[2014/10/28]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\afterpage}[1]{#1}
%    \end{macrocode}
%
% \iffalse
%</afterpage>
% \fi
%
%
%
% \iffalse
%<*algorithm2e>
% \fi
%
% \part{lwarp-algorithm2e.sty}

% \section{algorithm2e}
%
% \credits{Christophe Fiorio}
%
% \DescribePackage{algorithm2e}
% \pkg{algorithm2e} is patched for use by \pkg{lwarp}.
%
% \changes{v0.57}{2018/05/20}{\pkg{algorithm2e}: Added.}
%
% For print output, captions are placed according to package options,
% but for \HTML\ output captions are placed where used.
% Therefore, to have captions appear at the top of the algorithms for both
% print and \HTML, place each captions at the top of each algorithm.
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{algorithm2e}[2017/07/18]
%    \end{macrocode}

% For the list-of entries:
%    \begin{macrocode}
\renewcommand{\l@algocf}[2]{\hypertocfloat{1}{algocf}{loa}{#1}{#2}}
%    \end{macrocode}
%
%
% Select the \pkg{lwarp} float style according to the \pkg{algorithm2e} style:
%    \begin{macrocode}
\newcommand*{\LWR@floatstyle@algocf}{ruled}

\ifdefstring{\algocf@style}{boxed}{%
\renewcommand*{\LWR@floatstyle@algocf}{boxed}
}{}

\ifdefstring{\algocf@style}{boxruled}{%
\renewcommand*{\LWR@floatstyle@algocf}{boxruled}
}{}

\ifdefstring{\algocf@style}{plain}{%
\renewcommand*{\LWR@floatstyle@algocf}{plain}
}{}
%    \end{macrocode}
%
%
% Paragraph handling to allow line numbers under certain conditions:
%    \begin{macrocode}
\newbool{LWR@algocf@dopars}
\booltrue{LWR@algocf@dopars}

\renewcommand{\algocf@everypar}{%
\ifbool{LWR@algocf@dopars}{%
    \ifbool{LWR@doingstartpars}{%
        \ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
            {}%
            {%
                \algocf@everyparnl\algocf@everyparhanging%
            }%
    }{}%
}{}%
}
%    \end{macrocode}
%
%
% \pkg{lwarp} caption handling:
%    \begin{macrocode}
\renewcommand{\algocf@makecaption}[2]{%
\LWR@HTML@caption@begin{algocf}%
\LWR@isolate{\algocf@captiontext{#1}{#2}}%
\LWR@HTML@caption@end%
}
%    \end{macrocode}
%
%
% Print any caption where it is declared:
%    \begin{macrocode}
\renewcommand{\algocf@makecaption@plain}[2]{%
    \LWR@HTML@caption@begin{algocf}%
    \LWR@isolate{\algocf@captiontext{#1}{#2}}%
    \LWR@HTML@caption@end%
}

\renewcommand{\algocf@makecaption@boxed}[2]{%
    \LWR@HTML@caption@begin{algocf}%
    \LWR@isolate{\algocf@captiontext{#1}{#2}}%
    \LWR@HTML@caption@end%
}

\renewcommand{\algocf@makecaption@ruled}[2]{%
    \LWR@HTML@caption@begin{algocf}%
    \LWR@isolate{\algocf@captiontext{#1}{#2}}%
    \LWR@HTML@caption@end%
}
%    \end{macrocode}
%
%
% Turn off line numbering while making the caption:
%    \begin{macrocode}
\long\def\algocf@latexcaption#1[#2]#3{% original definition of caption
\boolfalse{LWR@algocf@dopars}%  lwarp
  \par%
  \addcontentsline{\csname ext@#1\endcsname}{#1}%
  {\protect\numberline{\csname the#1\endcsname}{\ignorespaces \LWR@isolate{#2}}}%
  \begingroup%
  \@parboxrestore%
  \if@minipage%
    \@setminipage%
  \fi%
  \normalsize%
  \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par%
  \endgroup%
\booltrue{LWR@algocf@dopars}%   lwarp
}
%    \end{macrocode}
%
%
% Line numbers are printed in a \element{span} of class \attribute{alg2elinenumber}:
%    \begin{macrocode}
\renewcommand{\algocf@printnl}[1]{%
    \InlineClass{alg2elinenumber}{\NlSty{#1}}~%
}%
%    \end{macrocode}
%
%
% While initializing an algorithm environment,
% locally declare the style of a regular figure to be the same as the algorithm style,
% in case the \optn{figure} option was used.
%    \begin{macrocode}
\preto\@algocf@init{%
  \edef\LWR@floatstyle@figure{\LWR@floatstyle@algocf}%
}
%    \end{macrocode}
%
%
% For \pkg{lwarp}, the algorithm is not assembled inside a box,
% since \env{lateximage}s would not work, so the captions are
% printed where declared.
%    \begin{macrocode}
\renewcommand{\@algocf@start}{%
    \let\@mathsemicolon=\;\def\;{\ifmmode\@mathsemicolon\else\@endalgoln\fi}%
%     \raggedright%
    \AlFnt{}%
    \booltrue{LWR@algocf@dopars}% lwarp
}

\renewcommand{\@algocf@finish}{%
    \boolfalse{LWR@algocf@dopars}% lwarp
    \lineskip\normallineskip\setlength{\skiptotal}{\@defaultskiptotal}%
    \let\;=\@mathsemicolon%  
    \let\]=\@emathdisplay%
}
%    \end{macrocode}
%
%
% Use an \HTML\ break:
%    \begin{macrocode}
\renewcommand{\BlankLine}{%
\LWR@stoppars%
\LWR@htmltagc{br /}%
\LWR@startpars%
}
%    \end{macrocode}
%
%
% Simplified for \HTML.
% The paragraph handling must be preserved.
%    \begin{macrocode}
\renewcommand{\SetKwInOut}[2]{%
  \algocf@newcommand{#1}[1]{%
    \ifthenelse{\boolean{algocf@hanginginout}}%
        {\relax}%
        {\algocf@seteveryparhanging{\relax}}%
    \ifthenelse{\boolean{algocf@inoutnumbered}}%
        {\relax}%
        {\algocf@seteveryparnl{\relax}}%
    {%
            \KwSty{#2\algocf@typo:}%
        ~##1\par%
    }%
    \algocf@linesnumbered% reset the numbering of the lines
    \ifthenelse{\boolean{algocf@hanginginout}}%
        {\relax}%
        {\algocf@reseteveryparhanging}%
  }%
}%

\renewcommand{\ResetInOut}[1]{}%
%    \end{macrocode}
%
%
% Each of the following creates a \element{div} of a given class,
% and turns off line numbering while creating the \element{div} tags:
%    \begin{macrocode}
\renewcommand{\algocf@Vline}[1]{%
\boolfalse{LWR@algocf@dopars}%
\begin{BlockClass}{alg2evline}
\booltrue{LWR@algocf@dopars}%
#1
\boolfalse{LWR@algocf@dopars}%
\end{BlockClass}
\booltrue{LWR@algocf@dopars}%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand{\algocf@Vsline}[1]{%
\boolfalse{LWR@algocf@dopars}%
\begin{BlockClass}{alg2evsline}
\booltrue{LWR@algocf@dopars}%
#1
\boolfalse{LWR@algocf@dopars}%
\end{BlockClass}
\booltrue{LWR@algocf@dopars}%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand{\algocf@Noline}[1]{%
\boolfalse{LWR@algocf@dopars}%
\begin{BlockClass}{alg2enoline}
\booltrue{LWR@algocf@dopars}%
#1
\boolfalse{LWR@algocf@dopars}%
\end{BlockClass}
\booltrue{LWR@algocf@dopars}%
}
%    \end{macrocode}
%
%
% The |[H]| environment is converted to a regular float, which in \HTML\
% is placed where declared.  Reusing the regular float allows the |[H]|
% version to reuse the ruled and boxed options.
%    \begin{macrocode}
\LetLtxMacro\algocf@Here\algocf
\LetLtxMacro\endalgocf@Here\endalgocf
%    \end{macrocode}

% \iffalse
%</algorithm2e>
% \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}[2005/04/27]
%    \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 \progcode{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%
\LWR@htmltagc{%
span style="width:\LWR@printlength{\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}[1997/06/16]
%    \end{macrocode}
%
%    \begin{macrocode}
\AfterEndPreamble{
\LWR@traceinfo{Patching alltt.}
\AtBeginEnvironment{alltt}{%
\LWR@forcenewpage
\LWR@atbeginverbatim{3}{alltt}%
}
\AfterEndEnvironment{alltt}{%
    \LWR@afterendverbatim{2}%
}
}
%    \end{macrocode}
%
% \iffalse
%</alltt>
% \fi
%
%
%
%
%
% \iffalse
%<*amsmath>
% \fi
%
% \part{lwarp-amsmath.sty}
%
% \section{amsmath}
%
% \credits{American Mathematical Society, \LaTeX3 Project}
%
% \DescribePackage{amsmath}
% \pkg{amsmath} is patched for use by \pkg{lwarp}.
%
% \changes{v0.33}{2016/06/21}{\pkg{amsmath}: Removed \optn{fleqn} option.}
% \changes{v0.59}{2018/07/13}{\pkg{amsmath}: Moved from the \pkg{lwarp} core.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{amsmath}[2017/09/02]
%    \end{macrocode}
%
% Patches to allow \cs{eqref} inside a caption:
%
% \changes{v0.49}{2018/02/18}{\pkg{amsmath}: Fix: Patches for \cs{eqref}.}
% \changes{v0.50}{2018/03/02}{\pkg{amsmath}: Fix: Upright tags for \SVG math.}
%    \begin{macrocode}
\def\maketag@@@#1{\text{#1}}
\def\tagform@#1{\maketag@@@{(\ignorespaces#1\unskip)}}
%    \end{macrocode}

% Patches for \AmS\ math \cs{tag} macro to remember the first tag:
%    \begin{macrocode}
\ifbool{mathjax}{}{% not mathjax

\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
%    \end{macrocode}
%
% The following \AmS\ environments are more easily patched in-place:
%
% \changes{v0.44}{2017/11/16}{AMS environments: Fix: Groups for \env{lateximage}s.}
% \changes{v0.50}{2018/03/01}{AMS environments: Improved \SVG\ math display.}
% \changes{v0.51}{2018/03/11}{AMS environments: Fix: \cs{addcontentsline} inside \SVG\ math.  Provides an autoid anchor.}
% \changes{v0.67}{2019/02/17}{AMS environments: Added \pkg{xfakebold} support.}
%
% \begin{environment}{multline}
%    \begin{macrocode}
\BeforeBeginEnvironment{multline}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@syncmathjax
    \booltrue{LWR@amsmultline}
    \LWR@beginhideamsmath
}
{
    \begin{BlockClass}{displaymathnumbered}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[\LWR@amsmathbodynumbered{multline}]
    \LWR@applyxfakebold%
}
}

\AfterEndEnvironment{multline}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \boolfalse{LWR@amsmultline}
    \LWR@addmathjax{multline}{\the\@envbody}
}
{\end{lateximage}\end{BlockClass}}

}
%    \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{BlockClass}{displaymath}
    \LWR@newautoidanchor
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[\LWR@amsmathbody{multline*}]
    \LWR@applyxfakebold%
}
}

\AfterEndEnvironment{multline*}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \boolfalse{LWR@amsmultline}
    \LWR@addmathjax{multline*}{\the\@envbody}
}
{\end{lateximage}\end{BlockClass}}

}

%    \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{BlockClass}{displaymathnumbered}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[\LWR@amsmathbodynumbered{gather}]
    \LWR@applyxfakebold%
}
}

\AfterEndEnvironment{gather}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \LWR@addmathjax{gather}{\the\@envbody}
}
{\end{lateximage}\end{BlockClass}}

}
%    \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{BlockClass}{displaymath}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[\LWR@amsmathbody{gather*}]
    \LWR@applyxfakebold%
}
}

\AfterEndEnvironment{gather*}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \LWR@addmathjax{gather*}{\the\@envbody}
}
{\end{lateximage}\end{BlockClass}}

}
%    \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{BlockClass}{displaymathnumbered}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[\LWR@amsmathbodynumbered{align}]
    \LWR@applyxfakebold%
}
}

\AfterEndEnvironment{align}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \LWR@addmathjax{align}{\the\@envbody}
}
{\end{lateximage}\end{BlockClass}}

}
%    \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{BlockClass}{displaymath}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[\LWR@amsmathbody{align*}]
    \LWR@applyxfakebold%
}
}

\AfterEndEnvironment{align*}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \LWR@addmathjax{align*}{\the\@envbody}
}
{\end{lateximage}\end{BlockClass}}

}
%    \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{BlockClass}{displaymathnumbered}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[\LWR@amsmathbodynumbered{flalign}]
    \LWR@applyxfakebold%
}
}

\AfterEndEnvironment{flalign}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \LWR@addmathjax{flalign}{\the\@envbody}
}
{\end{lateximage}\end{BlockClass}}

}
%    \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{BlockClass}{displaymath}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[\LWR@amsmathbody{flalign*}]
    \LWR@applyxfakebold%
}
}

\AfterEndEnvironment{flalign*}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \LWR@addmathjax{flalign*}{\the\@envbody}
}
{\end{lateximage}\end{BlockClass}}

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


% \begin{environment}{alignat}
% \changes{v0.51}{2018/03/11}{Fix: Added.}
%    \begin{macrocode}
\BeforeBeginEnvironment{alignat}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@syncmathjax
    \boolfalse{LWR@amsmultline}
    \LWR@beginhideamsmath
}
{
    \begin{BlockClass}{displaymathnumbered}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[\LWR@amsmathbodynumbered{alignat}]
    \LWR@applyxfakebold%
}
}

\AfterEndEnvironment{alignat}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \LWR@addmathjax{alignat}{\the\@envbody}
}
{\end{lateximage}\end{BlockClass}}

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


% \begin{environment}{alignat*}
%    \begin{macrocode}
\BeforeBeginEnvironment{alignat*}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@syncmathjax
    \boolfalse{LWR@amsmultline}
    \LWR@beginhideamsmath
}
{
    \begin{BlockClass}{displaymath}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[\LWR@amsmathbody{alignat*}]
    \LWR@applyxfakebold%
}
}

\AfterEndEnvironment{alignat*}{

\ifboolexpr{bool{mathjax} or ( bool{FormatWP} and bool{WPMarkMath} ) }%
{
    \LWR@endhideamsmath
    \LWR@addmathjax{alignat*}{\the\@envbody}
}
{\end{lateximage}\end{BlockClass}}

}
%    \end{macrocode}
% \end{environment}
%
% \iffalse
%</amsmath>
% \fi
%
%
%
%
%
% \iffalse
%<*amsthm>
% \fi

% \part{lwarp-amsthm.sty}

% \section{amsthm}
%
% \credits{Publications Technical Group \Dash American Mathematical Society}
%
% The original source code is located in |amsclass.dtx|, and printed in
% |amsclass.pdf|.
%
% \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{\pkg{amsthm} package \Dash \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
%
% \pkg{amsthm} must be loaded before \pkg{mdframed}:
% \changes{v0.63}{2018/12/01}{\pkg{amsthm}, \pkg{mdframed}: Fix for enforced load order.}
%    \begin{macrocode}
\@ifpackageloaded{mdframed}{
    \PackageError{lwarp}
    {Package mdframed must be loaded after package amsthm.}
    {%
        Move \detokenize{\usepackage}{amsthm} before \detokenize{\usepackage}{mdframed}.
        Package amsthm may be loaded by something else, which must also be moved
        before mdframed.%
    }
}
{}
%    \end{macrocode}
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{amsthm}[2017/10/31]
%    \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}% lwarp
  }{%
    \thm@style{#1}%
    \renewcommand{\LWR@newtheoremstyle}{#1}% lwarp
  }%
}
%    \end{macrocode}

% Patched to remember the style for this theorem type:
%    \begin{macrocode}
\def\@xnthm#1#2{%
  \csedef{LWR@thmstyle#2}{\LWR@newtheoremstyle}% lwarp
  \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{\@nameuse{LWR@thmstyle#2}}}% lwarp
  }%
  \@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]{%
    \item[
%   \deferred@thm@head{
%     \the\thm@headfont \thm@indent
    \@ifempty{#1}{\let\thmname\@gobble}{\LWR@haveamsthmname}% lwarp
    \@ifempty{#2}{\let\thmnumber\@gobble}{\LWR@haveamsthmnumber}% lwarp
    \@ifempty{#3}{\let\thmnote\@gobble}{\LWR@haveamsthmnote}% lwarp
    \thm@swap\swappedhead\thmhead{#1}{#2}{#3}%
    \the\thm@headpunct~
    \thmheadnl % possibly a newline.
    \hskip\thm@headsep
%   }%
    ]
  \ignorespaces}
%    \end{macrocode}
%
% Patched for \CSS:
% \changes{v0.46}{2018/01/22}{\pkg{amsthm}: Adapted to \env{trivlist} changes.}
%    \begin{macrocode}
\def\@thm#1#2#3{%
  \ifhmode\unskip\unskip\par\fi
  \normalfont
  \LWR@forcenewpage% lwarp
  \BlockClass{amsthmbody\LWR@thisthmstyle}% lwarp
  \trivlist
  \let\thmheadnl\relax
  \let\thm@swap\@gobble
  \thm@notefont{\fontseries\mddefault\upshape}%
  \thm@headpunct{.}% add period after heading
  \thm@headsep 5\p@ plus\p@ minus\p@\relax
  \thm@space@setup
  #1% style overrides
  \@topsep \thm@preskip               % used by thm head
  \@topsepadd \thm@postskip           % used by \@endparenv
  \def\@tempa{#2}\ifx\@empty\@tempa
    \def\@tempa{\@oparg{\@begintheorem{#3}{}}[]}%
  \else
    \refstepcounter{#2}%
    \def\@tempa{\@oparg{\@begintheorem{#3}{\csname the#2\endcsname}}[]}%
  \fi
  \@tempa
}
%    \end{macrocode}
% \pkg{cleveref} patches \cs{@thm} to do \cs{cref@thmoptarg} if an optional
% argument is given.  \pkg{lwarp} then patches \cs{cref@thmoptarg}
% \cs{AtBeginDocument}.
%    \begin{macrocode}
\AtBeginDocument{%
\def\cref@thmoptarg[#1]#2#3#4{%
    \ifhmode\unskip\unskip\par\fi%
    \normalfont%
    \LWR@forcenewpage% lwarp
    \BlockClass{amsthmbody\LWR@thisthmstyle}% lwarp
    \trivlist%
    \let\thmheadnl\relax%
    \let\thm@swap\@gobble%
    \thm@notefont{\fontseries\mddefault\upshape}%
    \thm@headpunct{.}% add period after heading
    \thm@headsep 5\p@ plus\p@ minus\p@\relax%
    \thm@space@setup%
    #2% style overrides
    \@topsep \thm@preskip               % used by thm head
    \@topsepadd \thm@postskip           % used by \@endparenv
    \def\@tempa{#3}\ifx\@empty\@tempa%
        \def\@tempa{\@oparg{\@begintheorem{#4}{}}[]}%
    \else%
        \refstepcounter[#1]{#3}%  <<< cleveref modification
        \def\@tempa{\@oparg{\@begintheorem{#4}{\csname the#3\endcsname}}[]}%
    \fi%
    \@tempa
}%
}% AtBeginDocument

\def\@endtheorem{\endtrivlist\endBlockClass\@endpefalse }
%    \end{macrocode}
%
%
%
%
% Proof QED symbol:
% \changes{v0.55}{2018/04/24}{Fix: QED symbols in \env{lateximage}.}
%    \begin{macrocode}
\AtBeginDocument{
\@ifundefined{LWR@orig@openbox}{
\LetLtxMacro\LWR@orig@openbox\openbox
\LetLtxMacro\LWR@orig@blacksquare\blacksquare
\LetLtxMacro\LWR@orig@Box\Box

\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

\appto\LWR@restoreorigformatting{%
\LetLtxMacro\openbox\LWR@orig@openbox%
\LetLtxMacro\blacksquare\LWR@orig@blacksquare%
\LetLtxMacro\Box\LWR@orig@Box%
}% appto
}{}% @ifundefined
}% AtBeginDocument
%    \end{macrocode}
%
% Patched for \CSS:
%    \begin{macrocode}
\renewenvironment{proof}[1][\proofname]{\par
\LWR@forcenewpage% lwarp
    \BlockClass{amsthmproof}% lwarp
  \pushQED{\qed}%
  \normalfont \topsep6\p@\@plus6\p@\relax
  \trivlist
  \item[
        \InlineClass{amsthmproofname}{#1\@addpunct{.}}]\ignorespaces% changes
}{%
  \InlineClass{theoremendmark}{\popQED}\endtrivlist%
  \endBlockClass% lwarp
  \@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}[2009/08/03]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\simplechapter}[1][\@empty]{%
    \def\@chapcntformat##1{%
        #1~\csname the##1\endcsname\simplechapterdelim\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}[1994/08/13]
%    \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}[2009/09/02]
%    \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
%<*ar>
% \fi
%
% \part{lwarp-ar.sty}
%
% \section{ar}
%
% \credits{Agostino De Marco}
%
% \DescribePackage{ar}
% \pkg{ar} is patched for use by \pkg{lwarp}.
%
% \changes{v0.66}{2018/12/31}{\pkg{ar}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{ar}[2012/01/23]
%    \end{macrocode}
%
% Measure and print the width of the supplied glyph.
%    \begin{macrocode}
\newlength{\LWR@ar@width}

\newcommand*{\LWR@ar@printwidth}[1]{%
    \setlength{\LWR@ar@width}{\widthof{#1}}%
    width:%
    \LWR@convertto{em}{\the\LWR@ar@width}em%
}
%    \end{macrocode}
%
% The \HTML\ version of \cs{AR}:
%    \begin{macrocode}
\newrobustcmd*{\LWR@HTML@AR}{%
%    \end{macrocode}
% Start a hashed \env{lateximage}, additionally hashed by the font series,
% with a width depending on the given glyph:
%    \begin{macrocode}
    \begin{lateximage}*[AR][\LWR@f@series][\LWR@ar@printwidth{\LWR@print@AR}]%
%    \end{macrocode}
% For text mode, set the font series according to the \HTML\ font series:
%    \begin{macrocode}
    \ifmmode\else\csuse{LWR@orig\LWR@f@series series}\fi%
%    \end{macrocode}
% Print the original glyph using the newly set font series:
%    \begin{macrocode}
    \LWR@print@AR%
%    \end{macrocode}
% Done.
%    \begin{macrocode}
    \end{lateximage}%
}
%    \end{macrocode}
%
% Combine the print and \HTML\ versions:
%    \begin{macrocode}
\LWR@formatted{AR}
%    \end{macrocode}
%
%    \begin{macrocode}
\newrobustcmd*{\LWR@HTML@ARb}{%
    \begin{lateximage}*[AR][b][\LWR@ar@printwidth{\LWR@print@ARb}]%
    \LWR@print@ARb%
    \end{lateximage}%
}
\LWR@formatted{ARb}
%    \end{macrocode}
%
%    \begin{macrocode}
\newrobustcmd*{\LWR@HTML@ARss}{%
    \begin{lateximage}*[ARss][\LWR@f@series][\LWR@ar@printwidth{\LWR@print@ARss}]%
    \ifmmode\else\csuse{LWR@orig\LWR@f@series series}\fi%
    \LWR@print@ARss%
    \end{lateximage}%
}
\LWR@formatted{ARss}
%    \end{macrocode}
%
%    \begin{macrocode}
\newrobustcmd*{\LWR@HTML@ARssb}{%
    \begin{lateximage}*[AR][ssb][\LWR@ar@printwidth{\LWR@print@ARssb}]%
    \LWR@print@ARssb%
    \end{lateximage}%
}
\LWR@formatted{ARssb}
%    \end{macrocode}
%
%    \begin{macrocode}
\newrobustcmd*{\LWR@HTML@ARtt}{%
    \begin{lateximage}*[AR][tt][\LWR@ar@printwidth{\LWR@print@ARtt}]%
    \LWR@print@ARtt%
    \end{lateximage}%
}
\LWR@formatted{ARtt}
%    \end{macrocode}
%
% \iffalse
%</ar>
% \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}[2006/09/03]
%    \end{macrocode}
%
%
% \iffalse
%</arabicfront>
% \fi
%
%
%
%
%
% \iffalse
%<*array>
% \fi
%
% \part{lwarp-array.sty}
%
% \section{array}
%
% \DescribePackage{array}
% \pkg{array} is used as-is for print output, and emulated for \HTML.
%
% \pkg{plarray} and \pkg{plextarray} do not affect \cs{firsthline} or
% \cs{lasthline}, and so are not affected by the following.
%
% \changes{v0.45}{2017/12/03}{\pkg{array}: Added.}
% \changes{v0.58}{2018/06/07}{\pkg{array}: Improved print/\HTML\ output selection.}
%
% \codehtml
%
% Remove the default nullfied macros:
%    \begin{macrocode}
\let\firsthline\relax
\let\lasthline\relax

\LWR@ProvidesPackagePass{array}[2018/12/30]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\LWR@HTML@firsthline}{\LWR@HTMLhline}%
\LWR@expandableformatted{firsthline}

\newcommand*{\LWR@HTML@lasthline}{\LWR@HTMLhline}%
\LWR@expandableformatted{lasthline}
%    \end{macrocode}
%
% \iffalse
%</array>
% \fi
%
%
%
%
%
%
% \iffalse
%<*arydshln>
% \fi
%
% \part{lwarp-arydshln.sty}

% \section{arydshln}
%
% \credits{Hiroshi Nakashima}
%
% \DescribePackage{arydshln}
% \pkg{arydshln} heavily patches tabular code, so the
% actual package is not used.
% \pkg{arydshln} is emulated for \HTML\ \env{tabular},
% and reverts to solid rules for \SVG\ math \env{array}
% and \env{tabular} in a \env{lateximage}.
%
% \CSS\ is not able to display a double-dashed border, so
% a single-dashed rule is displayed as a single-dashed border, and
% a double-dashed rule is displayed as a thicker single-dashed border.
%
% \changes{v0.56}{2018/05/02}{\pkg{arydshln}: Added.}
%
% \codehtml
%
% \pkg{array} is required to allow \cs{newcolumn} below.
%    \begin{macrocode}
\RequirePackage{array}
%    \end{macrocode}
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{arydshln}[2018/09/26]
%    \end{macrocode}
%
% Ignored, but included for source compatibility:
%    \begin{macrocode}
\newdimen\dashlinedash \dashlinedash4pt %
\newdimen\dashlinegap \dashlinegap4pt %
\let\hdashlinewidth\dashlinedash
\let\hdashlinegap\dashlinegap

\def\ADLnullwide{}
\def\ADLsomewide{}
\def\ADLnullwidehline{}
\def\ADLsomewidehline{}

\def\ADLactivate{}
\def\ADLinactivate{}
\newcommand*{\ADLdrawingmode}[1]{}
\newcommand*{\ADLnoshorthanded}{}
\newcommand*{\dashgapcolor}[2][]{}
\newcommand*{\nodashgapcolor}{}
%    \end{macrocode}
%
%
% In a \env{lateximage}, revert to solid vertical rules:
%    \begin{macrocode}
\appto\LWR@restoreorigformatting{%
\newcolumntype{:}{|}%
\newcolumntype{;}[1]{|}%
\LetLtxMacro\hdashline\hline%
}
%    \end{macrocode}
%
%
% Some of these macros are already defined as temporary placeholders in the
% \pkg{lwarp} core, so they must be redefined here.
%
% The emulated defaults also work for an emulated print mode inside a \env{lateximage}:
%    \begin{macrocode}
\def\hdashline{
%     \adl@hdashline\adl@ihdashline
    \adl@hdashline\adl@inactivehdl
}
\def\adl@hdashline#1{\noalign{\ifnum0=`}\fi
%         \ifadl@zwhrule \vskip-\arrayrulewidth
%         \else
%             \adl@hline\adl@connect\arrayrulewidth
                \hrule \@height \arrayrulewidth% lwarp
%         \fi
        \@ifnextchar[%]
                     {#1}%
                     {#1[%
%                          \dashlinedash/\dashlinegap
                        1pt/1pt
                     ]}}
% \def\adl@ihdashline[#1/#2]{\ifnum0=`{\fi}%
%         \multispan{\adl@columns}\unskip \adl@hcline\z@[#1/#2]%
%         \noalign{\ifnum0=`}\fi
%         \futurelet\@tempa\adl@xhline}
\def\adl@inactivehdl[#1/#2]{
%         \ifadl@zwhrule \vskip-\arrayrulewidth \fi
        \hrule\@height\arrayrulewidth
        \futurelet\@tempa\adl@xhline}
\def\adl@xhline{\ifx\@tempa\hline \adl@ixhline\fi
        \ifx\@tempa\hdashline \adl@ixhline\fi
        \ifnum0=`{\fi}}
\def\adl@ixhline{\vskip\doublerulesep \adl@hline\relax\doublerulesep}
\def\adl@hline#1#2{%
% \@tempcnta#2
%         \global\advance\adl@totalheight\@tempcnta
%         \xdef\adl@rowsL{\adl@rowsL
%                 (#1/\number\@tempcnta);}%
%         \xdef\adl@rowsR{\adl@rowsR
%                 (#1/\number\@tempcnta);}
}

\def\cdashline#1{\noalign{\ifnum0=`}\fi
        \@ifnextchar[%]
%                      {\adl@cdline[#1]}%
%                      {\adl@cdline[#1][\dashlinedash/\dashlinegap]}
                     {\adl@inactivecdl[#1]}%
                     {\adl@inactivecdl[#1][\dashlinedash/\dashlinegap]}
}

\def\adl@inactivecdl[#1-#2][#3]{\ifnum0=`{\fi}\cline{#1-#2}}
%    \end{macrocode}

% \iffalse
%</arydshln>
% \fi
%
%
%
%
%
%
% \iffalse
%<*asymptote>
% \fi
%
% \part{lwarp-asymptote.sty}
%
% \section{asymptote}
%
% \credits{Andy Hammerlindl, John Bowman, Tom Prince}
%
% \DescribePackage{asymptote}
% \pkg{asymptote} is patched for use by \pkg{lwarp}.
%
% \needspace{3\baselineskip}
% \limitsasymptote
%
% \changes{v0.59}{2018/07/10}{\pkg{asymptote}: Added.}
% \changes{v0.62}{2018/10/16}{\pkg{asymptote}: Improved \attribute{alt} tags.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{asymptote}[2016/11/26]
%    \end{macrocode}
%
%    \begin{macrocode}
\BeforeBeginEnvironment{asy}{\begin{lateximage}[(-asymptote-~\packagediagramname)]}
\AfterEndEnvironment{asy}{\end{lateximage}}

\xpatchcmd{\asyinclude}
    {\begingroup}
    {\begin{lateximage}[(-asymptote-~\packagediagramname)]}
    {}
    {\LWR@patcherror{asymptote}{asyinclude-begingroup}}

\xpatchcmd{\asyinclude}
    {\endgroup}
    {\end{lateximage}}
    {}
    {\LWR@patcherror{asymptote}{asyinclude-endgroup}}
%    \end{macrocode}
%
% \iffalse
%</asymptote>
% \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
%<*attachfile>
% \fi
%
% \part{lwarp-attachfile.sty}

% \section{attachfile}
%
% \credits{Scott Pakin}
%
% \DescribePackage{attachfile}
% \pkg{attachfile} is patched for use by \pkg{lwarp}.
%
% Metadata is ignored for now.\watchout
%
% \changes{v0.58}{2018/06/08}{\pkg{attachfile}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{attachfile}[2016/09/18]
%    \end{macrocode}
%
% Encloses each icon:
%    \begin{macrocode}
\newenvironment*{LWR@attachfile@icon}
{
    \begin{lateximage}*%
        [-attachfile-]%
        [%
            \detokenize\expandafter{\atfi@icon@icon}-%
            \detokenize\expandafter{\atfi@color@rgb}%
        ]%
}
{
    \end{lateximage}
}
%    \end{macrocode}
%
% Each icon is enclosed inside a \env{LWR@attachfile@icon} environment:
%    \begin{macrocode}
\xpretocmd{\atfi@acroGraph}{\LWR@attachfile@icon}{}{}
\xapptocmd{\atfi@acroGraph}{\endLWR@attachfile@icon}{}{}

\xpretocmd{\atfi@acroPaperclip}{\LWR@attachfile@icon}{}{}
\xapptocmd{\atfi@acroPaperclip}{\endLWR@attachfile@icon}{}{}

\xpretocmd{\atfi@acroPushPin}{\LWR@attachfile@icon}{}{}
\xapptocmd{\atfi@acroPushPin}{\endLWR@attachfile@icon}{}{}

\xpretocmd{\atfi@acroTag}{\LWR@attachfile@icon}{}{}
\xapptocmd{\atfi@acroTag}{\endLWR@attachfile@icon}{}{}
%    \end{macrocode}
%
% Disable \PDF\ file embedding:
%    \begin{macrocode}
\DeclareRobustCommand{\atfi@embedfile}[1]{}
%    \end{macrocode}
%
% The displayed output for an \cs{attachfile} reference:
%    \begin{macrocode}
\newcommand*{\LWR@attachfile@appearance}{}

\DeclareRobustCommand{\atfi@set@appearance}[1]{%
    \def\LWR@attachfile@appearance{#1}%
}
%    \end{macrocode}
%
% A file annotation becomes a reference:
%    \begin{macrocode}
\DeclareRobustCommand{\atfi@insert@file@annot}[1]{%
    \href{#1}{\LWR@attachfile@appearance}%
}
%    \end{macrocode}

% \iffalse
%</attachfile>
% \fi
%
%
%
%
% \iffalse
%<*attachfile2>
% \fi
%
% \part{lwarp-attachfile2.sty}

% \section{attachfile2}
%
% \credits{Heiko Oberdiek}
%
% \DescribePackage{attachfile2}
% \pkg{attachfile2} is patched for use by \pkg{lwarp}.
%
% Metadata is ignored for now.\watchout
%
% \changes{v0.58}{2018/06/08}{\pkg{attachfile2}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{attachfile2}[2016/05/16]
%    \end{macrocode}
%
% Adds memory of the selected color:
%    \begin{macrocode}
\def\LWR@attachfiletwo@color{}%

\define@key{AtFi}{color}{%
    \def\LWR@attachfiletwo@color{#1}%   lwarp
  \HyColor@AttachfileColor{#1}%
          \atfi@color@tex\atfi@color@inline\atfi@color@annot
          {attachfile2}{color}%
}
%    \end{macrocode}
%
% Encloses each icon:
%    \begin{macrocode}
\newenvironment*{LWR@attachfile@icon}
{
    \begin{lateximage}*%
        [-attachfile-]%
        [%
            \detokenize\expandafter{\atfi@icon@icon}-%
            \detokenize\expandafter{\LWR@attachfiletwo@color}%
        ]%
}
{
    \end{lateximage}
}
%    \end{macrocode}
%
% Each icon is enclosed inside a \env{LWR@attachfile@icon} environment:
%    \begin{macrocode}
\xpretocmd{\atfi@acroGraph}{\LWR@attachfile@icon}{}{}
\xapptocmd{\atfi@acroGraph}{\endLWR@attachfile@icon}{}{}

\xpretocmd{\atfi@acroPaperclip}{\LWR@attachfile@icon}{}{}
\xapptocmd{\atfi@acroPaperclip}{\endLWR@attachfile@icon}{}{}

\xpretocmd{\atfi@acroPushPin}{\LWR@attachfile@icon}{}{}
\xapptocmd{\atfi@acroPushPin}{\endLWR@attachfile@icon}{}{}

\xpretocmd{\atfi@acroTag}{\LWR@attachfile@icon}{}{}
\xapptocmd{\atfi@acroTag}{\endLWR@attachfile@icon}{}{}
%    \end{macrocode}
%
% Disable \PDF\ file embedding:
%    \begin{macrocode}
\DeclareRobustCommand{\atfi@embedfile}[1]{}
%    \end{macrocode}
%
% The displayed output for an \cs{attachfile} reference:
%    \begin{macrocode}
\newcommand*{\LWR@attachfile@appearance}{}

\def\atfi@set@appearance@icon{%
    \atfi@set@appearance{\csname atfi@acro\atfi@icon@icon\endcsname}%
}

\DeclareRobustCommand{\atfi@set@appearance}[1]{%
    \def\LWR@attachfile@appearance{#1}%
}
%    \end{macrocode}
%
% A file annotation becomes a reference:
%    \begin{macrocode}
\DeclareRobustCommand{\atfi@insert@file@annot}[1]{%
    \href{#1}{\LWR@attachfile@appearance}%
}
%    \end{macrocode}
%
% Modified for text color:
%    \begin{macrocode}
\DeclareRobustCommand{\notextattachfile}[2][]{%
  \begingroup
    \atfi@setup{#1}%
    \ifatfi@print
      \leavevmode
      \begingroup
        \HyColor@UseColor\atfi@color@tex
        \LWR@textcurrentcolor{#2}%      lwarp
% \strut
      \endgroup
%     \else
%       \sbox\ltx@zero{#2\strut}%
%       \makebox[\wd0]{}%
    \fi
  \endgroup
}
%    \end{macrocode}
%
% Modified to draw the icon:
%    \begin{macrocode}
\DeclareRobustCommand{\noattachfile}[1][]{%
  \begingroup
    \atfi@setup{#1}%
    \atfi@set@appearance@icon
    \ifatfi@print
        \LWR@attachfile@appearance%     lwarp
%       \expandafter
%       \atfi@refxform\csname atfi@appobj@\atfi@icon@icon\endcsname
%     \else
%       \makebox[\atfi@appearancewidth]{}%
    \fi
  \endgroup
}
%    \end{macrocode}

% \iffalse
%</attachfile2>
% \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}[2001/02/27]
%    \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
%<*axessibility>
% \fi
%
% \part{lwarp-axessibility.sty}
%
% \section{axessibility}
%
% \DescribePackage{axessibility}
% \pkg{axessibility} is ignored.
%
% \changes{v0.59}{2018/07/25}{\pkg{axessibility}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{axessibility}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\wrap}[1]{}
%    \end{macrocode}
%
% \iffalse
%</axessibility>
% \fi
%
%
% \iffalse
%<*axodraw2>
% \fi
%
% \part{lwarp-axodraw2.sty}

% \section{axodraw2}
%
% \credits{John C. Collins, J.A.M. Vermaseren}
%
% \DescribePackage{axodraw2}
% \pkg{axodraw2} is patched for use by \pkg{lwarp}.
%
% \changes{v0.50}{2018/02/22}{\pkg{axodraw2}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{axodraw2}[2018/02/15]
%    \end{macrocode}

%    \begin{macrocode}
\BeforeBeginEnvironment{axopicture}{\begin{lateximage}[(-axopicture-~\packagediagramname)]}

\AfterEndEnvironment{axopicture}{\end{lateximage}}
%    \end{macrocode}

% \iffalse
%</axodraw2>
% \fi
%
%
%
%
%
% \iffalse
%<*backref>
% \fi
%
% \part{lwarp-backref.sty}

% \section{backref}
%
% \credits{David Carlisle and Sebastian Rahtz}
%
% \DescribePackage{backref}
% \pkg{backref} is patched for use by \pkg{lwarp}.
%
% Note that \pkg{backref} must be explicitly loaded,
% \trouble[loading]{backref}
% and is not automatically loaded by \pkg{hyperref} when
% generating \HTML\ output.
%
% \changes{v0.45}{2018/01/14}{\pkg{backref}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{backref}[2016/05/21]
%    \end{macrocode}

% Force the \optn{hyperref} option:
%    \begin{macrocode}
\def\backref{}\let\backrefxxx\hyper@section@backref
%    \end{macrocode}

% \iffalse
%</backref>
% \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}[1999/02/23]
%    \end{macrocode}
%
%
%    \begin{macrocode}
\newcommand*{\balance}{}
\newcommand*{\nobalance}{}
%    \end{macrocode}
%
%
% \iffalse
%</balance>
% \fi
%
%
%
%
% \iffalse
%<*bbding>
% \fi
%
% \part{lwarp-bbding.sty}
%
% \section{bbding}
%
% \credits{Karel Horak, Peter Møller Neergaard}
%
% \DescribePackage{bbding}
% \pkg{bbding} is patched for use by \pkg{lwarp}.
%
% \changes{v0.67}{2019/02/20}{\pkg{bbding}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{bbding}[1999/04/15]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\LWR@bbdingsymbol}[2]{\HTMLunicode{#2}}

\newcommand{\LWR@HTML@ScissorRightBrokenBottom}{\LWR@bbdingsymbol{000}    {2701}}
\newcommand{\LWR@HTML@ScissorRight}{\LWR@bbdingsymbol{001}                {2702}}
\newcommand{\LWR@HTML@ScissorRightBrokenTop}{\LWR@bbdingsymbol{002}       {2703}}
\newcommand{\LWR@HTML@ScissorLeftBrokenBottom}{\LWR@bbdingsymbol{003}     {2701}}
\newcommand{\LWR@HTML@ScissorLeft}{\LWR@bbdingsymbol{004}                 {2702}}
\newcommand{\LWR@HTML@ScissorLeftBrokenTop}{\LWR@bbdingsymbol{005}        {2703}}
\newcommand{\LWR@HTML@ScissorHollowRight}{\LWR@bbdingsymbol{006}          {2704}}
\newcommand{\LWR@HTML@ScissorHollowLeft}{\LWR@bbdingsymbol{007}           {2704}}
\newcommand{\LWR@HTML@Phone}{\LWR@bbdingsymbol{010}                       {260E}}
\newcommand{\LWR@HTML@PhoneHandset}{\LWR@bbdingsymbol{011}                {2706}}
\newcommand{\LWR@HTML@Tape}{\LWR@bbdingsymbol{012}                        {2707}}
\newcommand{\LWR@HTML@Plane}{\LWR@bbdingsymbol{013}                       {2708}}
\newcommand{\LWR@HTML@Envelope}{\LWR@bbdingsymbol{014}                    {2709}}
\newcommand{\LWR@HTML@HandCuffRight}{\LWR@bbdingsymbol{015}               {261B}}
\newcommand{\LWR@HTML@HandCuffLeft}{\LWR@bbdingsymbol{016}                {261A}}
\newcommand{\LWR@HTML@HandCuffRightUp}{\LWR@bbdingsymbol{017}             {261D}}
\newcommand{\LWR@HTML@HandCuffLeftUp}{\LWR@bbdingsymbol{020}              {261F}}
\newcommand{\LWR@HTML@HandRight}{\LWR@bbdingsymbol{021}                   {261E}}
\newcommand{\LWR@HTML@HandLeft}{\LWR@bbdingsymbol{022}                    {261C}}
\newcommand{\LWR@HTML@HandRightUp}{\LWR@bbdingsymbol{023}                 {261D}}
\newcommand{\LWR@HTML@HandLeftUp}{\LWR@bbdingsymbol{024}                  {261F}}
\newcommand{\LWR@HTML@Peace}{\LWR@bbdingsymbol{025}                       {270C}}
\newcommand{\LWR@HTML@HandPencilLeft}{\LWR@bbdingsymbol{026}              {270D}}
\newcommand{\LWR@HTML@PencilRight}{\LWR@bbdingsymbol{027}                 {270F}}
\newcommand{\LWR@HTML@PencilLeft}{\LWR@bbdingsymbol{030}                  {270F}}
\newcommand{\LWR@HTML@PencilRightUp}{\LWR@bbdingsymbol{031}               {2710}}
\newcommand{\LWR@HTML@PencilLeftUp}{\LWR@bbdingsymbol{032}                {2710}}
\newcommand{\LWR@HTML@PencilRightDown}{\LWR@bbdingsymbol{033}             {270E}}
\newcommand{\LWR@HTML@PencilLeftDown}{\LWR@bbdingsymbol{034}              {270E}}
\newcommand{\LWR@HTML@NibRight}{\LWR@bbdingsymbol{035}                    {2711}}
\newcommand{\LWR@HTML@NibLeft}{\LWR@bbdingsymbol{036}                     {2711}}
\newcommand{\LWR@HTML@NibSolidRight}{\LWR@bbdingsymbol{037}               {2712}}
\newcommand{\LWR@HTML@NibSolidLeft}{\LWR@bbdingsymbol{040}                {2712}}
\newcommand{\LWR@HTML@Checkmark}{\LWR@bbdingsymbol{041}                   {2713}}
\newcommand{\LWR@HTML@CheckmarkBold}{\LWR@bbdingsymbol{042}               {2714}}
\newcommand{\LWR@HTML@XSolid}{\LWR@bbdingsymbol{043}                      {2715}}
\newcommand{\LWR@HTML@XSolidBold}{\LWR@bbdingsymbol{044}                  {2716}}
\newcommand{\LWR@HTML@XSolidBrush}{\LWR@bbdingsymbol{045}                 {2717}}
\newcommand{\LWR@HTML@PlusOutline}{\LWR@bbdingsymbol{046}                 {2719}}
\newcommand{\LWR@HTML@Plus}{\LWR@bbdingsymbol{047}                        {271A}}
\newcommand{\LWR@HTML@PlusCenterOpen}{\LWR@bbdingsymbol{050}              {271C}}
\newcommand{\LWR@HTML@PlusThinCenterOpen}{\LWR@bbdingsymbol{051}          {271B}}
\newcommand{\LWR@HTML@Cross}{\LWR@bbdingsymbol{052}                       {271D}}
\newcommand{\LWR@HTML@CrossOpenShadow}{\LWR@bbdingsymbol{053}             {271E}}
\newcommand{\LWR@HTML@CrossOutline}{\LWR@bbdingsymbol{054}                {271F}}
\newcommand{\LWR@HTML@CrossBoldOutline}{\LWR@bbdingsymbol{055}            {271F}}
\newcommand{\LWR@HTML@CrossMaltese}{\LWR@bbdingsymbol{056}                {2720}}
\newcommand{\LWR@HTML@DavidStarSolid}{\LWR@bbdingsymbol{057}              {2721}}
\newcommand{\LWR@HTML@DavidStar}{\LWR@bbdingsymbol{060}                   {2721}}
\newcommand{\LWR@HTML@FourAsterisk}{\LWR@bbdingsymbol{061}                {2722}}
\newcommand{\LWR@HTML@JackStar}{\LWR@bbdingsymbol{062}                    {2723}}
\newcommand{\LWR@HTML@JackStarBold}{\LWR@bbdingsymbol{063}                {2724}}
\newcommand{\LWR@HTML@CrossClowerTips}{\LWR@bbdingsymbol{064}             {2725}}
\newcommand{\LWR@HTML@FourStar}{\LWR@bbdingsymbol{065}                    {2726}}
\newcommand{\LWR@HTML@FourStarOpen}{\LWR@bbdingsymbol{066}                {2727}}
\newcommand{\LWR@HTML@FiveStarLines}{\LWR@bbdingsymbol{067}               {2729}}
\newcommand{\LWR@HTML@FiveStar}{\LWR@bbdingsymbol{070}                    {2605}}
\newcommand{\LWR@HTML@FiveStarOpen}{\LWR@bbdingsymbol{071}                {2729}}
\newcommand{\LWR@HTML@FiveStarOpenCircled}{\LWR@bbdingsymbol{072}         {272A}}
\newcommand{\LWR@HTML@FiveStarCenterOpen}{\LWR@bbdingsymbol{073}          {272B}}
\newcommand{\LWR@HTML@FiveStarOpenDotted}{\LWR@bbdingsymbol{074}          {272C}}
\newcommand{\LWR@HTML@FiveStarOutline}{\LWR@bbdingsymbol{075}             {272D}}
\newcommand{\LWR@HTML@FiveStarOutlineHeavy}{\LWR@bbdingsymbol{076}        {272E}}
\newcommand{\LWR@HTML@FiveStarConvex}{\LWR@bbdingsymbol{077}              {272F}}
\newcommand{\LWR@HTML@FiveStarShadow}{\LWR@bbdingsymbol{100}              {2730}}
\newcommand{\LWR@HTML@AsteriskBold}{\LWR@bbdingsymbol{101}                {2731}}
\newcommand{\LWR@HTML@AsteriskCenterOpen}{\LWR@bbdingsymbol{102}          {2732}}
\newcommand{\LWR@HTML@AsteriskThin}{\LWR@bbdingsymbol{103}                {273B}}
\newcommand{\LWR@HTML@AsteriskThinCenterOpen}{\LWR@bbdingsymbol{104}      {273C}}
\newcommand{\LWR@HTML@EightStarTaper}{\LWR@bbdingsymbol{105}              {2733}}
\newcommand{\LWR@HTML@EightStarConvex}{\LWR@bbdingsymbol{106}             {2735}}
\newcommand{\LWR@HTML@SixStar}{\LWR@bbdingsymbol{107}                     {2736}}
\newcommand{\LWR@HTML@EightStar}{\LWR@bbdingsymbol{110}                   {2737}}
\newcommand{\LWR@HTML@EightStarBold}{\LWR@bbdingsymbol{111}               {2738}}
\newcommand{\LWR@HTML@TwelweStar}{\LWR@bbdingsymbol{112}                  {2739}}
\newcommand{\LWR@HTML@SixteenStarLight}{\LWR@bbdingsymbol{113}            {273A}}
\newcommand{\LWR@HTML@SixFlowerPetalRemoved}{\LWR@bbdingsymbol{114}       {273B}}
\newcommand{\LWR@HTML@SixFlowerOpenCenter}{\LWR@bbdingsymbol{115}         {273C}}
\newcommand{\LWR@HTML@Asterisk}{\LWR@bbdingsymbol{116}                    {273D}}
\newcommand{\LWR@HTML@SixFlowerAlternate}{\LWR@bbdingsymbol{117}          {273E}}
\newcommand{\LWR@HTML@FiveFlowerPetal}{\LWR@bbdingsymbol{120}             {273F}}
\newcommand{\LWR@HTML@SixFlowerPetalDotted}{\LWR@bbdingsymbol{121}        {2740}}
\newcommand{\LWR@HTML@FiveFlowerOpen}{\LWR@bbdingsymbol{122}              {2740}}
\newcommand{\LWR@HTML@EightFlowerPetal}{\LWR@bbdingsymbol{123}            {2741}}
\newcommand{\LWR@HTML@SunshineOpenCircled}{\LWR@bbdingsymbol{124}         {2742}}
\newcommand{\LWR@HTML@SixFlowerAltPetal}{\LWR@bbdingsymbol{125}           {2743}}
\newcommand{\LWR@HTML@FourClowerOpen}{\LWR@bbdingsymbol{126}              {273F}}
\newcommand{\LWR@HTML@FourClowerSolid}{\LWR@bbdingsymbol{127}             {273F}}
\newcommand{\LWR@HTML@AsteriskRoundedEnds}{\LWR@bbdingsymbol{130}         {2749}}
\newcommand{\LWR@HTML@EightFlowerPetalRemoved}{\LWR@bbdingsymbol{131}     {274A}}
\newcommand{\LWR@HTML@EightAsterisk}{\LWR@bbdingsymbol{132}               {274B}}
\newcommand{\LWR@HTML@SixFlowerRemovedOpenPetal}{\LWR@bbdingsymbol{133}   {2740}}
\newcommand{\LWR@HTML@SparkleBold}{\LWR@bbdingsymbol{134}                 {2748}}
\newcommand{\LWR@HTML@Sparkle}{\LWR@bbdingsymbol{135}                     {2747}}
\newcommand{\LWR@HTML@SnowflakeChevron}{\LWR@bbdingsymbol{136}            {2744}}
\newcommand{\LWR@HTML@SnowflakeChevronBold}{\LWR@bbdingsymbol{137}        {2746}}
\newcommand{\LWR@HTML@Snowflake}{\LWR@bbdingsymbol{140}                   {2744}}
\newcommand{\LWR@HTML@CircleSolid}{\LWR@bbdingsymbol{141}                 {25CF}}
\newcommand{\LWR@HTML@Ellipse}{\LWR@bbdingsymbol{142}                     {274D}}
\newcommand{\LWR@HTML@EllipseSolid}{\LWR@bbdingsymbol{143}                {25CF}}
\newcommand{\LWR@HTML@CircleShadow}{\LWR@bbdingsymbol{144}                {274D}}
\newcommand{\LWR@HTML@EllipseShadow}{\LWR@bbdingsymbol{145}               {274D}}
\newcommand{\LWR@HTML@Square}{\LWR@bbdingsymbol{146}                      {25A1}}
\newcommand{\LWR@HTML@SquareSolid}{\LWR@bbdingsymbol{147}                 {25A0}}
\newcommand{\LWR@HTML@SquareShadowBottomRight}{\LWR@bbdingsymbol{150}     {2751}}
\newcommand{\LWR@HTML@SquareShadowTopRight}{\LWR@bbdingsymbol{151}        {2752}}
\newcommand{\LWR@HTML@SquareShadowTopLeft}{\LWR@bbdingsymbol{152}         {2752}}
\newcommand{\LWR@HTML@SquareCastShadowBottomRight}{\LWR@bbdingsymbol{153} {2751}}
\newcommand{\LWR@HTML@SquareCastShadowTopRight}{\LWR@bbdingsymbol{154}    {2752}}
\newcommand{\LWR@HTML@SquareCastShadowTopLeft}{\LWR@bbdingsymbol{155}     {2752}}
\newcommand{\LWR@HTML@TriangleUp}{\LWR@bbdingsymbol{156}                  {25B2}}
\newcommand{\LWR@HTML@TriangleDown}{\LWR@bbdingsymbol{157}                {25BC}}
\newcommand{\LWR@HTML@DiamondSolid}{\LWR@bbdingsymbol{160}                {25C6}}
\newcommand{\LWR@HTML@OrnamentDiamondSolid}{\LWR@bbdingsymbol{161}        {2756}}
\newcommand{\LWR@HTML@HalfCircleRight}{\LWR@bbdingsymbol{162}             {25D7}}
\newcommand{\LWR@HTML@HalfCircleLeft}{\LWR@bbdingsymbol{163}              {25D6}}
\newcommand{\LWR@HTML@RectangleThin}{\LWR@bbdingsymbol{164}               {2758}}
\newcommand{\LWR@HTML@Rectangle}{\LWR@bbdingsymbol{165}                   {2759}}
\newcommand{\LWR@HTML@RectangleBold}{\LWR@bbdingsymbol{166}               {275A}}
\newcommand{\LWR@HTML@ArrowBoldRightStrobe}{\LWR@bbdingsymbol{167}        {27A0}}
\newcommand{\LWR@HTML@ArrowBoldUpRight}{\LWR@bbdingsymbol{170}            {27A6}}
\newcommand{\LWR@HTML@ArrowBoldDownRight}{\LWR@bbdingsymbol{171}          {27A5}}
\newcommand{\LWR@HTML@ArrowBoldRightShort}{\LWR@bbdingsymbol{172}         {27A7}}
\newcommand{\LWR@HTML@ArrowBoldRightCircled}{\LWR@bbdingsymbol{173}       {27B2}}


\LWR@formatted{ScissorRightBrokenBottom}
\LWR@formatted{ScissorRight}
\LWR@formatted{ScissorRightBrokenTop}
\LWR@formatted{ScissorLeftBrokenBottom}
\LWR@formatted{ScissorLeft}
\LWR@formatted{ScissorLeftBrokenTop}
\LWR@formatted{ScissorHollowRight}
\LWR@formatted{ScissorHollowLeft}
\LWR@formatted{Phone}
\LWR@formatted{PhoneHandset}
\LWR@formatted{Tape}
\LWR@formatted{Plane}
\LWR@formatted{Envelope}
\LWR@formatted{HandCuffRight}
\LWR@formatted{HandCuffLeft}
\LWR@formatted{HandCuffRightUp}
\LWR@formatted{HandCuffLeftUp}
\LWR@formatted{HandRight}
\LWR@formatted{HandLeft}
\LWR@formatted{HandRightUp}
\LWR@formatted{HandLeftUp}
\LWR@formatted{Peace}
\LWR@formatted{HandPencilLeft}
\LWR@formatted{PencilRight}
\LWR@formatted{PencilLeft}
\LWR@formatted{PencilRightUp}
\LWR@formatted{PencilLeftUp}
\LWR@formatted{PencilRightDown}
\LWR@formatted{PencilLeftDown}
\LWR@formatted{NibRight}
\LWR@formatted{NibLeft}
\LWR@formatted{NibSolidRight}
\LWR@formatted{NibSolidLeft}
\LWR@formatted{Checkmark}
\LWR@formatted{CheckmarkBold}
\LWR@formatted{XSolid}
\LWR@formatted{XSolidBold}
\LWR@formatted{XSolidBrush}
\LWR@formatted{PlusOutline}
\LWR@formatted{Plus}
\LWR@formatted{PlusCenterOpen}
\LWR@formatted{PlusThinCenterOpen}
\LWR@formatted{Cross}
\LWR@formatted{CrossOpenShadow}
\LWR@formatted{CrossOutline}
\LWR@formatted{CrossBoldOutline}
\LWR@formatted{CrossMaltese}
\LWR@formatted{DavidStarSolid}
\LWR@formatted{DavidStar}
\LWR@formatted{FourAsterisk}
\LWR@formatted{JackStar}
\LWR@formatted{JackStarBold}
\LWR@formatted{CrossClowerTips}
\LWR@formatted{FourStar}
\LWR@formatted{FourStarOpen}
\LWR@formatted{FiveStarLines}
\LWR@formatted{FiveStar}
\LWR@formatted{FiveStarOpen}
\LWR@formatted{FiveStarOpenCircled}
\LWR@formatted{FiveStarCenterOpen}
\LWR@formatted{FiveStarOpenDotted}
\LWR@formatted{FiveStarOutline}
\LWR@formatted{FiveStarOutlineHeavy}
\LWR@formatted{FiveStarConvex}
\LWR@formatted{FiveStarShadow}
\LWR@formatted{AsteriskBold}
\LWR@formatted{AsteriskCenterOpen}
\LWR@formatted{AsteriskThin}
\LWR@formatted{AsteriskThinCenterOpen}
\LWR@formatted{EightStarTaper}
\LWR@formatted{EightStarConvex}
\LWR@formatted{SixStar}
\LWR@formatted{EightStar}
\LWR@formatted{EightStarBold}
\LWR@formatted{TwelweStar}
\LWR@formatted{SixteenStarLight}
\LWR@formatted{SixFlowerPetalRemoved}
\LWR@formatted{SixFlowerOpenCenter}
\LWR@formatted{Asterisk}
\LWR@formatted{SixFlowerAlternate}
\LWR@formatted{FiveFlowerPetal}
\LWR@formatted{SixFlowerPetalDotted}
\LWR@formatted{FiveFlowerOpen}
\LWR@formatted{EightFlowerPetal}
\LWR@formatted{SunshineOpenCircled}
\LWR@formatted{SixFlowerAltPetal}
\LWR@formatted{FourClowerOpen}
\LWR@formatted{FourClowerSolid}
\LWR@formatted{AsteriskRoundedEnds}
\LWR@formatted{EightFlowerPetalRemoved}
\LWR@formatted{EightAsterisk}
\LWR@formatted{SixFlowerRemovedOpenPetal}
\LWR@formatted{SparkleBold}
\LWR@formatted{Sparkle}
\LWR@formatted{SnowflakeChevron}
\LWR@formatted{SnowflakeChevronBold}
\LWR@formatted{Snowflake}
\LWR@formatted{CircleSolid}
\LWR@formatted{Ellipse}
\LWR@formatted{EllipseSolid}
\LWR@formatted{CircleShadow}
\LWR@formatted{EllipseShadow}
\LWR@formatted{Square}
\LWR@formatted{SquareSolid}
\LWR@formatted{SquareShadowBottomRight}
\LWR@formatted{SquareShadowTopRight}
\LWR@formatted{SquareShadowTopLeft}
\LWR@formatted{SquareCastShadowBottomRight}
\LWR@formatted{SquareCastShadowTopRight}
\LWR@formatted{SquareCastShadowTopLeft}
\LWR@formatted{TriangleUp}
\LWR@formatted{TriangleDown}
\LWR@formatted{DiamondSolid}
\LWR@formatted{OrnamentDiamondSolid}
\LWR@formatted{HalfCircleRight}
\LWR@formatted{HalfCircleLeft}
\LWR@formatted{RectangleThin}
\LWR@formatted{Rectangle}
\LWR@formatted{RectangleBold}
\LWR@formatted{ArrowBoldRightStrobe}
\LWR@formatted{ArrowBoldUpRight}
\LWR@formatted{ArrowBoldDownRight}
\LWR@formatted{ArrowBoldRightShort}
\LWR@formatted{ArrowBoldRightCircled}
%    \end{macrocode}
%
% \iffalse
%</bbding>
% \fi
%
%
%
%
% \iffalse
%<*biblatex>
% \fi
%
% \part{lwarp-biblatex.sty}
%
% \section{biblatex}
%
% \credits{Philipp Lehman}
%
% \DescribePackage{biblatex}
% When \pkg{biblatex} is used, modifications from \pkg{newfloat} may have to
% be undone.
%
% \changes{v0.64}{2018/12/08}{\pkg{biblatex}: Added patch for C\TeX.}
%
% \codehtml
%
% \begin{enumerate}
% \item \pkg{lwarp} uses \pkg{newfloat}.
% \item For classes with chapters which \pkg{newfloat} does not know about,
%           such as C\TeX-related classes, \pkg{newfloat} may modify
%           \cs{addtocontents}.
% \item \pkg{biblatex}, though, wants to patch \cs{addtocontents},
%           which causes an error if \cs{addtocontents} has been changed.
% \item Therefore, \cs{addtocontents} is restored to its original here,
%           since \pkg{biblatex} is about to be loaded.
% \item This means that the \pkg{newfloat}'s \optn{chapterlistsgaps}
%           option may no longer work.
% \end{enumerate}
% 
%    \begin{macrocode}
\ifdef{\newfloat@addtocontents@ORI}{
    \let\addtocontents\newfloat@addtocontents@ORI
}{}
%    \end{macrocode}
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{biblatex}[2018/03/04]
%    \end{macrocode}
%
%
% \iffalse
%</biblatex>
% \fi
%
%
%
% \iffalse
%<*bibunits>
% \fi
%
% \part{lwarp-bibunits.sty}

% \section{bibunits}
%
% \credits{Thorsten Hansen}
%
% \DescribePackage{bibunits}
% \pkg{bibunits} is patched for use by \pkg{lwarp}.
%
% \changes{v0.54}{2018/03/09}{\pkg{bibunits}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{bibunits}[2004/05/12]
%    \end{macrocode}

%    \begin{macrocode}
\def\bu@bibdata{\BaseJobname}
%    \end{macrocode}

% \iffalse
%</bibunits>
% \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.}
% \changes{v0.57}{2018/06/01}{\pkg{bigdelim}: Improved print/\HTML\ output selection.}
%
% \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}[2018/08/03]
%    \end{macrocode}
%
%
% \marg{1:delimiter} \marg{2:\#rows} \marg{3:width} \oarg{4:text}
% \marginpar{\hfill\cs{ldelim}}\marginpar{\hfill\cs{rdelim}}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@ldelim}{m m m O{}}{%
\renewcommand{\LWR@multirowborder}{right}%
\multirow{#2}{#3}{#4 \InlineClass{ldelim}{#1}}%
}

\LWR@formatted{ldelim}

\NewDocumentCommand{\LWR@HTML@rdelim}{m m m O{}}{%
\renewcommand{\LWR@multirowborder}{left}%
\multirow{#2}{#3}{\InlineClass{rdelim}{#1} #4}%
}

\LWR@formatted{rdelim}
%    \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}[2018/08/03]
%    \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
%<*bitpattern>
% \fi
%
% \part{lwarp-bitpattern.sty}
%
% \section{bitpattern}
%
% \credits{Jean-Marc Bourguet}
%
% \DescribePackage{bitpattern}
% \pkg{bitpattern} is patched for use by \pkg{lwarp}.
%
% \changes{v0.62}{2018/10/16}{\pkg{bitpattern}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{bitpattern}[2015/12/11]
%    \end{macrocode}
%
%    \begin{macrocode}
\xpatchcmd{\bitpattern}
    {\begingroup}
    {\begin{lateximage}[(-bitpattern-~\packagediagramname)]}
    {}
    {\LWR@patcherror{bitpattern}{bitpattern}}

\xpatchcmd{\bp@Done}
    {\endgroup}
    {\end{lateximage}}
    {}
    {\LWR@patcherror{bitpattern}{bp@Done}}
%    \end{macrocode}
%
% \iffalse
%</bitpattern>
% \fi
%
%
%
%
% \iffalse
%<*blowup>
% \fi
%
% \part{lwarp-blowup.sty}
%
% \section{blowup}
%
% \DescribePackage{blowup}
% \pkg{blowup} is ignored.
%
% \changes{v0.47}{2018/01/25}{\pkg{blowup}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{blowup}[2018/01/02]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*\blowUp[1]{}
%    \end{macrocode}
%
% \iffalse
%</blowup>
% \fi
%
%
%
%
%
% \iffalse
%<*booklet>
% \fi
%
% \part{lwarp-booklet.sty}
%
% \section{booklet}
%
% \credits{Peter Wilson}
%
% \DescribePackage{booklet}
% \pkg{booklet} is nullified.
%
% \changes{v0.60}{2018/09/18}{\pkg{booklet}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{booklet}[2009/09/02]
%    \end{macrocode}
%
%    \begin{macrocode}
\newdimen\pageseplength
\newdimen\pagesepwidth
\newdimen\pagesepoffset
\newif\ifsidebyside     \sidebysidetrue
\newif\ifuselandscape   \uselandscapefalse
\newif\ifprintoption    \printoptionfalse
\newcommand*{\pagespersignature}[1]{}
\def\magstepminus#1{}
\newcommand*{\target}[3]{}
\newcommand*{\source}[3]{}
\newcommand*{\setpdftargetpages}{}
\newcommand*{\setdvipstargetpages}{}
\newcommand*{\targettopbottom}{}
\newcommand*{\twoupemptypage}{}
\newcommand*{\twoupclearpage}{}
\newcommand*{\checkforlandscape}{}
%    \end{macrocode}
%
% \iffalse
%</booklet>
% \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}[2016/05/17]
%    \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
%
% First, forget the placeholder macros:
%    \begin{macrocode}
\LetLtxMacro\toprule\relax
\LetLtxMacro\midrule\relax
\LetLtxMacro\cmidrule\cline
\LetLtxMacro\bottomrule\relax
\LetLtxMacro\addlinespace\relax
\LetLtxMacro\morecmidrules\relax
\LetLtxMacro\specialrule\relax

\LWR@ProvidesPackagePass{booktabs}[2016/04/27]
%    \end{macrocode}
%
% \changes{v0.41}{2017/10/03}{Improved rules.}
% \changes{v0.42}{2017/10/19}{If \progcode{FormatWP} force explicit border.}
%    \begin{macrocode}
\DeclareDocumentCommand{\LWR@HTML@toprule}{o d()}%
    {%
        \IfValueTF{#1}%
            {\LWR@docmidrule[#1](){1-\arabic{LWR@tabletotalLaTeXcols}}}%
            {%
                \ifbool{FormatWP}%
                {\LWR@docmidrule[#1](){1-\arabic{LWR@tabletotalLaTeXcols}}}%
                {\global\booltrue{LWR@doingtbrule}}%
            }%
    \LWR@getmynexttoken}

\LWR@expandableformatted{toprule}

\DeclareDocumentCommand{\LWR@HTML@midrule}{o d()}%
    {%
        \IfValueTF{#1}%
            {\LWR@docmidrule[#1](){1-\arabic{LWR@tabletotalLaTeXcols}}}%
            {%
                \ifbool{FormatWP}%
                {\LWR@docmidrule[#1](){1-\arabic{LWR@tabletotalLaTeXcols}}}%
                {\addtocounter{LWR@hlines}{1}}%
            }%
    \LWR@getmynexttoken}

\LWR@expandableformatted{midrule}

\DeclareDocumentCommand{\LWR@HTML@cmidrule}{O{\LWR@cmidrulewidth} d() m}{%
    \LWR@docmidrule[#1](#2){#3}%
    \LWR@getmynexttoken%
}%

\LWR@expandableformatted{cmidrule}

\DeclareDocumentCommand{\LWR@HTML@bottomrule}{o d()}{%
    \IfValueTF{#1}%
        {\LWR@docmidrule[#1](){1-\arabic{LWR@tabletotalLaTeXcols}}}%
        {%
            \ifbool{FormatWP}%
            {\LWR@docmidrule[#1](){1-\arabic{LWR@tabletotalLaTeXcols}}}%
            {\global\booltrue{LWR@doingtbrule}}%
        }%
    \LWR@getmynexttoken%
}%

\LWR@expandableformatted{bottomrule}

\DeclareDocumentCommand{\LWR@HTML@addlinespace}{o}{}%

\LWR@expandableformatted{addlinespace}

\DeclareDocumentCommand{\LWR@HTML@morecmidrules}{}{}%

\LWR@expandableformatted{morecmidrules}

\DeclareDocumentCommand{\LWR@HTML@specialrule}{m m m d()}%
    {\LWR@docmidrule[#1](){1-\arabic{LWR@tabletotalLaTeXcols}}\LWR@getmynexttoken}%

\LWR@expandableformatted{specialrule}
%    \end{macrocode}
%
% \iffalse
%</booktabs>
% \fi
%
%
%
%
% \iffalse
%<*bophook>
% \fi
%
% \part{lwarp-bophook.sty}
%
% \section{bophook}
%
% \DescribePackage{bophook}
% \pkg{bophook} is ignored.
%
% \changes{v0.60}{2018/09/19}{\pkg{bophook}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{bophook}[2001/03/29]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\AtBeginPage}[1]{}
\newcommand*{\PageLayout}[1]{}
%    \end{macrocode}
%
% \iffalse
%</bophook>
% \fi
%
%
%
%
% \iffalse
%<*bounddvi>
% \fi
%
% \part{lwarp-bounddvi.sty}
%
% \section{bounddvi}
%
% \DescribePackage{bounddvi}
% \pkg{bounddvi} is ignored.
%
% \changes{v0.65}{2018/12/18}{\pkg{bounddvi}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{bounddvi}[2016/12/28]
%    \end{macrocode}
%
% \iffalse
%</bounddvi>
% \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}[2015/03/09]
%    \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.}
% \changes{v0.45}{2017/12/29}{\pkg{breakurl}: Fix: Underscore in \URL.}
% \changes{v0.52}{2018/03/26}{\pkg{breakurl}: Fix: \progcode{\#}, \progcode{\%}, \progcode{\&}, \progcode{\~}, \progcode{\_} in \URL.}
% \changes{v0.57}{2018/06/05}{\pkg{breakurl}: Fix: Text catcodes.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{breakurl}[2013/04/10]
%    \end{macrocode}
%
%    \begin{macrocode}
\LetLtxMacro\burl\url

\NewDocumentCommand{\LWR@burlaltb}{O{} +m m}{%
\LWR@ensuredoingapar%
\LWR@subhyperref{#2}%
\LWR@subhyperreftext{#3}%
\endgroup% restore catcodes
}

\newrobustcmd*{\burlalt}{%
\begingroup%
\catcode`\#=12%
\catcode`\%=12%
\catcode`\&=12%
\catcode`\~=12%
\catcode`\_=12%
\LWR@burlaltb%
}

\LetLtxMacro\urlalt\burlalt
%    \end{macrocode}
%
% \iffalse
%</breakurl>
% \fi
%
%
%
%
% \iffalse
%<*breqn>
% \fi
%
% \part{lwarp-breqn.sty}
%
% \section{breqn}
%
% \credits{Michael J. Downes, Morten Høgholm}
%
% \DescribePackage{breqn}
% \pkg{breqn} is patched for use by \pkg{lwarp}.
%
% \env{darray} is not supported.
% \trouble[\env{darray}]{breqn=\pkg{breqn}>darray}
%
% MathJax does not support \pkg{breqn}.
% \trouble[\brand{MathJax}]{breqn=\pkg{breqn}>MathJax=\brand{MathJax}}
% \trouble{MathJax=\brand{MathJax}>breqn=\pkg{breqn}}
%
% \changes{v0.59}{2018/07/25}{\pkg{breqn}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{breqn}[2017/01/27]
%    \end{macrocode}
%
%    \begin{macrocode}
\setkeys{breqn}{spread={5pt}}

\def\eqnumside{R}
% \def\eqnumplace{T}

\BeforeBeginEnvironment{dmath}{
    \begin{BlockClass}{displaymathnumbered}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[-breqn dmath- \mathimagename]
}

\AfterEndEnvironment{dmath}{
    \end{lateximage}\end{BlockClass}
}

\BeforeBeginEnvironment{dmath*}{
    \begin{BlockClass}{displaymath}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[-breqn dmath*- \mathimagename]
}

\AfterEndEnvironment{dmath*}{
    \end{lateximage}\end{BlockClass}
}

\BeforeBeginEnvironment{dseries}{
    \begin{BlockClass}{displaymathnumbered}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[-breqn dseries- \mathimagename]
}

\AfterEndEnvironment{dseries}{
    \end{lateximage}\end{BlockClass}
}

\BeforeBeginEnvironment{dseries*}{
    \begin{BlockClass}{displaymath}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[-breqn dseries*- \mathimagename]
}

\AfterEndEnvironment{dseries*}{
    \end{lateximage}\end{BlockClass}
}

\BeforeBeginEnvironment{dgroup}{
    \begin{BlockClass}{displaymath}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[-breqn dgroup- \mathimagename]
}

\AfterEndEnvironment{dgroup}{
    \end{lateximage}\end{BlockClass}
}

\BeforeBeginEnvironment{dgroup*}{
    \begin{BlockClass}{displaymath}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[-breqn dgroup*- \mathimagename]
}

\AfterEndEnvironment{dgroup*}{
    \end{lateximage}\end{BlockClass}
}
%    \end{macrocode}
%
% \iffalse
%</breqn>
% \fi
%
%
%
% \iffalse
%<*bsheaders>
% \fi
%
% \part{lwarp-bsheaders.sty}
%
% \section{bsheaders}
%
% \DescribePackage{bsheaders}
% \pkg{bsheaders} is ignored.
%
% \changes{v0.64}{2018/12/07}{\pkg{bsheaders}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{bsheaders}[1997/10/06]
%    \end{macrocode}
%
% \iffalse
%</bsheaders>
% \fi
%
%
%
%
% \iffalse
%<*bxpapersize>
% \fi
%
% \part{lwarp-bxpapersize.sty}
%
% \section{bxpapersize}
%
% \DescribePackage{bxpapersize}
% \pkg{bxpapersize} is ignored.
%
% \changes{v0.59}{2018/09/06}{\pkg{bxpapersize}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{bxpapersize}[2017/10/08]
%    \end{macrocode}
%
%    \begin{macrocode}
\providecommand*\papersizesetup{\bxpapersizesetup}
\newcommand*\bxpapersizesetup[1]{}
%    \end{macrocode}
%
% \iffalse
%</bxpapersize>
% \fi
%
%
%
%
% \iffalse
%<*bytefield>
% \fi
%
% \part{lwarp-bytefield.sty}

% \section{bytefield}
%
% \credits{Scott Pakin}
%
% \DescribePackage{bytefield}
% \pkg{bytefield} is patched for use by \pkg{lwarp}.
%
% \changes{v0.50}{2018/02/22}{\pkg{bytefield}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{bytefield}[2017/09/15]
%    \end{macrocode}

%    \begin{macrocode}
\BeforeBeginEnvironment{bytefield}{\begin{lateximage}[(-bytefield-~\packagediagramname)]}

\AfterEndEnvironment{bytefield}{\end{lateximage}}
%    \end{macrocode}

% \iffalse
%</bytefield>
% \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@origRequirePackage{lwarp-xcolor}% for \convertcolorspec
\LWR@ProvidesPackagePass{cancel}[2013/04/12]
%    \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}%
{\InlineClass(#5){#3}{#1}}%
{\LWR@htmlspanclass[#5;#4:\LWR@origpound\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
%<*canoniclayout>
% \fi
%
% \part{lwarp-canoniclayout.sty}
%
% \section{canoniclayout}
%
% \DescribePackage{canoniclayout}
% \pkg{canoniclayout} is ignored.
%
% \changes{v0.59}{2018/07/10}{\pkg{canoniclayout}: Added.}
%
% \codehtml
s%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{canoniclayout}[2011/11/05]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\currentfontletters}{}
\newcommand*{\charactersperpage}{}
%    \end{macrocode}
%
% \iffalse
%</canoniclayout>
% \fi
%
%
%
%
% \iffalse
%<*caption>
% \fi
%
% \part{lwarp-caption.sty}

% \section{caption}
%
% \credits{Axel Sommerfeldt}
%
% \DescribePackage{caption}
% \pkg{caption} is patched for use by \pkg{lwarp}.
%
% \changes{v0.47}{2018/01/25}{\pkg{caption}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{caption}[2018/10/05]
%    \end{macrocode}

%    \begin{macrocode}
\renewcommand\caption@ibox[3]{%
  \@testopt{\caption@iibox{#1}{#2}{#3}}{%
%         \wd\@tempboxa%
        \linewidth% lwarp
  }%
% \LWR@traceinfo{caption@ibox: done}%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\long\def\caption@iibox#1#2#3[#4]{%
  \@testopt{\caption@iiibox{#1}{#2}{#3}{#4}}\captionbox@hj@default
}
%    \end{macrocode}
%
%    \begin{macrocode}
\long\def\caption@iiibox#1#2#3#4[#5]#6{%
%   \setbox\@tempboxa\hbox{#6}%
  \begingroup
  #1*% set \caption@position
  \caption@iftop{%
    \LWR@traceinfo{caption@iiibox top}%
    \endgroup
    \parbox[t]{#4}{%
      #1\relax
      \caption@setposition t%
%       \vbox{\caption#2{#3}}%
      {\caption#2{#3}}% lwarp
%       \captionbox@hrule
%       \csname caption@hj@#5\endcsname
%       \unhbox\@tempboxa
       #6% lwarp
    }%
  }{%
    \LWR@traceinfo{caption@iiibox bottom}%
    \endgroup
    \parbox[b]{#4}{%
      #1\relax
      \caption@setposition b%
%       \csname caption@hj@#5\endcsname
%       \unhbox\@tempboxa
         #6% lwarp
%       \captionbox@hrule
%       \vtop{\caption#2{#3}}}%
      {\caption#2{#3}}% lwarp
     }%
  }%
\LWR@traceinfo{caption@iiibox: done}%
}

\def\caption@caption{%
  \caption@iftype
    {%
     \caption@checkgrouplevel\@empty\caption
     \caption@star
       {\caption@refstepcounter\@captype}%
       {\caption@dblarg{\@caption\@captype}}}%
    {\caption@Error{\noexpand\caption outside float}%
     \caption@gobble}%
}

\long\def\caption@@caption#1[#2]#3{%
%    \end{macrocode}
%    \begin{macrocode}
  \ifcaption@star \else
    \caption@prepareanchor{#1}{#2}%
    \memcaptioninfo{#1}{\csname the#1\endcsname}{#2}{#3}%
    \@nameuse{nag@hascaptiontrue}%
  \fi
%    \end{macrocode}
%    \begin{macrocode}
  \par
  \caption@beginex{#1}{#2}{#3}%
    \caption@setfloatcapt{%
      \caption@boxrestore
      \if@minipage
        \@setminipage
      \fi
      \caption@normalsize
      \ifcaption@star
        \let\caption@makeanchor\@firstofone
      \fi
      \@makecaption{\csname fnum@#1\endcsname}%
                   {\ignorespaces\caption@makeanchor{#3}}\par
      \caption@if@minipage\@minipagetrue\@minipagefalse}%
  \caption@end%
}
%    \end{macrocode}

% \begin{noindmacro}{\caption@@@make}
%   \marg{caption label} \marg{caption text}
%    \begin{macrocode}
\renewcommand\caption@@@make[2]{%
\LWR@startpars% lwarp
%   \sbox\@tempboxa{#1}%
%   \ifdim\wd\@tempboxa=\z@
%     \let\caption@lsep\relax
%   \fi
  \caption@ifempty{#2}{%
    \let\caption@lsep\@empty
    \let\caption@tfmt\@firstofone
  }%
  \@setpar{\LWR@closeparagraph\@@par}% lwarp
  \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% lwarp
      \caption@ifstrut
        {\ifhmode\@finalstrut\strutbox\fi}%
        {}%
      \par}}
\LWR@stoppars% lwarp
}
%    \end{macrocode}
% \end{noindmacro}

% ^^A *8* move to caption itself?
% \begin{noindmacro}{\caption@@make@} \marg{} \marg{}
%    \begin{macrocode}
\renewcommand{\caption@@make@}[2]{%
  \caption@stepthecounter
  \caption@beginhook
      \caption@@@make{#1}{#2}%
  \caption@endhook
}
%    \end{macrocode}
% \end{noindmacro}


%    \begin{macrocode}
% \DeclareCaptionBox{none}{#2}
\DeclareCaptionBox{parbox}{%
#2%
}
\DeclareCaptionBox{colorbox}{%
#2%
}
%    \end{macrocode}

% \iffalse
%</caption>
% \fi
%
%
%
%
%
%
%
%
% \iffalse
%<*cases>
% \fi
%
% \part{lwarp-cases.sty}
%
% \section{cases}
%
% \credits{Donald Arseneau}
%
% \DescribePackage{cases}
% \pkg{cases} is patched for use by \pkg{lwarp}.
%
% 
%
% MathJax does not support \pkg{cases}.
% \trouble[\brand{MathJax}]{cases=\pkg{cases}>MathJax=\brand{MathJax}}
% \trouble{MathJax=\brand{MathJax}>cases=\pkg{cases}}
%
% \changes{v0.58}{2018/06/08}{\pkg{cases}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{cases}[2002/05/02]
%    \end{macrocode}
%
%    \begin{macrocode}
\BeforeBeginEnvironment{numcases}{
    \begin{BlockClass}{displaymathnumbered}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[-cases- \mathimagename]
}

\AfterEndEnvironment{numcases}{
    \end{lateximage}\end{BlockClass}
}

\BeforeBeginEnvironment{subnumcases}{
    \begin{BlockClass}{displaymathnumbered}
    \LWR@newautoidanchor%
    \booltrue{LWR@indisplaymathimage}%
    \begin{lateximage}[-cases- \mathimagename]
}

\AfterEndEnvironment{subnumcases}{
    \end{lateximage}\end{BlockClass}
}
%    \end{macrocode}
%
% \iffalse
%</cases>
% \fi
%
%
%
% \iffalse
%<*changebar>
% \fi
%
% \part{lwarp-changebar.sty}
%
% \section{changebar}
%
% \DescribePackage{changebar}
% \pkg{changebar} is ignored.
%
% \changes{v0.45}{2017/12/15}{\pkg{changebar}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{changebar}[2018/03/09]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\cbstart}{}
\newcommand*{\cbend}{}
\newenvironment*{\changebar}{}{}
\newcommand*{\cbdelete}{}
\newcommand*{\nochnagebars}{}
\newcommand*{\cbcolor}[1]{}
\newlength{\changebarwidth}
\newlength{\deletebarwidth}
\newlength{\changebarsep}
\newcounter{changebargrey}
%    \end{macrocode}
%
% \iffalse
%</changebar>
% \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}[2009/10/20]
%    \end{macrocode}

%    \begin{macrocode}
\newif\ifoddpage
\DeclareRobustCommand{\checkoddpage}{\oddpagetrue}
\DeclareRobustCommand{\changetext}[5]{}
\DeclareRobustCommand{\changepage}[9]{}

\@ifundefined{adjustwidth}{
\newenvironment{adjustwidth}[2]{}{}
\newenvironment{adjustwidth*}[2]{}{}
}{
\renewenvironment{adjustwidth}[2]{}{}
\renewenvironment{adjustwidth*}[2]{}{}
}
%    \end{macrocode}

% \changes{v0.44}{2017/11/13}{\pkg{changepage}: Additional options.}
% \changes{v0.47}{2018/01/30}{\pkg{changepage}: Fix for pagecheck macros.}
%    \begin{macrocode}
\DeclareDocumentCommand{\strictpagecheck}{}{}
\DeclareDocumentCommand{\easypagecheck}{}{}
%    \end{macrocode}

% \iffalse
%</changepage>
% \fi
%
%
%
% \iffalse
%<*changes>
% \fi
%
% \part{lwarp-changes.sty}
%
% \section{changes}
%
% \credits{Ekkart Kleinod}
%
% \DescribePackage{changes}
% \pkg{changes} is patched for use by \pkg{lwarp}.
%
% \changes{v0.67}{2019/02/15}{\pkg{changes}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{changes}[2015/04/27]
%    \end{macrocode}
%
%    \begin{macrocode}
\xpatchcmd{\Changes@output}
    {#1}
    {\LWR@textcurrentcolor{#1}}
    {}
    {\LWR@patcherror{changes}{Changes@output}}

\xpatchcmd{\listofchanges}
    {
        \ifthenelse{\equal{\Changes@InID}{\@empty}}
        {\changesauthorname: \changesanonymousname}
        {%
        \changesauthorname: \Changes@InID
        \ifthenelse{\equal{\Changes@InName}{\@empty}}
        {}
        { (\Changes@InName)}
        }
    }
    {
        \LWR@textcurrentcolor{% lwarp
            \ifthenelse{\equal{\Changes@InID}{\@empty}}
            {\changesauthorname: \changesanonymousname}
            {%
            \changesauthorname: \Changes@InID
            \ifthenelse{\equal{\Changes@InName}{\@empty}}
            {}
            { (\Changes@InName)}
            }
        }
    }
    {}
    {\LWR@patcherror{changes}{listofchanges}}

\xpatchcmd{\listofchanges}
    {\parbox{\Changes@Len@summ}}
    {}
    {}
    {\LWR@patcherror{changes}{listofchanges}}

\xpatchcmd{\listofchanges}
    {\parbox{\Changes@Len@summ}}
    {}
    {}
    {\LWR@patcherror{changes}{listofchanges}}

\xpatchcmd{\listofchanges}
    {\parbox{\Changes@Len@summ}}
    {}
    {}
    {\LWR@patcherror{changes}{listofchanges}}
%    \end{macrocode}
%
% \iffalse
%</changes>
% \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}[2006/05/09]
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand{\pagenumbering}[2][]{}
\providecommand{\chappgsep}{--}
%    \end{macrocode}
%
% \iffalse
%</chappg>
% \fi
%
%
%
%
% \iffalse
%<*chapterbib>
% \fi
%
% \part{lwarp-chapterbib.sty}

% \section{chapterbib}
%
% \credits{Donald Arseneau}
%
% \DescribePackage{chapterbib}
% \pkg{chapterbib} is patched for use by \pkg{lwarp}.
%
% \changes{v0.48}{2018/02/05}{\pkg{chapterbib}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{chapterbib}[2010/09/18]
%    \end{macrocode}

%    \begin{macrocode}
\xdef\@savedjobname{\BaseJobname}
\let\@currentipfile\@savedjobname
%    \end{macrocode}

% \iffalse
%</chapterbib>
% \fi
%
%
%
%
% \iffalse
%<*chemfig>
% \fi
%
% \part{lwarp-chemfig.sty}

% \section{chemfig}
%
% \credits{Christian Tellechea}
%
% \DescribePackage{chemfig}
% \pkg{chemfig} is patched for use by \pkg{lwarp}.
%
% \limitschemfig
%
% The images are not hashed because they depend on external settings which
% may be changed at any time, and are unlikely to be reused inline anyhow.
%
% \changes{v0.51}{2018/03/04}{\pkg{chemfig}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{chemfig}
%    \end{macrocode}

%    \begin{macrocode}
\LetLtxMacro\LWR@chemfig@origchemfig\chemfig

\DeclareDocumentCommand\chemfig{s O{} O{} m}{%
    \begin{lateximage}[(-chemfig-~\packagediagramname)]%
    \IfBooleanTF{#1}{%
        \LWR@chemfig@origchemfig*[#2][#3]{#4}%
    }{%
        \LWR@chemfig@origchemfig[#2][#3]{#4}%
    }
    \end{lateximage}%
}

\LetLtxMacro\LWR@chemfig@origCF@lewis@b\CF@lewis@b

\def\CF@lewis@b#1#2{%
\begin{lateximage}[(-chemfig-~\packagediagramname)]%
\LWR@chemfig@origCF@lewis@b{#1}{#2}%
\end{lateximage}%
}

\preto{\schemestart}{\begin{lateximage}[(-chemfig-~\packagediagramname)]}
\appto{\CF@schemestop}{\end{lateximage}}

\LetLtxMacro\LWR@chemfig@origchemleft\chemleft

\def\chemleft#1#2\chemright#3{%
\begin{lateximage}[(-chemfig-~\packagediagramname)]%
\LWR@chemfig@origchemleft#1#2\chemright#3%
\end{lateximage}%
}

\LetLtxMacro\LWR@chemfig@origchemup\chemup

\def\chemup#1#2\chemdown#3{%
\begin{lateximage}[(-chemfig-~\packagediagramname)]%
\LWR@chemfig@origchemup#1#2\chemdown#3%
\end{lateximage}%
}
%    \end{macrocode}

% \iffalse
%</chemfig>
% \fi
%
%
%
%
%
% \iffalse
%<*chemformula>
% \fi
%
% \part{lwarp-chemformula.sty}

% \section{chemformula}
%
% \credits{Clemens Niederberger}
%
% \DescribePackage{chemformula}
% \pkg{chemformula} is patched for use by \pkg{lwarp}.
%
% The \SVG\ images are hashed according to contents and local options.
% Global options are assumed to be constant document-wide.
%
% \limitschemformula
%
% \changes{v0.51}{2018/03/05}{\pkg{chemformula}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{chemformula}[2017/03/23]
%    \end{macrocode}

%    \begin{macrocode}
\ExplSyntaxOn
%    \end{macrocode}
%
% \begin{noindmacro}{\ch}
% Enclose in an inline \SVG\ image or MathJax.
% The \attribute{alt} tag is is the contents of the \cs{ch} expression.
% The filename is hashed, and also has additional hashing information based on
% the local options.
%    \begin{macrocode}
\RenewDocumentCommand \ch { O{}m }
  {%
%    \end{macrocode}
% To work inside \env{align} with \cs{displaymathother}, a simple version
% must be used to work with \pkg{chemformula}'s adaptation to \env{align}.
%    \begin{macrocode}
    \ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%  lwarp
    {
        \chemformula_ch:nn {#1} {#2}%   original
    }
%    \end{macrocode}
% If used as the outer level, must temporarily ensure \brand{MathJax} is disabled:
%    \begin{macrocode}
    {
        \begingroup%
        \boolfalse{mathjax}%
%    \end{macrocode}
% An inline image is used, adjusted for the baseline:
%    \begin{macrocode}
        \LWR@subsingledollar*{% lwarp
            \textbackslash{}ch\{\LWR@HTMLsanitize{#2}\}% alt text
        }{%
           \protect\LWR@HTMLsanitize{\detokenize\expandafter{#1}}% add'l hashing
        }%
        {%
            \chemformula_ch:nn {#1} {#2}%   original
        }%
        \endgroup%
    }
  }
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\chcpd}
% Similar to \cs{ch}.
%    \begin{macrocode}
\cs_gset_protected:Npn \chemformula_chcpd:nn #1#2
  {
    \begingroup%
    \boolfalse{mathjax}%
    \LWR@subsingledollar*{% lwarp
        \textbackslash{}chcpd\{\LWR@HTMLsanitize{#2}\}%
    }{%
        \protect\LWR@HTMLsanitize{\detokenize\expandafter{#1}}%
    }{% original
    \group_begin:
      \tl_if_blank:nF {#2}
        {
          \keys_set:nn {chemformula} {#1}
          \__chemformula_save_catcodes:
          \__chemformula_sanitize:Nn
            \l__chemformula_chemformula_tmpa_tl
            {#2}
          \__chemformula_input_compound_no_check:NV
            \l__chemformula_compound_tl
            \l__chemformula_chemformula_tmpa_tl
          \__chemformula_prepare_output:N \l__chemformula_compound_tl
          \chemformula_write:V \l__chemformula_compound_tl
        }
    \group_end:
    }
    \endgroup
  }
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\charrow}
% If standalone, appears in a regular \env{lateximage}.
%    \begin{macrocode}
\RenewDocumentCommand \charrow { mO{}O{} }
{
    \begin{lateximage}[(-chemformula- charrow)]
    \group_begin:
      \__chemformula_draw_arrow:nnn {#1} {#2} {#3}
    \group_end:
    \end{lateximage}
}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\chname}
% If standalone, appears in a regular \env{lateximage}, hashed according to contents.
%    \begin{macrocode}
\RenewDocumentCommand \chname { R(){}R(){} }
  {
    \begin{lateximage}*[%
        \textbackslash{}chname(\LWR@HTMLsanitize{#1})(\LWR@HTMLsanitize{#2})
    ]%
        \chemformula_chwritebelow:nn {#1} {#2}
    \end{lateximage}
  }
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\chlewis}
% Placed inline, hashed according to contents and options.
%    \begin{macrocode}
\RenewDocumentCommand \chlewis { O{}mm }
  {
    \begingroup%
    \boolfalse{mathjax}%
    \LWR@subsingledollar*{\textbackslash{}chlewis\{#2\}\{#3\}}%
    {
        \protect\LWR@HTMLsanitize{\detokenize\expandafter{#1}}%
    }{
        \chemformula_lewis:nnn {#1} {#2} {#3}
    }
    \endgroup%
  }
%    \end{macrocode}
% \end{noindmacro}
%
%
% \pkg{lwarp} redefines the |$| character, so special handling is required
% to escape math expressions inside \cs{ch}.
%
% This boolean tracks a new kind of escaped math:
%    \begin{macrocode}
\bool_new:N      \l__chemformula_first_last_LWRdollar_bool
%    \end{macrocode}
%
% \begin{noindmacro}{\chemformula\_input\_escape\_math} \\
%
% Adds additional escaping for the new dollar definition:
%    \begin{macrocode}
\cs_gset_protected:Npn \__chemformula_input_escape_math:n #1
  {
    \__chemformula_first_last_math:n {#1}
    \bool_if:NT \l__chemformula_first_last_dollar_bool
      {
        \bool_set_true:N \l__chemformula_first_last_math_bool
        \__chemformula_read_escape_dollar:w #1 \q_nil
      }
    \bool_if:NT \l__chemformula_first_last_mathbraces_bool
      {
        \bool_set_true:N \l__chemformula_first_last_math_bool
        \__chemformula_read_escape_mathbraces:w #1 \q_nil
      }
%    \end{macrocode}
% Added by \pkg{lwarp}:
%    \begin{macrocode}
    \bool_if:NT \l__chemformula_first_last_LWRdollar_bool%      lwarp
      {
        \bool_set_true:N \l__chemformula_first_last_math_bool%  lwarp
        \__chemformula_read_escape_LWRdollar:w #1 \q_nil%       lwarp
      }
  }
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\chemformula\_read\_escape\_LWRdollar} \\
%
% The following parses the contents inside the new dollars.
%
% \pkg{lwarp} keeps the dollar as its original math shift until the document
% starts.
% While \pkg{chemmacros} is being patched, the dollar must temporarily
% be set to its new meaning during the following definition.
%
%    \begin{macrocode}
\begingroup
\catcode`\$=\active

\cs_new_protected:Npn \__chemformula_read_escape_LWRdollar:w $#1$ \q_nil
{
    \__chemformula_read_escape_math:n {#1}
}

\endgroup
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\chemformula\_bool\_set\_if\_first\_last} \\
%
% The following looks at the first and last tokens for delimiters to escape
% math inside \cs{ch}.
% The original definition is modified to look for the
% control sequences which are used by the new meaning of |$|.
%    \begin{macrocode}
\cs_new_protected:Npn \__chemformula_bool_cs_set_if_first_last:NnNN #1#2#3#4
  {
    \int_zero:N \l__chemformula_tmpa_int
    \int_zero:N \l__chemformula_tmpb_int
    \int_set:Nn \l__chemformula_tmpa_int { \tl_count:n {#2} }
    \tl_map_inline:nn {#2}
      {
        \int_incr:N \l__chemformula_tmpb_int
        \int_compare:nT { \l__chemformula_tmpb_int = 1 }
          {
%    \end{macrocode}
% At the start, the |cs_| version compares control sequences:
%    \begin{macrocode}
            \ifdefstrequal{##1}{#3}% lwarp
                {
                    \bool_set_true:N #1
                }% lwarp
                {}
          }
%    \end{macrocode}
% At the end, compare more control sequences:
%    \begin{macrocode}
        \int_compare:nT { \l__chemformula_tmpb_int = \l__chemformula_tmpa_int }
          {
            \ifdefstrequal{##1}{#4}
                {}
                {
                    \bool_set_false:N #1
                }
          }
      }
  }
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\chemformula\_first\_last\_math} \\
%
% Modified to check for the new meaning of |$| at first/last:
%    \begin{macrocode}
\cs_gset_protected:Npn \__chemformula_first_last_math:n #1
  {
    \bool_set_false:N \l__chemformula_first_last_math_bool
    \bool_set_false:N \l__chemformula_first_last_dollar_bool
    \bool_set_false:N \l__chemformula_first_last_LWRdollar_bool%    lwarp
    \bool_set_false:N \l__chemformula_first_last_mathbraces_bool
    \__chemformula_bool_set_if_first_last:Nnnn
      \l__chemformula_first_last_dollar_bool
      {#1}
      { $ } { $ }
    \bool_if:NF \l__chemformula_first_last_dollar_bool
      {
        \__chemformula_bool_set_if_first_last:Nnnn
          \l__chemformula_first_last_mathbraces_bool
          {#1}
          { \( } { \) }
%    \end{macrocode}
% Added by \pkg{lwarp}:
%    \begin{macrocode}
          \bool_if:NF \l__chemformula_first_last_mathbraces_bool%   lwarp
            {
                \__chemformula_bool_cs_set_if_first_last:NnNN
                \l__chemformula_first_last_LWRdollar_bool
                {#1}
                { \LWR@newsingledollar } { \LWR@newsingledollar }
            }%  lwarp
      }
  }
%    \end{macrocode}
% \end{noindmacro}
%
%
%    \begin{macrocode}
\ExplSyntaxOff
%    \end{macrocode}
%
% \iffalse
%</chemformula>
% \fi
%
%
%
% \iffalse
%<*chemgreek>
% \fi
%
% \part{lwarp-chemgreek.sty}

% \section{chemgreek}
%
% \credits{Clemens Niederberger}
%
% \DescribePackage{chemgreek}
% \pkg{chemgreek} is patched for use by \pkg{lwarp}.
%
% To use text-mode symbols, \margintag{Greek symbols}
% use packages \pkg{textalpha} or \pkg{textgreek}.
% Using the other packages supported by \pkg{chemgreek}
% \trouble[package selection]{Greek packages}
% \trouble{chemgreek=\pkg{chemgreek}>text-mode symbols}
% will result in math-mode greek characters,
% which will result in \SVG\ images being used.
% These images will be hashed.
% \gindex{chemistry>Greek symbols}
% \gindex{Greek>chemistry symbols}
%
% If using \XeLaTeX\ or \LuaLaTeX, select the |fontspec| mapping:
% \trouble[\XeLaTeX, \LuaLaTeX]{chemgreek=\pkg{chemgreek}>fontspec mapping}
% \begin{sourcedisplay}
% \cs{selectchemgreekmapping}\{fontspec\}
% \end{sourcedisplay}
%
%
% \changes{v0.51}{2018/03/08}{\pkg{chemgreek}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{chemgreek}[2016/02/10]
%    \end{macrocode}

%    \begin{macrocode}
\ExplSyntaxOn

\cs_gset_protected:Npn \chemgreek_text:n #1
  { { \text {#1} } }

\appto\LWR@restoreorigformatting{%
\cs_set_protected:Npn \chemgreek_text:n #1%
  { \ensuremath { \text {#1} } }%
}

\ExplSyntaxOff
%    \end{macrocode}

% \iffalse
%</chemgreek>
% \fi
%
%
%
%
% \iffalse
%<*chemmacros>
% \fi
%
% \part{lwarp-chemmacros.sty}

% \section{chemmacros}
%
% \credits{Clemens Niederberger}
%
% \DescribePackage{chemmacros}
% \pkg{chemmacros} is patched for use by \pkg{lwarp}.
%
% \changes{v0.51}{2018/03/13}{\pkg{chemmacros}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{chemmacros}[2017/08/28]
%    \end{macrocode}
%
% SVG file hashing assumes that the relevent options are constant for the entire document.
%
% \subsection{Changes to the user's document}
%
% When using \cs{makepolymerdelims},
% \trouble[\cs{makepolymerdelims}]{chemmacros=\pkg{chemmacros}>makepolymerdelims=\cs{makepolymerdelims}}
% enclose the entire expression inside a \env{polymerdelims} environment,
% such as (from the \pkg{chemmacros} manual):
%
% \begin{Verbatim}[gobble=2]
% \begin{polymerdelims}
% \chemfig{-[@{op,.75}]CH_2-CH(-[6]Cl)-[@{cl,0.25}]}
% \makepolymerdelims{5pt}[27pt]{op}{cl}
% \end{polymerdelims}
% \end{Verbatim}
%
% \hrule
%
% Redox reactions must be enclosed inside
% a \env{redoxreaction} environment.
% \trouble[redox reactions]{chemmacros=\pkg{chemmacros}>redox reactions}
% For print output, extra space must be included above and/or below the result,
% so they are declared as arguments to the environment, instead of
% being manually entered as per the \pkg{chemmacros} manual.
% For \HTML\ output, the extra space is ignored and a \env{lateximage} is used instead.
% \begin{Verbatim}[gobble=2]
% \begin{redoxreaction}{7mm}{7mm}
% \OX{a,Na} $\rightarrow$ \OX{b,Na}\pch\redox(a,b){oxidation}
% \end{redoxreaction}
% \end{Verbatim}
%
% \subsection{Code}
%
%
% \subsection{Loading modules}
%
% Patching \pkg{chemmacros} modules must be done \cs{AtBeginDocument},
% since modules are invoked by the user in the preamble, and each patch is
% only done if the module is loaded.
%
%    \begin{macrocode}
\ExplSyntaxOn

\newcommand{\@ifchemmacrosmoduleloaded}[1]{%
\@ifl@aded{\c__chemmacros_module_extension_tl}{\c__chemmacros_module_prefix_tl.#1}%
}

\ExplSyntaxOff
%    \end{macrocode}
%
%
% \subsection{New environments}
% \label{sec:chemmacroshtmlenvs}
%
% \cs{makepolymerdelims} and redox reactions must be enclosed in a \env{lateximage}
% during \HTML\ output.
% These environments are provided here in \HTML\ mode, and in the \pkg{lwarp} core
% in print mode, as a high-level semantic syntax which automatically embeds the
% contents in a \env{lateximage} with an appropriate \attribute{alt} tag.
%
% \begin{noindenvironment}{polymerdelims}
%    \begin{macrocode}
\DeclareDocumentEnvironment{polymerdelims}{}
{\begin{lateximage}[(-chemmacros- polymer)]}
{\end{lateximage}}
%    \end{macrocode}
% \end{noindenvironment}

% \begin{noindenvironment}{redoxreaction} \marg{space above} \marg{space below}
%
% For \HTML\ output, the above and below space is ignored, and a \env{lateximage}
% is used instead.
% For the print output version, see \cref{sec:chemmacrosprintenvs}.
%    \begin{macrocode}
\DeclareDocumentEnvironment{redoxreaction}{m m}
{\begin{lateximage}[(-chemmacros- redoxreaction)]}
{\end{lateximage}}
%    \end{macrocode}
% \end{noindenvironment}
%
%
%    \begin{macrocode}
\ExplSyntaxOn
%    \end{macrocode}
%
%
% \subsection{Acid-base}
%
%    \begin{macrocode}
\AtBeginDocument{
\@ifchemmacrosmoduleloaded{acid-base}{
\PackageInfo{lwarp}{Patching~chemmacros~module~acid-base}

\cs_gset_protected:Npn \chemmacros_p:n #1
  {
    \begingroup
    \boolfalse{mathjax}
    \LWR@subsingledollar*{
        \textbackslash{}p\{\LWR@HTMLsanitize{#1}\}
    }{
        chemmacrosp\protect\LWR@HTMLsanitize{\detokenize\expandafter{#1}}%
    }{
    \group_begin:
      \mbox
        {
          \chemmacros_p_style:n {p}
          \ensuremath {#1}
        }
    \group_end:
    }
    \endgroup
  }

\RenewDocumentCommand \pH  {} {
    \begingroup
    \boolfalse{mathjax}
    \LWR@subsingledollar*{\textbackslash{}pH}{chemmacros}{
        \chemmacros_p:n { \chemmacros_chemformula:n {H} }
    }
    \endgroup
}

\RenewDocumentCommand \pOH {} {
    \begingroup
    \boolfalse{mathjax}
    \LWR@subsingledollar*{\textbackslash{}pOH}{chemmacros}{
        \chemmacros_p:n { \chemmacros_chemformula:n {OH} }
    }
    \endgroup
}

\RenewDocumentCommand \pKa {O{}}
  {
    \begingroup
    \boolfalse{mathjax}
    \LWR@subsingledollar*{\textbackslash{}pKa{[}#1{]}}{chemmacros #1}{
        \chemmacros_p:n
        {
            \Ka \ifblank {#1} {}
            { {} \c_math_subscript_token { \chemmacros_bold:n {#1} } }
        }
    }
    \endgroup
  }

\RenewDocumentCommand \pKb {O{}}
  {
    \begingroup
    \boolfalse{mathjax}
    \LWR@subsingledollar*{\textbackslash{}pKb{[}#1{]}}{chemmacros #1}{
        \chemmacros_p:n
        {
            \Kb \ifblank {#1} {}
            { {} \c_math_subscript_token { \chemmacros_bold:n {#1} } }
        }
    }
    \endgroup
  }

\LetLtxMacro\LWR@chemmacros@origKa\Ka
\renewcommand*{\Ka}{%
    \begingroup
    \boolfalse{mathjax}
    \LWR@subsingledollar*{\textbackslash{}Ka}{chemmacros}{%
        \LWR@chemmacros@origKa%
    }%
    \endgroup
}

\LetLtxMacro\LWR@chemmacros@origKb\Kb
\renewcommand*{\Kb}{%
    \begingroup
    \boolfalse{mathjax}
    \LWR@subsingledollar*{\textbackslash{}Kb}{chemmacros}{%
        \LWR@chemmacros@origKb%
    }%
    \endgroup
}

\LetLtxMacro\LWR@chemmacros@origKw\Kw
\renewcommand*{\Kw}{%
    \begingroup
    \boolfalse{mathjax}
    \LWR@subsingledollar*{\textbackslash{}Kw}{chemmacros}{
        \LWR@chemmacros@origKw
    }
    \endgroup
}

}{}% \@ifchemmacrosmoduleloaded
}% AtBeginDocument
%    \end{macrocode}
%
%
% \subsection{Charges}
%
%    \begin{macrocode}
\AtBeginDocument{
\@ifchemmacrosmoduleloaded{charges}{
\PackageInfo{lwarp}{Patching~chemmacros~module~charges}

\cs_gset_protected:Npn \fplus  {
    \begingroup
    \boolfalse{mathjax}
    \LWR@subsingledollar*{\textbackslash{}fplus}{chemmacros}
    { \LWR@origensuredmath{\chemformula_fplus:}  }
    \endgroup
}
\cs_gset_protected:Npn \fminus {
    \begingroup
    \boolfalse{mathjax}
    \LWR@subsingledollar*{\textbackslash{}fminus}{chemmacros}
    { \LWR@origensuredmath{\chemformula_fminus:} }
    \endgroup
}

}{}% \@ifchemmacrosmoduleloaded
}% AtBeginDocument
%    \end{macrocode}
%
%
% \subsection{Nomenclature}
%
%    \begin{macrocode}
\AtBeginDocument{
\@ifchemmacrosmoduleloaded{nomenclature}{
\PackageInfo{lwarp}{Patching~chemmacros~module~nomenclature}

\cs_gset_protected:Npn \chemmacros_charge:n #1
  {
    \ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}
    {\chemmacros_chemformula:n { {}^{#1} }}
    {
        \ifmmode
            {\chemmacros_chemformula:n { {}^{#1} }}
        \else
            { \textsuperscript{\ensuremath{#1}} }
        \fi
    }
  }


\LetLtxMacro\LWR@chemmacros@origchemprime\chemprime

\protected\def\chemprime { \HTMLunicode{2032} }

\appto\LWR@restoreorigformatting{%
\LetLtxMacro\chemprime\LWR@chemmacros@origchemprime%
}
%    \end{macrocode}
%
% ^^A \RenewChemIUPAC \chemprime { \HTMLunicode{2032} }
%
%    \begin{macrocode}
\ChemCompatibilityFrom{5.8}
\cs_gset_protected:Npn \__chemmacros_cip:n #1
  {
    \tl_set:Nn \l__chemmacros_tmpa_tl {#1}
    \int_step_inline:nnnn {0} {1} {9}
      {
        \tl_replace_all:Nnn \l__chemmacros_tmpa_tl
          {##1}
          { { \l__chemmacros_cip_number_tl ##1} }
      }
    {
        \l__chemmacros_cip_inner_tl
        \LWR@textcurrentcolor{\LWR@textcurrentfont{% lwarp
            \l__chemmacros_tmpa_tl
        }}% lwarp
    }
  }
\EndChemCompatibility
%    \end{macrocode}
%
%    \begin{macrocode}
\RenewDocumentCommand \Sconf { O{S} } {
\begin{lateximage}[\textbackslash{}Sconf{[}#1{]}]
    \chemmacros_sconf:n {#1}
\end{lateximage}
}

\RenewDocumentCommand \Rconf { O{R} } {
\begin{lateximage}[\textbackslash{}Rconf{[}#1{]}]
    \chemmacros_rconf:n {#1}
\end{lateximage}
}
%    \end{macrocode}
%
%    \begin{macrocode}
\cs_gset_protected:Npn \chemmacros_hapto:n #1
  {
    \begingroup
    \boolfalse{mathjax}
    \LWR@subsingledollar*{\textbackslash{}hapto\{#1\}}{chemmacros}{
        \chemmacros_coordination_symbol:nnnn
        { \l__chemmacros_coord_use_hyphen_bool }
        {
            \chemmacros_if_compatibility:nnTF {>} {5.7}
            { \c_true_bool }
            { \c_false_bool }
        }
        { \chemeta }
        {#1}
    }
    \endgroup
  }

\cs_gset_protected:Npn \chemmacros_dento:n #1
  {
    \begingroup
    \boolfalse{mathjax}
    \LWR@subsingledollar*{\textbackslash{}dento\{#1\}}{chemmacros}{
        \chemmacros_coordination_symbol:nnnn
        { \l__chemmacros_coord_use_hyphen_bool }
        {
            \chemmacros_if_compatibility:nnTF {>} {5.7}
            { \c_true_bool }
            { \c_false_bool }
        }
        { \chemkappa }
        {#1}
    }
    \endgroup
  }

\cs_gset_protected:Npn \chemmacros_bridge:n #1
  {
    \begingroup
    \boolfalse{mathjax}
    \LWR@subsingledollar*{\textbackslash{}bridge\{#1\}}{chemmacros}{
        \chemmacros_coordination_symbol:nnnn
        { \l__chemmacros_coord_use_hyphen_bool }
        { \l__chemmacros_bridge_super_bool }
        { \chemmu }
        {#1}
    }
    \endgroup
  }
}{}% \@ifchemmacrosmoduleloaded
}% AtBeginDocument
%    \end{macrocode}
%
%
% \subsection{Particles}
%
%    \begin{macrocode}
\AtBeginDocument{
\@ifchemmacrosmoduleloaded{particles}{
\PackageInfo{lwarp}{Patching~chemmacros~module~particles}

\cs_gset_protected:Npn \chemmacros_declare_nucleophile:Nn #1#2
  {
    \cs_set_protected:cpn {__chemmacros_ \chemmacros_remove_backslash:N #1:}
      {
        \bool_if:NTF \l__chemmacros_nucleophile_elpair_bool
          {
            \chemmacros_elpair:n { #2 }
            \chemmacros_if_compatibility:nnT {>=} {5.3}
              { \skip_horizontal:N \l__chemmacros_nucleophile_dim }
            \chemmacros_chemformula:n { {}^{-} }
          }
          { \chemmacros_chemformula:n { #2^{-} } }
      }
    \DeclareDocumentCommand #1 {o}
      {%
        \begin{lateximage}%
        \group_begin:%
          \IfNoValueF {##1}%
            { \chemmacros_set_keys:nn {particles} {##1} }%
          \use:c {__chemmacros_ \chemmacros_remove_backslash:N #1:}%
        \group_end:%
        \end{lateximage}%
      }
  }

\RenewChemNucleophile \Nuc {Nu}
\RenewChemNucleophile \ba  {ba}

}{}% \@ifchemmacrosmoduleloaded
}% AtBeginDocument
%    \end{macrocode}
%
%
% \subsection{Phases}
%
%    \begin{macrocode}
\AtBeginDocument{
\@ifchemmacrosmoduleloaded{phases}{
\PackageInfo{lwarp}{Patching~chemmacros~module~phases}

\cs_undefine:N \chemmacros_phase:n
\cs_new_protected:Npn \chemmacros_phase:n #1
  {
    \chemmacros_leave_vmode:
    \bool_if:NTF \l__chemmacros_phases_sub_bool
      {
        \ifnumequal{\value{LWR@lateximagedepth}}{0}
        {
            \textsubscript{ (#1) }
        }
        {
            \chemformula_subscript:n { (#1) }
        }
      }
      {
        \skip_horizontal:N \l__chemmacros_phases_space_dim
        \chemmacros_text:n { (#1) }
      }
  }

}{}% \@ifchemmacrosmoduleloaded
}% AtBeginDocument
%    \end{macrocode}
%
% \subsection{Mechanisms}
%
%    \begin{macrocode}
\AtBeginDocument{
\@ifchemmacrosmoduleloaded{mechanisms}{
\PackageInfo{lwarp}{Patching~chemmacros~module~mechanisms}

\chemmacros_define_keys:nn {textmechanisms}
  {
    type      .choice: ,
    type /    .code:n    =
      {
        \__chemmacros_set_mechanisms:nnn { S }
          {
              \textsubscript{N}
          }
          { }
      } ,
    type / 1  .code:n    =
      {
        \__chemmacros_set_mechanisms:nnn { S }
          {
              \textsubscript{N}
            1
          }
          { }
      } ,
    type / 2  .code:n    =
      {
        \__chemmacros_set_mechanisms:nnn { S }
          {
              \textsubscript{N}
            2
          }
          { }
      } ,
    type / se .code:n    =
      {
        \__chemmacros_set_mechanisms:nnn { S }
          {
              \textsubscript{E}
          }
          { }
      } ,
    type / 1e .code:n    =
      {
        \__chemmacros_set_mechanisms:nnn { S }
          {
              \textsubscript{E}
            1
          }
          { }
      } ,
    type / 2e .code:n    =
      {
        \__chemmacros_set_mechanisms:nnn { S }
          {
              \textsubscript{E}
            2
          }
          { }
      } ,
    type / ar .code:n    =
      {
        \__chemmacros_set_mechanisms:nnn { S }
          {
              \textsubscript{E}
          }
          { Ar - }
      } ,
    type / e  .code:n    =
      { \__chemmacros_set_mechanisms:nnn { E } { } { } } ,
    type / e1 .code:n    =
      { \__chemmacros_set_mechanisms:nnn { E } { 1 } { } } ,
    type / e2 .code:n    =
      { \__chemmacros_set_mechanisms:nnn { E } { 2 } { } } ,
    type / cb .code:n    =
      {
        \__chemmacros_set_mechanisms:nnn { E }
          {
            1
              \textsubscript{cb}
          }
          { }
      } ,
    type      .default:n = 
  }

\cs_gset_protected:Npn \chemmacros_mechanisms:n #1
  {
    \tl_if_blank:nTF {#1}
      { \chemmacros_set_keys:nn {textmechanisms} { type } }
      { \chemmacros_set_keys:nn {textmechanisms} { type = #1 } }
    \mbox
      {
        \tl_use:N \l__chemmacros_mechanisms_ar_tl
        \tl_use:N \l__chemmacros_mechanisms_type_tl
        \tl_use:N \l__chemmacros_mechanisms_mol_tl
      }
  }

\appto\LWR@restoreorigformatting{%
\cs_set_protected:Npn \chemmacros_mechanisms:n #1%
  {%
    \tl_if_blank:nTF {#1}%
      { \chemmacros_set_keys:nn {mechanisms} { type } }%
      { \chemmacros_set_keys:nn {mechanisms} { type = #1 } }%
    \mbox%
      {%
        \tl_use:N \l__chemmacros_mechanisms_ar_tl%
        \tl_use:N \l__chemmacros_mechanisms_type_tl%
        \tl_use:N \l__chemmacros_mechanisms_mol_tl%
      }%
  }%
}

}{}% \@ifchemmacrosmoduleloaded
}% AtBeginDocument
%    \end{macrocode}
%
% \subsection{Newman}
%
%    \begin{macrocode}
\AtBeginDocument{
\@ifchemmacrosmoduleloaded{newman}{
\PackageInfo{lwarp}{Patching~chemmacros~module~newman}

\RenewDocumentCommand \newman {od()m}%
  {
    \IfValueTF{#2}
    {\begin{lateximage}[\textbackslash{}newman(#2)\{#3\}]}
    {\begin{lateximage}[\textbackslash{}newman\{#3\}]}
    \group_begin:
      \IfNoValueF  {#1} { \chemmacros_set_keys:nn {newman} {#1} }
      \IfNoValueTF {#2}
        { \chemmacros_newman:nn {  } {#3} }
        { \chemmacros_newman:nn {#2} {#3} }
    \group_end:
    \end{lateximage}
  }%

}{}% \@ifchemmacrosmoduleloaded
}% AtBeginDocument
%    \end{macrocode}
%
% \subsection{Orbital}
%
%    \begin{macrocode}
\AtBeginDocument{
\@ifchemmacrosmoduleloaded{orbital}{
\PackageInfo{lwarp}{Patching~chemmacros~module~orbital}

\RenewDocumentCommand \orbital {om}
  {
    \IfValueTF{#1}
    {
        \begin{lateximage}[%
            \textbackslash{}orbital{[}\LWR@HTMLsanitize{#1}{]}\{#2\}%
        ][][margin-left: 1em ; margin-right: 1em]
    }
    {
        \begin{lateximage}[%
            \textbackslash{}orbital\{#2\}%
        ][][margin-left: 1em ; margin-right: 1em]
    }
    \group_begin:
      \chemmacros_set_keys:nn {orbital/type} {#2}
      \IfNoValueTF {#1}
        { \chemmacros_orbital:n {  } }
        { \chemmacros_orbital:n {#1} }
    \group_end:
    \end{lateximage}
  }

}{}% \@ifchemmacrosmoduleloaded
}% AtBeginDocument
%    \end{macrocode}
%
%
% \subsection{Reactions}
%
% \begin{noindmacro}{\chemmacros\_declare\_reaction\_env} \\
%   \fqquad \marg{chem} \marg{math} \marg{args number} \marg{argument list (\{\#2\}\{\#3\}...)}
%    \begin{macrocode}
\AtBeginDocument{
\@ifchemmacrosmoduleloaded{reactions}{
\PackageInfo{lwarp}{Patching~chemmacros~module~reactions}

\cs_gset_protected:Npn \chemmacros_declare_reaction_env:nnnn #1#2#3#4
  {
    \exp_args:Nnx \DeclareDocumentEnvironment {#1} { O{} \prg_replicate:nn {#3+0} {m} }
      {
        \boolfalse{mathjax}%    lwarp
        \chemmacros_add_reaction_description:n {##1}
        \__chemmacros_begin_reaction:
        \chemmacros_reaction_read:nnw {#2} {#4}
      }
      {
        \__chemmacros_end_reaction:
      }
  }
\cs_generate_variant:Nn \chemmacros_declare_reaction_env:nnnn {nnnV}

\RenewChemReaction {reaction}   {equation}
\RenewChemReaction {reaction*}  {equation*}
\RenewChemReaction {reactions}  {align}
\RenewChemReaction {reactions*} {align*}

}{}% \@ifchemmacrosmoduleloaded
}% AtBeginDocument
%    \end{macrocode}
% \end{noindmacro}
%
%
% \subsection{Redox}
%
%    \begin{macrocode}
\AtBeginDocument{
\@ifchemmacrosmoduleloaded{redox}{
\PackageInfo{lwarp}{Patching~chemmacros~module~redox}

\NewDocumentCommand \LWR@chemmacros@ox { s m >{\SplitArgument{1}{,}}m }
  {
    \IfBooleanTF {#1}
      { \chemmacros_ox:nnnn {#1} {#2} #3 }
      { \chemmacros_ox:nnnn {  } {#2} #3 }
  }

\RenewDocumentCommand \ox { s O{} m }
  {
    \begingroup
    \boolfalse{mathjax}
    \IfBooleanTF {#1}
      {
        \LWR@subsingledollar*{% yes hash
            \textbackslash{}ox*\{\LWR@HTMLsanitize{#3}\}% alt
        }{%
            star \protect\LWR@HTMLsanitize{\detokenize\expandafter{#2}}%
        }{%
            \LWR@chemmacros@ox* {#2} {#3}% contents
        }%
      }
      {
        \LWR@subsingledollar*{% yes hash
            \textbackslash{}ox*\{\LWR@HTMLsanitize{#3}\}% alt
        }{%
            \protect\LWR@HTMLsanitize{\detokenize\expandafter{#2}}%
        }{%
            \LWR@chemmacros@ox {#2} {#3}% contents
        }%
      }
    \endgroup
  }

}{}% \@ifchemmacrosmoduleloaded
}% AtBeginDocument
%    \end{macrocode}
%
% \subsection{Scheme}
%
% Fix for \pkg{chemmacros} as of v5.8b, when using \pkg{newfloat} and \pkg{babel}:
%    \begin{macrocode}
\AtBeginDocument{
\@ifchemmacrosmoduleloaded{scheme}{
\PackageInfo{lwarp}{Patching~chemmacros~module~scheme}

\ifdefstring{\schemename}{los}{
\SetupFloatingEnvironment{scheme}{
name = \chemmacros_translate:n {scheme-name}
}
}{}

}{}% \@ifchemmacrosmoduleloaded
}% AtBeginDocument
%    \end{macrocode}
%
% \subsection{Spectroscopy}
%
%    \begin{macrocode}
\AtBeginDocument{
\@ifchemmacrosmoduleloaded{spectroscopy}{
\PackageInfo{lwarp}{Patching~chemmacros~module~spectroscopy}

\ChemCompatibilityTo{5.8}
\cs_gset_protected:Npn \__chemmacros_nmr_base:nn #1#2
  {
    \tl_if_blank:VF \g__chemmacros_nmr_element_coupled_tl
      {
        \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl { \{ }
        \tl_put_right:Nn \g__chemmacros_nmr_element_coupled_tl { \} }
      }
    \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl {#2}
%     \chemmacros_chemformula:n { ^{#1} }
    \textsuperscript{#1}
    \bool_if:NTF \l__chemmacros_nmr_parse_bool
      { \chemformula_ch:nV {} \g__chemmacros_nmr_element_coupled_tl }
      { \chemmacros_chemformula:V \g__chemmacros_nmr_element_coupled_tl }
    \tl_use:N \l__chemmacros_nmr_element_method_connector_tl
    \tl_use:N \l__chemmacros_nmr_method_tl
  }
\EndChemCompatibility
\ChemCompatibilityFrom{5.8}
\cs_gset_protected:Npn \__chemmacros_nmr_base:nn #1#2
  {
    \group_begin:
      \tl_use:N \l__chemmacros_nmr_base_format_tl
      \tl_if_blank:VF \g__chemmacros_nmr_element_coupled_tl
        {
          \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl { \{ }
          \tl_put_right:Nn \g__chemmacros_nmr_element_coupled_tl { \} }
        }
      \tl_put_left:Nn \g__chemmacros_nmr_element_coupled_tl {#2}
%       \chemmacros_chemformula:n { ^{#1} }
      \textsuperscript{#1}
      \tl_if_blank:VF \g__chemmacros_nmr_element_coupled_tl
        {
          \bool_if:NTF \l__chemmacros_nmr_parse_bool
            { \chemformula_ch:nV {} \g__chemmacros_nmr_element_coupled_tl }
            { \chemmacros_chemformula:V \g__chemmacros_nmr_element_coupled_tl }
        }
      \tl_use:N \l__chemmacros_nmr_element_method_connector_tl
      \tl_use:N \l__chemmacros_nmr_method_tl
    \group_end:
  }
\EndChemCompatibility


\cs_gset_protected:Npn \chemmacros_nmr_position:n #1
  {
    \chemmacros_chemformula:x
      {
        \exp_not:V \g__chemmacros_nmr_element_tl
        \bool_if:NF \l__chemmacros_nmr_position_side_bool
          {
            \tl_if_eq:NnTF \l__chemmacros_nmr_position_tl {^}% lwarp
            { \textsuperscript{\exp_not:n { {#1} }} }% lwarp
            { \textsubscript{\exp_not:n { {#1} }} }% lwarp
%             \exp_not:V \l__chemmacros_nmr_position_tl
%             \exp_not:n { {#1} }
          }
      }
    \bool_if:NT \l__chemmacros_nmr_position_side_bool
      {
        \tl_use:N \l__chemmacros_nmr_position_tl
        \__chemmacros_nmr_position:n {#1}
      }
  }

\cs_gset_protected:Npn \__chemmacros_nmr_coupling:w (#1;#2)
  {
    \tl_set:Nn \l__chemmacros_nmr_coupling_bonds_tl
      {
        \l__chemmacros_nmr_coupling_bonds_pre_tl
        #1
        \l__chemmacros_nmr_coupling_bonds_post_tl
      }
    \bool_if:NTF \l__chemmacros_nmr_coupling_nuclei_sub_bool
      {
        \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl
          {
%             \c_math_subscript_token
            \textsubscript% lwarp
              {
                \l__chemmacros_nmr_coupling_nuclei_pre_tl
                \chemmacros_chemformula:n {#2}
                \l__chemmacros_nmr_coupling_nuclei_post_tl
              }
          }
      }
      {
        \tl_set:Nn \l__chemmacros_nmr_coupling_nuclei_tl
          {
            \l__chemmacros_nmr_coupling_nuclei_pre_tl
            \chemmacros_chemformula:n {#2}
            \l__chemmacros_nmr_coupling_nuclei_post_tl
          }
      }
    \__chemmacros_nmr_coupling_aux_i:w
  }

\AfterEndPreamble{% After \AtBeginDocument
% \NMR{<num>,<elem>}(<num>,<unit>)[<solvent>] ALL arguments are optional
% \NMR* same but without ": $\delta$" at end
\cs_gset_protected:Npn \chemmacros_nmr:nnnn #1#2#3#4
    {
    \bool_if:NT \l__chemmacros_nmr_list_bool { \item \scan_stop: }
    \group_begin:
        \chemmacros_leave_vmode:
        \bool_set_false:N \l__chemmacros_nmr_frequency_bool
        \bool_set_false:N \l__chemmacros_nmr_solvent_bool
        \tl_if_empty:nF {#3}
        { \bool_set_true:N \l__chemmacros_nmr_frequency_bool }
        \tl_if_empty:nF {#4}
        { \bool_set_true:N \l__chemmacros_nmr_solvent_bool }
        \bool_if:nT
        {
            \l__chemmacros_nmr_frequency_bool
            ||
            \l__chemmacros_nmr_solvent_bool
        }
        { \bool_set_true:N \l__chemmacros_nmr_delimiters_bool }
        \bool_if:nT
        {
            \l__chemmacros_nmr_frequency_bool
            &&
            \l__chemmacros_nmr_solvent_bool
        }
        { \bool_set_true:N \l__chemmacros_nmr_comma_bool }
        \tl_if_empty:nTF {#2}
        {
            \__chemmacros_nmr_nucleus:VV
            \l__chemmacros_nmr_isotope_default_tl
            \l__chemmacros_nmr_element_default_tl
        }
        { \__chemmacros_nmr_nucleus:w #2 \q_stop }
        \mode_if_math:TF
        {
            \text
            {
                \group_begin:
                \tl_use:N \l__chemmacros_nmr_format_tl
\LWR@textcurrentcolor{\LWR@textcurrentfont{% lwarp
                \__chemmacros_nmr_base:VV
                    \g__chemmacros_nmr_isotope_tl
                    \g__chemmacros_nmr_element_tl
                \bool_if:NT \l__chemmacros_nmr_delimiters_bool
                    { ~ ( }
                \bool_if:NT \l__chemmacros_nmr_frequency_bool
                    { \__chemmacros_nmr_frequency:n {#3} }
                \bool_if:NT \l__chemmacros_nmr_comma_bool
                    { , ~ }
                \bool_if:NT \l__chemmacros_nmr_solvent_bool
                    { \chemmacros_chemformula:n {#4} }
                \bool_if:NT \l__chemmacros_nmr_delimiters_bool
                    { ) }
                \tl_if_blank:nT {#1} {:~}
}}% lwarp
                \group_end:
            }
            \tl_if_blank:nT {#1}
            {
                \delta
                \text { \l__chemmacros_nmr_delta_tl }
                \bool_if:NT \l__chemmacros_nmr_use_equal_bool {=}
            }
        }
        {
            \group_begin:
            \tl_use:N \l__chemmacros_nmr_format_tl
\LWR@textcurrentcolor{\LWR@textcurrentfont{% lwarp
            \__chemmacros_nmr_base:VV
                \g__chemmacros_nmr_isotope_tl
                \g__chemmacros_nmr_element_tl
            \bool_if:NT \l__chemmacros_nmr_delimiters_bool
                {~(}
            \bool_if:NT \l__chemmacros_nmr_frequency_bool
                { \__chemmacros_nmr_frequency:n {#3} }
            \bool_if:NT \l__chemmacros_nmr_comma_bool
                {,~}
            \bool_if:NT \l__chemmacros_nmr_solvent_bool
                {
                \bool_if:NTF \l__chemmacros_nmr_parse_bool
%    \end{macrocode}
% \changes{v0.59}{2018/08/30}{\pkg{chemformula}: Fix for \cs{NMR}.}
%    \begin{macrocode}
%                     { \chemformula_ch:nn { } {#4} }%  original
                    {\ch{#4}}%  lwarp
                    {#4}
                }
            \bool_if:NT \l__chemmacros_nmr_delimiters_bool
                {)}
}}% lwarp
            \tl_if_blank:nT {#1} {:}
            \group_end:
            \tl_if_blank:nT {#1}
            {
                \tl_use:N \c_space_tl
                \c_math_toggle_token
                \delta
                \c_math_toggle_token
                \l__chemmacros_nmr_delta_tl
                \bool_if:NT \l__chemmacros_nmr_use_equal_bool {~=}
            }
        }
    \group_end:
    }
}% AfterEndPremble


\RenewDocumentCommand \chemmacros_data:w { smo }
  {
    \bool_if:NT \l__chemmacros_nmr_list_bool { \item }
      {
%         \tl_use:N \l__chemmacros_nmr_format_tl #2
        \tl_use:N \l__chemmacros_nmr_format_tl
        \LWR@textcurrentcolor{\LWR@textcurrentfont{% lwarp
            #2
            \IfNoValueF {#3} { ~ ( #3 ) }
            \IfBooleanT {#1} { \bool_if:NT \l__chemmacros_nmr_use_equal_bool { : } }
        }}% lwarp
      }
    \IfBooleanF {#1} { \bool_if:NT \l__chemmacros_nmr_use_equal_bool { ~ = } }
  }

}{}% \@ifchemmacrosmoduleloaded
}% AtBeginDocument
%    \end{macrocode}
%
% \subsection{Thermodynamics}
%
%    \begin{macrocode}
\AtBeginDocument{
\@ifchemmacrosmoduleloaded{thermodynamics}{
\PackageInfo{lwarp}{Patching~chemmacros~module~thermodynamics}

\cs_gset_protected:Npn \chemmacros_state:nn #1#2
  {
    \group_begin:
      \boolfalse{mathjax}
      \chemmacros_set_keys:nn {thermodynamics} {#1}
        \LWR@subsingledollar*{% yes hashing
            \textbackslash{}state\{\LWR@HTMLsanitize{#2}\}% alt
        }{%
            chemmacros_state% add'l hashing
            #1% options
            LSP \tl_use:N \l__chemmacros_state_sp_left_tl% super/subscripts
            LSB \tl_use:N \l__chemmacros_state_sb_left_tl
            RSP \tl_use:N \l__chemmacros_state_sp_right_tl
            RSB \tl_use:N \l__chemmacros_state_sb_right_tl
        }
        {
         \LWR@origensuredmath{
          \chemmacros_text:V \l__chemmacros_state_pre_tl
          \c_math_superscript_token
            { \chemmacros_text:V \l__chemmacros_state_sp_left_tl }
%    \end{macrocode}
% Only add the subscripts if they are being used.
% This avoids causing an incorrect depth, as the empty subscript will be
% measured by \TeX\ but cropped out by \prog{pdfcrop}.
%    \begin{macrocode}
          \tl_if_empty:NTF \l__chemmacros_state_sb_left_tl
          {}
          {
            \c_math_subscript_token
            { \chemmacros_text:V \l__chemmacros_state_sb_left_tl }
          }
          #2
          \c_math_superscript_token
            { \chemmacros_text:V \l__chemmacros_state_sp_right_tl }
          \tl_if_empty:NTF \l__chemmacros_state_sb_right_tl
          {}
          {
            \c_math_subscript_token
            { \chemmacros_text:V \l__chemmacros_state_sb_right_tl }
          }
          \chemmacros_text:V \l__chemmacros_state_post_tl
         }
        }
    \group_end:
  }
\cs_generate_variant:Nn \chemmacros_state:nn { nV }

\cs_gset_protected:Npn \chemmacros_declare_state:Nn #1#2
  {
    \chemmacros_define_keys:xn
      {thermodynamics/\chemmacros_remove_backslash:N #1}
      {
        pre               .meta:nn = {chemmacros/thermodynamics} { pre = ##1 } ,
        post              .meta:nn = {chemmacros/thermodynamics} { post = ##1 } ,
        superscript-left  .meta:nn = {chemmacros/thermodynamics} { superscript-left = ##1 } ,
        superscript-right .meta:nn = {chemmacros/thermodynamics} { superscript-right = ##1 } ,
        superscript       .meta:n  = { superscript-right = ##1 } ,
        subscript-left    .meta:nn = {chemmacros/thermodynamics} { subscript-left = ##1 } ,
        subscript-right   .meta:nn = {chemmacros/thermodynamics} { subscript-right = ##1 } ,
        subscript         .meta:n     = { subscript-left = ##1 } ,
        subscript-pos     .choices:nn =
          { left , right }
          { \tl_set_eq:NN \l__chemmacros_state_sb_pos_tl \l_keys_choice_tl } ,
        symbol            .tl_set:N = \l__chemmacros_state_symbol_tl ,
        unit              .tl_set:N = \l__chemmacros_state_unit_tl
      }
    \DeclareDocumentCommand #1 { sO{}D(){}m }
      {
        \group_begin:
          \chemmacros_set_keys:xn
            {thermodynamics/\chemmacros_remove_backslash:N #1}
            {#2}
          \tl_if_blank:nF {##3}
            {
              \chemmacros_set_keys:nx {thermodynamics}
                { subscript-\l__chemmacros_state_sb_pos_tl = \exp_not:n {##3} }
            }
              \chemmacros_state:nV {##2} \l__chemmacros_state_symbol_tl
              \chemmacros_set_keys_groups:nnn {thermodynamics} {variables} {##2}
              \IfBooleanF {##1} {  = ~ \SI {##4} { \l__chemmacros_state_unit_tl } }
        \group_end:
      }
  }
%    \end{macrocode}
%
% The pre-existing macros are redefined with the new definition:
%    \begin{macrocode}
\RenewChemState \enthalpy { symbol = H , unit = \kilo\joule\per\mole }
\RenewChemState \entropy  { symbol = S , unit = \joule\per\kelvin\per\mole , pre = }
\RenewChemState \gibbs    { symbol = G , unit = \kilo\joule\per\mole }

}{}% \@ifchemmacrosmoduleloaded
}% AtBeginDocument
%    \end{macrocode}
%
%    \begin{macrocode}
\ExplSyntaxOff
%    \end{macrocode}

% \iffalse
%</chemmacros>
% \fi
%
%
%
%
% \iffalse
%<*chemnum>
% \fi
%
% \part{lwarp-chemnum.sty}

% \section{chemnum}
%
% \credits{Clemens Niederberger}
%
% \DescribePackage{chemnum}
% \pkg{chemnum} is patched for use by \pkg{lwarp}.
%
% \changes{v0.51}{2018/03/04}{\pkg{chemnum}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{chemnum}[2016/04/14]
%    \end{macrocode}

%    \begin{macrocode}
\ExplSyntaxOn

\cs_gset_protected:Npn \chemnum_compound_write:n #1
  {
    \chemnum_get_compound_property:nn {#1} {pre-main-label-code}
    \group_begin:
      \bool_if:NTF \l__chemnum_compound_local_bool
        { \l__chemnum_local_label_format_tl }
        { \chemnum_get_compound_property:nn {#1} {label-format} }
      {
        \LWR@textcurrentfont{
            \chemnum_get_compound_property:nn {#1} {counter-representation}
        }
      }
    \group_end:
    \chemnum_get_compound_property:nn {#1} {post-main-label-code}
  }

\cs_gset_protected:Npn \chemnum_subcompound_write:nn #1#2
  {
    \group_begin:
      \bool_if:NTF \l__chemnum_compound_local_bool
        { \l__chemnum_local_label_format_tl }
        { \chemnum_get_compound_property:nn {#1} {label-format} }
      {
        \LWR@textcurrentfont{
            \chemnum_get_subcompound_property:nnn {#1} {#2}
            {counter-representation}
        }
      }
    \group_end:
  }

\ExplSyntaxOff
%    \end{macrocode}

% \iffalse
%</chemnum>
% \fi
%
%
%
%
% \iffalse
%<*chkfloat>
% \fi
%
% \part{lwarp-chkfloat.sty}
%
% \section{chkfloat}
%
% \DescribePackage{chkfloat}
% \pkg{chkfloat} is ignored.
%
% \changes{v0.61}{2018/10/05}{\pkg{chkfloat}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{chkfloat}[2012/08/19]
%    \end{macrocode}
%
% \iffalse
%</chkfloat>
% \fi
%
%
%
%
%
%
% \iffalse
%<*chngpage>
% \fi

% \part{lwarp-chngpage.sty}

% \section{chngpage}
%
% \credits{Peter Wilson}
%
% \DescribePackage{chngpage}
% \pkg{chngpage} is emulated.
%
% \changes{v0.54}{2018/04/19}{\pkg{chngpage}: Added.}
% \changes{v0.62}{2018/10/18}{\pkg{chngpage}: Fix: Loads \pkg{lwarp-chngpage}.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-chngpage}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{chngpage}[2009/10/20]
\LWR@origRequirePackage{lwarp-changepage}
%    \end{macrocode}

% \iffalse
%</chngpage>
% \fi
%
%
%
% \iffalse
%<*cite>
% \fi
%
% \part{lwarp-cite.sty}

% \section{cite}
%
% \credits{Donald Arseneau}
%
% \DescribePackage{cite}
% \pkg{cite} is patched for use by \pkg{lwarp}.
%
% \changes{v0.45}{2018/01/13}{\pkg{cite}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{cite}[2015/02/27]
%    \end{macrocode}

% For the [super] option, the \cs{kern} must be removed:
%    \begin{macrocode}
\def\LWRCT@biblabel#1{\@citess{#1}\kern-\labelsep\,}

\ifdefstrequal{\@biblabel}{\LWRCT@biblabel}
{
    \def\@biblabel#1{\@citess{#1}}
}{}
%    \end{macrocode}

% For the [super] option, \cs{textsuperscript} is used instead of math superscript:
%    \begin{macrocode}
\def\@citess#1{\textsuperscript{#1}}

\DeclareDocumentCommand\citepunct{}{,\,\relax}
%    \end{macrocode}

% \iffalse
%</cite>
% \fi
%
%
%
% \iffalse
%<*CJK>
% \fi
%
% \part{lwarp-CJK.sty}
%
% \section{CJK}
%
% \DescribePackage{CJK}
% \pkg{CJK} does not work with \pkg{lwarp} unless called from \pkg{ctex}.
%
% \changes{v0.62}{2018/11/18}{\pkg{CJK}: Prevented unless \pkg{xeCJK}.}
%
% \codehtml
%    \begin{macrocode}
\@ifpackageloaded{xeCJK}{}{
    \LWR@loadnever{CJK}{ctex, xeCJK}
}

\LWR@ProvidesPackagePass{CJK}[2015/04/18]
%    \end{macrocode}
%
% \iffalse
%</CJK>
% \fi
%
%
%
%
% \iffalse
%<*CJKutf8>
% \fi
%
% \part{lwarp-CJKutf8.sty}
%
% \section{CJKutf8}
%
% \DescribePackage{CJKutf8}
% \pkg{CJKutf8} does not work with \pkg{lwarp} unless called from \pkg{ctex}.
%
% \changes{v0.62}{2018/11/18}{\pkg{CJKutf8}: Prevented unless \pkg{xeCJK}.}
%
% \codehtml
%    \begin{macrocode}
\@ifpackageloaded{xeCJK}{}{
    \LWR@loadnever{CJKutf8}{ctex, xeCJK}
}

\LWR@ProvidesPackagePass{CJKutf8}[2015/04/18]
%    \end{macrocode}
%
% \iffalse
%</CJKutf8>
% \fi
%
%
%
%
% \iffalse
%<*clrdblpg>
% \fi
%
% \part{lwarp-clrdblpg.sty}
%
% \section{clrdblpg}
%
% \DescribePackage{clrdblpg}
% \pkg{clrdblpg} is ignored.
%
% \changes{v0.55}{2018/04/24}{\pkg{clrdblpg}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{clrdblpg}[2018/04/21]
%    \end{macrocode}
%
% \iffalse
%</clrdblpg>
% \fi
%
%
%
%
% \iffalse
%<*cmdtrack>
% \fi
%
% \part{lwarp-cmdtrack.sty}
%
% \section{cmdtrack}
%
% \DescribePackage{cmdtrack}
% \pkg{cmdtrack} is ignored.
%
% \changes{v0.61}{2018/10/05}{\pkg{cmdtrack}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{cmdtrack}[2012/12/18]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\untrack}[1]{}
%    \end{macrocode}
%
% \iffalse
%</cmdtrack>
% \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.}
% \changes{v0.67}{2019/02/12}{\pkg{color}: Fix for version number.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{color}[2016/07/10]
\RequirePackage{xcolor}
%    \end{macrocode}
%
% \iffalse
%</color>
% \fi
%
%
%
%
% \iffalse
%<*colortbl>
% \fi
%
% \part{lwarp-colortbl.sty}
%
% \section{colortbl}
%
% \DescribePackage{colortbl}
% \pkg{colortbl} is used as-is for print output,
% and emulated for \HTML.
%
% \changes{v0.48}{2018/02/05}{\pkg{colortbl}: Added.}
%
% \limitscolortbl
%
%
% \codehtml
%
% A placeholder definition is forgotten first:
%    \begin{macrocode}
\let\rowcolor\relax

\LWR@ProvidesPackagePass{colortbl}[2018/12/12]
%    \end{macrocode}
%
%
% The following \cs{LWR@HTML} versions are used inside an \HTML\ \env{tabular}.
%
% \begin{noindmacro}{\columncolor} \oarg{model} \marg{color} \oarg{left overhang} \oarg{right overhang}
%
% \cs{LWR@getmynexttoken} is not used here because \cs{columncolor} is not used
% inside the data area of the tabular.
%
% \changes{v0.57}{2018/06/02}{\pkg{colortbl}: New system for switching print and \HTML\ outputs.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@columncolor}{O{named} m o o}{%
\convertcolorspec{#1}{#2}{HTML}\LWR@columnHTMLcolor%
\LWR@addtabularcellcolor%
}

\AtBeginDocument{\LWR@formatted{columncolor}}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \cs{LWR@getmynexttoken} is used for \cs{rowcolor} because it is used
% inside the data area of the tabular.
%
%
% \begin{noindmacro}{\rowcolor} \oarg{model} \marg{color} \oarg{left overhang} \oarg{right overhang}
%
% \changes{v0.57}{2018/06/02}{\pkg{colortbl}: New system for switching print and \HTML\ outputs.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@rowcolor}{O{named} m o o}{%
\convertcolorspec{#1}{#2}{HTML}\LWR@rowHTMLcolor%
\LWR@getmynexttoken%
}

\AtBeginDocument{\LWR@expandableformatted{rowcolor}}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\cellcolor} \oarg{model} \marg{color} \oarg{left overhang} \oarg{right overhang}
%
% \changes{v0.57}{2018/06/02}{\pkg{colortbl}: New system for switching print and \HTML\ outputs.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@cellcolor}{O{named} m o o}{%
\convertcolorspec{#1}{#2}{HTML}\LWR@cellHTMLcolor%
\LWR@addtabularcellcolor%
}

\AtBeginDocument{\LWR@formatted{cellcolor}}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\arrayrulecolor} \oarg{model} \marg{color}
%
% The \HTML\ version for use outside a \env{tabular}.
% Inside a \env{tabular}, \cs{LWR@HTML@arrayrulecolornexttoken} is used instead.
%
% \changes{v0.57}{2018/06/02}{\pkg{colortbl}: New system for switching print and \HTML\ outputs.}
%    \begin{macrocode}
\newcommand{\LWR@HTML@arrayrulecolor}[2][named]{%
\convertcolorspec{#1}{#2}{HTML}\LWR@ruleHTMLcolor%
}

\AtBeginDocument{\LWR@expandableformatted{arrayrulecolor}}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\LWR@arrayrulecolornexttoken} \oarg{model} \marg{color}
%
% The \HTML\ version for use inside a \env{tabular}.
%
% \changes{v0.57}{2018/06/02}{\pkg{colortbl}: New system for switching print and \HTML\ outputs.}
%    \begin{macrocode}
\newcommand{\LWR@HTML@arrayrulecolornexttoken}[2][named]{%
\convertcolorspec{#1}{#2}{HTML}\LWR@ruleHTMLcolor%
\LWR@getmynexttoken%
}

\AtBeginDocument{\LWR@expandableformatted{arrayrulecolornexttoken}}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\doublerulesepcolor} \oarg{model} \marg{color}
%
% The version for use outside a \env{tabular}.
%    \begin{macrocode}
\newcommand{\LWR@HTML@doublerulesepcolor}[2][named]{}

\AtBeginDocument{\LWR@expandableformatted{doublerulesepcolor}}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\LWR@doublerulesepcolornexttoken} \oarg{model} \marg{color}
%
% The version for use inside a \env{tabular}.
%    \begin{macrocode}
\newcommand{\LWR@HTML@doublerulesepcolornexttoken}[2][named]{\LWR@getmynexttoken}

\AtBeginDocument{\LWR@expandableformatted{doublerulesepcolornexttoken}}
%    \end{macrocode}
% \end{noindmacro}

% \iffalse
%</colortbl>
% \fi
%
%
%
%
% \iffalse
%<*continue>
% \fi
%
% \part{lwarp-continue.sty}
%
% \section{continue}
%
% \DescribePackage{continue}
% \pkg{continue} is ignored.
%
% \changes{v0.45}{2017/12/19}{\pkg{continue}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{continue}}[2018/12/09]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\flagcont}{}
\newcommand*{\flagend}{}
\newcommand*{\flagword}{}
\newcommand*{\preflagword}{}
\newcommand*{\postflagword}{}
\newlength\contsep
\newlength\contdrop
%    \end{macrocode}
%
% \iffalse
%</continue>
% \fi
%
%
%
%
% \iffalse
%<*copyrightbox>
% \fi
%
% \part{lwarp-copyrightbox.sty}
%
% \section{copyrightbox}
%
% \credits{Thomas Fischer, Ives van der Flaas}
%
% \DescribePackage{copyrightbox}
% \pkg{copyrightbox} is emulated for use by \pkg{lwarp}.
%
% The entire copyright box is placed inside a \element{div} of class \attribute{copyrightbox}.
%
% The contents are placed inside a \element{div} of class \attribute{copyrightboxcontents}.
%
% The copyright notice is placed inside a \element{div} of class \attribute{copyrightboxnote}.
%
% \changes{v0.61}{2018/09/23}{\pkg{copyrightbox}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{copyrightbox}[2011/11/27]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\copyrightbox}[3][r]{%
\begin{BlockClass}[
    display: inline-flex;
    flex-direction: column ;
]{copyrightbox}
\begin{BlockClass}{copyrightboxcontents}
#2
\end{BlockClass}
\begin{BlockClass}{copyrightboxnote}
#3
\end{BlockClass}
\end{BlockClass}
}

\newcommand{\CRB@setcopyrightfont}{}
\newcommand{\CRB@setcopyrightparagraphstyle}{}
%    \end{macrocode}
%
% \iffalse
%</copyrightbox>
% \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}[2003/05/20]
%    \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}[2012/10/04]
%    \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}[2010/09/29]
%    \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
%<*dblfloatfix>
% \fi
%
% \part{lwarp-dblfloatfix.sty}
%
% \section{dblfloatfix}
%
% \DescribePackage{dblfloatfix}
% \pkg{dblfloatfix} is ignored.
%
% \changes{v0.50}{2018/02/20}{\pkg{dblfloatfix}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{dblfloatfix}[2012/12/31]
%    \end{macrocode}
%
% \iffalse
%</dblfloatfix>
% \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}[1999/07/14]
%    \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}[2014/10/28]
%    \end{macrocode}
%
% \iffalse
%</dcolumn>
% \fi
%
%
%
%
% \iffalse
%<*diagbox>
% \fi
%
% \part{lwarp-diagbox.sty}

% \section{diagbox}
%
% \credits{Leo Liu}
%
% \DescribePackage{diagbox}
% \pkg{diagbox} is patched for use by \pkg{lwarp}.
%
% \changes{v0.50}{2018/02/21}{\pkg{diagbox}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{diagbox}[2016/12/28]
%    \end{macrocode}
%
% To restore print-mode inside a \env{lateximage}:
%    \begin{macrocode}
\LetLtxMacro\LWR@origdiagbox@double\diagbox@double
\LetLtxMacro\LWR@origdiagbox@triple\diagbox@triple

\appto\LWR@restoreorigformatting{%
\LetLtxMacro\diagbox@double\LWR@origdiagbox@double%
\LetLtxMacro\diagbox@triple\LWR@origdiagbox@triple%
}
%    \end{macrocode}

% \begin{noindmacro}{\LWR@diagbox@AB} \marg{E/W} \marg{A} \marg{E/W} \marg{B}
%    \begin{macrocode}
\newcommand{\LWR@diagbox@AB}[4]{
\begingroup%
\LetLtxMacro\\\newline%
\BlockClassSingle{diagbox#1}{#2}%
\BlockClassSingle{diagbox#3}{#4}%
\endgroup%
\LWR@stoppars%
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\LWR@diagboxNW} \marg{A} \marg{B}
%    \begin{macrocode}
\newcommand{\LWR@diagboxNW}[2]{%
\LWR@diagbox@AB{E}{#2}{W}{#1}%
}
%    \end{macrocode}
% \end{noindmacro}

% Likewise for NE, SW, SE:
%    \begin{macrocode}
\newcommand{\LWR@diagboxNE}[2]{%
\LWR@diagbox@AB{W}{#1}{E}{#2}%
}

\let\LWR@diagboxSW\LWR@diagboxNE
\let\LWR@diagboxSE\LWR@diagboxNW
%    \end{macrocode}

% \begin{noindmacro}{\diagbox@double} \marg{keys} \marg{A} \marg{B}
%    \begin{macrocode}
\def\diagbox@double#1#2#3{%
\setkeys{diagbox}{dir=NW,#1}%
\@nameuse{LWR@diagbox\diagbox@dir}{#2}{#3}%
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\LWR@diagboxTNW} \marg{title} \marg{A} \marg{B}
%    \begin{macrocode}
\newcommand{\LWR@diagboxTNW}[3]{%
\BlockClassSingle{diagboxtitleN}{#1}
\LWR@diagboxNW{#2}{#3}
}
%    \end{macrocode}
% \end{noindmacro}

% Likewise for NE, SW, SE:
% \changes{v0.60}{2018/09/17}{\pkg{diagbox}: Fix for par tags.}
%    \begin{macrocode}
\newcommand{\LWR@diagboxTNE}[3]{%
\BlockClassSingle{diagboxtitleN}{#1}
\LWR@diagboxNE{#2}{#3}
}

\newcommand{\LWR@diagboxTSW}[3]{%
\LWR@diagboxSW{#2}{#3}
\BlockClassSingle{diagboxtitleS}{#1}
\LWR@stoppars%
}

\newcommand{\LWR@diagboxTSE}[3]{%
\LWR@diagboxSE{#2}{#3}
\BlockClassSingle{diagboxtitleS}{#1}
\LWR@stoppars%
}
%    \end{macrocode}
%
% \begin{noindmacro}{\diagbox@triple} \marg{keys} \marg{A} \marg{T} \marg{B}
%    \begin{macrocode}
\def\diagbox@triple#1#2#3#4{%
\setkeys{diagbox}{dir=NW,#1}%
\@nameuse{LWR@diagboxT\diagbox@dir}{#3}{#2}{#4}%
}
%    \end{macrocode}
% \end{noindmacro}
%
% \iffalse
%</diagbox>
% \fi
%
%
%
%
%
% \iffalse
%<*dingbat>
% \fi
%
% \part{lwarp-dingbat.sty}
%
% \section{dingbat}
%
% \credits{Scott Pakin}
%
% \DescribePackage{dingbat}
% \pkg{dingbat} is patched for use by \pkg{lwarp}.
%
% \changes{v0.67}{2019/02/22}{\pkg{dingbat}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{dingbat}[2001/04/27]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\LWR@dingbatsymbol}[1]{\HTMLunicode{#1}}

\newcommand{\LWR@HTML@rightpointright}{\LWR@dingbatsymbol{261E}}
\newcommand{\LWR@HTML@leftpointright}{\LWR@dingbatsymbol{261E}}
\newcommand{\LWR@HTML@leftthumbsdown}{\LWR@dingbatsymbol{1F44E}}
\newcommand{\LWR@HTML@leftthumbsup}{\LWR@dingbatsymbol{1F44D}}
\newcommand{\LWR@HTML@rightpointleft}{\LWR@dingbatsymbol{261C}}
\newcommand{\LWR@HTML@rightthumbsdown}{\LWR@dingbatsymbol{1F44E}}
\newcommand{\LWR@HTML@rightthumbsup}{\LWR@dingbatsymbol{1F44D}}
\newcommand{\LWR@HTML@squarewithdots}{\LWR@dingbatsymbol{25C7}}
\newcommand{\LWR@HTML@filledsquarewithdots}{\LWR@dingbatsymbol{25C6}}
\newcommand{\LWR@HTML@Sborder}{\LWR@dingbatsymbol{271A}}
\newcommand{\LWR@HTML@Zborder}{\LWR@dingbatsymbol{274B}}
\newcommand{\LWR@HTML@largepencil}{\LWR@dingbatsymbol{270E}}
\newcommand{\LWR@HTML@anchor}{\LWR@dingbatsymbol{2693}}
\newcommand{\LWR@HTML@carriagereturn}{\LWR@dingbatsymbol{23CE}}
\newcommand{\LWR@HTML@checkmark}{\LWR@dingbatsymbol{2713}}
\newcommand{\LWR@HTML@eye}{\LWR@dingbatsymbol{1F441}}
\newcommand{\LWR@HTML@satellitedish}{\LWR@dingbatsymbol{1F4E1}}
\newcommand{\LWR@HTML@smallpencil}{\LWR@dingbatsymbol{270E}}

\LWR@formatted{rightpointright}
\LWR@formatted{leftpointright}
\LWR@formatted{leftthumbsdown}
\LWR@formatted{leftthumbsup}
\LWR@formatted{rightpointleft}
\LWR@formatted{rightthumbsdown}
\LWR@formatted{rightthumbsup}
\LWR@formatted{squarewithdots}
\LWR@formatted{filledsquarewithdots}
\LWR@formatted{Sborder}
\LWR@formatted{Zborder}
\LWR@formatted{largepencil}
\LWR@formatted{anchor}
\LWR@formatted{carriagereturn}
\LWR@formatted{checkmark}
\LWR@formatted{eye}
\LWR@formatted{satellitedish}
\LWR@formatted{smallpencil}
%    \end{macrocode}
%
% \iffalse
%</dingbat>
% \fi
%
%
%
% \iffalse
%<*dprogress>
% \fi
%
% \part{lwarp-dprogress.sty}
%
% \section{dprogress}
%
% \DescribePackage{dprogress}
% \pkg{dprogress} is ignored.
%
% \changes{v0.61}{2018/10/05}{\pkg{dprogress}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{dprogress}[2008/02/21]
%    \end{macrocode}
%
% \iffalse
%</dprogress>
% \fi
%
%
%
% \iffalse
%<*draftcopy>
% \fi
%
% \part{lwarp-draftcopy.sty}
%
% \section{draftcopy}
%
% \DescribePackage{draftcopy}
% \pkg{draftcopy} is ignored.
%
% \changes{v0.59}{2018/09/06}{\pkg{draftcopy}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{draftcopy}[2002/02/25]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\draftcopyVersion}[1]{}
\newcommand{\draftcopySetGrey}[1]{}
\newcommand{\draftcopySetScale}[1]{}
\newcommand{\draftcopySetScaleFactor}[1]{}
\newcommand{\draftcopyFirstPage}[1]{}
\newcommand{\draftcopyLastPage}[1]{}
\newcommand{\draftcopyName}[2]{}
\newcommand{\draftcopyPageTransform}[1]{}
\newcommand{\draftcopyBottomTransform}[1]{}
\newcommand{\draftcopyPageX}[1]{}
\newcommand{\draftcopyPageY}[1]{}
\newcommand{\draftcopyBottomX}[1]{}
\newcommand{\draftcopyBottomY}[1]{}
%    \end{macrocode}
%
% \iffalse
%</draftcopy>
% \fi
%
%
%
%
% \iffalse
%<*draftfigure>
% \fi
%
% \part{lwarp-draftfigure.sty}
%
% \section{draftfigure}
%
% \DescribePackage{draftfigure}
% \pkg{draftfigure} is ignored.
%
% \changes{v0.60}{2018/09/18}{\pkg{draftfigure}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{draftfigure}[2017/07/19]
\RequirePackage{xkeyval}
%    \end{macrocode}
%
%    \begin{macrocode}
\define@key{draftfigure}{code}{}
\define@key{draftfigure}{noframe}[true]{}
\define@key{draftfigure}{filename}[true]{}
\define@key{draftfigure}{content}[]{}
\define@key{draftfigure}{style}[normal]{}
\define@key{draftfigure}{position}[left]{}
\define@key{draftfigure}{size}[normal]{}
\newcommand\setdf[1]{\setkeys{draftfigure}{#1}}
%    \end{macrocode}
%
% \iffalse
%</draftfigure>
% \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}[2015/02/19]
%    \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}[2014/01/01]
%    \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. }\LWR@isolate{#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
%<*ed>
% \fi
%
% \part{lwarp-ed.sty}
%
% \section{ed}
%
% \credits{Michael Kohlhase}
%
% \DescribePackage{ed}
% \pkg{ed} is patched for use by \pkg{lwarp}.
%
% \changes{v0.66}{2019/02/05}{\pkg{ed}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{ed}[2012/01/29]
%    \end{macrocode}
%
% Bugs:
%   \begin{enumerate}
%   \item \env{todolist} fails with the \optn{hide} option, as does \cs{edexplanation}.
%   \item \cs{edstubURI} is actually \cs{edstuURI}.
%   \end{enumerate}
%
%    \begin{macrocode}
\RequirePackage{xcolor}

\renewenvironment{edstub}[2][The following blue text]
{%
    \def\@test{#1}%
    \begin{center}%
        \huge%
        \textcolor{red}{%
            #1 is only a provisional stub\\\Large
            the Office document
            \ifx\ed@stubURI\@empty{#2}\else\href{\ed@stubURI}{#2}\fi\
            contains more text\\which will be merged for the final document%
        }%
    \end{center}%
    \BlockClass[color:blue]{edstub}%
}
{\endBlockClass}
%    \end{macrocode}
%
% \iffalse
%</ed>
% \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.}
% \changes{v0.57}{2018/05/15}{\pkg{ellipsis}: Added \cs{midwordellipsis}.}
%
% \DescribePackage{ellipsis}
% \pkg{ellipsis} is emulated.

%    \begin{macrocode}
\LWR@ProvidesPackageDrop{ellipsis}[2004/09/28]

\newcommand{\ellipsisgap}{0.1em}

\newcommand*{\midwordellipsis}{\,\textellipsis\,}
%    \end{macrocode}

% \iffalse
%</ellipsis>
% \fi
%
%
%
%
%
% \iffalse
%<*embrac>
% \fi
%
% \part{lwarp-embrac.sty}
%
% \section{embrac}
%
% \credits{Clemens Niederberger}
%
% \DescribePackage{embrac}
% \pkg{embrac} is nullfied for \HTML\, and used as-is for print.
%
% \changes{v0.65}{2018/12/10}{\pkg{embrac}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{embrac}[2017/07/04]
%    \end{macrocode}
%
%    \begin{macrocode}
\LetLtxMacro\LWR@orig@HTML@emph\LWR@HTML@emph
\RenewDocumentCommand{\LWR@HTML@emph}{s m}{\LWR@orig@HTML@emph{#2}}

\LetLtxMacro\LWR@orig@HTML@textit\LWR@HTML@textit
\RenewDocumentCommand{\LWR@HTML@textit}{s m}{\LWR@orig@HTML@textit{#2}}

\LetLtxMacro\LWR@orig@HTML@textsl\LWR@HTML@textsl
\RenewDocumentCommand{\LWR@HTML@textsl}{s m}{\LWR@orig@HTML@textsl{#2}}

\ifxetexorluatex
    \LetLtxMacro\LWR@orig@HTML@textsi\LWR@HTML@textsi
    \RenewDocumentCommand{\LWR@HTML@textsi}{s m}{%
    \LWR@orig@HTML@textsi{#2}}
\fi

\AtBeginDocument{
    \LWR@formatted{emph}
    \LWR@formatted{textit}
    \LWR@formatted{textsl}
    \ifxetexorluatex
        \LWR@formatted{textsi}
    \fi
}

\newcommand{\LWR@HTML@EmbracOff}{}
\LWR@formatted{EmbracOff}

\newcommand{\LWR@HTML@EmbracOn}{}
\LWR@formatted{EmbracOn}
%    \end{macrocode}
%
% \iffalse
%</embrac>
% \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}[2010/05/30]
%    \end{macrocode}

% \iffalse
%</emptypage>
% \fi
%
%
%
%
%
%
% \iffalse
%<*endfloat>
% \fi
%
% \part{lwarp-endfloat.sty}
%
% \section{endfloat}
%
% \DescribePackage{endfloat}
% \pkg{endfloat} is ignored.
%
% \changes{v0.45}{2017/12/19}{\pkg{endfloat}: Added.}
% \changes{v0.52}{2018/03/26}{\pkg{endfloat}: Updated for v2.6.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{endfloat}[2018/03/24]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand\figureplace{}
\newcommand\tableplace{}
\newcommand\floatplace[1]{}
\newcounter{posttable}
\newcounter{postfigure}
\newcommand*{\theposttbl}{}
\newcommand*{\thepostfig}{}
\newcommand{\AtBeginFigures}[1]{}
\newcommand{\AtBeginTables}[1]{}
\newcommand{\AtBeginDelayedFloats}[1]{}
\newcommand*{\processdelayedfloats}{}
\newcommand*{\efloatseparator}{}
\def\efloattype{}
\providecommand\efloatheading[1]{}
\providecommand\efloatpreamble{}
\providecommand\efloatpostamble{}
%    \end{macrocode}
%
% \iffalse
%</endfloat>
% \fi
%
%
%
%
% \iffalse
%<*endheads>
% \fi
%
% \part{lwarp-endheads.sty}
%
% \section{endheads}
%
% \DescribePackage{endheads}
% \pkg{endheads} is ignored.
%
% \changes{v0.47}{2018/01/25}{\pkg{endheads}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{endheads}[2017/04/06]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\changesinglepageabbrev}[1]{}
\newcommand{\changemultiplepageabbrev}[1]{}
\newcommand{\changenotesname}[1]{}
\newcommand{\changenotesheader}[1]{}
\newcommand{\changenotescontentsname}[1]{}
\newcommand{\changechapternotesline}[1]{}
\newcommand{\checknoteheaders}{}
\newif\ifnotesincontentson \notesincontentsonfalse
\newcommand{\notesincontents}{\notesincontentsontrue}
\newif\ifendnoteheaderson \endnoteheadersonfalse
\newcommand{\setupendnoteheaders}{%
    \endnoteheadersontrue%
}
\newif\iftitleinnotes \titleinnotestrue
\newcommand{\styleforchapternotebegin}{}
\newcommand{\styleforchapternoteend}{}
\newcommand{\setstyleforchapternotebegin}[1]{%
    \renewcommand{\styleforchapternotebegin}{#1}%
}
\newcommand{\setstyleforchapternoteend}[1]{%
    \renewcommand{\styleforchapternoteend}{#1}%
}
\newcommand{\resetendnotes}{}
\newif\ifnotesbychapteron \notesbychapteronfalse
\newcommand{\notesbychapter}{\notesbychapterontrue}
%    \end{macrocode}
%
% \iffalse
%</endheads>
% \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}[2015/07/23]
%    \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.}
% \changes{v0.63}{2018/12/02}{\pkg{emumitem}: v3.6: Nullifiy \cs{DrawEnumitemLabel}.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{enumitem}[2018/11/30]
%    \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@enumitem@orignewlist\newlist

\renewcommand*{\newlist}[3]{%
\LWR@enumitem@orignewlist{#1}{#2}{#3}%
\AtBeginEnvironment{#1}{\@nameuse{LWR@#2start}}%
\AtEndEnvironment{#1}{\@nameuse{LWR@#2end}}%
}

\def\DrawEnumitemLabel{}
%    \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 \progcode{FormatWP} add \HTML\ styles.}
%
% \codehtml

%    \begin{macrocode}
\LWR@ProvidesPackageDrop{epigraph}[2009/09/02]
%    \end{macrocode}

%    \begin{macrocode}
\DeclareDocumentCommand{\qitem}{m m}
{
\begin{BlockClass}{qitem}
#1
\ifbool{FormatWP}
{\begin{BlockClass}[border-top:1px solid gray]{epigraphsource}}
{\begin{BlockClass}{epigraphsource}}
#2
\end{BlockClass}
\end{BlockClass}
}
%    \end{macrocode}

% \changes{v0.47}{2018/01/26}{\pkg{epigraph}: Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\DeclareDocumentCommand{\epigraph}{m m}
{
\begin{LWR@BlockClassWP}{\LWR@print@mbox{text-align:right}}{}{epigraph}
\qitem{#1}{#2}
\end{LWR@BlockClassWP}
}

\DeclareDocumentEnvironment{epigraphs}{}
{\LWR@BlockClassWP{\LWR@print@mbox{text-align:right}}{}{epigraph}}
{\endLWR@BlockClassWP}
%    \end{macrocode}
%
% Use \CSS\ to format epigraphs.
%
% The following are null commands for source compatibility:
%    \begin{macrocode}
\newenvironment*{flushepinormal}{}{}
%    \end{macrocode}
%
% \changes{v0.45}{2017/12/22}{\pkg{epigraph}: Support for \pkg{memoir}.}
%    \begin{macrocode}
\@ifclassloaded{memoir}{
\setlength{\epigraphwidth}{.5\linewidth}
\renewcommand{\textflush}{flushepinormal}
\renewcommand{\epigraphhead}[2][0]{#2}
\renewcommand{\dropchapter}[1]{}
\renewcommand*{\undodrop}{}
}{% not memoir
\newlength{\epigraphwidth}
\setlength{\epigraphwidth}{.5\linewidth}
\newcommand{\textflush}{flushepinormal}
\newcommand{\epigraphflush}{flushright}
\newcommand{\sourceflush}{flushright}
\newcommand*{\epigraphsize}{\small}
\newlength{\epigraphrule}
\newlength{\beforeepigraphskip}
\newlength{\afterepigraphskip}
\newcommand{\epigraphhead}[2][0]{#2}
\newcommand{\dropchapter}[1]{}
\newcommand*{\undodrop}{}
}% not memoir

\let\cleartoevenpage\relax% also in nextpage
\newcommand{\cleartoevenpage}[1][]{}
%    \end{macrocode}
%
% \iffalse
%</epigraph>
% \fi
%
%
%
%
% \iffalse
%<*epsfig>
% \fi
%
% \part{lwarp-epsfig.sty}
%
% \section{epsfig}
%
% \DescribePackage{epsfig}
% \pkg{epsfig} is emulated for use by \pkg{lwarp}.
%
% Only the \LaTeX 2e syntax is emulated.
% \watchout
%
% \changes{v0.61}{2018/10/01}{\pkg{epsfig}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{epsfig}[2017/06/25]
%    \end{macrocode}
%
% A few additional keys to capture the filename:
%    \begin{macrocode}
\RequirePackage{graphics}

\define@key{igraph}{file}{%
    \xdef\LWR@epsfig@filename{#1}%
}

\define@key{igraph}{figure}{%
    \xdef\LWR@epsfig@filename{#1}%
}

\define@key{igraph}{prolog}{}

\define@key{igraph}{silent}[]{}
%    \end{macrocode}
%
% The captured filename is used as the argument to \cs{includegraphics}:
%    \begin{macrocode}
\newcommand{\epsfig}[1]{\includegraphics[#1]{\LWR@epsfig@filename}}

\newcommand{\psfig}[1]{\includegraphics[#1]{\LWR@epsfig@filename}}
%    \end{macrocode}
%
% \iffalse
%</epsfig>
% \fi
%
%
%
%
%
% \iffalse
%<*epstopdf>
% \fi
%
% \part{lwarp-epstopdf.sty}
%
% \section{epstopdf}
%
% \DescribePackage{epstopdf}
% Previous versions of \pkg{lwarp} had a nullfied version, but
% now \pkg{epstopdf-base} is supported.
% \pkg{lwarp-epstopdf} becomes a placeholder to overwrite
% previous versions.
%
% See package \pkg{epstopdf-base} for details.
%
% \changes{v0.50}{2018/02/21}{\pkg{epstopdf}: Added.}
% \changes{v0.59}{2018/08/27}{\pkg{epstopdf}: Improved.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{epstopdf}[2016/05/15]
%    \end{macrocode}
%
% \iffalse
%</epstopdf>
% \fi
%
%
%
% \iffalse
%<*epstopdf-base>
% \fi
%
% \part{lwarp-epstopdf-base.sty}
%
% \section{epstopdf-base}
%
% \DescribePackage{epstopdf-base}
%
% \limitsepstopdf
%
% \changes{v0.51}{2018/03/03}{\pkg{epstopdf-base}: Added.}
% \changes{v0.59}{2018/08/27}{\pkg{epstopdf-base}: Improved.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{epstopdf-base}[2016/05/15]
%    \end{macrocode}
%
% Redefine to remember the image filename, replacing |.pdf| with |.svg|.
% Use the \pkg{epstopdf} print version inside a \env{lateximage}.
%    \begin{macrocode}
\newcommand*{\LWR@HTML@ETE@OrgGin@setfile}[3]{%
    \edef\LWR@tempone{#3}%
    \StrSubstitute{\LWR@tempone}{.pdf}{.svg}[\LWR@tempone]%
    \StrSubstitute{\LWR@tempone}{.PDF}{.SVG}[\LWR@tempone]%
    \xdef\LWR@parsedfilename{\LWR@tempone}%
}

\LWR@formatted{ETE@OrgGin@setfile}
%    \end{macrocode}
%
% \cs{includegraphics} in \HTML\ mode redefines \cs{Gin@setfile} to
% be \cs{LWR@HTML@Gin@setfile}, which is now redirected to \pkg{epstopdf}'s version:
%    \begin{macrocode}
\renewcommand*{\LWR@HTML@Gin@setfile}[3]{%
    \ETE@Gin@setfile{#1}{#2}{#3}%
}
%    \end{macrocode}
%
% Allow \filenm{.eps} images to be found if a suffix is not provided:
%    \begin{macrocode}
\AtBeginDocument{
\DeclareGraphicsExtensions{%
    .eps,.EPS,.svg,.SVG,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG%
}
\DeclareGraphicsRule{.svg}{svg}{.svg}{}
\DeclareGraphicsRule{.SVG}{svg}{.SVG}{}
}
%    \end{macrocode}
%
% Likewise when inside a \env{lateximage}:
%    \begin{macrocode}
\appto\LWR@restoreorigformatting{%
\DeclareGraphicsExtensions{%
    .eps,.EPS,.pdf,.PDF,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG%
}%
}
%    \end{macrocode}
%
% \iffalse
%</epstopdf-base>
% \fi
%
%
%
%
% \iffalse
%<*errata>
% \fi
%
% \part{lwarp-errata.sty}

% \section{errata}
%
% \credits{Michael Kohlhase}
%
% \DescribePackage{errata}
% \pkg{errata} is patched for use by \pkg{lwarp}.
%
% This is for v0.3 of \pkg{errata}.
% A newer version of \pkg{errata} with more features is under development,
% at which time the \pkg{lwarp} version will have to be updated.
%
% \changes{v0.57}{2018/05/23}{\pkg{errata}: Added.}
%
% \codehtml
%
% Macros are being defined with the math dollar,
% so enable the \HTML\ version during package loading:
%    \begin{macrocode}
\StartDefiningMath
%    \end{macrocode}

% Now load the package:
%    \begin{macrocode}
\LWR@ProvidesPackagePass{errata}[2006/11/12]
%    \end{macrocode}

% Patches for dynamic inline math:
%    \begin{macrocode}
\xpatchcmd{\erratumAdd}
    {$_a^{\arabic{erratum}}$}
%     {\inlinemathother$_a^{\arabic{erratum}}$\inlinemathnormal}
    {\textsubscript{a}\textsuperscript{\arabic{erratum}}}
    {}
    {\LWR@patcherror{erratum}{erratumAdd}}

\xpatchcmd{\erratumDelete}
    {$_d^{\arabic{erratum}}$}
%     {\inlinemathother$_d^{\arabic{erratum}}$\inlinemathnormal}
    {\textsubscript{d}\textsuperscript{\arabic{erratum}}}
    {}
    {\LWR@patcherror{erratum}{erratumDelete}}

\xpatchcmd{\erratumReplace}
    {$_r^{\arabic{erratum}}$}
%     {\inlinemathother$_r^{\arabic{erratum}}$\inlinemathnormal}
    {\textsubscript{r}\textsuperscript{\arabic{erratum}}}
    {}
    {\LWR@patcherror{erratum}{erratumReplace}}

\xpatchcmd{\erratum}
    {$_a$}
%     {\inlinemathother$_a$\inlinemathnormal}
    {\textsubscript{a}}
    {}
    {\LWR@patcherror{erratum}{erratumDelete}}

\xpatchcmd{\erratum}
    {$_d^{\@thefnmark}$}
%     {\inlinemathother$_d^{\@thefnmark}$\inlinemathnormal}
    {\textsubscript{d}\textsuperscript{\@thefnmark}}
    {}
    {\LWR@patcherror{erratum}{eDelete}}

\xpatchcmd{\erratum}
    {$_r^{\@thefnmark}$}
%     {\inlinemathother$_r^{\@thefnmark}$\inlinemathnormal}
    {\textsubscript{r}\textsuperscript{\@thefnmark}}
    {}
    {\LWR@patcherror{erratum}{eReplace}}
%    \end{macrocode}

% Finish the current page's errata before closing and reloading the list:
%    \begin{macrocode}
\preto\PrintErrata{\LWR@orignewpage}
%    \end{macrocode}

% No longer defining math macros with the \HTML\ |$|:
%    \begin{macrocode}
\StopDefiningMath
%    \end{macrocode}

% \iffalse
%</errata>
% \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}[2018/04/12]
%    \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}{}
%    \end{macrocode}
% \changes{v0.49}{2018/02/18}{\pkg{eso-pic}: Fix for \cs{AddToShipoutPicture}.}
%    \begin{macrocode}
\newcommand{\AddToShipoutPicture}{\AddToShipoutPictureBG}
\NewDocumentCommand{\AddToShipoutPictureFG}{s +m}{}
\newcommand*{\ClearShipoutPictureBG}{}
\newcommand*{\ClearShipoutPicture}{}
\newcommand*{\ClearShipoutPictureFG}{}
\newcommand{\gridSetup}[6][]{}
%    \end{macrocode}

% \iffalse
%</eso-pic>
% \fi
%
%
%
%
%
% \iffalse
%<*eurosym>
% \fi
%
% \part{lwarp-eurosym.sty}
%
% \section{eurosym}
%
% \credits{Henrik Theiling}
%
% \DescribePackage{eurosym}
% \pkg{eurosym} is patched for use by \pkg{lwarp}.
%
% \changes{v0.67}{2019/02/20}{\pkg{eurosym}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{eurosym}[1998/08/06]
%    \end{macrocode}
%
%    \begin{macrocode}
\renewrobustcmd\officialeuro{\HTMLentity{euro}}
\let\geneuro\officialeuro
\let\geneuronarrow\officialeuro
\let\geneurowide\officialeuro
\let\euro\officialeuro
\renewrobustcmd\eurobars{}
\renewrobustcmd\eurobarsnarrow{}
\renewrobustcmd\eurobarswide{}
%    \end{macrocode}
%
% \iffalse
%</eurosym>
% \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}[2007/06/20]
%    \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}[2001/05/15]
%    \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.}
% \changes{v0.66}{2019/02/02}{\pkg{extramarks}: Updated to v3.10.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-extramarks}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{extramarks}[2019/01/31]
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\extramarks}[2]{}
\newcommand*{\firstleftxmark}{}
\newcommand*{\lastleftxmark}{}
\newcommand*{\firstrightxmark}{}
\newcommand*{\lastrightxmark}{}
\newcommand*{\firstxmark}{}
\newcommand*{\lastxmark}{}
\newcommand*{\topxmark}{}
\newcommand*{\topleftxmark}{}
\newcommand*{\toprightxmark}{}
\newcommand*{\firstleftmark}{}
\newcommand*{\lastrightmark}{}
\newcommand*{\firstrightmark}{}
\newcommand*{\lastleftmark}{}
%    \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
%
% \limitsverbatimfootnotes
%
% \changes{v0.34}{2017/07/27}{\pkg{fancybox}: Added.}
% \changes{v0.42}{2017/10/27}{\pkg{fancybox}: If \progcode{FormatWP} add \HTML\ styles.}
% \changes{v0.52}{2018/03/29}{\pkg{fancyvrb}: Initial support for \cs{VerbatimFootnotes}.}
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{fancybox}[2010/05/15]
%    \end{macrocode}
%
% After the preamble is loaded, after any patches to \env{Verbatim}:
%    \begin{macrocode}
\AfterEndPreamble{
\LWR@traceinfo{Patching fancybox.}
%    \end{macrocode}
%
% \begin{noindmacro}{\VerbatimFootnotes}
% Patched to use the new version.
%    \begin{macrocode}
\def\VerbatimFootnotes{%
\let\@footnotetext\V@footnotetext%
\let\LWR@footnotetext\V@footnotetext% lwarp
}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\V@@footnotetext}
% Patches in a subset of \pkg{lwarp}'s \cs{LWR@footnotetext} to the
% \pkg{fancyvrb} version of \cs{V@@footnotetext}.
%    \begin{macrocode}
\def\V@@footnotetext{%
\LWR@traceinfo{V@footnotetext}%
\global\setbox\LWR@footnotes=\vbox\bgroup%
%    \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}
% Use \HTML\ superscripts in the footnote even inside a \env{lateximage}:
%    \begin{macrocode}
    \renewrobustcmd{\textsuperscript}[1]{\LWR@htmlspan{sup}{##1}}%
%    \end{macrocode}
% Use paragraph tags if in a tabular data cell or a \env{lateximage}:
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
    \ifthenelse{%
        \boolean{LWR@doingstartpars} \AND%
        \cnttest{\value{LWR@lateximagedepth}}{=}{0}%
    }%
        {}%
        {\LWR@htmltagc{\LWR@tagregularparagraph}\LWR@orignewline}%
%    \end{macrocode}
% Append the footnote to the list:
%    \begin{macrocode}
    \@makefntext{}%
%    \end{macrocode}
%    \begin{macrocode}
  \bgroup%
  \aftergroup{\V@@@footnotetext}%
  \ignorespaces%
}%
%    \end{macrocode}
% \end{noindmacro}
%
%    \begin{macrocode}
}% AfterEndPreamble
%    \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 \brand{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%
\LWR@isolate{#1}%
\endLWR@figcaption%
}
%    \end{macrocode}
%
% \env{Btrivlist} is enclosed in an \HTML\ block.
% This is a tabular, and does not use \cs{item}.
%
% \begin{noindmacro}{Btrivlist} \marg{l/c/r} \oarg{t/c/b}
%    \begin{macrocode}
\RenewDocumentEnvironment{Btrivlist}{m o}
{%
    \begin{BlockClass}{Btrivlist}%
    \tabular{#1}%
}
{%
    \endtabular%
    \end{BlockClass}%
}
%    \end{macrocode}
% \end{noindmacro}
%
% \env{Btrivlist} is also neutralized when used inside a span:
%
%    \begin{macrocode}
\AtBeginEnvironment{LWR@nestspan}{%
\RenewDocumentEnvironment{Btrivlist}{m o}{}{}%
}
%    \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

\RenewDocumentCommand{\LWR@itemizeitem}{d()o}{%
    \IfValueTF{#2}{%
        \LWRFB@origitemizeitem[#2]%
    }{%
        \LWRFB@origitemizeitem%
    }%
}

\RenewDocumentCommand{\LWR@descitem}{d()o}{%
    \IfValueTF{#2}{%
        \LWRFB@origdescitem[#2]~%
    }{%
        \LWRFB@origdescitem%
    }%
}
%    \end{macrocode}
%
% \changes{v0.51}{2018/03/17}{\pkg{fancybox}: Fix: Optional tag for \cs{item} in a span.}
%    \begin{macrocode}
\RenewDocumentCommand{\LWR@nestspanitem}{d()}{%
\if@newlist\else{\LWR@htmltagc{br /}}\fi%
\LWR@origitem%
}
%    \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{UseVerbatim} and friends:
%
%    \begin{macrocode}
\let\LWRFB@UseVerbatim\UseVerbatim
\renewcommand*{\UseVerbatim}[1]{%
\LWR@atbeginverbatim{3}{Verbatim}%
\LWRFB@UseVerbatim{#1}%
\LWR@afterendverbatim{.5}%
}

\let\LWRFB@LUseVerbatim\LUseVerbatim

\renewcommand*{\LUseVerbatim}[1]{%
\LWR@atbeginverbatim{3}{LVerbatim}%
\noindent%
\LWRFB@LUseVerbatim{#1}%
\LWR@afterendverbatim{.5}%
}

\def\@BUseVerbatim[#1]#2{%
\LWR@atbeginverbatim{3}{BVerbatim}%
\LWRFB@UseVerbatim{#2}%
\LWR@afterendverbatim{.5}%
}
%    \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.}
% \changes{v0.66}{2019/02/02}{\pkg{fancyhdr}: Updated to v3.10.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-fancyhdr}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fancyhdr}[2019/01/31]
%    \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*{\headrule}{}
\newcommand*{\footrule}{}
\newlength{\headwidth}
\newcommand*{\fancyheadoffset}[2][]{}
\newcommand*{\fancyfootoffset}[2][]{}
\newcommand*{\fancyhfoffset}[2][]{}
\newcommand*{\iffloatpage}[2]{#2}
\newcommand*{\ifftopfloat}[2]{#2}
\newcommand*{\iffbotfloat}[2]{#2}
\newcommand*{\iffootnote}[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.}
% \changes{v0.48}{2018/02/04}{\pkg{fancyref}: Now directly supported.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{fancyref}[1999/02/03]
%    \end{macrocode}
%
% To remove the \optn{margin} option, if \cs{fancyrefhook} is anything
% other than the \optn{paren} option, then force it to the default instead.
% (Comparing to the \optn{margin} option was not possible since \pkg{lwarp} has
% revised the meaning of \cs{mbox} so the comparison failed.)
%    \begin{macrocode}
\newcommand*{\LWRfref@parenfancyrefhook}[1]{(#1)}

\ifdefstrequal{\fancyrefhook}{\LWRfref@parenfancyrefhook}
{}{
    \renewcommand*{\fancyrefhook}[1]{#1}%
}
%    \end{macrocode}

% Modified to ignore the page number and \pkg{varioref}.
%    \begin{macrocode}
\renewcommand*{\@f@ref}[4]{%
  \@ifundefined{#1r@#2@#3}{%
    \PackageError{fancyref}{%
      \backslashchar#1ref\space format ``#2''
      undefined\MessageBreak
      for label type ``#3''%
    }{%
      The format ``#2'' was not defined for the label type
      ``#3''\MessageBreak
      and the \backslashchar#1ref\space command.  Perhaps
      you have only misspelled its name.\MessageBreak
      Otherwise you will have to define it with
      \protect\new#1refformat\MessageBreak
      prior to using it.%
    }%
  }{%
    \fancyrefhook{%
      \@nameuse{#1r@#2@#3}%
        {\ref{#3\fancyrefargdelim#4}}%
%         {\pageref{#3\fancyrefargdelim#4}}% original
%         {\@fancyref@page@ref{#3\fancyrefargdelim#4}}% original
        {}% lwarp
        {}% lwarp
    }%
  }%
}%
%    \end{macrocode}
%
% \iffalse
%</fancyref>
% \fi
%
%
%
%
%
% \iffalse
%<*fancytabs>
% \fi
%
% \part{lwarp-fancytabs.sty}
%
% \section{fancytabs}
%
% \DescribePackage{fancytabs}
% \pkg{fancytabs} is ignored.
%
% \changes{v0.60}{2018/09/19}{\pkg{fancytabs}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fancytabs}[2016/03/29]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\fancytab}[3][RIGHT]{}
\newcommand{\fancytabsStyle}[1]{}
\newcommand{\fancytabsHeight}[1]{}
\newcommand{\fancytabsWidth}[1]{}
\newcommand{\fancytabsCount}[1]{}
\newcommand{\fancytabsLeftColor}[1]{}
\newcommand{\fancytabsRightColor}[1]{}
\newcommand{\fancytabsTop}[1]{}
\newcommand{\fancytabsTextVPos}[1]{}
\newcommand{\fancytabsTextHPos}[1]{}
\newcommand{\fancytabsGap}[1]{}
\newcommand{\fancytabsFloor}[1]{}
\newcommand{\fancytabsRotate}[1]{}
%    \end{macrocode}
%
% \iffalse
%</fancytabs>
% \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.
%
% \limitsverbatimfootnotes
%
% \changes{v0.34}{2017/07/27}{\pkg{fancyvrb}: Added, no longer required.}
% \changes{v0.45}{2018/01/07}{\pkg{fancyvrb}: Improvements.}
% \changes{v0.52}{2018/03/29}{\pkg{fancyvrb}: Initial support for \cs{VerbatimFootnotes}.}
%
%
%    \begin{macrocode}
\RequirePackage{xcolor}% for \convertcolorspec

\LWR@ProvidesPackagePass{fancyvrb}[2008/02/07]
%    \end{macrocode}
%
% Initial default patch for fancyvrb:
%    \begin{macrocode}
\fvset{frame=none}%
%    \end{macrocode}
%
% After the preamble is loaded, after any patches to \env{Verbatim}:
%    \begin{macrocode}
\AfterEndPreamble{
\LWR@traceinfo{Patching fancyvrb.}
%    \end{macrocode}
%
%
% \begin{noindmacro}{\VerbatimFootnotes}
% Patched to use the new version.
%    \begin{macrocode}
\def\VerbatimFootnotes{%
\let\@footnotetext\V@footnotetext%
\let\footnote\V@footnote%
\let\LWR@footnotetext\V@footnotetext% lwarp
}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\V@@footnotetext}
% Patches in a subset of \pkg{lwarp}'s \cs{LWR@footnotetext} to the
% \pkg{fancyvrb} version of \cs{V@@footnotetext}.
%    \begin{macrocode}
\def\V@@footnotetext{%
\LWR@traceinfo{V@footnotetext}%
\global\setbox\LWR@footnotes=\vbox\bgroup%
%    \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}
% Use \HTML\ superscripts in the footnote even inside a \env{lateximage}:
%    \begin{macrocode}
    \renewrobustcmd{\textsuperscript}[1]{\LWR@htmlspan{sup}{##1}}%
%    \end{macrocode}
% Use paragraph tags if in a tabular data cell or a \env{lateximage}:
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
    \ifthenelse{%
        \boolean{LWR@doingstartpars} \AND%
        \cnttest{\value{LWR@lateximagedepth}}{=}{0}%
    }%
        {}%
        {\LWR@htmltagc{\LWR@tagregularparagraph}\LWR@orignewline}%
%    \end{macrocode}
% Append the footnote to the list:
%    \begin{macrocode}
    \@makefntext{}%
%    \end{macrocode}
%    \begin{macrocode}
  \bgroup%
  \aftergroup{\V@@@footnotetext}%
  \ignorespaces%
}%
%    \end{macrocode}
% \end{noindmacro}
%
%
% \changes{v0.45}{2018/01/07}{\pkg{fancyvrb}: Improvements.}
%    \begin{macrocode}
\preto\FVB@Verbatim{\LWR@forcenewpage}
\preto\FVB@LVerbatim{\LWR@forcenewpage}
% \preto\FVB@BVerbatim{\LWR@forcenewpage}% Fails, so done below.
%    \end{macrocode}
%
% Simplified to remove \PDF\ formatting:
% \changes{v0.45}{2018/01/07}{\pkg{fancyvrb}: Improvements.}
%    \begin{macrocode}
\def\FV@BeginListFrame@Single{%
  \FV@SingleFrameLine{\z@}%
}

\def\FV@EndListFrame@Single{%
  \FV@SingleFrameLine{\@ne}%
}

\def\FV@BeginListFrame@Lines{%
  \FV@SingleFrameLine{\z@}%
}

\def\FV@EndListFrame@Lines{%
    \FV@SingleFrameLine{\@ne}%
}

\renewcommand*{\FV@SingleFrameSep}{}
%    \end{macrocode}
%
% Adds \HTML\ formatting:
%    \begin{macrocode}
\def\FV@BUseVerbatim#1{%
    \LWR@atbeginverbatim[\LWR@FVstyle]{0}{verbatim}%
    \FV@BVerbatimBegin#1\FV@BVerbatimEnd%
    \LWR@afterendverbatim{0}%
}
%    \end{macrocode}


% \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]{0}{verbatim}%
% }%
}

\newcommand*{\LWR@fvendnone}{%
\LWR@traceinfo{fvendnone}%
% \hbox to\z@{
\LWR@afterendverbatim{0}%
% }%
}

\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%
% \setlength{\LWR@templengthone}{\baselineskip}%
\FV@BeginListFrame@Lines%
% \setlength{\baselineskip}{\LWR@templengthone}%
% \setlength{\baselineskip}{5pt}%
}

\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@origpound\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" % extra space
                style="color: \LWR@origpound\LWR@tempcolor"%
        }
        \LWR@print@textrm{\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" % extra space
                style="color: \LWR@origpound\LWR@tempcolor"%
        }
        \LWR@print@textrm{\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% instead of \preto
\LWR@atbeginverbatim{0}{bverbatim}%
}

\AfterEndEnvironment{BVerbatim}
{%
\LWR@afterendverbatim{0}%
}
%    \end{macrocode}
% \end{environment}

% End of the modifications to make at the end of the preamble:
%    \begin{macrocode}
} % \AfterEndPreamble
%    \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}[1999/02/23]
%    \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
%<*figsize>
% \fi
%
% \part{lwarp-figsize.sty}
%
% \section{figsize}
%
% \credits{Anthony A. Tanbakuchi}
%
% \DescribePackage{figsize}
% \pkg{figsize} is emulated.
%
% \changes{v0.49}{2018/02/15}{\pkg{figsize}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{figsize}[2002/03/18]
%    \end{macrocode}
%
% Emulates a virtual 6\texttimes9 inch textsize.
%    \begin{macrocode}
\newlength{\figwidth}
\newlength{\figheight}

\newcommand{\SetFigLayout}[3][0]{%
\setlength{\figheight}{8in}%
\setlength{\figheight}{\figheight / #2}%
%
\setlength{\figwidth}{5.5in}%
\setlength{\figwidth}{\figwidth / #3}%
}
%    \end{macrocode}
%
% \iffalse
%</figsize>
% \fi
%
%
%
%
% \iffalse
%<*fitbox>
% \fi
%
% \part{lwarp-fitbox.sty}
%
% \section{fitbox}
%
% \DescribePackage{fitbox}
% \pkg{fitbox} is ignored.
%
% \changes{v0.67}{2019/02/23}{\pkg{fitbox}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fitbox}[2019/02/20]
%    \end{macrocode}
%
%    \begin{macrocode}
\NewDocumentCommand{\fitbox}{s o m}{%
    \begin{BlockClass}{fitbox}
    #3
    \end{BlockClass}
}

\newcommand*{\fitboxset}[1]{}

\newdimen\fitboxnatheight
\newdimen\fitboxnatwidth

\newcommand\SetFitboxLayout[3][]{}
%    \end{macrocode}
%
% \iffalse
%</fitbox>
% \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}[2015/11/13]
%    \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}[2017/03/05]
%    \end{macrocode}
%
% Restore \pkg{lwarp}'s version of \cs{@wrindex},
% ignoring the \pkg{fixme} package's \optn{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}[2013/04/28]
%    \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
%<*flafter>
% \fi
%
% \part{lwarp-flafter.sty}
%
% \section{flafter}
%
% \DescribePackage{flafter}
% \pkg{flafter} is ignored.
%
% \changes{v0.45}{2017/12/02}{\pkg{flafter}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{flafter}[2018/01/08]
\providecommand\fl@trace[1]{}
%    \end{macrocode}
%
% \iffalse
%</flafter>
% \fi
%
%
%
%
% \iffalse
%<*flippdf>
% \fi
%
% \part{lwarp-flippdf.sty}
%
% \section{flippdf}
%
% \DescribePackage{flippdf}
% \pkg{flippdf} is ignored.
%
% \changes{v0.62}{2018/10/18}{\pkg{flippdf}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{flippdf}[2006/06/30]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand\FlipPDF{}
\newcommand\UnFlipPDF{}
%    \end{macrocode}
%
% \iffalse
%</flippdf>
% \fi
%
%
%
%
%
% \iffalse
%<*float>
% \fi

% \part{lwarp-float.sty}

% \section{float}
% \label{sec:newfloat}
% \label{sec:float}
%
% \credits{Anselm Lingnau}
%
% \DescribePackage{float}
% \pkg{float} is emulated.
%
% Float styles |boxed| and |ruled| are emulated by \CSS\ and a float class according
% to style.
%
% The \HTML\ \element{figure} \attribute{class} is set to the float type,
% so \CSS\ may also be used to format the float and its caption, according to
% float type.
% Furthermore, an additional class is set to the float style: |plain|, |plaintop|,
% |boxed|, or |ruled|, so \CSS\ may be used to format by float style as well.
% Default formatting by \CSS\ is provided for |ruled| and |boxed| styles.
%
% \changes{v0.20}{2017/01/22}{\pkg{float}: Improved float caption type handling.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{float}[2001/11/08]
%    \end{macrocode}

% \begin{noindmacro}{\listof}
% See \cref{sec:listof} for the \cs{listof} command.
% \end{noindmacro}

% \begin{macro}{\LWR@floatstyle}
% The default float style:
%    \begin{macrocode}
\newcommand*{\LWR@floatstyle}{plain}
%    \end{macrocode}
% \end{macro}

% \begin{noindmacro}{\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}
% Remember the float style:
% \changes{v0.57}{2018/05/14}{\pkg{float}: Added float styles.}
%    \begin{macrocode}
\csedef{LWR@floatstyle@#1}{\LWR@floatstyle}%
%    \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}
% Likesize, \pkg{newfloat} also creates \cs{l@<type>}, but \pkg{float} does not,
% so remove it here:
% \changes{v0.57}{2018/05/26}{\pkg{float}: Fix: Do not pre-define \cs{l@name}.}
%    \begin{macrocode}
\cslet{l@#1}\relax%
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\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{noindmacro}

% \begin{noindmacro}{\floatplacement} \marg{type} \marg{placement}
%
% Float placement is ignored.
%    \begin{macrocode}
\newcommand*{\floatplacement}[2]{%
    \SetupFloatingEnvironment{#1}{placement=#2}%
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\floatstyle} \marg{style}
%
% Remember the style for future floats:
%    \begin{macrocode}
\newcommand{\floatstyle}[1]{%
    \def\LWR@floatstyle{#1}%
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\restylefloat} * \marg{type}
%
% Remember the style for this float:
%    \begin{macrocode}
\NewDocumentCommand{\restylefloat}{s m}{%
    \csedef{LWR@floatstyle@#2}{\LWR@floatstyle}%
}
%    \end{macrocode}
% \end{noindmacro}

% \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}[1997/07/16]
%    \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}%
\LWR@BlockClassWP{%
    float:right; %
    width:\LWR@printlength{\LWR@templengthone};  % extra space
    margin:10pt%
}{%
    width:\LWR@printlength{\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}[2012/05/29]
%    \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}[2008/08/02]
%    \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
%<*fltrace>
% \fi
%
% \part{lwarp-fltrace.sty}
%
% \section{fltrace}
%
% \DescribePackage{fltrace}
% \pkg{fltrace} is ignored.
%
% \changes{v0.45}{2017/12/02}{\pkg{fltrace}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fltrace}[2018/01/08]
%    \end{macrocode}
%
%    \begin{macrocode}
\def\tracefloats{}
\def\tracefloatsoff{}
\def\tracefloatvals{}
%    \end{macrocode}
%
% \iffalse
%</fltrace>
% \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}[2017/03/27]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\flushend}{}
\newcommand*{\raggedend}{}
\newcommand*{\flushcolsend}{}
\newcommand*{\raggedcolsend}{}
\newcommand*{\atColsBreak}[1]{}
\newcommand*{\atColsEnd}[1]{}
\newcommand*{\showcolsendrule}{}
%    \end{macrocode}
%
% \iffalse
%</flushend>
% \fi
%
%
%
%
% \iffalse
%<*fnbreak>
% \fi
%
% \part{lwarp-fnbreak.sty}
%
% \section{fnbreak}
%
% \DescribePackage{fnbreak}
% \pkg{fnbreak} is ignored.
%
% \changes{v0.59}{2018/07/09}{\pkg{fnbreak}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fnbreak}[2012/01/01]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\fnbreakverbose}{}
\newcommand*{\fnbreaknonverbose}{}
\newcommand*{\fnbreaklabel}{}
\newcommand*{\fnbreaknolabel}{}
%    \end{macrocode}
%
% \iffalse
%</fnbreak>
% \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}[2007/07/30]
%    \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
%<*fnlineno>
% \fi
%
% \part{lwarp-fnlineno.sty}
%
% \section{fnlineno}
%
% \DescribePackage{fnlineno}
% \pkg{fnlineno} is ignored.
%
% \changes{v0.49}{2018/02/19}{\pkg{fnlineno}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fnlineno}[2011/01/07]
%    \end{macrocode}
%
% \iffalse
%</fnlineno>
% \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}[1999/07/14]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\makeFNbottom}{}
\newcommand*{\makeFNmid}{}
\newcommand*{\makeFNbelow}{}
\newcommand*{\makeFNabove}{}
%    \end{macrocode}
%
% \iffalse
%</fnpos>
% \fi
%
%
%
%
%
% \iffalse
%<*fontawesome>
% \fi
%
% \part{lwarp-fontawesome.sty}
%
% \section{fontawesome}
%
% \credits{Xavier Danaux}
%
% \DescribePackage{fontawesome}
% \pkg{fontawesome} is patched for use by \pkg{lwarp}.
%
% Hashed inline images are used, as there may not be Unicode support for all icons.
%
% If using pdf\LaTeX, \prog{poppler} may issue a syntax warning
% \trouble[\prog{poppler} syntax warning]{poppler=\prog{poppler}>Syntax Warning (ligature)}
% \trouble{Syntax Warning (ligature)}
% regarding parsing a ligature component.
% \XeLaTeX\ or \LuaLaTeX\ may be used to avoid this warning.
%
% In the following, the general strategy is to intercept \cs{symbol} and
% embed it inside a \env{lateximage}.  These changes are done inside a local group.
%
% For pdf\LaTeX, the \attribute{alt} tag includes the icon (symbol) number.
% For \XeLaTeX\ and \LuaLaTeX, the \attribute{alt} tag is generic.
%
% \changes{v0.67}{2019/02/22}{\pkg{fontawesome}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{fontawesome}[2016/05/15]
%    \end{macrocode}
%
%    \begin{macrocode}
\LetLtxMacro\LWR@orig@symbol\symbol

\ifxetexorluatex

\newfontfamily{\LWR@orig@FA}{FontAwesome}

\newcommand*{\LWR@fontawesome@xelatex@symbol}[1]{%
\begin{lateximage}*[(icon)][fontawesomexetex#1]%
\begingroup%
\LWR@orig@FA%
\LWR@orig@symbol{#1}%
\endgroup%
\end{lateximage}%
}

\RenewDocumentCommand{\FA}{}{%
    \LetLtxMacro\symbol\LWR@fontawesome@xelatex@symbol%
}

\else

\newcommand*{\LWR@fontawesome@symbolone}[1]{%
\begin{lateximage}*[(icon #1)][fontawesomeone#1]%
\begingroup%
\fontencoding{U}\fontfamily{fontawesomeone}\selectfont%
\LWR@orig@symbol{#1}%
\endgroup%
\end{lateximage}%
}

\newcommand*{\LWR@fontawesome@symboltwo}[1]{%
\begin{lateximage}*[(icon #1)][fontawesometwo#1]%
\begingroup%
\fontencoding{U}\fontfamily{fontawesometwo}\selectfont%
\LWR@orig@symbol{#1}%
\endgroup%
\end{lateximage}%
}

\newcommand*{\LWR@fontawesome@symbolthree}[1]{%
\begin{lateximage}*[(icon #1)][fontawesomethree#1]%
\begingroup%
\fontencoding{U}\fontfamily{fontawesomeonethree}\selectfont%
\LWR@orig@symbol{#1}%
\endgroup%
\end{lateximage}%
}

\renewrobustcmd\FAone{%
    \LetLtxMacro\symbol\LWR@fontawesome@symbolone%
}

\renewrobustcmd\FAtwo{%
    \LetLtxMacro\symbol\LWR@fontawesome@symboltwo%
}

\renewrobustcmd\FAthree{%
    \LetLtxMacro\symbol\LWR@fontawesome@symbolthree%
}
\fi
%    \end{macrocode}
%
% \iffalse
%</fontawesome>
% \fi
%
%
%
%
%
% \iffalse
%<*fontawesome5>
% \fi
%
% \part{lwarp-fontawesome5.sty}
%
% \section{fontawesome5}
%
% \credits{Marcel Kr\"uger}
%
% \DescribePackage{fontawesome5}
% \pkg{fontawesome5} is patched for use by \pkg{lwarp}.
%
% Hashed inline images are used, as there may not be Unicode support for all icons.
%
% The \attribute{alt} tag has the name of the icon.
%
% \changes{v0.67}{2019/02/22}{\pkg{fontawesome5}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{fontawesome5}[2018/07/27]
%    \end{macrocode}
%
%    \begin{macrocode}
\ExplSyntaxOn
\cs_set:Nn\fontawesome_use_icon:nn{
  \cs_if_exist:cTF{c__fontawesome_slot_#2_tl}{
    \begin{lateximage}*[(#2)][#1]
    \exp_last_unbraced:Nv
      \__fontawesome_icon_at:nnnn
      {c__fontawesome_slot_#2_tl}
        {#1}{#2}
    \end{lateximage}
  }{
    \msg_error:nnxx{fontawesome5}{icon-not-found}{#2}{#1}
  }
}
\ExplSyntaxOff
%    \end{macrocode}
%
% \iffalse
%</fontawesome5>
% \fi
%
%
%
%
% \iffalse
%<*fontenc>
% \fi
%
% \part{lwarp-fontenc.sty}
%
% \section{fontenc}
%
% \DescribePackage{fontenc}
% If using pdf\LaTeX, \pkg{lwarp} used to require \pkg{fontenc} be loaded
% before \pkg{lwarp},
% but now \pkg{lwarp} itself loads \cs{fontenc} with T1 encoding, which
% \pkg{lwarp} requires.  \pkg{fontenc} 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}[2017/04/05]
%    \end{macrocode}
%
% \iffalse
%</fontenc>
% \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.
%
% \pkg{lwarp} incidentally happens to emulate the \optn{stable} option.
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{footmisc}[2011/06/06]
%    \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}[1997/01/28]
%    \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
\def\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}[2018/01/23]
%    \end{macrocode}
%
%
% \iffalse
%</footnotehyper>
% \fi
%
%
%
%
% \iffalse
%<*footnoterange>
% \fi
%
% \part{lwarp-footnoterange.sty}
%
% \section{footnoterange}
%
% \credits{H.-Martin Münch}
%
% \DescribePackage{footnoterange}
% \pkg{footnoterange} is patched for use by \pkg{lwarp}.
%
% \changes{v0.65}{2018/12/10}{\pkg{footnoterange}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{footnoterange}[2012/02/17]
%    \end{macrocode}
%
%    \begin{macrocode}
\csletcs{footnoterange}{footnoterange*}
\csletcs{endfootnoterange}{endfootnoterange*}
%    \end{macrocode}
%
% \iffalse
%</footnoterange>
% \fi
%
%
%
%
% \iffalse
%<*footnpag>
% \fi
%
% \part{lwarp-footnpag.sty}
%
% \section{footnpag}
%
% \DescribePackage{footnpag}
% \pkg{footnpag} is ignored.
%
% \changes{v0.45}{2017/12/19}{\pkg{footnpag}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{footnpag}
%    \end{macrocode}
%
% \iffalse
%</footnpag>
% \fi
%
%
%
%
% \iffalse
%<*foreign>
% \fi
%
% \part{lwarp-foreign.sty}
%
% \section{foreign}
%
% \credits{Philip G. Ratcliffe}
%
% \DescribePackage{foreign}
% \pkg{foreign} is patched for use by \pkg{lwarp}.
%
% \changes{v0.67}{2019/02/17}{\pkg{foreign}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{foreign}[2012/09/25]
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand\foreignabbrfont{\emph}
%    \end{macrocode}
%
% \iffalse
%</foreign>
% \fi
%
%
%
% \iffalse
%<*forest>
% \fi
%
% \part{lwarp-forest.sty}

% \section{forest}
%
% \credits{Sa\v{s}o \v{Z}ivanovi\'{c}}
%
% \DescribePackage{forest}
% \pkg{forest} is patched for use by \pkg{lwarp}.
%
% The starred version of the macro \cs{Forest*} is not supported.
% \trouble[\cs{Forest*}]{forest=\pkg{forest}}
% \pkg{lwarp} encases each \env{lateximage} in an environment, so the
% global results of the starred \cs{Forest*} are lost.
%
% \changes{v0.54}{2018/04/14}{\pkg{forest}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{forest}[2017/07/14]
%    \end{macrocode}

%    \begin{macrocode}
\BeforeBeginEnvironment{forest}{\begin{lateximage}[forest]}

\AfterEndEnvironment{forest}{\end{lateximage}}

\RenewDocumentCommand{\Forest}{s D(){} m}{%
  \forest@config{#2}%
  \IfBooleanTF{#1}{%
        \PackageError{lwarp-forest}%
        {Starred \Forest is not supported}%
        {Lwarp uses an environment for images, but \Forest* cannot work in an environment.}%
        \let\forest@next\forest@env%
    }{\let\forest@next\forest@group@env}%
    \begin{lateximage}[forest]%     lwarp
  \forest@next{#3}%
    \end{lateximage}%               lwarp
}
%    \end{macrocode}

% \iffalse
%</forest>
% \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}[2011/10/22]
\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@origpound\LWR@tempcolor]{shaded}%
}
{\endBlockClass}

\renewenvironment{shaded*}{%
\convertcolorspec{named}{shadecolor}{HTML}\LWR@tempcolor%
\LWR@forcenewpage
\BlockClass[background: \LWR@origpound\LWR@tempcolor]{shaded}%
}
{\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@origpound\LWR@tempcolor]{snugframed}%
}
{\endBlockClass}

\renewenvironment{snugshade*}{%
\convertcolorspec{named}{shadecolor}{HTML}\LWR@tempcolor%
\LWR@forcenewpage
\BlockClass[background: \LWR@origpound\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@origpound\LWR@tempcolor]{framed}%
\ifthenelse{\isempty{#1}}{}{% not empty
    \begin{BlockClass}[background: \LWR@origpound\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@origpound\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}[2014/10/28]
%    \end{macrocode}

% \iffalse
%</ftnright>
% \fi
%
%
%
%
%
% \iffalse
%<*fullminipage>
% \fi
%
% \part{lwarp-fullminipage.sty}
%
% \section{fullminipage}
%
% \DescribePackage{fullminipage}
% \pkg{fullminipage} is nullified.
%
% \changes{v0.60}{2018/09/18}{\pkg{fullminipage}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fullminipage}[2014/07/06]
%    \end{macrocode}
%
%    \begin{macrocode}
\newenvironment{fullminipage}[1][]{}{}
%    \end{macrocode}
%
% \iffalse
%</fullminipage>
% \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}[1994/06/01]
%    \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}[2011/11/18]
%    \end{macrocode}
%
%    \begin{macrocode}
\newenvironment*{fullwidth}[1][]{%
\minipagefullwidth%
\minipage{\linewidth}%
}
{%
\endminipage%
}
%    \end{macrocode}
%
% \iffalse
%</fullwidth>
% \fi
%
%
%
%
%
% \iffalse
%<*fwlw>
% \fi
%
% \part{lwarp-fwlw.sty}
%
% \section{fwlw}
%
% \DescribePackage{fwlw}
% \pkg{fwlw} is ignored.
%
% \changes{v0.45}{2017/12/19}{\pkg{fwlw}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{fwlw}
%    \end{macrocode}
%
%    \begin{macrocode}
\newbox\FirstWordBox     \global\setbox\FirstWordBox\hbox{}
\newbox\NextWordBox      \global\setbox\NextWordBox\hbox{}
\newbox\LastWordBox      \global\setbox\LastWordBox\hbox{}
\def\ps@fwlwhead{}
\def\ps@NextWordFoot{}
%    \end{macrocode}
%
% \iffalse
%</fwlw>
% \fi
%
%
%
%
%
% \iffalse
%<*gentombow>
% \fi
%
% \part{lwarp-gentombow.sty}
%
% \section{gentombow}
%
% \DescribePackage{gentombow}
% \pkg{gentombow} is ignored.
%
% \changes{v0.65}{2018/12/18}{\pkg{gentombow}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{gentombow}[2018/05/17]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\settombowbanner}[1]{}
\newcommand{\settombowbannerfont}[1]{}
\newcommand{\settombowwidth}[1]{}
\newcommand{\settombowbleed}[1]{}
\newcommand{\settombowcolor}[1]{}
%    \end{macrocode}
%
% \iffalse
%</gentombow>
% \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}[2018/04/16]
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand*{\geometry}[1]{}
\renewcommand*{\newgeometry}[1]{}
\renewcommand*{\restoregeometry}{}
\renewcommand*{\savegeometry}[1]{}
\renewcommand*{\loadgeometry}[1]{}
%    \end{macrocode}
%
% \iffalse
%</geometry>
% \fi
%
%
%
%
%
% \iffalse
%<*gloss>
% \fi
%
% \part{lwarp-gloss.sty}
%
% \section{gloss}
%
% \credits{Jose Luis D\'iiaz, Javier Bezos}
%
% \DescribePackage{gloss}
% \pkg{gloss} is patched for use by \pkg{lwarp}.
%
% \limitsgloss
%
% \changes{v0.67}{2019/02/19}{\pkg{gloss}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{gloss}[2002/07/26]
%    \end{macrocode}
%
%    \begin{macrocode}
\xpatchcmd{\gls@gloss@iii}
    {\thepage}
    {\theLWR@previousautopagelabel}
    {}
    {\LWR@patcherror{gloss}{gls@gloss@iii}}

\def\gls@page@i#1#2{%
  \endgroup
  \global\@namedef{glsp@#1}{\nameref{autopage-#2}}}
%    \end{macrocode}
%
% \iffalse
%</gloss>
% \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}[2018/07/23]

\setupglossaries{nonumberlist}
\setglossarystyle{index}
%    \end{macrocode}
%
% Patched to fix \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 \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,
% which could be a different \HTML\ file.
% Here, the \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}
%
% \pkg{lwarp}'s sectioning commands cannot handle robust macros when
% splitting \HTML\ into named filenames.
% \pkg{glossaries} uses \cs{translate} in sectioning names, and \cs{translate}
% is robust and cannot be expanded.
% The following pre-expands the translations at this moment, making use
% of \cs{translatelet}.
%
% \changes{v0.54}{2018/04/21}{\pkg{glossaries}: Fix when
%           not using \pkg{babel} or \pkg{polyglossia}.}
%
%    \begin{macrocode}
\newcommand*{\LWR@comp@glossaryname}{\translate{Glossary}}

\ifdefstrequal{\glossaryname}{\LWR@comp@glossaryname}{
    \translatelet\LWR@translatetemp{Glossary}
    \edef\glossaryname{\LWR@translatetemp}
}{}

\newcommand*{\LWR@comp@acronymname}{\translate{Acronym}}

\ifdefstrequal{\acronymname}{\LWR@comp@acronymname}{
    \translatelet\LWR@translatetemp{Acronym}
    \edef\acronymname{\LWR@translatetemp}
}{}

\newcommand*{\LWR@comp@glssymbolsgroupname}{\translate{Symbols (glossaries)}}

\ifdefstrequal{\glssymbolsgroupname}{\LWR@comp@glssymbolsgroupname}{
    \translatelet\LWR@translatetemp{Symbols (glossaries)}
    \edef\glssymbolsgroupname{\LWR@translatetemp}
}{}

\newcommand*{\LWR@comp@glsnumbersgroupname}{\translate{Numbers (glossaries)}}

\ifdefstrequal{\glsnumbersgroupname}{\LWR@comp@glsnumbersgroupname}{
    \translatelet\LWR@translatetemp{Numbers (glossaries)}
    \edef\glsnumbersgroupname{\LWR@translatetemp}
}{}
%    \end{macrocode}
%
% \iffalse
%</glossaries>
% \fi
%
%
%
%
% \iffalse
%<*gmeometric>
% \fi
%
% \part{lwarp-gmeometric.sty}
%
% \section{gmeometric}
%
% \DescribePackage{gmeometric}
% \pkg{gmeometric} is ignored.
%
% \changes{v0.64}{2018/12/07}{\pkg{gmeometric}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{gmeometric}[2008/11/22]
%    \end{macrocode}
%
% \iffalse
%</gmeometric>
% \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}[2017/06/25]
%    \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:
% \changes{v0.61}{2018/10/06}{Fix: \EPS\ for \DVI\ \LaTeX.}
%    \begin{macrocode}
\ifpdf
\appto\LWR@restoreorigformatting{%
\DeclareGraphicsExtensions{.pdf,.PDF,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG}%
}
\else% \ifpdf
        \ifXeTeX
\appto\LWR@restoreorigformatting{%
\DeclareGraphicsExtensions{.pdf,.PDF,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG}%
}
        \else
\appto\LWR@restoreorigformatting{%
\DeclareGraphicsExtensions{.eps,.EPS,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG}%
}
        \fi
\fi
%    \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
% \trouble[whitespace]{graphics>scaled}
% original unscaled image would have taken,
% with the scaled image over- or under-flowing the area.

% Used to store the user's selected dimensions and \HTML\ class.
%
% The class defaults to ``inlineimage'' unless changed by a \optn{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}
% \changes{v0.65}{2018/12/19}{\pkg{graphics}: Added \cs{includegraphics} \attribute{alt} key.}
%    \begin{macrocode}
\newcommand*{\LWR@igalt}{(image)}
%    \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}
    \renewcommand*{\LWR@igwidthstyle}{width:\LWR@printlength{\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}
    \renewcommand*{\LWR@igheightstyle}{%
    height:\LWR@printlength{\LWR@igheight} % extra space
    }%
%    \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:
% \changes{v0.52}{2018/03/27}{pkg{graphics}: Added defaults.}
%    \begin{macrocode}
\define@key{igraph}{origin}[c]{%
    \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}
%
% Handle alt key:
% \changes{v0.65}{2018/12/19}{\pkg{graphics}: Added \cs{includegraphics} \attribute{alt} key.}
%    \begin{macrocode}
\define@key{igraph}{alt}{\renewcommand*{\LWR@igalt}{#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:
% \changes{v0.52}{2018/03/27}{pkg{graphics}: Added defaults.}
%    \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}[true]{}
\define@key{igraph}{viewport}{}
\define@key{igraph}{trim}{}
\define@key{igraph}{totalheight}{}
\define@key{igraph}{keepaspectratio}[true]{}
\define@key{igraph}{clip}[true]{}
\define@key{igraph}{draft}[true]{}
\define@key{igraph}{type}{}
\define@key{igraph}{ext}{}
\define@key{igraph}{read}{}
\define@key{igraph}{command}{}
%    \end{macrocode}
% New in v1.1a:
% \changes{v0.52}{2018/03/27}{pkg{graphicx}: Updated for v1.1a.}
%    \begin{macrocode}
\define@key{igraph}{quite}{}
\define@key{igraph}{page}{}
\define@key{igraph}{pagebox}{}
\define@key{igraph}{interpolate}[true]{}
%    \end{macrocode}
% New in v1.1b:
% \changes{v0.52}{2018/03/27}{pkg{graphicx}: Updated for v1.1b.}
%    \begin{macrocode}
\define@key{igraph}{decodearray}{}
%    \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}


% \begin{macro}{\LWR@opacity} For \HTML, used only for \cs{includegraphics}.
%
% \cs{LWR@opacity} may be set by the \pkg{transparent} package.
%    \begin{macrocode}
\def\LWR@opacity{1}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@imagesizebox}
% Used to determine the actual image size if needed.
%    \begin{macrocode}
\newsavebox{\LWR@imagesizebox}
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\LWR@HTML@Gin@setfile} \marg{w} \marg{h} \marg{filename}
% Sets the parsed filename for \HTML\ output.
%    \begin{macrocode}
\newcommand*{\LWR@HTML@Gin@setfile}[3]{%
    \xdef\LWR@parsedfilename{#3}%
}
%    \end{macrocode}
% \end{macro}


% \DescribeKey[Gin]{class} \CSS\ class for the image.
%
% 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.}
% \changes{v0.65}{2018/12/19}{\pkg{graphics}: Added \cs{includegraphics} \attribute{alt} key.}
%    \begin{macrocode}
\AtBeginDocument{
\define@key{Gin}{class}{}
\define@key{Gin}{alt}{}
}
%    \end{macrocode}


% \begin{macro}{\LWR@replaceEPSSVG}
%
% Usually, references to \EPS\ files become \SVG\ files,
% but if the \pkg{epstopdf} package is being used, it automatically
% converts \EPS\ to \PDF, and the following must NOT be done.
%    \begin{macrocode}
\AtBeginDocument{
\@ifpackageloaded{epstopdf}
{
    \newcommand*{\LWR@replaceEPSSVG}{}
}{%
    \newcommand*{\LWR@replaceEPSSVG}{%
        \StrSubstitute{\LWR@tempone}{.eps}{.svg}[\LWR@tempone]%
        \StrSubstitute{\LWR@tempone}{.EPS}{.SVG}[\LWR@tempone]%
    }
}%
}
%    \end{macrocode}
% \end{macro}


% \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.
%
% If using \cs{epsfig} or \cs{psfig} from the \pkg{epsfig} package,
% |#4| will be \cs{LWR@epsfig@filename}, which will have been set by the |file| or |figure| keys.
% Therefore, |#4| must not be used until after the keys have been processed.
%
% \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.}
% \changes{v0.45}{2017/12/29}{Improved URLs with underscores.}
% \changes{v0.59}{2018/09/07}{Now works with \filenm{.pdf} and \filenm{.eps}
%                               filename extensions.}
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@includegraphicsb}{s o o m}
{%
%    \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 \cs{linewidth}, \cs{textwidth}, \cs{textheight} arguments with a 6x9 inch size
% until the next \cs{endgroup}.
% \changes{v0.48}{2018/02/11}{Fix: Virtual page size limited to a group.}
%    \begin{macrocode}
\begingroup%
\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}
% 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}
% \changes{v0.65}{2018/12/19}{\pkg{graphics}: Added \cs{includegraphics} \attribute{alt} key.}
%    \begin{macrocode}
\renewcommand*{\LWR@igalt}{(image)}%
%    \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}
%
% Fully expand and detokenize the filename,
% changing the file extension to \filenm{.svg} if necessary.
% \changes{v0.59}{2018/08/28}{Fix: Expand filename.}
% \changes{v0.61}{2018/10/01}{Set keys before using filename, for \pkg{epsfig}.}
%    \begin{macrocode}
\begingroup%
\LetLtxMacro\Gin@setfile\LWR@HTML@Gin@setfile%
\edef\LWR@tempone{#4}%
\StrSubstitute{\LWR@tempone}{.pdf}{.svg}[\LWR@tempone]%
\StrSubstitute{\LWR@tempone}{.PDF}{.SVG}[\LWR@tempone]%
\LWR@replaceEPSSVG%
\xdef\LWR@parsedfilename{\LWR@tempone}%
\Ginclude@graphics{\detokenize\expandafter{\LWR@tempone}}%
\endgroup%
\filename@parse{\LWR@parsedfilename}%
\LWR@traceinfo{LWR@parsedfilename is \LWR@parsedfilename}%
% \LWR@sanitize{\LWR@parsedfilename}%
%    \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 \progcode{FormatWP}, use explicit size.}
% \changes{v0.61}{2018/10/06}{Fix: \EPS\ for \DVI\ \LaTeX.}
% \changes{v0.62}{2018/10/27}{Fix: \bool{FormatWP}.}
%    \begin{macrocode}
\ifbool{FormatWP}{%
    \begingroup%
    \LWR@restoreorigformatting%
    \ifpdf%
    \appto\LWR@restoreorigformatting{%
    \DeclareGraphicsExtensions{.pdf,.PDF,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG}%
    }%
    \else% \ifpdf
            \ifXeTeX%
    \appto\LWR@restoreorigformatting{%
    \DeclareGraphicsExtensions{.pdf,.PDF,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG}%
    }%
            \else%
    \appto\LWR@restoreorigformatting{%
    \DeclareGraphicsExtensions{.eps,.EPS,.gif,.GIF,.png,.PNG,.jpg,.JPG,.jpeg,.JPEG}%
    }%
            \fi%
    \fi% \ifpdf
    \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%
    \settowidth{\LWR@igwidth}{\usebox{\LWR@imagesizebox}}%
    \global\renewcommand*{\LWR@igwidthstyle}{width:\LWR@printlength{\LWR@igwidth}}%
    \settoheight{\LWR@igheight}{\usebox{\LWR@imagesizebox}}%
    \global\renewcommand*{\LWR@igheightstyle}{height:\LWR@printlength{\LWR@igheight}}%
}{}% FormatWP
%    \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\LWR@indentHTML%
src="%
%    \end{macrocode}
% \changes{v0.62}{2018/10/27}{Fix: Filename expansion.}
%    \begin{macrocode}
\detokenize\expandafter{\LWR@parsedfilename}%
%    \end{macrocode}
%    \begin{macrocode}
"\LWR@indentHTML%
%    \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}
}%
{%
    style="\LWR@indentHTML
    \ifthenelse{\NOT\equal{\LWR@igwidthstyle}{}}%
        {\LWR@igwidthstyle;\LWR@indentHTML}{}%
    \ifthenelse{\NOT\equal{\LWR@igheightstyle}{}}%
        {\LWR@igheightstyle;\LWR@indentHTML}{}%
    \ifthenelse{\NOT\equal{\LWR@igorigin}{}}%
        {%
            transform-origin: \LWR@originnames{\LWR@igorigin};\LWR@indentHTML%
        }{}%
    \ifthenelse{\NOT\equal{\LWR@igangle}{}}%
    {%
        \LWR@rotstyle{-ms-}{\LWR@igangle}\LWR@indentHTML
        \LWR@rotstyle{-webkit-}{\LWR@igangle}\LWR@indentHTML
        \LWR@rotstyle{}{\LWR@igangle }\LWR@indentHTML
    }{}%
    \ifthenelse{%
        \NOT\equal{\LWR@igxscale}{1}\OR%
        \NOT\equal{\LWR@igyscale}{1}%
    }%
    {%
        \LWR@scalestyle{-ms-}{\LWR@igxscale}{\LWR@igyscale}\LWR@indentHTML
        \LWR@scalestyle{-webkit-}{\LWR@igxscale}{\LWR@igyscale}\LWR@indentHTML
        \LWR@scalestyle{}{\LWR@igxscale}{\LWR@igyscale}\LWR@indentHTML
    }{}%
    %
    \ifthenelse{\NOT\equal{\LWR@opacity}{1}}%
        {opacity:\LWR@opacity;\LWR@indentHTML}{}%
    %
    "\LWR@indentHTML%
}{}%
%    \end{macrocode}
% Set the class and alt tag:
% \changes{v0.65}{2018/12/19}{\pkg{graphics}: Added \cs{includegraphics} \attribute{alt} key.}
%    \begin{macrocode}
class="\LWR@igclass"\LWR@indentHTML%
alt="\LWR@igalt" \LWR@orignewline%
}% end of image tags
}% end of href
%    \end{macrocode}
% Return to original page size and font size:
% \changes{v0.48}{2018/02/11}{Fix: Virtual page size limited to a group.}
%    \begin{macrocode}
\endgroup
\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.

% The user should always use no file suffix 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%
\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}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\AtBeginDocument{
%    \end{macrocode}
%
% The \HTML\ version:
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@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:
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
\LWR@htmltagc{%
    span\LWR@indentHTML
    style="\LWR@indentHTML
    display: inline-block;\LWR@indentHTML
%    \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@indentHTML}%
        {}%
%    \end{macrocode}
% Print the rotation information:
%    \begin{macrocode}
    \LWR@rotstyle{-ms-}{#2}\LWR@indentHTML
    \LWR@rotstyle{-webkit-}{#2}\LWR@indentHTML
    \LWR@rotstyle{}{#2}"\LWR@orignewline%
}\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}%
}
%    \end{macrocode}
%
% The high-level interface:
%    \begin{macrocode}
\LWR@formatted{rotatebox}

}% AtBeginDocument
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\scalebox} \marg{h-scale} \oarg{v-scale} \marg{text}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\AtBeginDocument{
%    \end{macrocode}
%
% The \HTML\ version:
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@scalebox}{m o m}{%
%    \end{macrocode}
% Select |inline-block| so that \HTML\ will transform this span:
% \changes{v0.66}{2019/02/02}{Improved \HTML\ formatting.}
%    \begin{macrocode}
\LWR@htmltagc{%
    span\LWR@indentHTML
    style="\LWR@indentHTML
    display: inline-block;\LWR@indentHTML
%    \end{macrocode}
% Print the scaling information:
%    \begin{macrocode}
    \LWR@scalestyle{-ms-}{#1}{\IfNoValueTF{#2}{#1}{#2}}\LWR@indentHTML
    \LWR@scalestyle{-webkit-}{#1}{\IfNoValueTF{#2}{#1}{#2}}\LWR@indentHTML
    \LWR@scalestyle{}{#1}{\IfNoValueTF{#2}{#1}{#2}}
    "\LWR@orignewline
}\LWR@orignewline%
%    \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}%
}
%    \end{macrocode}
%
% The high-level interface:
%    \begin{macrocode}
\LWR@formatted{scalebox}

}% AtBeginDocument
%    \end{macrocode}
% \end{macro}


% \begin{macro}{\reflectbox} \marg{text}
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\AtBeginDocument{

\newcommand{\LWR@HTML@reflectbox}[1]{%
\scalebox{-1}[1]{#1}%
}% \reflectbox

\LWR@formatted{reflectbox}

}% AtBeginDocument
%    \end{macrocode}
% \end{macro}



% \begin{macro}{\resizebox} \marg{h-length} \marg{v-length} \marg{text}
%
% Simply prints its text argument.
%
% \changes{v0.57}{2018/05/28}{Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\AtBeginDocument{

\NewDocumentCommand{\LWR@HTML@resizebox}{s m m m}{%
#4%
}

\LWR@formatted{resizebox}

}% AtBeginDocument
%    \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}[2017/06/01]
%    \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}[2017/06/30]
%    \end{macrocode}
%
% \iffalse
%</grffile>
% \fi
%
%
%
%
%
% \iffalse
%<*grid>
% \fi
%
% \part{lwarp-grid.sty}
%
% \section{grid}
%
% \DescribePackage{grid}
% \pkg{grid} is ignored.
%
% \changes{v0.51}{2018/03/08}{\pkg{grid}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{grid}[2009/06/16]
%    \end{macrocode}
%
%    \begin{macrocode}
\newenvironment*{gridenv}{}{}
%    \end{macrocode}
%
% \iffalse
%</grid>
% \fi
%
%
%
%
% \iffalse
%<*grid-system>
% \fi
%
% \part{lwarp-grid-system.sty}
%
% \section{grid-system}
%
% \credits{Marcus Bitzl}
%
% \DescribePackage{grid-system}
% \pkg{grid-system} is patched for use by \pkg{lwarp}.
%
% \changes{v0.60}{2018/09/18}{\pkg{grid-system}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{grid-system}[2014/02/16]
%    \end{macrocode}
%
% (\cs{ifdef} is in case the older syntax is removed.)
%
%    \begin{macrocode}
\AtBeginEnvironment{Row}{\setlength{\linewidth}{6in}}

\ifdef{\endrow}{
    \AtBeginEnvironment{row}{\setlength{\linewidth}{6in}}
}{}

\renewcommand{\gridsystem@finishcell}{\hspace{\gridsystem@cellsep}}
%    \end{macrocode}
%
% \iffalse
%</grid-system>
% \fi
%
%
%
%
% \iffalse
%<*gridset>
% \fi
%
% \part{lwarp-gridset.sty}
%
% \section{gridset}
%
% \DescribePackage{gridset}
% \pkg{gridset} is ignored.
%
% \changes{v0.54}{2018/04/11}{\pkg{gridset}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{gridset}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\gridbase}{}
\newcommand*{\gridinterval}{}
\newcommand*{\savepos}[1]{}
\newcounter{gridcnt}
\newcommand*{\vskipnextgrid}{}
\newcommand*{\thegridinfo}[1]{}
\newcommand*{\theposinfo}[1]{}
\newcommand*{\theypos}[1]{}
%    \end{macrocode}
%
% \iffalse
%</gridset>
% \fi
%
%
%
% \iffalse
%<*hang>
% \fi
%
% \part{lwarp-hang.sty}
%
% \section{hang}
%
% \credits{Andreas Nolda}
%
% \DescribePackage{hang}
% \pkg{hang} is emulated.
%
% \changes{v0.44}{2017/11/15}{\pkg{hang}: Added.}
% \changes{v0.47}{2018/01/26}{\pkg{hang}: Fix: Line wrap at \HTML\ hyphen.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{hang}[2017/02/18]
%    \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%
    \BlockClass[%
        \LWR@print@mbox{margin-left:\LWR@printlength{\LWR@templengthone}} ; %
        \LWR@print@mbox{text-indent:-\LWR@printlength{\hangingindent}}%
    ]%
    {hangingpar}%
}
{\endBlockClass}

\newenvironment{hanginglist}
{%
    \renewcommand*{\LWR@printcloselist}{\LWR@printcloseitemize}%
    \renewcommand*{\LWR@printopenlist}{%
        \LWR@findhangingleftmargin%
        ul style="%
            \LWR@print@mbox{list-style-type:none;} % extra space
            \LWR@print@mbox{%
                margin-left:\LWR@printlength{\LWR@templengthone}%
            } ; % extra space
            \LWR@print@mbox{%
                text-indent:-\LWR@printlength{\hangingindent}%
            }%
        "%
    }%
    \let\item\LWR@itemizeitem%
    \list{}{}%
}
{\endlist}

\newenvironment{compacthang}
{\hanginglist}
{\endhanginglist}

\newlength{\labeledleftmargin}
\setlength{\labeledleftmargin}{0em}

\newenvironment{labeledpar}[2]
{%
    \BlockClass[%
        \LWR@findhangingleftmargin%
        \LWR@print@mbox{margin-left:\LWR@printlength{\LWR@templengthone}} ; %
        \LWR@print@mbox{text-indent:-\LWR@printlength{\hangingindent}}%
    ]{labeledpar}#2%
}
{\endBlockClass}

\newenvironment{labeledlist}[1]
{\hanginglist}
{\endhanginglist}

\newenvironment{compactlabel}[1]
{\hanginglist}
{\endhanginglist}
%    \end{macrocode}
%
% \iffalse
%</hang>
% \fi
%
%
%
%
% \iffalse
%<*hanging>
% \fi
%
% \part{lwarp-hanging.sty}
%
% \section{hanging}
%
% \DescribePackage{hanging}
% \pkg{hanging} is emulated.
%
% \changes{v0.45}{2017/12/02}{\pkg{hanging}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{hanging}[2009/09/02]
%    \end{macrocode}
%
%
%    \begin{macrocode}
\@ifclassloaded{memoir}{
\let\hangpara\relax
\let\hangparas\relax
\let\endhangparas\relax
\let\hangpunct\relax
\let\endhangpunct\relax
}{}
%    \end{macrocode}
%
% \begin{noindmacro}{\hangpara} \marg{indent} \marg{afternum}
%
% \textred{Use \env{hangparas} instead.}
%    \begin{macrocode}
\newcommand*{\hangpara}[2]{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindenvironment}{hangparas} \marg{indent} \marg{afternum}
% \changes{v0.47}{2018/01/26}{\pkg{hanging}: Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\newenvironment*{hangparas}[2]
{%
    \BlockClass[%
        \LWR@print@mbox{margin-left:\LWR@printlength{#1}} ; %
        \LWR@print@mbox{text-indent:-\LWR@printlength{#1}}%
    ]%
    {hangingpar}%
}
{\endBlockClass}
%    \end{macrocode}
% \end{noindenvironment}
%
% \begin{noindenvironment}{hangpunct}
%    \begin{macrocode}
\newenvironment*{hangpunct}
{\BlockClass{hangpunct}}
{\endBlockClass}
%    \end{macrocode}
% \end{noindenvironment}
%
%    \begin{macrocode}
\newcommand{\nhpt}{.}
\newcommand{\nhlq}{‘}
\newcommand{\nhrq}{’}
%    \end{macrocode}
%
% \iffalse
%</hanging>
% \fi
%
%
%
%
% \iffalse
%<*hypcap>
% \fi
%
% \part{lwarp-hypcap.sty}
%
% \section{hypcap}
%
% \DescribePackage{hypcap}
% \pkg{hypcap} is ignored.
%
% \changes{v0.48}{2018/02/07}{\pkg{hypcap}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{hypcap}[2016/05/16]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\capstart}{}
\newcommand*{\hypcapspace}{}
\newcommand*{\hypcapredef}[1]{}
\newcommand*{\capstartfalse}{}
\newcommand*{\capstarttrue}{}
%    \end{macrocode}
%
% \iffalse
%</hypcap>
% \fi
%
%
%
%
% \iffalse
%<*hypdestopt>
% \fi
%
% \part{lwarp-hypdestopt.sty}
%
% \section{hypdestopt}
%
% \DescribePackage{hypdestopt}
% \pkg{hypdestopt} is ignored.
%
% \changes{v0.49}{2018/02/15}{\pkg{hypdestopt}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{hypdestopt}[2016/05/21]
%    \end{macrocode}
%
% \iffalse
%</hypdestopt>
% \fi
%
%
%
%
% \iffalse
%<*hypernat>
% \fi
%
% \part{lwarp-hypernat.sty}
%
% \section{hypernat}
%
% \DescribePackage{hypernat}
% \pkg{hypernat} is ignored.
%
% \changes{v0.48}{2018/02/07}{\pkg{hypernat}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{hypernat}[2001/07/09]
%    \end{macrocode}
%
% \iffalse
%</hypernat>
% \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.}
% \changes{v0.45}{2017/12/29}{\pkg{hyperref}: Fix: Underscore in \URL.}
% \changes{v0.52}{2018/03/26}{\pkg{hyperref}: Fix: \progcode{\#}, \progcode{\%}, \progcode{\&}, \progcode{\~}, \progcode{\_} in \URL.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@hyperimageb}{m +m}{%
\LWR@ensuredoingapar%
\def\LWR@templink{#1}%
\@onelevel@sanitize\LWR@templink%
\LWR@htmltag{img src="\LWR@templink" alt="#2" class="hyperimage"}%
\LWR@ensuredoingapar%
\endgroup%
}

\newrobustcmd*{\hyperimage}{%
\begingroup%
\catcode`\#=12%
\catcode`\%=12%
\catcode`\&=12%
\catcode`\~=12%
\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.
%
% \changes{v0.52}{2018/03/26}{\pkg{hyperref}: Fix: \progcode{\#}, \progcode{\%}, \progcode{\&}, \progcode{\~}, \progcode{\_} in \URL.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@hyperdefb}{m m +m}{%
\LWR@ensuredoingapar%
\LWR@sublabel{#1.#2}%
#3%
\endgroup%
}

\newcommand*{\hyperdef}{%
\begingroup%
\catcode`\#=12%
\catcode`\%=12%
\catcode`\&=12%
\catcode`\~=12%
\catcode`\_=12%
\LWR@hyperdefb%
}

%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\LWR@hyperrefb} \marg{1: URL} \marg{2: category}
%							\marg{3: name} \marg{4: text}
% \changes{v0.45}{2018/01/02}{\pkg{hyperref}: Fix: Underscore in \URL.}
% \changes{v0.52}{2018/03/26}{\pkg{hyperref}: Fix: \progcode{\#}, \progcode{\%}, \progcode{\&}, \progcode{\~}, \progcode{\_} in \URL.}
% \changes{v0.57}{2018/06/05}{\pkg{subcaption}: Fix: \cs{subref}.}
%
% Creates an \HTML\ link to |URL#category.name| with the given text.
%    \begin{macrocode}
\newcommand{\LWR@hyperreffinish}[1]{%
\begingroup%
\RenewDocumentCommand{\ref}{}{\LWR@ref@ignorestar}%
#1%
\endgroup%
\LWR@htmltag{/a}%
}

\newcommand*{\LWR@hyperrefbb}[3]{%
\LWR@htmltag{%
    a href="%
        \detokenize\expandafter{#1}\LWR@hashmark%
        \detokenize\expandafter{#2}.\detokenize\expandafter{#3}%
    "%
}%
\endgroup%
\LWR@hyperreffinish%
}

\newrobustcmd*{\LWR@hyperrefb}{%
\begingroup%
\catcode`\#=12%
\catcode`\%=12%
\catcode`\&=12%
\catcode`\~=12%
\catcode`\_=12%
\LWR@hyperrefbb%
}
%    \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@hyperrefcb}{O{label}}{%
\LWR@startref{#1}%
\endgroup%
\LWR@hyperreffinish%
}

\newcommand*{\LWR@hyperrefc}{%
\begingroup%
\catcode`\#=12%
\catcode`\%=12%
\catcode`\&=12%
\catcode`\~=12%
\catcode`\_=12%
\LWR@hyperrefcb%
}
%    \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.}
% \changes{v0.54}{2018/04/19}{\pkg{hyperref}: Fix: \cs{ref} in \cs{hyperref} and \cs{hyperlink} caused nested link.}
% \changes{v0.54}{2018/04/19}{\pkg{hyperref}: Fix: \cs{hyperref} and \cs{hyperlink} with special chars in text.}
%    \begin{macrocode}
\DeclareRobustCommand*{\hyperref}{%
\LWR@ensuredoingapar%
\@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.
%
% \changes{v0.52}{2018/03/26}{\pkg{hyperref}: Fix: \progcode{\#}, \progcode{\%}, \progcode{\&}, \progcode{\~}, \progcode{\_} in \URL.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@hypertargetb}{m +m}{%
\label{LWR-ht-#1}%
#2%
\endgroup%
}

\newcommand*{\hypertarget}{%
\begingroup%
\catcode`\#=12%
\catcode`\%=12%
\catcode`\&=12%
\catcode`\~=12%
\catcode`\_=12%
\LWR@hypertargetb%
}
%    \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.
%
% Declared because also defined by \pkg{memoir}.
%
% \changes{v0.52}{2018/03/26}{\pkg{hyperref}: Fix: \progcode{\#}, \progcode{\%}, \progcode{\&}, \progcode{\~}, \progcode{\_} in \URL.}
% \changes{v0.54}{2018/04/19}{\pkg{hyperref}: Fix: \cs{ref} in \cs{hyperref} and \cs{hyperlink} caused nested link.}
% \changes{v0.54}{2018/04/19}{\pkg{hyperref}: Fix: \cs{hyperref} and \cs{hyperlink} with special chars in text.}
%    \begin{macrocode}
\DeclareDocumentCommand{\LWR@hyperlinkb}{m}{%
\LWR@hyperrefcb[LWR-ht-#1]%
}

\DeclareDocumentCommand{\hyperlink}{}{%
\LWR@ensuredoingapar%
\begingroup%
\catcode`\#=12%
\catcode`\%=12%
\catcode`\&=12%
\catcode`\~=12%
\catcode`\_=12%
\LWR@hyperlinkb%
}
%    \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}
%
% \changes{v0.48}{2018/02/02}{\pkg{hyperref}: \cs{texorpdfstring} now uses the \TeX\ string.}
%    \begin{macrocode}
\newcommand{\texorpdfstring}[2]{#1}
%    \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}[2018/11/27]
%    \end{macrocode}
%
%
% \iffalse
%</hyperxmp>
% \fi
%
%
%
%
%
% \iffalse
%<*hyphenat>
% \fi
%
% \part{lwarp-hyphenat.sty}
%
% \section{hyphenat}
%
% \DescribePackage{hyphenat}
% \pkg{hyphenat} is emulated during \HTML\ output, while
% the print-mode version is used inside a \env{lateximage}.
%
% \changes{v0.49}{2018/02/15}{\pkg{hyphenat}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{hyphenat}[2009/09/02]
%    \end{macrocode}
%
%    \begin{macrocode}
\LetLtxMacro\LWRHYNAT@origtextnhtt\textnhtt
\LetLtxMacro\LWRHYNAT@orignhttfamily\nhttfamily
\LetLtxMacro\LWRHYNAT@orignohyphens\nohyphens
\LetLtxMacro\LWRHYNAT@origbshyp\bshyp
\LetLtxMacro\LWRHYNAT@origfshyp\fshyp
\LetLtxMacro\LWRHYNAT@origdothyp\dothyp
\LetLtxMacro\LWRHYNAT@origcolonhyp\colonhyp
\LetLtxMacro\LWRHYNAT@orighyp\hyp

\LetLtxMacro\textnhtt\texttt
\LetLtxMacro\nhttfamily\ttfamily

\renewcommand{\nohyphens}[1]{#1}
\renewrobustcmd{\bshyp}{%
    \ifmmode\backslash\else\textbackslash\fi%
}
\renewrobustcmd{\fshyp}{/}
\renewrobustcmd{\dothyp}{.}
\renewrobustcmd{\colonhyp}{:}
\renewrobustcmd{\hyp}{-}

\appto\LWR@restoreorigformatting{%
\LetLtxMacro\textnhtt\LWRHYNAT@origtextnhtt%
\LetLtxMacro\nhttfamily\LWRHYNAT@orignhttfamily%
\LetLtxMacro\nohyphens\LWRHYNAT@orignohyphens%
\LetLtxMacro\bshyp\LWRHYNAT@origbshyp%
\LetLtxMacro\fshyp\LWRHYNAT@origfshyp%
\LetLtxMacro\dothyp\LWRHYNAT@origdothyp%
\LetLtxMacro\colonhyp\LWRHYNAT@origcolonhyp%
\LetLtxMacro\hyp\LWRHYNAT@orighyp%
}
%    \end{macrocode}
%
% \iffalse
%</hyphenat>
% \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}[2012/03/30]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\LWR@indexprenote}{}

\preto\printindex{

\LWR@orignewpage
\LWR@startpars

\LWR@indexprenote

}

\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}[2016/04/23]
%    \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
%<*imakeidx>
% \fi
%
% \part{lwarp-imakeidx.sty}
%
% \section{imakeidx}
% \label{sec:imakeidx}
%
% \credits{Enrico Gregorio}
%
% \DescribePackage{imakeidx}
% \pkg{imakeidx} is patched for use by \pkg{lwarp}.
%
% \limitsimakeidx
%
% \changes{v0.58}{2018/06/13}{\pkg{imakeidx}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{imakeidx}[2016/10/15]
%    \end{macrocode}
%
% Use the new \HTML\ suffix:
%    \begin{macrocode}
\catcode`\_=12%
\define@key{imki}{name}{\def\imki@name{#1_html}}
\catcode`\_=8%
%    \end{macrocode}
%
% \begin{noindmacro}{\printindex}
% The \HTML\ version of \cs{printindex}:
%    \begin{macrocode}
\catcode`\_=12%

\renewcommand*{\printindex}[1][\imki@jobname]{%
\LWR@orignewpage%
\LWR@startpars%
\ifstrequal{#1}{\imki@jobname}{%
  \@ifundefined{#1@idxfile}{%
        \imki@error{#1}%
    }{%
        \imki@putindex{#1}%
    }%
}{%
  \@ifundefined{#1_html@idxfile}{\imki@error{#1_html}}{\imki@putindex{#1_html}}%
}%
}

\catcode`\_=8%
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\@index}
% The \HTML\ version of \cs{\@index}:
%    \begin{macrocode}
\catcode`\_=12%

\def\@index[#1]{%
    \ifstrequal{#1}{\imki@jobname}%
    {%
        \@ifundefined{#1@idxfile}%
        {%
            \PackageWarning{imakeidx}{Undefined index file `#1'}%
            \begingroup
            \@sanitize
            \imki@nowrindex%
        }%
        {%
            \edef\@idxfile{#1}%
            \begingroup
            \@sanitize
            \@wrindex\@idxfile%
        }%
    }%
    {%
        \@ifundefined{#1_html@idxfile}%
        {%
            \PackageWarning{imakeidx}{Undefined index file `#1_html'}%
            \begingroup
            \@sanitize
            \imki@nowrindex%
        }%
        {%
            \edef\@idxfile{#1_html}%
            \begingroup
            \@sanitize
            \@wrindex\@idxfile%
        }%
    }%
}

\catcode`\_=8%
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\item}
% \begin{noindmacro}{\subitem}
% \begin{noindmacro}{\subsubitem}
% \HTML\ versions of \cs{item}, etc.:
%    \begin{macrocode}
\appto\theindex{%
    \let\item\LWR@indexitem%
    \let\subitem\LWR@indexsubitem%
    \let\subsubitem\LWR@indexsubsubitem%
}
%    \end{macrocode}
% \end{noindmacro}
% \end{noindmacro}
% \end{noindmacro}
%
% \begin{noindmacro}{\imki@wrindexentrysplit} \marg{file} \marg{entry} \marg{page}
% \begin{noindmacro}{\imki@wrindexentryunique} \marg{file} \marg{entry} \marg{page}
%
% While writing index entries, adds an \HTML\ label, and
% writes the label's index instead of the page number:
%    \begin{macrocode}
\renewcommand\imki@wrindexentrysplit[3]{%
\addtocounter{LWR@autoindex}{1}%
\LWR@new@label{LWRindex-\arabic{LWR@autoindex}}%
  \expandafter\protected@write\csname#1@idxfile\endcsname{}%
    {\string\indexentry{#2}{\arabic{LWR@autoindex}}}%
}

\renewcommand\imki@wrindexentryunique[3]{%
\addtocounter{LWR@autoindex}{1}%
\LWR@new@label{LWRindex-\arabic{LWR@autoindex}}%
  \protected@write\@indexfile{}%
    {\string\indexentry[#1]{#2}{\arabic{LWR@autoindex}}}%
}

\def\imki@wrindexsplit#1#2{%
\imki@wrindexentrysplit{#1}{#2}{\thepage}%
\endgroup\imki@showidxentry{#1}{#2}%
  \@esphack%
}

\def\imki@wrindexunique#1#2{%
\imki@wrindexentryunique{#1}{#2}{\thepage}%
\endgroup\imki@showidxentry{#1}{#2}%
  \@esphack%
  }

%    \end{macrocode}
% \end{noindmacro}
% \end{noindmacro}
%
% \begin{noindmacro}{\LWR@imki@setxdydefopts}
%
% Sets the \pkg{xindy} \HTML\ options, ignoring the user's settings.
%    \begin{macrocode}
\newcommand*{\LWR@imki@setxdydefopts}{%
    \edef\imki@options{ \space %
        -M \space \LWR@xindyStyle\space %
        -L \space \LWR@xindyLanguage\space %
        -C \space \LWR@xindyCodepage\space %
    }%
}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\LWR@imki@setdefopts} \marg{user options}
%
% Sets the \HTML\ options, added to the user's settings,
% depending on whether \pkg{makeindex} or \pkg{xindy} are used.
%
% For \prog{makeindex}, the user's choice is ignored, and only the \pkg{lwarp}
% version is used.  (Only one style at a time is possible.)
%
% For \prog{xindy}, multiple modules may be specified, and the \pkg{lwarp}
% version is appended.
%    \begin{macrocode}
\newcommand*{\LWR@imki@setdefopts}[1]{%
\ifblank{#1}{%
    \edef\imki@options{\space -s \space \LWR@makeindexStyle \space}%
    \ifdefstring{\imki@progdefault}{xindy}{\LWR@imki@setxdydefopts}{}%
    \ifdefstring{\imki@progdefault}{texindy}{\LWR@imki@setxdydefopts}{}%
    \ifdefstring{\imki@progdefault}{truexindy}{\LWR@imki@setxdydefopts}{}%
}{%
    \edef\imki@options{\space #1 \space}%
}%
}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\imki@makeindex}
% Use the new \HTML\ options:
%    \begin{macrocode}
\xpatchcmd{\imki@makeindex}
    {\let\imki@options\space}
    {\LWR@imki@setdefopts{}}%
    {}
    {\LWR@patcherror{imakeidx}{makeindex}}
%    \end{macrocode}
% \end{noindmacro}
%
% Use the new \HTML\ options.
%    \begin{macrocode}
\define@key{imki}{options}{\LWR@imki@setdefopts{#1}}
%    \end{macrocode}
%
% \begin{noindmacro}{\imki@resetdefaults}
% Use the new \HTML\ options:
%    \begin{macrocode}
\xpatchcmd{\imki@resetdefaults}
    {\def\imki@options{ }}
    {\LWR@imki@setdefopts{}}
    {}
    {\LWR@patcherror{imakeidx}{resetdefaults}}
%    \end{macrocode}
% \end{noindmacro}
%
% \env{theindex} was already defined \cs{AtBeginDocument} by  the \pkg{lwarp} core,
% so it must be redefined here similarly, but patched for \pkg{imakeidx}:
% \begin{noindenvironment}{theindex}
%    \begin{macrocode}
\AtBeginDocument{
\renewenvironment*{theindex}{%
    \imki@maybeaddtotoc
     \imki@indexlevel{\indexname}
    \let\item\LWR@indexitem%
    \let\subitem\LWR@indexsubitem%
    \let\subsubitem\LWR@indexsubsubitem%
}{}
}% AtBeginDocument
%    \end{macrocode}
% \end{noindenvironment}
%
%
% Update to the new defaults:
%    \begin{macrocode}
\imki@resetdefaults
%    \end{macrocode}
%
% Update to the new patches:
%
% \cs{AtBeginDocument} is because \cs{@wrindex} is previously defined
% as \cs{AtBeginDocument} in the \pkg{lwarp} core.
%
%    \begin{macrocode}
\ifimki@splitindex
  \let\imki@startidx\imki@startidxunique
  \AtBeginDocument{\let\@wrindex\imki@wrindexunique}
  \let\imki@putindex\imki@putindexunique
  \let\imki@wrindexentry\imki@wrindexentryunique
  \let\imki@startidxsplit\@undefined
  \let\imki@wrindexsplit\@undefined
  \let\imki@putindexsplit\@undefined
\else
  \let\imki@startidx\imki@startidxsplit
  \AtBeginDocument{\let\@wrindex\imki@wrindexsplit}
  \let\imki@putindex\imki@putindexsplit
  \let\imki@wrindexentry\imki@wrindexentrysplit
  \let\imki@startidxunique\@undefined
  \let\imki@wrindexunique\@undefined
  \let\imki@putindexunique\@undefined
\fi
%    \end{macrocode}
%
% \iffalse
%</imakeidx>
% \fi
%
%
%
%
% \iffalse
%<*index>
% \fi
%
% \part{lwarp-index.sty}
%
% \section{index}
% \label{sec:indexpkg}
%
% \credits{David M. Jones}
%
% \DescribePackage{index}
% \pkg{index} is patched for use by \pkg{lwarp}.
%
% \changes{v0.58}{2018/07/06}{\pkg{index}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{index}[2004/01/20]
%    \end{macrocode}
%
% Use \cs{theLWR@autoindex} instead of \cs{thepage}.
% \cs{@tempswatrue} is used to force an immediate write to the index file
% instead of waiting until the end of the page.
%    \begin{macrocode}
\xpatchcmd{\newindex}
    {\x@newindex[thepage]}
    {%
        \@tempswatrue%
        \x@newindex[theLWR@autoindex]%
    }
    {}
    {\LWR@patcherror{index}{newindex}}

\xpatchcmd{\renewindex}
    {\x@renewindex[thepage]}
    {%
        \@tempswatrue%
        \x@renewindex[theLWR@autoindex]%
    }
    {}
    {\LWR@patcherror{index}{renewindex}}
%    \end{macrocode}
%
% Patched to set a new autoindex:
%    \begin{macrocode}
\xpatchcmd{\@wrindex}
    {\begingroup}
    {%
        \addtocounter{LWR@autoindex}{1}%                    lwarp
        \LWR@new@label{LWRindex-\arabic{LWR@autoindex}}%    lwarp
        \begingroup%
    }
    {}
    {\LWR@patcherror{index}{@wrindex}}
%    \end{macrocode}
%
% \cs{AtBeginDocument} \pkg{lwarp} core \cs{let}s \cs{@wrindex} to \cs{LWR@wrindex}.
% Since the \pkg{index} package has been loaded, \cs{let} to its version instead:
%    \begin{macrocode}
\let\LWR@index@wrindex\@wrindex

\AtBeginDocument{
\let\@wrindex\LWR@index@wrindex
}
%    \end{macrocode}
%
% Modified to add \cs{index@prologue}:
%    \begin{macrocode}
\AtBeginDocument{
\renewenvironment*{theindex}{%
    \LWR@indexsection{\indexname}%
    \ifx\index@prologue\@empty\else
        \index@prologue
        \bigskip
    \fi
    \let\item\LWR@indexitem%
    \let\subitem\LWR@indexsubitem%
    \let\subsubitem\LWR@indexsubsubitem%
}{}
}% AtBeginDocument
%    \end{macrocode}
%
%
% Disabled:
%    \begin{macrocode}
\def\@showidx#1{}
\let\@texttop\relax
\renewcommand*{\raggedbottom}{}
\renewcommand*{\flushbottom}{}
\renewcommand*{\markboth}[2]{}
\renewcommand*{\markright}[1]{}
%    \end{macrocode}

%
% \iffalse
%</index>
% \fi
%
%
%
%
% \iffalse
%<*intopdf>
% \fi
%
% \part{lwarp-intopdf.sty}
%
% \section{intopdf}
%
% \DescribePackage{intopdf}
% \pkg{intopdf} is emulated.
%
% \changes{v0.58}{2018/06/08}{\pkg{intopdf}: Added.}
%
% The MIME type and description are ignored for now.
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{intopdf}[2018/03/15]
%    \end{macrocode}
%
%    \begin{macrocode}
\NewDocumentCommand{\attachandlink}{m o m m}{%
    \href{#1}{#4}%
}
%    \end{macrocode}
%
% \iffalse
%</intopdf>
% \fi
%
%
%
%
%
% \iffalse
%<*karnaugh-map>
% \fi
%
% \part{lwarp-karnaugh-map.sty}
%
% \section{karnaugh-map}
%
% \credits{Mattias Jacobsson}
%
% \DescribePackage{karnaugh-map}
% \pkg{karnaugh-map} is patched for use by \pkg{lwarp}.
%
% \changes{v0.67}{2019/02/17}{\pkg{karnaugh-map}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{karnaugh-map}[2017/02/20]
%    \end{macrocode}
%
% (It is hard to patch this macro, so the entire thing is redefined here,
%   with the \pkg{lwarp} modificaitions identified in comments.)
%
%    \begin{macrocode}
\RenewDocumentEnvironment{karnaugh-map}{s O{4} O{4} O{1} O{$X_1X_0$} O{$X_3X_2$} O{$X_5X_4$}} {%
  \begingroup
    % store map size {[START]
      \renewcommand{\@karnaughmap@var@mapsizex@}{#2}%
      \renewcommand{\@karnaughmap@var@mapsizey@}{#3}%
      \renewcommand{\@karnaughmap@var@mapsizez@}{#4}%
    % [END]}
    % determinate if markings should be color or black and white
    \IfBooleanTF{#1}{%
      % should be black and white
      \renewcommand{\@karnaughmap@var@bw@}{1}%
    }{%
      % should be color
      \renewcommand{\@karnaughmap@var@bw@}{0}%
    }%
    %
    % find matching matrix template and alignment parameters {[START]
      \newcommand{\@karnaughmap@local@matrixtemplate@}{0}% '0' is considered as missing matrix template
      \newcommand{\@karnaughmap@local@maprealignmentx@}{0}%
      \newcommand{\@karnaughmap@local@maprealignmenty@}{0}%
      \ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=221
        \renewcommand{\@karnaughmap@local@matrixtemplate@}{%
                       \&                       0 \&                       1 \& \phantom{0} \\
                     0 \& |(000000)|  \phantom{0} \& |(000001)|  \phantom{0} \&             \\
                     1 \& |(000010)|  \phantom{0} \& |(000011)|  \phantom{0} \&             \\
          \phantom{0}  \&                         \&                         \&             \\
        }%
      \fi
      \ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=241
        \renewcommand{\@karnaughmap@local@matrixtemplate@}{%
                       \&                       0 \&                       1 \& \phantom{00} \\
                    00 \& |(000000)|  \phantom{0} \& |(000001)|  \phantom{0} \&              \\
                    01 \& |(000010)|  \phantom{0} \& |(000011)|  \phantom{0} \&              \\
                    11 \& |(000110)|  \phantom{0} \& |(000111)|  \phantom{0} \&              \\
                    10 \& |(000100)|  \phantom{0} \& |(000101)|  \phantom{0} \&              \\
          \phantom{00} \&                         \&                         \&              \\
        }%
      \fi
      \ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=421
        \renewcommand{\@karnaughmap@local@matrixtemplate@}{%
                       \&                      00 \&                      01 \&                      11 \&                      10 \& \phantom{00} \\
                    0  \& |(000000)|  \phantom{0} \& |(000001)|  \phantom{0} \& |(000011)|  \phantom{0} \& |(000010)|  \phantom{0} \&              \\
                    1  \& |(000100)|  \phantom{0} \& |(000101)|  \phantom{0} \& |(000111)|  \phantom{0} \& |(000110)|  \phantom{0} \&              \\
          \phantom{00} \&                         \&                         \&                         \&                         \&              \\
        }%
      \fi
      \ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=441
        \renewcommand{\@karnaughmap@local@matrixtemplate@}{%
                       \&                      00 \&                      01 \&                      11 \&                      10 \& \phantom{00} \\
                    00 \& |(000000)|  \phantom{0} \& |(000001)|  \phantom{0} \& |(000011)|  \phantom{0} \& |(000010)|  \phantom{0} \&              \\
                    01 \& |(000100)|  \phantom{0} \& |(000101)|  \phantom{0} \& |(000111)|  \phantom{0} \& |(000110)|  \phantom{0} \&              \\
                    11 \& |(001100)|  \phantom{0} \& |(001101)|  \phantom{0} \& |(001111)|  \phantom{0} \& |(001110)|  \phantom{0} \&              \\
                    10 \& |(001000)|  \phantom{0} \& |(001001)|  \phantom{0} \& |(001011)|  \phantom{0} \& |(001010)|  \phantom{0} \&              \\
          \phantom{00} \&                         \&                         \&                         \&                         \&              \\
        }%
      \fi
      \ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=442
        \renewcommand{\@karnaughmap@local@matrixtemplate@}{%
                       \&                      00 \&                      01 \&                      11 \&                      10 \& \phantom{00} \&                      00 \&                      01 \&                      11 \&                      10 \& \phantom{00} \\
                    00 \& |(000000)|  \phantom{0} \& |(000001)|  \phantom{0} \& |(000011)|  \phantom{0} \& |(000010)|  \phantom{0} \&              \& |(010000)|  \phantom{0} \& |(010001)|  \phantom{0} \& |(010011)|  \phantom{0} \& |(010010)|  \phantom{0} \&              \\
                    01 \& |(000100)|  \phantom{0} \& |(000101)|  \phantom{0} \& |(000111)|  \phantom{0} \& |(000110)|  \phantom{0} \&              \& |(010100)|  \phantom{0} \& |(010101)|  \phantom{0} \& |(010111)|  \phantom{0} \& |(010110)|  \phantom{0} \&              \\
                    11 \& |(001100)|  \phantom{0} \& |(001101)|  \phantom{0} \& |(001111)|  \phantom{0} \& |(001110)|  \phantom{0} \&              \& |(011100)|  \phantom{0} \& |(011101)|  \phantom{0} \& |(011111)|  \phantom{0} \& |(011110)|  \phantom{0} \&              \\
                    10 \& |(001000)|  \phantom{0} \& |(001001)|  \phantom{0} \& |(001011)|  \phantom{0} \& |(001010)|  \phantom{0} \&              \& |(011000)|  \phantom{0} \& |(011001)|  \phantom{0} \& |(011011)|  \phantom{0} \& |(011010)|  \phantom{0} \&              \\
          \phantom{00} \&                         \&                         \&                         \&                         \&              \&                         \&                         \&                         \&                         \&              \\
        }%
        \renewcommand{\@karnaughmap@local@maprealignmentx@}{2.5}%
      \fi
      \ifnum\@karnaughmap@var@mapsizex@\@karnaughmap@var@mapsizey@\@karnaughmap@var@mapsizez@=444
        \renewcommand{\@karnaughmap@local@matrixtemplate@}{%
                       \&                      00 \&                      01 \&                      11 \&                      10 \& \phantom{00} \&                      00 \&                      01 \&                      11 \&                      10 \& \phantom{00} \\
                    00 \& |(000000)|  \phantom{0} \& |(000001)|  \phantom{0} \& |(000011)|  \phantom{0} \& |(000010)|  \phantom{0} \&              \& |(010000)|  \phantom{0} \& |(010001)|  \phantom{0} \& |(010011)|  \phantom{0} \& |(010010)|  \phantom{0} \&              \\
                    01 \& |(000100)|  \phantom{0} \& |(000101)|  \phantom{0} \& |(000111)|  \phantom{0} \& |(000110)|  \phantom{0} \&              \& |(010100)|  \phantom{0} \& |(010101)|  \phantom{0} \& |(010111)|  \phantom{0} \& |(010110)|  \phantom{0} \&              \\
                    11 \& |(001100)|  \phantom{0} \& |(001101)|  \phantom{0} \& |(001111)|  \phantom{0} \& |(001110)|  \phantom{0} \&              \& |(011100)|  \phantom{0} \& |(011101)|  \phantom{0} \& |(011111)|  \phantom{0} \& |(011110)|  \phantom{0} \&              \\
                    10 \& |(001000)|  \phantom{0} \& |(001001)|  \phantom{0} \& |(001011)|  \phantom{0} \& |(001010)|  \phantom{0} \&              \& |(011000)|  \phantom{0} \& |(011001)|  \phantom{0} \& |(011011)|  \phantom{0} \& |(011010)|  \phantom{0} \&              \\
          \phantom{00} \&                         \&                         \&                         \&                         \&              \&                         \&                         \&                         \&                         \&              \\
                    00 \& |(100000)|  \phantom{0} \& |(100001)|  \phantom{0} \& |(100011)|  \phantom{0} \& |(100010)|  \phantom{0} \&              \& |(110000)|  \phantom{0} \& |(110001)|  \phantom{0} \& |(110011)|  \phantom{0} \& |(110010)|  \phantom{0} \&              \\
                    01 \& |(100100)|  \phantom{0} \& |(100101)|  \phantom{0} \& |(100111)|  \phantom{0} \& |(100110)|  \phantom{0} \&              \& |(110100)|  \phantom{0} \& |(110101)|  \phantom{0} \& |(110111)|  \phantom{0} \& |(110110)|  \phantom{0} \&              \\
                    11 \& |(101100)|  \phantom{0} \& |(101101)|  \phantom{0} \& |(101111)|  \phantom{0} \& |(101110)|  \phantom{0} \&              \& |(111100)|  \phantom{0} \& |(111101)|  \phantom{0} \& |(111111)|  \phantom{0} \& |(111110)|  \phantom{0} \&              \\
                    10 \& |(101000)|  \phantom{0} \& |(101001)|  \phantom{0} \& |(101011)|  \phantom{0} \& |(101010)|  \phantom{0} \&              \& |(111000)|  \phantom{0} \& |(111001)|  \phantom{0} \& |(111011)|  \phantom{0} \& |(111010)|  \phantom{0} \&              \\
          \phantom{00} \&                         \&                         \&                         \&                         \&              \&                         \&                         \&                         \&                         \&              \\
        }%
        \renewcommand{\@karnaughmap@local@maprealignmentx@}{2.5}%
        \renewcommand{\@karnaughmap@local@maprealignmenty@}{-2.5}%
      \fi
    % [END]}
    % test if a matrix template is found or not(aka "\@karnaughmap@local@matrixtemplate@" equals to '0')
    \ifdefstring{\@karnaughmap@local@matrixtemplate@}{0}{%  lwarp
%     \ifnum0=\@karnaughmap@local@matrixtemplate@%  original
      % print error if no template could be found
      \PackageError{karnaugh-map}{%
        Can not find a template fitting your specification (\@karnaughmap@var@mapsizex@\space x \@karnaughmap@var@mapsizey@\space x \@karnaughmap@var@mapsizez@)%
      }{%
        Existing templates have the following dimensions: 2x2x1, 2x4x1, 4x2x1, 4x4x1, 4x4x2, and 4x4x4.
      }%
%     \fi   original
    }{}%    lwarp
    \begin{tikzpicture}
      % grid
      % for all dimensions
      \draw[color=black, ultra thin] (0,0) grid (\@karnaughmap@var@mapsizex@,\@karnaughmap@var@mapsizey@);
      % when there are 2 sub maps
      \ifnum\@karnaughmap@var@mapsizez@=2
        \draw[color=black, ultra thin] (5,0) grid (9,4);
      \fi
      % when there are 4 sub maps
      \ifnum\@karnaughmap@var@mapsizez@=4
        \draw[color=black, ultra thin] (5,0) grid (9,4);
        \draw[color=black, ultra thin] (0,-5) grid (4,-1);
        \draw[color=black, ultra thin] (5,-5) grid (9,-1);
      \fi
      % labels
      % for all dimensions
      \node[above] at (\@karnaughmap@var@mapsizex@*0.5,\@karnaughmap@var@mapsizey@+0.9) {\small{#5}};
      \node[left] at (-0.9,\@karnaughmap@var@mapsizey@*0.5) {\small{#6}};
      % when there are 2 sub maps
      \ifnum\@karnaughmap@var@mapsizez@=2
        \node[above] at (7,4.9) {\small{#5}};
        % extra sub maps labels
        \node[below] at (2,-0.1) {\small{#7$=0$}};
        \node[below] at (7,-0.1) {\small{#7$=1$}};
      \fi
      % when there are 4 sub maps
      \ifnum\@karnaughmap@var@mapsizez@=4
        \node[above] at (7,4.9) {\small{#5}};
        \node[left] at (-0.9,-3) {\small{#6}};
        % extra sub maps labels
        \node[below] at (2,-0.1) {\small{#7$=00$}};
        \node[below] at (7,-0.1) {\small{#7$=01$}};
        \node[below] at (2,-5.1) {\small{#7$=10$}};
        \node[below] at (7,-5.1) {\small{#7$=11$}};
      \fi
      % data
      \matrix[
        matrix of nodes,
        ampersand replacement=\&,
        column sep={1cm,between origins},
        row sep={1cm,between origins},
      ] at (\@karnaughmap@var@mapsizex@*0.5+\@karnaughmap@local@maprealignmentx@,\@karnaughmap@var@mapsizey@*0.5+\@karnaughmap@local@maprealignmenty@) {
        \@karnaughmap@local@matrixtemplate@%
      };
}{
    \end{tikzpicture}
  \endgroup
}
%    \end{macrocode}
%
% \iffalse
%</karnaugh-map>
% \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}[2017/05/12]
%    \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}
%
%
% \changes{v0.47}{2018/01/26}{\pkg{keyfloat}: Fix for \SVG\ math in captions.}
%    \begin{macrocode}
\RenewDocumentCommand{\KFLT@onefigureimage}{}
{%
\LWR@traceinfo{KFLT@onefigureimage}%
% \begin{lrbox}{\KFLT@envbox}%
\ifthenelse{\NOT\equal{\KFLT@lw}{}}%
    {%
        \includegraphics%
        [scale=\KFLT@s,width=\KFLT@imagewidth]{\KFLT@i}%
    }%
    {% not linewidth
        \ifthenelse{\dimtest{\KFLT@w}{>}{0pt}}%
        {% width is given
            \ifthenelse{\dimtest{\KFLT@h}{>}{0pt}}%
            {% w and h
                \includegraphics%
                [scale=\KFLT@s,%
                width=\KFLT@imagewidth,height=\KFLT@h]{\KFLT@i}%
            }% w and h
            {% only w
                \includegraphics%
                [scale=\KFLT@s,width=\KFLT@imagewidth]{\KFLT@i}%
            }% only w
        }% width is given
        {% width is not given
            \ifthenelse{\dimtest{\KFLT@h}{>}{0pt}}%
            {%
                \includegraphics%
                [scale=\KFLT@s,height=\KFLT@h]{\KFLT@i}%
            }%
            {%
                \includegraphics%
                [scale=\KFLT@s]{\KFLT@i}%
            }%
        }% width is not given
    }% not linewidth
% \end{lrbox}%
% \unskip%
% \KFLT@findenvboxwidth%
% \begin{turn}{\KFLT@r}%
% \KFLT@frame{\usebox{\KFLT@envbox}}%
% \unskip%
% \end{turn}%
\LWR@traceinfo{KFLT@onefigureimage: done}%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\RenewDocumentEnvironment{KFLT@boxinner}{}
{%
\LWR@traceinfo{KFLT@boxinner}%
\LWR@stoppars%
}
{
\LWR@startpars%
\LWR@traceinfo{KFLT@boxinner: done}%
}
%    \end{macrocode}


% \changes{v0.42}{2017/10/26}{\pkg{keyfloat}: If \progcode{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}%
\begin{LWR@BlockClassWP}{%
    float:right; width:\LWR@printlength{\LWR@templengthone};  % extra space
    margin:10pt%
}%
{%
    width:\LWR@printlength{\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
%<*layaureo>
% \fi
%
% \part{lwarp-layaureo.sty}
%
% \section{layaureo}
%
% \DescribePackage{layaureo}
% \pkg{layaureo} is ignored.
%
% \changes{v0.60}{2018/09/18}{\pkg{layaureo}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{layaureo}[2004/09/16]
%    \end{macrocode}
%
% \iffalse
%</layaureo>
% \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}[2014/10/28]
%    \end{macrocode}

%    \begin{macrocode}
\NewDocumentCommand{\layout}{s}{}
%    \end{macrocode}

% \iffalse
%</layout>
% \fi
%
%
%
%
% \iffalse
%<*leading>
% \fi
%
% \part{lwarp-leading.sty}
%
% \section{leading}
%
% \DescribePackage{leading}
% \pkg{leading} is ignored.
%
% \changes{v0.60}{2018/09/18}{\pkg{leading}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{leading}[2008/12/11]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand\leading[1]{}
%    \end{macrocode}
%
% \iffalse
%</leading>
% \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}[2018/01/14]
%    \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}[2018-08-28]
%    \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} % extra space
}

\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
%<*lineno>
% \fi
%
% \part{lwarp-lineno.sty}
%
% \section{lineno}
%
% \credits{Stephan I. Böttcher}
%
% \DescribePackage{lineno}
% \pkg{lineno} is ignored.
%
% \changes{v0.49}{2018/02/19}{\pkg{lineno}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{lineno}[2005/11/02]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*\resetlinenumber[1][\@ne]{}

\def\linenumbers{% 
     \@ifnextchar[{\resetlinenumber}%]
                 {\@ifstar{\resetlinenumber}{}}%
     }

\newcommand*{\nolinenumbers}{}

\@namedef{linenumbers*}{\par\linenumbers*}
\@namedef{runninglinenumbers*}{\par\runninglinenumbers*}

\def\endlinenumbers{\par}
\let\endrunninglinenumbers\endlinenumbers
\let\endpagewiselinenumbers\endlinenumbers
\expandafter\let\csname endlinenumbers*\endcsname\endlinenumbers
\expandafter\let\csname endrunninglinenumbers*\endcsname\endlinenumbers
\let\endnolinenumbers\endlinenumbers

\def\pagewiselinenumbers{\linenumbers\setpagewiselinenumbers}

\def\runninglinenumbers{\setrunninglinenumbers\linenumbers}

\def\setpagewiselinenumbers{}

\def\setrunninglinenumbers{}

\def\linenomath{}%
\@namedef{linenomath*}{}%
\def\endlinenomath{}
\expandafter\let\csname endlinenomath*\endcsname\endlinenomath

\let\linelabel\label

\def\switchlinenumbers{\@ifstar{}{}}
\def\setmakelinenumbers#1{\@ifstar{}{}}

\def\leftlinenumbers{\@ifstar{}{}}
\def\rightlinenumbers{\@ifstar{}{}}

\newcounter{linenumber}
\newcount\c@pagewiselinenumber
\let\c@runninglinenumber\c@linenumber

\def\runningpagewiselinenumbers{}
\def\realpagewiselinenumbers{}


\NewDocumentCommand\modulolinenumbers{s o}{}

\chardef\c@linenumbermodulo=5
\modulolinenumbers[1]

\newcommand*\firstlinenumber[1]{}

\newcommand\internallinenumbers{}
\let\endinternallinenumbers\endlinenumbers
\@namedef{internallinenumbers*}{\internallinenumbers*}
\expandafter\let\csname endinternallinenumbers*\endcsname\endlinenumbers

\newcommand*{\linenoplaceholder}[1]{% redefine per language
    (line number reference for \detokenize\expandafter{#1})
}

\newcommand*{\lineref}[2][]{\linenoplaceholder{#2}}
\newcommand*{\linerefp}[2][]{\linenoplaceholder{#2}}
\newcommand*{\linerefr}[2][]{\linenoplaceholder{#2}}

\newcommand\quotelinenumbers
   {\@ifstar\linenumbers{\@ifnextchar[\linenumbers{\linenumbers*}}}

\newdimen\linenumbersep
\newdimen\linenumberwidth
\newdimen\quotelinenumbersep

\quotelinenumbersep=\linenumbersep
\let\quotelinenumberfont\linenumberfont

\def\linenumberfont{\normalfont\tiny\sffamily}


\linenumberwidth=10pt
\linenumbersep=10pt

\def\thelinenumber{}

\def\LineNumber{}
\def\makeLineNumber{}
\def\makeLineNumberLeft{}
\def\makeLineNumberRight{}
\def\makeLineNumberOdd{}
\def\makeLineNumberEven{}
\def\makeLineNumberRunning{}


\newenvironment{numquote}     {\quote}{\endquote}
\newenvironment{numquotation} {\quotation}{\endquotation}
\newenvironment{numquote*}    {\quote}{\endquote}
\newenvironment{numquotation*}{\quotation}{\endquotation}

\newdimen\bframerule
\bframerule=\fboxrule

\newdimen\bframesep
\bframesep=\fboxsep

\newenvironment{bframe}
{%
    \LWR@forceminwidth{\bframerule}%
    \BlockClass[
        border:\LWR@printlength{\LWR@atleastonept} solid black ; %
        padding:\LWR@printlength{\bframesep}%
    ]{bframe}
}
{\endBlockClass}
%    \end{macrocode}
%
% \iffalse
%</lineno>
% \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}[2001/08/31]

\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}[2015/06/04]
%    \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}}
%
% Force flexible columns.  Fixed columns inserts spaces in the \PDF\ output.
% \changes{v0.50}{2018/03/02}{\pkg{listings}: Force flexible columns.}
%    \begin{macrocode}
\lst@column@flexible
%    \end{macrocode}
%
%
% 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}{\lstset} \marg{options}
%
% Use the \pkg{listings} \optn{literate} option to replace
% \HTML\ entities:
% \changes{v0.60}{2018/09/12}{\pkg{listings}: Fix for \HTML\ entities.}
%    \begin{macrocode}
\def\lstset@#1{\endgroup%
%  \ifx\@empty#1%
%         \@empty%
%     \else%
        \setkeys{lst}{%
            #1%
            ,literate=%
            {<}{\HTMLentity{lt}}{4}%
            {>}{\HTMLentity{gt}}{4}%
            {\&}{\HTMLentity{amp}}{5}%
        }%
%     \fi%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\lst@Init} \marg{backslash-processing} \quad
% Done at the start of a listing.
%    \begin{macrocode}
\renewcommand{\lst@Init}[1]{%
%    \end{macrocode}
%
% Perform the \pkg{listings} initialization:
%
% \changes{v0.51}{2018/03/17}{\pkg{listings}: Forces cleared options.}
%    \begin{macrocode}
\LWR@traceinfo{lst@Init}%
\renewcommand*{\@captype}{lstlisting}%
\let\lst@aboveskip\z@\let\lst@belowskip\z@%
\gdef\lst@boxpos{t}%
\let\lst@frame\@empty
    \let\lst@frametshape\@empty
    \let\lst@framershape\@empty
    \let\lst@framebshape\@empty
    \let\lst@framelshape\@empty
\lstframe@\lst@frameround ffff\relax%
\lst@multicols\@empty%
\LWR@origlst@Init{#1}\relax%
%    \end{macrocode}
% Avoids extra horizontal space:
% \changes{v0.60}{2018/09/12}{\pkg{listings}: Fix if inside a list.}
%    \begin{macrocode}
\def\lst@framelr{}%
%    \end{macrocode}
%    \begin{macrocode}
\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{2}{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{0}%
\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 \LWR@isolate{\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
% \margintag{line numbers}
% place right line numbers in a field \cs{VerbatimHTMLWidth} wide.
%
% \changes{v0.60}{2018/09/12}{\pkg{listings}: Fix if inside a list.}
%
% ^^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{%
%    \end{macrocode}
% For now, \pkg{lwarp} places left line numbers inline.
% Ideally the entire line would be moved to the right, but
% conflicts with list indenting occurs.
%    \begin{macrocode}
%         \LWR@origllap{
            \LWR@orignormalfont%
            \lst@numberstyle{\thelstnumber}\kern\lst@numbersep%
%         }
    }\\%
     right&\def\lst@PlaceNumber{\LWR@origrlap{\LWR@orignormalfont
                \kern 6in \kern\lst@numbersep
                \lst@numberstyle{\thelstnumber}}}%
    }{\PackageError{Listings}{Numbers #1 unknown}\@ehc}}
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}

% \iffalse
%</listings>
% \fi
%
%
%
%
%
% \iffalse
%<*lltjext>
% \fi
%
% \part{lwarp-lltjext.sty}
%
% \section{lltjext}
%
% \credits{The Lua\TeX-ja project team}
%
% \DescribePackage{lltjext}
% \pkg{lltjext} is patched for use by \pkg{lwarp}.
%
% \changes{v0.65}{2018/12/21}{\pkg{lltjext}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{lltjext}[2018/10/07]
%    \end{macrocode}
%
%    \begin{macrocode}
\protected\def\yoko{%
  \directlua{luatexja.direction.set_list_direction(4, 'yoko')}%
}
\protected\def\tate{\yoko}
\protected\def\dtou{\yoko}
\protected\def\utod{\yoko}

\define@key[ltj]{japaram}{direction}{}

\yoko

\DeclareExpandableDocumentCommand{\rensuji}{s o m}{#3}

\DeclareDocumentCommand{\layoutfloat}{d() o m}{}

\DeclareDocumentCommand{\DeclareLayoutCaption}{m d<> d() o}{}

\LetLtxMacro\pcaption\caption

\DeclareDocumentCommand{\layoutcaption}{d<> d() o}{}

\let\captiondir\relax
\RenewDocumentEnvironment{LWR@HTML@minipage}{d<> O{t} O{} O{t} m}
    {\LWR@HTML@sub@minipage{#2}{#3}{#4}{#5}}
    {\endLWR@HTML@sub@minipage}

\RenewDocumentCommand{\LWR@HTML@parbox}{d<> O{t} O{} O{t} m +m}
{
\LWR@traceinfo{parbox of width #4}%
\begin{minipage}[#2][#3][#4]{#5}%
#6
\end{minipage}%
}

\RenewDocumentCommand{\pbox}{d<> O{0pt} O{c} m}{%
\global\booltrue{LWR@minipagefullwidth}%
\parbox{#2}{#4}%
}
%    \end{macrocode}
%
% \iffalse
%</lltjext>
% \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}[2014/10/28]
%    \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%
\tabular{#2}
}
{\endtabular\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%
\tabular{#2}
}
{\endtabular\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}
%
% \changes{v0.52}{2018/03/27}{Restore \cs{kill} in a \env{lateximage}.}
%    \begin{macrocode}
\LetLtxMacro\LWR@origkill\kill
\renewcommand*{\kill}{\LWR@tabularendofline}
\appto\LWR@restoreorigformatting{%
\LetLtxMacro\kill\LWR@origkill%
}
%    \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}[2000/10/22]
%    \end{macrocode}

%    \begin{macrocode}
\newenvironment*{landscape}{}{}
%    \end{macrocode}

% \iffalse
%</lscape>
% \fi
%
%
%
%
%
%
% \iffalse
%<*ltablex>
% \fi

% \part{lwarp-ltablex.sty}

% \section{ltablex}
%
% \credits{Anil K. Goel}
%
% \DescribePackage{ltablex}
% \pkg{ltablex} is emulated by \pkg{lwarp}.
%
% \changes{v0.57}{2018/05/25}{\pkg{ltablex}: Added.}
%
% \codehtml
%
% Relies on \pkg{tabularx}.
%
%    \begin{macrocode}
\RequirePackage{tabularx}

\LWR@ProvidesPackageDrop{ltablex}[2014/08/13]

\DeclareDocumentEnvironment{tabularx}{m o m}
{\longtable{#3}}
{\endlongtable}

\DeclareDocumentEnvironment{tabularx*}{m o m}
{\longtable{#3}}
{\endlongtable}

\newcommand*{\keepXColumns}{}
\newcommand*{\convertXColumns}{}
%    \end{macrocode}
%
%
% \iffalse
%</ltablex>
% \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}[2018/08/26]
%    \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
%<*ltxgrid>
% \fi
%
% \part{lwarp-ltxgrid.sty}
%
% \section{ltxgrid}
%
% \DescribePackage{ltxgrid}
% \pkg{ltxgrid} is ignored.
%
% \changes{v0.51}{2018/03/08}{\pkg{ltxgrid}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{ltxgrid}[2010/07/25]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\onecolumngrid}{}
\newcommand*{\twocolumngrid}{}
\newcommand*{\removestuff}{}
\newcommand*{\addstuff}[2]{}
\newcommand*{\replacestuff}[2]{}
%    \end{macrocode}
%
% \iffalse
%</ltxgrid>
% \fi
%
%
%
%
% \iffalse
%<*ltxtable>
% \fi
%
% \part{lwarp-ltxtable.sty}
%
% \section{ltxtable}
%
% \DescribePackage{ltxtable}
% \pkg{ltxtable} is emulated.
%
% The print version does not seem to honor \env{longtable*} from the
% \trouble[table numbering]{ltxtable=\pkg{ltxtable}>numbering}
% \trouble{table>numbering}
% \pkg{caption} package, while \pkg{lwarp} does.
%
% \changes{v0.44}{2017/11/15}{\pkg{ltxtable}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{ltxtable}[1995/12/11]
%    \end{macrocode}
%
% \begin{noindmacro}{\LTXtable} \marg{width} \marg{file}
%    \begin{macrocode}
\newcommand*{\LTXtable}[2]{%
\input{#2}%
}
%    \end{macrocode}
% \end{noindmacro}
%
% \iffalse
%</ltxtable>
% \fi
%
%
%
%
% \iffalse
%<*lua-check-hyphen>
% \fi
%
% \part{lwarp-lua-check-hyphen.sty}
%
% \section{lua-check-hyphen}
%
% \DescribePackage{lua-check-hyphen}
% \pkg{lua-check-hyphen} is ignored.
%
% \changes{v0.56}{2018/04/26}{\pkg{lua-check-hyphen}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{lua-check-hyphen}[2018/04/19]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\LuaCheckHyphen}[1]{}
%    \end{macrocode}
%
% \iffalse
%</lua-check-hyphen>
% \fi
%
%
%
%
% \iffalse
%<*lua-visual-debug>
% \fi
%
% \part{lwarp-lua-visual-debug.sty}
%
% \section{lua-visual-debug}
%
% \DescribePackage{lua-visual-debug}
% \pkg{lua-visual-debug} is ignored.
%
% \changes{v0.61}{2018/10/05}{\pkg{lua-visual-debug}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{lua-visual-debug}[2016/05/30]
%    \end{macrocode}
%
% \iffalse
%</lua-visual-debug>
% \fi
%
%
%
%
%
% \iffalse
%<*luacolor>
% \fi
%
% \part{lwarp-luacolor.sty}
%
% \section{luacolor}
%
% \DescribePackage{luacolor}
% \pkg{luacolor} is ignored.
%
% \changes{v0.49}{2018/02/15}{\pkg{luacolor}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{luacolor}[2016/05/16]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\luacolorProcessBox}[1]{}
%    \end{macrocode}
%
% \iffalse
%</luacolor>
% \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}[2017/09/30]
%    \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}}
%    \end{macrocode}
%
% \changes{v0.48}{2018/02/12}{\pkg{luatodonotes}: Improved \cs{todototoc}.}
%    \begin{macrocode}
\let\LWRTODONOTES@orig@todototoc\todototoc

\renewcommand*{\todototoc}{%
\phantomsection%
\LWRTODONOTES@orig@todototoc%
}


\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:\LWR@origpound{}B3FFB3]{highlight}{#1}%
}

\fi% \if@todonotes@disabled
%    \end{macrocode}
%
% \iffalse
%</luatodonotes>
% \fi
%
%
%
%
%
% \iffalse
%<*magaz>
% \fi
%
% \part{lwarp-magaz.sty}
%
% \section{magaz}
%
% \DescribePackage{magaz}
% \pkg{magaz} is emulated.
%
% \changes{v0.54}{2018/04/1}{\pkg{magaz}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{magaz}[2011/11/24]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand\FirstLine[1]{%
    \begingroup%
    \FirstLineFont{%
        \LWR@textcurrentcolor{%
            \LWR@textcurrentfont{%
                #1%
            }%
        }%
    }%
    \endgroup%
}

\providecommand\FirstLineFont{\scshape}
%    \end{macrocode}
%
% \iffalse
%</magaz>
% \fi
%
%
%
%
% \iffalse
%<*makeidx>
% \fi
%
% \part{lwarp-makeidx.sty}
%
% \section{makeidx}
%
% \credits{\LaTeX\ Project Team}
%
% \DescribePackage{makeidx}
% \pkg{makeidx} is patched for use by \pkg{lwarp}.
%
% \changes{v0.58}{2018/06/30}{\pkg{makeidx}: Added.  Moved from \pkg{lwarp} core.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{makeidx}[2014/09/29]
%    \end{macrocode}
%
% \cs{@wrindex} is redefined \cs{AtBeginDocument} by the \pkg{lwarp} core.
%
% \begin{macro}{\printindex}
%
% \changes{v0.58}{2018/06/13}{Fix: Extra \cs{newpage} to flush pending \cs{index} writes.}
%    \begin{macrocode}
\preto\printindex{%
    \LWR@orignewpage%
    \LWR@startpars%
}
%    \end{macrocode}
% \end{macro}
%
% \iffalse
%</makeidx>
% \fi
%
%
%
%
%
%
% \iffalse
%<*marginal>
% \fi
%
% \part{lwarp-marginal.sty}
%
% \section{marginal}
%
% \DescribePackage{marginal}
% \pkg{marginal} is emulated.
%
% \changes{v0.64}{2018/127/07}{\pkg{marginal}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{marginal}
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\showlostmarginals}{}
\newcommand*{\enlargefreelist}{}
\newcommand*{\onesidemarginals}{}
%    \end{macrocode}
%
% \iffalse
%</marginal>
% \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}[2018/06/08]
%    \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}[2013/09/08]
%    \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.}
% \changes{v0.57}{2018/06/05}{\pkg{marginnote}: Fix: Long optional argument.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-marginnote}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{marginnote}[2018/08/09]
%    \end{macrocode}
%
% \changes{v0.57}{2018/06/05}{\pkg{marginnote}: Fix: Long optional argument.}
%    \begin{macrocode}
\NewDocumentCommand{\marginnote}{+o +m o}{\marginpar{#2}}
%    \end{macrocode}
%    \begin{macrocode}
\newcommand*{\marginnoteleftadjust}{}
\newcommand*{\marginnoterightadjust}{}
\newcommand*{\marginnotetextwidth}{}
\let\marginnotetextwidth\textwidth
\newcommand*{\marginnotevadjust}{}
\newcommand*{\marginfont}{}
\newcommand*{\raggedleftmarginnote}{}
\newcommand*{\raggedrightmarginnote}{}
%    \end{macrocode}
%
% \iffalse
%</marginnote>
% \fi
%
%
%
%
% \iffalse
%<*marvosym>
% \fi
%
% \part{lwarp-marvosym.sty}
%
% \section{marvosym}
%
% \credits{Thomas Henlich, Mojca Miklavec}
%
% \DescribePackage{marvosym}
% \pkg{marvosym} is patched for use by \pkg{lwarp}.
%
% Hashed inline images are used, as there may not be Unicode support for all icons.
%
% \changes{v0.67}{2019/02/23}{\pkg{marvosym}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{marvosym}[2011/07/20]
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand{\mvchr}[1]{%
    \begin{lateximage}*[(symbol #1)][marvosym #1]%
    \mvs\char#1%
    \end{lateximage}%
}

\renewcommand{\textmvs}[1]{%
    \begin{lateximage}%
    \mvs #1%
    \end{lateximage}%
}
%    \end{macrocode}
%
% \iffalse
%</marvosym>
% \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}[2009/03/13]
%    \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{Limitations}
%
% \limitsmdframed
%
% Pre-existing hooks are used to patch extra functions before and after the frames.
%
%
% \subsection{Package loading}
%
% \codehtml
%    \begin{macrocode}
\RequirePackage{xcolor}% for \convertcolorspec

\LWR@ProvidesPackageDrop{mdframed}[2013/07/01]
%    \end{macrocode}
%
%
% Do not require \tikz{} or pstricks:
%    \begin{macrocode}
\LWR@origRequirePackage[framemethod=none]{mdframed}
%    \end{macrocode}
%
%
% \subsection{Patches}
%
% Patch to remove \PDF\ formatting and add \HTML\ tags:
%    \begin{macrocode}
\AtBeginDocument{
\def\mdf@trivlist#1{%
  \edef\mdf@temp{%
%     \topsep=\the\topsep\relax%
%     \partopsep=\the\partopsep\relax%
%     \parsep=\the\parsep\relax%
  }%
%   \setlength{\topsep}{#1}%
%   \topskip\z@%
%   \partopsep\z@%
%   \parsep\z@%
%   \@nmbrlistfalse%
%   \@trivlist%
%   \labelwidth\z@%
%   \leftmargin\z@%
%   \itemindent\z@%
  \let\@itemlabel\@empty%
  \def\makelabel##1{##1}%
%   \item\relax\mdf@temp\relax%
}

\renewcommand*{\endmdf@trivlist}{%
\LWR@traceinfo{endmdf@trivlist}%
% \endtrivlist%
\LWR@listend%
}
}% AtBeginDocument
%    \end{macrocode}
%
%
% \subsection{Initial setup}
%
% ^^A \DescribeMacro{\mdfsetup}
% To handle \CSS\ and paragraphs,
% patch code at start and end of environment and contents.
% \cs{LWR@print@raggedright} helps avoid hyphenation.
%
% \changes{v0.25}{2017/03/16}{\pkg{mdframed}: Help avoid hyphenation.}
%
%    \begin{macrocode}
\mdfsetup{
startcode={\LWR@mdframedstart\LWR@print@raggedright},
endcode={\LWR@mdframedend},
startinnercode={\LWR@startpars\LWR@print@raggedright},
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}{\@nameuse{mdf@#1}}{HTML}\LWR@tempcolor%
\LWR@origpound\LWR@tempcolor
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\LWR@mdfprintlength} \marg{mdflengthkey}
%
% Given the \pkg{mdframed} key, print the length.
%
% \changes{v0.63}{2018/12/02}{\pkg{mdframed}: Avoid thin rules.}
%    \begin{macrocode}
\newcommand*{\LWR@mdfprintlength}[1]{%
\LWR@forceminwidth{\@nameuse{mdf@#1@length}}%
\LWR@printlength{\LWR@atleastonept}%
}
%    \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}{%
\LWR@traceinfo{LWR@mdframedstart start}%
%    \end{macrocode}
% Turn off paragraph handling during the generation of
% the encapsulating tags:
%    \begin{macrocode}
\LWR@stoppars%
%    \end{macrocode}
% Open a \element{div} and with custom \attribute{class} and custom \attribute{style}.
% A \env{BlockClass} environment is not used because this \element{div} is
% created by the \pkg{mdframed} \optn{startcode} and \optn{endcode} settings,
% which do not properly nest the \element{div} inside the \env{mdframed} environment.
%    \begin{macrocode}
\LWR@htmltagc{div class="%
mdframed%
\ifdefstring{\LWR@mdthisenv}{mdframed}{}{ \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}
\LWR@select@print@hspace%
\renewcommand*{\rule}{\LWR@print@rule}
\LetLtxMacro\makebox\LWR@print@makebox%
%    \end{macrocode}
%    \begin{macrocode}
\LWR@startpars%
\LWR@traceinfo{LWR@mdframedstart done}%
}
%    \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}{
\LWR@traceinfo{LWR@mdframedend start}%
%    \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%
\LWR@traceinfo{LWR@mdframedend done}%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \subsection{Mdframed environment}
%
% \changes{v0.46}{2018/01/21}{\pkg{mdframed}: Fixes for \SVG\ math or \env{lateximage} in title.}
%    \begin{macrocode}
\renewenvironment{mdframed}[1][]{%
 \color@begingroup%
   \mdfsetup{userdefinedwidth=\linewidth,#1}%
   \mdf@startcode%
   \mdf@preenvsetting%
   \ifdefempty{\mdf@firstframetitle}{}%
           {\let\mdf@frametitlesave\mdf@frametitle%
            \let\mdf@frametitle\mdf@firstframetitle%
           }%
   \ifvmode\nointerlineskip\fi%
        \ifdefempty{\mdf@frametitle}{}%
            {\mdfframedtitleenv{\mdf@frametitle}%
%             \mdf@@frametitle@use%
            }%
   \mdf@trivlist{\mdf@skipabove@length}%%
   \mdf@settings%
%    \mdf@lrbox{\mdf@splitbox@one}%
%    \mdf@startinnercode%
  }%
  {%
%    \mdf@@ignorelastdescenders%
   \par%
%     \unskip\ifvmode\nointerlineskip\hrule \@height\z@ \@width\hsize\fi%%
   \ifmdf@footnoteinside%
      \def\mdf@reserveda{%
        \mdf@footnoteoutput%
%         \mdf@endinnercode%
%         \endmdf@lrbox%
%         \ifdefempty{\mdf@frametitle}{}%
%             {\mdfframedtitleenv{\mdf@frametitle}\mdf@@frametitle@use}%
%         \detected@mdf@put@frame
      }%
   \else%
      \def\mdf@reserveda{%
%         \mdf@endinnercode%
%         \endmdf@lrbox%
%         \ifdefempty{\mdf@frametitle}{}%
%             {\mdfframedtitleenv{\mdf@frametitle}\mdf@@frametitle@use}%
%         \detected@mdf@put@frame%
        \mdf@footnoteoutput%
        }%
   \fi%
   \mdf@reserveda%
  \aftergroup\endmdf@trivlist%
 \color@endgroup%
 \mdf@endcode%
}
%    \end{macrocode}
%
% \changes{v0.46}{2018/01/21}{\pkg{mdframed}: Fixes for footnotes.}
% \begin{noindmacro}{\mdf@footnoteoutput}
%    \begin{macrocode}
\renewrobustcmd*\mdf@footnoteoutput{%
    \LWR@printpendingmpfootnotes%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \subsection{Titles and subtitles}
%
% \begin{noindmacro}{\mdfframedtitleenv} \marg{title}
%
% Place the title inside a \element{div} of class \attribute{mdframedtitle}:
%    \begin{macrocode}
\newlength{\LWR@titleroundcorner}

\renewrobustcmd\mdfframedtitleenv[1]{%
\LWR@traceinfo{LWR@mdframedtitleenv start}%
%    \end{macrocode}
% Open a \element{div} with a custom |class| and custom |style|:
% \changes{v0.63}{2018/12/01}{Improved titles.}
%    \begin{macrocode}
\begin{BlockClass}[%
%    \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}
% ^^A The title's top border radius is adjusted for the line width:
% ^^A    \begin{macrocode}
% ^^A border-radius:
% ^^A \setlength{\LWR@titleroundcorner}
% ^^A     {\maxof{\mdf@roundcorner@length-\mdf@linewidth@length}{0pt}}
% ^^A     \LWR@printlength{\LWR@titleroundcorner}
% ^^A     \LWR@printlength{\LWR@titleroundcorner}
% ^^A     0pt 0pt
% ^^A     \LWR@orignewline
% ^^A    \end{macrocode}
% Finish the custom style and the opening \element{div} tag:
%    \begin{macrocode}
]{mdframedtitle}%
%    \end{macrocode}
% Print the title inside the \element{div}:
% \changes{v0.63}{2018/12/02}{\pkg{mdframed}: Improved font control.}
%    \begin{macrocode}
\mdf@frametitlefont{\LWR@textcurrentfont{#1}}%
%    \end{macrocode}
% Close the \element{div}:
%    \begin{macrocode}
\end{BlockClass}%
\LWR@traceinfo{LWR@mdframedtitleenv end}%
}
%    \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{div} of class |mdframedsubtitle|:
%    \begin{macrocode}
\NewDocumentCommand{\LWR@mdfsubtitlecommon}{m o m}
{% the following empty line is required

\LWR@traceinfo{LWR@mdframedsubtitlecommon start}%
%    \end{macrocode}
% Open a \element{div} with a custom \attribute{class} and custom \attribute{style}:
% \changes{v0.63}{2018/12/01}{Improved titles.}
%    \begin{macrocode}
\begin{BlockClass}[%
%    \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 \element{div} tag:
%    \begin{macrocode}
]{mdframed#1title}%
%    \end{macrocode}
% Perform the original subtitle action:
% \changes{v0.63}{2018/12/02}{\pkg{mdframed}: Improved font control.}
%    \begin{macrocode}
\IfNoValueTF{#2}
{\@nameuse{LWR@origmdf#1title}{\csuse{mdf@#1titlefont}{\LWR@textcurrentfont{#3}}}}%
{\@nameuse{LWR@origmdf#1title}[#2]{\csuse{mdf@#1titlefont}{\LWR@textcurrentfont{#3}}}}%
%    \end{macrocode}
% Close the \element{div}:
%    \begin{macrocode}
\end{BlockClass}%
\LWR@traceinfo{LWR@mdframedsubtitlecommon end}%
}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\LWR@mdfsubtitle} \oarg{options} \marg{title}
%    \begin{macrocode}
\newcommand*{\LWR@mdfsubtitle}{%
\LWR@mdfsubtitlecommon{sub}%
}
\let\mdfsubtitle\LWR@mdfsubtitle
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\LWR@mdfsubsubtitle} \oarg{options} \marg{title}
%    \begin{macrocode}
\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} \marg{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.}
% \changes{v0.63}{2018/12/02}{\pkg{mdframed}: Improved font control.}
%
%    \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%
                             \LWR@textcurrentfont{##1}}% lwarp
             \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%
                             \LWR@textcurrentfont{##1}}% lwarp
             \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%
                             \LWR@textcurrentfont{##1}}% lwarp
             \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%
                             \LWR@textcurrentfont{##1}}% lwarp
             \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}}% lwarp
    \BeforeBeginEnvironment{#2*}{\renewcommand*{\LWR@mdthisenv}{md#2}}% lwarp
   }%
 }
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\newmdtheoremenv} \oarg{1: mdframed-options} \marg{2: envname}
%        \oarg{3: numberedlike} \marg{4: caption} \oarg{5: 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
%<*memhfixc>
% \fi
%
% \part{lwarp-memhfixc.sty}
%
% \section{memhfixc}
%
% \DescribePackage{memhfixc}
% \pkg{memhfixc} is ignored.
%
% \changes{v0.45}{2018/01/03}{\pkg{memhfixc}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{memhfixc}[2013/05/30]
%    \end{macrocode}
%
% \iffalse
%</memhfixc>
% \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}[2010/05/29]
%    \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
%<*mhchem>
% \fi
%
% \part{lwarp-mhchem.sty}

% \section{mhchem}
% \label{sec:mhchem}
%
% \credits{Martin Hensel}
%
% \DescribePackage{mhchem}
% \pkg{mhchem} is patched for use by \pkg{lwarp}.
%
% \pkg{mhchem} expressions are converted to \SVG\ math.
% Inline expressions use hashed filenames to allow reuse,
% and assume that any \pkg{mhchem} options are global.
%
% The \brand{MathJax} \pkg{mhchem} extension is not yet used.
% \trouble[\brand{MathJax} and \pkg{mhchem}]{MathJax=\brand{MathJax}>mhchem=\pkg{mhchem}}
% \trouble{mhchem=\pkg{mhchem}>MathJax=\brand{MathJax}}
% If \brand{MathJax} is used for math in the rest of the document,
% \pkg{lwarp} converts standalone \pkg{mhchem}
% expressions into \SVG\ math images, but expressions inside math
% must be placed between \cs{displaymathother} and \cs{displaymathnormal}:
% \begin{sourcedisplay}
% \cs{displaymathother} \\
% \cs{[} \cs{ce}\{ \dots\ \} \cs{]}  \qquad \dots \qquad \$ \cs{ce} \{ \dots\ \} \$ \\
% \cs{displaymathnormal}
% \end{sourcedisplay}
%
% When producing \HTML\ output, \pkg{lwarp} does not support
% \trouble[nested math]{mhchem=\pkg{mhchem}>nested dollar signs}
% the use of nested dollar signs in \pkg{mhchem} expressions.
% \gindex{array>mhchem=\pkg{mhchem}}
% \gindex{math>mhchem=\pkg{mhchem}}
%
% For some examples from the \pkg{mhchem} manual, change as follows:
% \begin{Verbatim}[gobble=2,frame=leftline, xleftmargin=.5in,obeytabs,tabsize=4]
% $\ce{NaOH(aq,$\infty$)}$            % old
% $\ce{NaOH(aq,\infty)}$              % new
%
% $\ce{Fe(CN)_{$\frac{6}{2}}$}$       % old
% $\ce{Fe(CN)_{\frac{6}{2}}}$         % new
%
% $\ce{NO_$x$}$                       % old
% $\ce{NO_x}$                         % new
% 
% $\ce{NO_${x}$}$                     % old
% $\ce{NO_{x}}$                       % new
% 
% $\ce{$cis${-}[PtCl2(NH3)2]}$        % old
% $\ce{\mathit{cis}{-}[PtCl2(NH3)2]}$ % new
% \end{Verbatim}
%
% \changes{v0.51}{2018/03/04}{\pkg{mhchem}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{mhchem}[2018/06/22]
%    \end{macrocode}

% The original definition of \cs{ce}:
%    \begin{macrocode}
\LetLtxMacro\LWR@mhchem@origce\ce
%    \end{macrocode}

% The new definition, called from the new \cs{ce} after math shift is set.
% The starred \env{lateximage} uses a hashed filename for the \SVG\ image.
% The \attribute{alt} tag is set to the \pkg{mhchem} expression.
%    \begin{macrocode}
\newcommand{\LWR@mhchem@HTML@ce}[1]{%
\begin{lateximage}*[\textbackslash{}ce\{\LWR@HTMLsanitize{#1}\}]%
\LWR@mhchem@origce{#1}%
\end{lateximage}%
\endgroup%
\addtocounter{LWR@mhchem@cedepth}{-1}%
}
%    \end{macrocode}

% Only set math shift if outer depth:
%    \begin{macrocode}
\newcounter{LWR@mhchem@cedepth}
\setcounter{LWR@mhchem@cedepth}{0}
%    \end{macrocode}

% The new \cs{ce}.  Sets math shift then continues.
%    \begin{macrocode}
\renewcommand{\ce}{%
\begingroup%
\ifnumequal{\value{LWR@mhchem@cedepth}}{0}{%
    \catcode`\$=3% math shift
}{}%
\addtocounter{LWR@mhchem@cedepth}{1}%
\LWR@mhchem@HTML@ce%
}
%    \end{macrocode}

% The original definition of \cs{cesplit}:
%    \begin{macrocode}
\LetLtxMacro\LWR@mhchem@origcesplit\cesplit
%    \end{macrocode}

% The new definition, called from the new \cs{cesplit} after math shift is set.
% The starred \env{lateximage} uses a hashed filename for the \SVG\ image.
% The \attribute{alt} tag is set to the \pkg{mhchem} expression.
%    \begin{macrocode}
\newcommand*{\LWR@mhchem@HTML@cesplit}[2]
{%
\begin{lateximage}*[\textbackslash{}cesplit\{\LWR@HTMLsanitize{#2}\}]%
\LWR@mhchem@origcesplit{#1}{#2}%
\end{lateximage}%
\endgroup%
}
%    \end{macrocode}

% Only set math shift if outer depth:
%    \begin{macrocode}
\newcounter{LWR@mhchem@cesplitdepth}
\setcounter{LWR@mhchem@cesplitdepth}{0}
%    \end{macrocode}

% The new \cs{cesplit}.  Sets math shift then continues.
%    \begin{macrocode}
\renewcommand{\cesplit}{%
\begingroup%
\ifnumequal{\value{LWR@mhchem@cesplitdepth}}{0}{%
    \catcode`\$=3% math shift
}{}%
\addtocounter{LWR@mhchem@cesplitdepth}{1}%
\LWR@mhchem@HTML@cesplit%
}
%    \end{macrocode}

% Resore originals inside a \env{lateximage}:
%    \begin{macrocode}
\appto\LWR@restoreorigformatting{%
\LetLtxMacro\ce\LWR@mhchem@origce%
\LetLtxMacro\cesplit\LWR@mhchem@origcesplit%
}
%    \end{macrocode}

% \iffalse
%</mhchem>
% \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}[2018/01/14]
%    \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}[2012/05/29]
%    \end{macrocode}
%
%    \begin{macrocode}
\newenvironment{strip}[1][]{}{}
\newskip\stripsep
%    \end{macrocode}
%
% \iffalse
%</midfloat>
% \fi
%
%
%
%
% \iffalse
%<*midpage>
% \fi
%
% \part{lwarp-midpage.sty}
%
% \section{midpage}
%
% \DescribePackage{midpage}
% \pkg{midpage} is ignored.
%
% \changes{v0.39}{2017/08/27}{\pkg{midpage}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{midpage}[2009/09/03]
%    \end{macrocode}
%
% \changes{v0.47}{2018/01/26}{\pkg{midpage}: Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\newenvironment{midpage}
{\begin{BlockClass}[%
    \LWR@print@mbox{margin-top:6ex} ; \LWR@print@mbox{margin-bottom:6ex}%
]{midpage}}
{\end{BlockClass}}
%    \end{macrocode}
%
% \iffalse
%</midpage>
% \fi
%
%
%
%
% \iffalse
%<*morefloats>
% \fi
%
% \part{lwarp-morefloats.sty}
%
% \section{morefloats}
%
% \DescribePackage{morefloats}
% \pkg{morefloats} is ignored.
%
% \changes{v0.50}{2018/02/22}{\pkg{morefloats}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{morefloats}[2015/07/22]
%    \end{macrocode}
%
% \iffalse
%</morefloats>
% \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}[2008/06/03]
%    \end{macrocode}
%
%    \begin{macrocode}
\BeforeBeginEnvironment{verbatimtab}{%
\LWR@forcenewpage
\LWR@atbeginverbatim{3}{Verbatim}%
}
\AfterEndEnvironment{verbatimtab}{%
\LWR@afterendverbatim{1}%
}


\LetLtxMacro\LWRMV@orig@verbatimtabinput\@verbatimtabinput

\renewcommand{\@verbatimtabinput}[2][]{%
\LWR@forcenewpage
\LWR@atbeginverbatim{3}{Verbatim}%
\LWRMV@orig@verbatimtabinput[#1]{#2}%
\LWR@afterendverbatim{1}%
}

\BeforeBeginEnvironment{listing}{%
\LWR@forcenewpage
\LWR@atbeginverbatim{3}{programlisting}%
}

\AfterEndEnvironment{listing}{%
\LWR@afterendverbatim{1}%
}

\BeforeBeginEnvironment{listingcont}{%
\LWR@forcenewpage
\LWR@atbeginverbatim{3}{programlisting}%
}

\AfterEndEnvironment{listingcont}{%
\LWR@afterendverbatim{1}%
}
%    \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{3}{programlisting}%
\LWRMV@@listinginput[#1]{#2}{#3}%
\LWR@afterendverbatim{1}%
}


\renewenvironment*{boxedverbatim}
{
\LWR@forcenewpage
\LWR@atbeginverbatim{3}{boxedverbatim}%
\verbatim%
}
{
\endverbatim%
\LWR@afterendverbatim{1}%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
% \iffalse
%</moreverb>
% \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}[2005/04/17]
%    \end{macrocode}
%
% \iffalse
%</mparhack>
% \fi
%
%
%
%
% \iffalse
%<*multicap>
% \fi
%
% \part{lwarp-multicap.sty}
%
% \section{multicap}
%
% \DescribePackage{multicap}
% \pkg{multicap} is emualted.
%
% \changes{v0.67}{2019/02/18}{\pkg{multicap}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{multicap}[2002/05/04]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\mfcaption}{\captionof{figure}}
\newcommand*{\mtcaption}{\captionof{table}}
\newcounter{mcapsize}
\newcounter{mcapskip}
\newlength{\abvmcapskip}
\newlength{\blwmcapskip}
%    \end{macrocode}
%
% \iffalse
%</multicap>
% \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}[2018/12/27]
%    \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}
% Change \cs{linewidth} to compensate for expected size:
%    \begin{macrocode}
    \setlength{\linewidth}{\linewidth/#2}
%    \end{macrocode}
% Locally force any minipages to be fullwidth:
% \changes{v0.66}{2018/12/31}{Fix: Minipages inside \env{multicols}.}
%    \begin{macrocode}
    \booltrue{LWR@forceminipagefullwidth}
}
%    \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}
%
% \changes{v0.65}{2018/12/15}{\pkg{multicol}: Added \cs{docolaction}.}
%    \begin{macrocode}
\NewDocumentCommand{\docolaction}{s o m m m}{%
    \IfValueTF{#2}{#2}{#3}%
}
%    \end{macrocode}

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

% \iffalse
%</multicol>
% \fi
%
%
%
%
%
% \iffalse
%<*multicolrule>
% \fi
%
% \part{lwarp-multicolrule.sty}
%
% \section{multicolrule}
%
% \DescribePackage{multicolrule}
% \pkg{multicolrule} is ignored.
%
% \changes{v0.65}{2018/12/21}{\pkg{multicolrule}: Added.}
% \changes{v0.66}{2019/01/04}{\pkg{multicolrule}: Updated for v1.2.}
%
% \codehtml
%
%    \begin{macrocode}
\RequirePackage{multicol}

\LWR@ProvidesPackageDrop{multicolrule}[2019/01/01]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\SetMCRule}[1]{}
\NewDocumentCommand{\DeclareMCRulePattern}{m m}{}
%    \end{macrocode}
%
% \iffalse
%</multicolrule>
% \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
%
% Remove the placeholder macro which was used if \pkg{multirow} was not loaded:
%    \begin{macrocode}
\LetLtxMacro\multirow\relax
%    \end{macrocode}
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{multirow}[2018/08/03]
%    \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}{\pkg{multirow}: Added optional args.}
% \changes{v0.39}{2017/08/30}{\pkg{multirow}: Add: New optional \optn{vpos} argument.}
% \changes{v0.39}{2017/08/30}{\pkg{multirow}: Add: Supports left/right border for \pkg{bigdelim}.}
% \changes{v0.39}{2017/08/30}{\pkg{multirow}: Fix: Long text argument.}
% \changes{v0.40}{2017/09/22}{\pkg{multirow}: Improved \pkg{bigdelim} borders.}
% \changes{v0.41}{2017/09/28}{\pkg{multirow}: Add: \cs{cmidrule} trims.}
% \changes{v0.47}{2018/01/26}{\pkg{multirow}: Fix: Line wrap at \HTML\ hyphen.}
% \changes{v0.57}{2018/05/28}{\pkg{multirow}: Improved print/\HTML\ output selection.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@multirow}{O{c} m o m o +m}%
{%
\LWR@traceinfo{*** LWR@HTML@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="\LWR@print@mbox{vertical-align:bottom}" }{}%
\ifstrequal{#1}{t}{style="\LWR@print@mbox{vertical-align:top}" }{}%
}%
%    \end{macrocode}
% The left/right border, if given:
%    \begin{macrocode}
\ifdefvoid{\LWR@multirowborder}{}{%
style="\LWR@print@mbox{border-\LWR@multirowborder:} 2px dotted black ; %
\LWR@print@mbox{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:
% \changes{v0.60}{2018/09/17}{\env{tabular}: Improved memory management: Not using \pkg{xstring}.}
%    \begin{macrocode}
\LWR@getexparray{LWR@tablecolspec}{\arabic{LWR@tableLaTeXcolindex}}%
%    \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@tableLaTeXcolindex}}%
"%
%    \end{macrocode}
% \changes{v0.42}{2017/10/26}{\pkg{multirow}: If \progcode{FormatWP} add cell alignment.}
%    \begin{macrocode}
\LWR@tdstartstyles%
\LWR@addcmidrulewidth%
\LWR@addcdashline%
\LWR@addtabularrulecolors%
\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@tableLaTeXcolindex}}%
%    \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{*** LWR@HTML@multirow done}%
}%

\LWR@formatted{multirow}
%    \end{macrocode}
%
%
% \subsection{Combined multicolumn and multirow}
% \label{sec:multicolumnmultirow}
%
% \limitsmulticolumnrow
% \gindex{multicolumn=\cs{multicolumn}>with \cs{multirow}}
% \gindex{multirow=\cs{multirow}>with \cs{multicolumn}}
% \gindex{tabular>multicolumn=\cs{multicolumn} with \cs{multirow}}
% \trouble{tabular>multicolumn=\cs{multicolumn} with \cs{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.}
% \changes{v0.57}{2018/05/28}{\pkg{multirow}: Improved print/\HTML\ output selection.}
%
% |\@ifpackageloaded{multirow}| determines if v2.0 or later of
% \pkg{multirow} was used, which included the \cs{ProvidesPackage} macro.
%
%
% The \HTML\ version follows.
%
% \cs{AtBeginDocument} because the print version had to see if \pkg{multirow}
% was loaded before determining how to define \cs{LWR@print@multicolumnrow}.
%    \begin{macrocode}
\AtBeginDocument{

\NewExpandableDocumentCommand{\LWR@HTML@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@tableLaTeXcolindex}}{#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@tableLaTeXcolindex}{#1}%
\addtocounter{LWR@tableLaTeXcolindex}{-1}%
%    \end{macrocode}
% Skip any trailing |@| or |!| columns for this cell:
%    \begin{macrocode}
\global\booltrue{LWR@skipatbang}%
}

\LWR@expandableformatted{multicolumnrow}

}% \AtBeginDocument
%    \end{macrocode}
% \end{macro}
%
%
% \iffalse
%</multirow>
% \fi
%
%
%
%
% \iffalse
%<*multitoc>
% \fi
%
% \part{lwarp-multitoc.sty}
%
% \section{multitoc}
%
% \DescribePackage{multitoc}
% \pkg{multitoc} is ignored.
%
% \changes{v0.47}{2018/01/25}{\pkg{multitoc}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{multitoc}[1999/06/08]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\multicolumntoc}{2}
\newcommand{\multicolumnlot}{2}
\newcommand{\multicolumnlof}{2}
\newcommand*{\immediateaddtocontents}[2]{}
%    \end{macrocode}
%
% \iffalse
%</multitoc>
% \fi
%
%
%
%
% \iffalse
%<*musicography>
% \fi
%
% \part{lwarp-musicography.sty}
%
% \section{musicography}
%
% \credits{Andrew A. Cashner}
%
% \DescribePackage{musicography}
% \pkg{musicography} is patched for use by \pkg{lwarp}.
%
% Images are used for the meter symbols, since the
% \HTML\ fonts tend not to be the correct size.
% The \HTML\ \attribute{alt} tag copies |C| and |3/2|, etc.
% Hashes are used for the meter images, which are then reused
% as necessary.
%
% Note that browser support for musical symbols may be buggy.
% \watchout
% Copy/paste into a text editor works well.
%
% \changes{v0.62}{2017/11/12}{\pkg{musicography}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{musicography}[2018/05/21]
%    \end{macrocode}
%
%    \begin{macrocode}
\RenewDocumentCommand{\musSymbol}{ O{\musFont} m m m m }{%
\begin{lateximage}%
{#1\kern#2\raisebox{#3}{#5}\kern#4}%
\end{lateximage}%
}

\RenewDocumentCommand{\musStemmedNote}{ m }{%
\begin{lateximage}%
\musSymbol{0.05em}{0.5ex}{0.2em}{#1\musStem}%
\end{lateximage}%
}

\RenewDocumentCommand{\musFlaggedNote}{ m m }{%
\begin{lateximage}%
\musSymbol{0.05em}{0.5ex}{0pt}{#1\musStem}%
\musSymbol{0pt}{0pt}{0.9em}{#2}%
\end{lateximage}%
}

\RenewDocumentCommand{\musDottedNote}{ m }{%
\begin{lateximage}%
#1\musDot%
\end{lateximage}%
}

\RenewDocumentCommand{\musMeter}{ m m }{%
\begin{lateximage}*[#1/#2][#1#2]%
\musStack{#1}{#2}\kern0.05em%
\end{lateximage}%
}

\RenewDocumentCommand{\meterCplus}{ m }{%
\begin{lateximage}*[C#1]%
    \meterC{}\kern-0.7pt#1%
\end{lateximage}%
}

\RenewDocumentCommand{\meterC}{}{%
\begin{lateximage}*[C]%
\musSymbolMeter{\symbol{83}}%
\end{lateximage}%
}

\RenewDocumentCommand{\meterCutC}{}{%
\begin{lateximage}*[C|]%
\musSymbolMeter{\symbol{82}}%
\end{lateximage}%
}

\RenewDocumentCommand{\meterCThreeTwo}{}{%
\begin{lateximage}*[C3/2]%
\meterCplus{\musStack{3}{2}}%
\end{lateximage}%
}

\RenewDocumentCommand{\musFlat}       {}{\HTMLunicode{266D}}
\RenewDocumentCommand{\musDoubleFlat} {}{\HTMLunicode{1D12B}}
\RenewDocumentCommand{\musSharp}      {}{\HTMLunicode{266F}}
\RenewDocumentCommand{\musDoubleSharp}{}{\HTMLunicode{1D12A}}
\RenewDocumentCommand{\musNatural}    {}{\HTMLunicode{266E}}

\RenewDocumentCommand{\musWhole}{}{\HTMLunicode{1D15D}}
\RenewDocumentCommand{\musHalf}{}{\HTMLunicode{1D15E}}
\RenewDocumentCommand{\musQuarter}{}{\HTMLunicode{1D15F}}
\RenewDocumentCommand{\musEighth}{}{\HTMLunicode{1D160}}
\RenewDocumentCommand{\musSixteenth}{}{\HTMLunicode{1D161}}

\RenewDocumentCommand{\musWholeDotted}{}{\HTMLunicode{1D15D}\HTMLunicode{1D16D}}
\RenewDocumentCommand{\musHalfDotted}{}{\HTMLunicode{1D15E}\HTMLunicode{1D16D}}
\RenewDocumentCommand{\musQuarterDotted}{}{\HTMLunicode{1D15F}\HTMLunicode{1D16D}}
\RenewDocumentCommand{\musEighthDotted}{}{\HTMLunicode{1D160}\HTMLunicode{1D16D}}
\RenewDocumentCommand{\musSixteenthDotted}{}{\HTMLunicode{1D161}\HTMLunicode{1D16D}}
%    \end{macrocode}
%
% \iffalse
%</musicography>
% \fi
%
%
%
%
% \iffalse
%<*nameauth>
% \fi
%
% \part{lwarp-nameauth.sty}
%
% \section{nameauth}
%
% \credits{Charles P. Schaum}
%
% \DescribePackage{nameauth}
% \pkg{nameauth} is patched for use by \pkg{lwarp}.
%
% \changes{v0.66}{2019/02/05}{\pkg{nameauth}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{nameauth}[2017/03/22]
%    \end{macrocode}
%
% \pkg{lwarp} formatting is inserted in the following.
%    \begin{macrocode}
\renewcommand*\@nameauth@Hook[1]
{%
  \if@nameauth@Lock
    \@nameauth@InHooktrue%
    \protected@edef\test{#1}%
    \expandafter\@nameauth@TestDot\expandafter{\test}%
    \if@nameauth@InAKA
      \if@nameauth@AlwaysFormat
        \@nameauth@FirstFormattrue%
      \else
        \unless\if@nameauth@AKAFormat
        \@nameauth@FirstFormatfalse\fi
      \fi
      \if@nameauth@MainFormat
        \if@nameauth@FirstFormat
          \bgroup\NamesFormat{%
            \LWR@textcurrentcolor{\LWR@textcurrentfont{#1}}%    lwarp
          }\egroup%
        \else
          \bgroup\MainNameHook{%
            \LWR@textcurrentcolor{\LWR@textcurrentfont{#1}}%    lwarp
          }\egroup%
        \fi
      \else
        \if@nameauth@FirstFormat
          \bgroup\FrontNamesFormat{%
            \LWR@textcurrentcolor{\LWR@textcurrentfont{#1}}%    lwarp
          }\egroup%
        \else
          \bgroup\FrontNameHook{%
            \LWR@textcurrentcolor{\LWR@textcurrentfont{#1}}%    lwarp
          }\egroup%
        \fi
      \fi
    \else
      \if@nameauth@AlwaysFormat
        \@nameauth@FirstFormattrue%
      \fi
      \if@nameauth@MainFormat
        \if@nameauth@FirstFormat
          \bgroup\NamesFormat{%
            \LWR@textcurrentcolor{\LWR@textcurrentfont{#1}}%    lwarp
          }\egroup%
        \else
          \bgroup\MainNameHook{%
            \LWR@textcurrentcolor{\LWR@textcurrentfont{#1}}%    lwarp
          }\egroup%
        \fi
      \else
        \if@nameauth@FirstFormat
          \bgroup\FrontNamesFormat{%
            \LWR@textcurrentcolor{\LWR@textcurrentfont{#1}}%    lwarp
          }\egroup%
        \else
          \bgroup\FrontNameHook{%
            \LWR@textcurrentcolor{\LWR@textcurrentfont{#1}}%    lwarp
          }\egroup%
        \fi
      \fi
    \fi
    \@nameauth@FirstFormatfalse%
    \@nameauth@InHookfalse%
  \fi
}
%    \end{macrocode}
%
% \iffalse
%</nameauth>
% \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
%<*natbib>
% \fi
%
% \part{lwarp-natbib.sty}

% \section{natbib}
%
% \credits{Patrick W. Daly}
%
% \DescribePackage{natbib}
% \pkg{natbib} is patched for use by \pkg{lwarp}.
%
% \changes{v0.45}{2018/01/13}{\pkg{natbib}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{natbib}[2010/09/13]
%    \end{macrocode}
%
% Replace math $<$ and $>$ with \cs{textless} and \cs{textgreater}:
%
% A macro to compare:
%    \begin{macrocode}
\newcommand{\LWRNB@NAT@open}{$<$}
%    \end{macrocode}
% To patch \cs{NAT@open} and \cs{NAT@close}
%    \begin{macrocode}
\newcommand{\LWRNB@patchnatbibopenclose}{
\ifdefstrequal{\NAT@open}{\LWRNB@NAT@open}
{
    \renewcommand{\NAT@open}{\textless}
    \renewcommand{\NAT@close}{\textgreater}
}{}
}
%    \end{macrocode}
% Do it now in case |angle| was selected as an option:
%    \begin{macrocode}
\LWRNB@patchnatbibopenclose
%    \end{macrocode}
% Also patch \cs{setcitestyle} to patch after settings are made:
%    \begin{macrocode}
\let\LWRNB@origsetcitestyle\setcitestyle

\renewcommand{\setcitestyle}[1]{%
\LWRNB@origsetcitestyle{#1}%
\LWRNB@patchnatbibopenclose%
}
%    \end{macrocode}

% \iffalse
%</natbib>
% \fi
%
%
%
% \iffalse
%<*nccfancyhdr>
% \fi
%
% \part{lwarp-nccfancyhdr.sty}
%
% \section{nccfancyhdr}
%
% \credits{Alexander I. Rozhenko}
%
% \DescribePackage{nccfancyhdr}
% \pkg{nccfancyhdr} is ignored.
%
% \changes{v0.59}{2018/08/06}{\pkg{nccfancyhdr}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{nccfancyhdr}[2004/12/07]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\headrulewidth}{}
\newcommand*{\footrulewidth}{}
\newcommand{\headstrutheight}{}
\newcommand{\footstrutheight}{}
\newcommand*{\headrule}{}
\newcommand*{\footrule}{}

\newdimen\headwidth
\newcommand*{\extendedheaders}{}
\newcommand*{\normalheaders}{}

\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{\nouppercase}[1]{#1}

\NewDocumentCommand{\fancycenter}{o o m m m}{}

\NewDocumentCommand{\newpagestyle}{m o m}{}

\newcommand*{\iffloatpage}[2]{#2}
\newcommand*{\ifftopfloat}[2]{#2}
\newcommand*{\iffbotfloat}[2]{#2}
%    \end{macrocode}
%
% \iffalse
%</nccfancyhdr>
% \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}[2010/09/12]

\DeclareDocumentCommand{\needspace}{m}{}
\DeclareDocumentCommand{\Needspace}{s m}{}
%    \end{macrocode}

% \iffalse
%</needspace>
% \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}[2009/09/03]
%    \end{macrocode}

%    \begin{macrocode}
\DeclareDocumentCommand{\cleartoevenpage}{o}{}
\DeclareDocumentCommand{\movetoevenpage}{o}{}
\DeclareDocumentCommand{\cleartooddpage}{o}{}
\DeclareDocumentCommand{\movetooddpage}{o}{}
%    \end{macrocode}

% \iffalse
%</nextpage>
% \fi
%
%
%
%
% \iffalse
%<*nicefrac>
% \fi
%
% \part{lwarp-nicefrac.sty}

% \section{nicefrac}
%
% \credits{Axel Reichert}
%
% \DescribePackage{nicefrac}
% \pkg{nicefrac} is patched for use by \pkg{lwarp}.
%
% \changes{v0.52}{2018/03/25}{\pkg{nicefrac}: Added.}
% \changes{v0.62}{2018/11/15}{\pkg{nicefrac}: Improved font control and \CSS,
%       honors \optn{nice}, \optn{ugly}.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{nicefrac}[1998/08/04]
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareRobustCommand*{\LWR@HTML@@UnitsNiceFrac}[3][]{%
    {% localize font selection
        #1{%
            \LWR@textcurrentfont{%
                \InlineClass{numerator}{#2}%
                /%
                \InlineClass{denominator}{#3}%
            }%
        }%
    }%
}

\LWR@formatted{@UnitsNiceFrac}

\DeclareRobustCommand*{\LWR@HTML@@UnitsUglyFrac}[3][]{%
    {% localize font selection
        #1{\LWR@textcurrentfont{#2/#3}}%
    }%
}

\LWR@formatted{@UnitsUglyFrac}
%    \end{macrocode}
%
% For Mathjax:
%    \begin{macrocode}
\CustomizeMathJax{\newcommand{\nicefrac}[3][]{#2/#3}}
%    \end{macrocode}
%
% ^^A For Ka\TeX:
% ^^A %    \begin{macrocode}
% ^^A \CustomizeKaTeX{\gdef\nicefrac[#1]#2#3{#2/#3}}
% ^^A %    \end{macrocode}
%
% \iffalse
%</nicefrac>
% \fi
%
%
%
%
% \iffalse
%<*nomencl>
% \fi
%
% \part{lwarp-nomencl.sty}
%
% \section{nomencl}
%
% \credits{Boris Veytsman, Bernd Schandl, Lee Netherton, CV Radhakrishnan}
%
% \DescribePackage{nomencl}
% \pkg{nomencl} is patched for use by \pkg{lwarp}.
%
% \limitsnomencl
%
% \changes{v0.67}{2019/02/18}{\pkg{nomencl}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{nomencl}[2005/09/22]
%    \end{macrocode}
%
%    \begin{macrocode}
\def\@@@nomenclature[#1]#2#3{%
 \def\@tempa{#2}\def\@tempb{#3}%
 \protected@write\@nomenclaturefile{}%
  {\string\nomenclatureentry{#1\nom@verb\@tempa @[{\nom@verb\@tempa}]%
      \begingroup\nom@verb\@tempb\protect\nomeqref{\theequation}%
        |nompageref}{\theLWR@previousautopagelabel}}%   lwarp
 \endgroup
 \@esphack}

\renewcommand*{\pagedeclaration}[1]{, \nameref{autopage-#1}}
%    \end{macrocode}
%
% \iffalse
%</nomencl>
% \fi
%
%
%
%
%
% \iffalse
%<*nonfloat>
% \fi
%
% \part{lwarp-nonfloat.sty}
%
% \section{nonfloat}
%
% \credits{Kai Rascher}
%
% \DescribePackage{nonfloat}
% \pkg{nonfloat} is emulated.
%
% \changes{v0.50}{2018/02/21}{\pkg{nonfloat}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{nonfloat}[1999/07/05]
%    \end{macrocode}
%
%    \begin{macrocode}
\LetLtxMacro\topcaption\caption
\newcommand{\figcaption}{\def\@captype{figure}\caption}
\newcommand{\tabcaption}{\def\@captype{table}\topcaption}
\newenvironment{narrow}[2]{}{}
%    \end{macrocode}
%
% \iffalse
%</nonfloat>
% \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}[2011/04/15]
%    \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}[1989/01/01]
%    \end{macrocode}
%
%
% \iffalse
%</nopageno>
% \fi
%
%
%
%
%
% \iffalse
%<*notes>
% \fi
%
% \part{lwarp-notes.sty}
%
% \section{notes}
%
% \DescribePackage{notes}
% \pkg{notes} is emulated.
%
% \changes{v0.67}{2019/02/18}{\pkg{notes}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{notes}[2002/10/29]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\LWR@notes@onenote}[2]{%
\newenvironment{#1}
    {
        \BlockClass{notes#1}
        \begin{BlockClass}{notesicon}\textcircled{~#2~}\end{BlockClass}
        \BlockClass{notescontents}
    }
    {\endBlockClass\endBlockClass}
}

\LWR@notes@onenote{importantnote}{!}

\LWR@notes@onenote{warningnote}{--}

\LWR@notes@onenote{informationnote}{i}
%    \end{macrocode}
%
% \iffalse
%</notes>
% \fi
%
%
%
%
%
% \iffalse
%<*notespages>
% \fi
%
% \part{lwarp-notespages.sty}
%
% \section{notespages}
%
% \DescribePackage{notespages}
% \pkg{notespages} is ignored.
%
% \changes{v0.62}{2018/11/11}{\pkg{notespages}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{notespages}[2016/08/21]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\npnotesname}{}
\newcommand*{\npnotestext}{}
\newcommand*{\remainingtextheight}{}
\newdimen\remainingtextheight
\newcommand*{\notestitletext}{}
\newcommand*{\notesareatext}{}
\newcommand*{\npnpinfo}[1]{}
\newcommand*{\tracingnpmarks}{}
\newcommand*{\notespage}[1][]{}
\newcommand*{\notespages}[1][]{}
\newcommand*{\notesfill}[1][]{}
\newcommand*{\setnotespages}[1]{}
\newcommand*{\definenotesoption}[2]{}
\newcommand{\definenotesstyle}[2]{}
\newcommand{\definetitlestyle}[2]{}
\newcommand{\nppatchchapter}[1]{}
\newcommand{\npunpatchchapter}{}
%    \end{macrocode}
%
% \iffalse
%</notespages>
% \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}[2011/09/20]
%    \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.}
% \changes{v0.46}{2018/01/22}{\pkg{ntheorem}: Adapted to \env{trivlist} changes.}
%
% \begin{table}[ht]
% \hrule
% \smallskip
% \caption{Ntheorem package \Dash \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
% \trouble[Disabled options]{ntheorem=\pkg{ntheorem}}
% 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}[2011/08/15]
%    \end{macrocode}
%
%
% \subsection{Remembering the theorem style}
%
% Storage for the style being used for new theorems.
%    \begin{macrocode}
\newcommand{\LWR@newtheoremstyle}{plain}
%    \end{macrocode}
%
%
%    \begin{macrocode}
\AtBeginDocument{
\@ifpackageloaded{cleveref}{
\gdef\@thm#1#2#3{%
   \if@thmmarks
     \stepcounter{end\InTheoType ctr}%
   \fi
   \renewcommand{\InTheoType}{#1}%
   \if@thmmarks
     \stepcounter{curr#1ctr}%
     \setcounter{end#1ctr}{0}%
   \fi
   \refstepcounter[#1]{#2}%  <<< cleveref modification
   \theorem@prework
    \LWR@forcenewpage% lwarp
    \BlockClass{theorembody#1}%\LWR@thisthmstyle% lwarp
   \trivlist % latex's \trivlist, calling latex's \@trivlist unchanged
   \ifuse@newframeskips  % cf. latex.ltx for topsepadd: \@trivlist
     \ifthm@inframe
       \thm@topsep\theoreminframepreskipamount
       \thm@topsepadd\theoreminframepostskipamount
      \else
       \thm@topsep\theorempreskipamount
       \thm@topsepadd\theorempostskipamount
      \fi
    \else% oldframeskips
      \thm@topsep\theorempreskipamount
      \thm@topsepadd \theorempostskipamount
      \ifvmode\advance\thm@topsepadd\partopsep\fi
   \fi
   \@topsep\thm@topsep
   \@topsepadd\thm@topsepadd
   \advance\linewidth -\theorem@indent
   \advance\linewidth -\theorem@rightindent
   \advance\@totalleftmargin \theorem@indent
   \parshape \@ne \@totalleftmargin \linewidth
   \@ifnextchar[{\@ythm{#1}{#2}{#3}}{\@xthm{#1}{#2}{#3}}
}
}{% not @ifpackageloaded{cleveref}
\gdef\@thm#1#2#3{%
   \if@thmmarks
     \stepcounter{end\InTheoType ctr}%
   \fi
   \renewcommand{\InTheoType}{#1}%
   \if@thmmarks
     \stepcounter{curr#1ctr}%
     \setcounter{end#1ctr}{0}%
   \fi
   \refstepcounter{#2}%
   \theorem@prework
    \LWR@forcenewpage% lwarp
    \BlockClass{theorembody#1}%\LWR@thisthmstyle% lwarp
   \trivlist % latex's \trivlist, calling latex's \@trivlist unchanged
   \ifuse@newframeskips  % cf. latex.ltx for topsepadd: \@trivlist
     \ifthm@inframe
       \thm@topsep\theoreminframepreskipamount
       \thm@topsepadd\theoreminframepostskipamount
      \else
       \thm@topsep\theorempreskipamount
       \thm@topsepadd\theorempostskipamount
      \fi
    \else% oldframeskips
      \thm@topsep\theorempreskipamount
      \thm@topsepadd \theorempostskipamount
      \ifvmode\advance\thm@topsepadd\partopsep\fi
   \fi
   \@topsep\thm@topsep
   \@topsepadd\thm@topsepadd
   \advance\linewidth -\theorem@indent
   \advance\linewidth -\theorem@rightindent
   \advance\@totalleftmargin \theorem@indent
   \parshape \@ne \@totalleftmargin \linewidth
   \@ifnextchar[{\@ythm{#1}{#2}{#3}}{\@xthm{#1}{#2}{#3}}
}
}
}% AtBeginDocument
%    \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}% lwarp
            }%
      {
        \theorem@style{#1}
        \renewcommand{\LWR@newtheoremstyle}{#1}% lwarp
        }
}
%    \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}% lwarp
     \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{\@nameuse{LWR@thmstyle#1}}}% lwarp
  \fi
}

\gdef\@ynthm#1#2{%
  \ifthm@tempif
     \csedef{LWR@thmstyle#1}{\LWR@newtheoremstyle}% lwarp
     \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{\@nameuse{LWR@thmstyle#1}}}% lwarp
  \fi
}

\gdef\@othm#1[#2]#3{%
  \@ifundefined{c@#2}{\@nocounterr{#2}}%
   {\ifthm@tempif
     \csedef{LWR@thmstyle#1}{\LWR@newtheoremstyle}% lwarp
     \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{\@nameuse{LWR@thmstyle#1}}}% lwarp
  \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.
% \changes{v0.47}{2018/01/26}{\pkg{ntheorem}: Fix: Line wrap at \HTML\ hyphen.}
%    \begin{macrocode}
\newcommand{\LWR@inctheorem}{%
\addtocounter{LWR@thisautoid}{1}%
\LWR@stoppars%
\LWR@htmltag{a id="\LWR@print@mbox{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@inctheorem% lwarp
    #2}%
    \def\@opargbegintheorem####1####2####3{%
    \LWR@inctheorem% lwarp
    #3}%
}%
}%
{\PackageError{\basename}{Theorem style #1 already defined}\@eha}
}
%    \end{macrocode}
%
% \subsection{Standard styles}
%
%    \begin{macrocode}
\renewtheoremstyle{plain}%
  {\item[
    \InlineClass{theoremheaderplain}{##1\ ##2\theorem@separator}]}%
  {\item[
    \InlineClass{theoremheaderplain}{##1\ ##2\ (##3)\theorem@separator}]}

\renewtheoremstyle{break}%
  {\item[
    \InlineClass{theoremheaderbreak}{##1\ ##2\theorem@separator}\newline
    ]}%
  {\item[
    \InlineClass{theoremheaderbreak}%
        {##1\ ##2\ (##3)\theorem@separator}\newline
    ]}

\renewtheoremstyle{change}%
  {\item[
    \InlineClass{theoremheaderchange}{##2\ ##1\theorem@separator}]}%
  {\item[
    \InlineClass{theoremheaderchange}{##2\ ##1\ (##3)\theorem@separator}]}

\renewtheoremstyle{changebreak}%
  {\item[
        \InlineClass{theoremheaderchangebreak}%
            {##2\ ##1\theorem@separator}\newline
    ]}%
  {\item[
        \InlineClass{theoremheaderchangebreak}%
            {##2\ ##1\ (##3)\theorem@separator}\newline
    ]}

\renewtheoremstyle{margin}%
  {\item[
        \InlineClass{theoremheadermargin}{##2 \qquad ##1\theorem@separator}
    ]}%
  {\item[
        \InlineClass{theoremheadermargin}{##2 \qquad ##1\ (##3)\theorem@separator}
    ]}

\renewtheoremstyle{marginbreak}%
  {\item[
    \InlineClass{theoremheadermarginbreak}%
        {##2 \qquad ##1\theorem@separator}\newline
    ]}%
  {\item[
    \InlineClass{theoremheadermarginbreak}%
        {##2 \qquad ##1\ (##3)\theorem@separator}\newline
    ]}

\renewtheoremstyle{nonumberplain}%
  {\item[
    \InlineClass{theoremheaderplain}{##1\theorem@separator}]}%
  {\item[
    \InlineClass{theoremheaderplain}{##1\ (##3)\theorem@separator}]}

\renewtheoremstyle{nonumberbreak}%
  {\item[
    \InlineClass{theoremheaderbreak}{##1\theorem@separator}\newline
    ]}%
  {\item[
    \InlineClass{theoremheaderbreak}{##1\ (##3)\theorem@separator}\newline
    ]}

\renewtheoremstyle{empty}%
  {\item[]}%
  {\item[
    \InlineClass{theoremheaderplain}{##3}]}

\renewtheoremstyle{emptybreak}%
  {\item[]}%
  {\item[
    \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}{}{%
%    \end{macrocode}
% Upright text via CSS:
%    \begin{macrocode}
    \newtheoremstyle{plainupright}%
    {\item[
        \InlineClass{theoremheaderplain}{##1\ ##2\theorem@separator}]}%
    {\item[
        \InlineClass{theoremheaderplain}{##1\ ##2\ (##3)\theorem@separator}]}
%    \end{macrocode}
% Upright text and small caps header via CSS:
%    \begin{macrocode}
    \newtheoremstyle{nonumberplainuprightsc}%
    {\item[
        \InlineClass{theoremheadersc}{##1\theorem@separator}]}%
    {\item[
        \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}{}{%
%    \end{macrocode}
% \changes{v0.50}{2018/03/01}{\pkg{ntheorem}: Fix: Not \optn{standard} nor \optn{amsthm} selected.}
%    \begin{macrocode}
\ifx\thm@usestd\@undefined
\else
    \theoremnumbering{arabic}
    \theoremstyle{plain}
    \RequirePackage{latexsym}
    \theoremsymbol{\Box}
    \theorembodyfont{\itshape}
    \theoremheaderfont{\normalfont\bfseries}
    \theoremseparator{}
    \renewtheorem{Theorem}{Theorem}
    \renewtheorem{theorem}{Theorem}
    \renewtheorem{Satz}{Satz}
    \renewtheorem{satz}{Satz}
    \renewtheorem{Proposition}{Proposition}
    \renewtheorem{proposition}{Proposition}
    \renewtheorem{Lemma}{Lemma}
    \renewtheorem{lemma}{Lemma}
    \renewtheorem{Korollar}{Korollar}
    \renewtheorem{korollar}{Korollar}
    \renewtheorem{Corollary}{Corollary}
    \renewtheorem{corollary}{Corollary}

    \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{}
\fi
}% not amsthm
%    \end{macrocode}
%
%
% \subsection{\pkg{amsthm} option}
%
% Only if the \optn{amsthm} option was given:
%    \begin{macrocode}
\ifbool{LWR@ntheoremamsthm}{

\gdef\th@plain{%
  \def\theorem@headerfont{\normalfont\bfseries}\itshape%
  \def\@begintheorem##1##2{%
        \LWR@inctheorem% lwarp
      \item[
 			\InlineClass{theoremheaderplain}{##1\ ##2.}
        ]}%
  \def\@opargbegintheorem##1##2##3{%
        \LWR@inctheorem% lwarp
     \item[
 		\InlineClass{theoremheaderplain}{##1\ ##2\ (##3).}
        ]}}

\gdef\th@nonumberplain{%
  \def\theorem@headerfont{\normalfont\bfseries}\itshape%
  \def\@begintheorem##1##2{%
        \LWR@inctheorem% lwarp
      \item[
 			\InlineClass{theoremheaderplain}{##1.}
        ]}%
  \def\@opargbegintheorem##1##2##3{%
        \LWR@inctheorem% lwarp
     \item[
 		\InlineClass{theoremheaderplain}{##1\ (##3).}
        ]}}

\gdef\th@definition{%
  \def\theorem@headerfont{\normalfont\bfseries}\normalfont%
  \def\@begintheorem##1##2{%
        \LWR@inctheorem% lwarp
      \item[
 			\InlineClass{theoremheaderdefinition}{##1\ ##2.}
        ]}%
  \def\@opargbegintheorem##1##2##3{%
        \LWR@inctheorem% lwarp
     \item[
 		\InlineClass{theoremheaderdefinition}{##1\ ##2\ (##3).}
        ]}}

\gdef\th@nonumberdefinition{%
  \def\theorem@headerfont{\normalfont\bfseries}\normalfont%
  \def\@begintheorem##1##2{%
        \LWR@inctheorem% lwarp
      \item[
 			\InlineClass{theoremheaderdefinition}{##1.}
        ]}%
  \def\@opargbegintheorem##1##2##3{%
        \LWR@inctheorem% lwarp
     \item[
 		\InlineClass{theoremheaderdefinition}{##1\ (##3).}
        ]}}

\gdef\th@remark{%
  \def\theorem@headerfont{\itshape}\normalfont%
  \def\@begintheorem##1##2{%
        \LWR@inctheorem% lwarp
      \item[
 			\InlineClass{theoremheaderremark}{##1\ ##2.}
        ]}%
  \def\@opargbegintheorem##1##2##3{%
        \LWR@inctheorem% lwarp
     \item[
 		\InlineClass{theoremheaderremark}{##1\ ##2\ (##3).}
        ]}}

\gdef\th@nonumberremark{%
  \def\theorem@headerfont{\itshape}\normalfont%
  \def\@begintheorem##1##2{%
        \LWR@inctheorem% lwarp
      \item[
 			\InlineClass{theoremheaderremark}{##1.}
        ]}%
  \def\@opargbegintheorem##1##2##3{%
        \LWR@inctheorem% lwarp
     \item[
 		\InlineClass{theoremheaderremark}{##1\ (##3).}
        ]}}

\gdef\th@proof{%
  \def\theorem@headerfont{\normalfont\bfseries}\itshape%
  \def\@begintheorem##1##2{%
        \LWR@inctheorem% lwarp
      \item[
 			\InlineClass{theoremheaderproof}{##1.}
        ]}%
  \def\@opargbegintheorem##1##2##3{%
        \LWR@inctheorem% lwarp
     \item[
 		\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% also does \@endtrivlist
\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:
% \changes{v0.55}{2018/04/24}{Fix: QED symbols in \env{lateximage}.}
%    \begin{macrocode}
\newcommand{\qed}{\qquad\the\qedsymbol}

\AtBeginDocument{
\@ifundefined{LWR@orig@openbox}{
\LetLtxMacro\LWR@orig@openbox\openbox
\LetLtxMacro\LWR@orig@blacksquare\blacksquare
\LetLtxMacro\LWR@orig@Box\Box

\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

\appto\LWR@restoreorigformatting{%
\LetLtxMacro\openbox\LWR@orig@openbox%
\LetLtxMacro\blacksquare\LWR@orig@blacksquare%
\LetLtxMacro\Box\LWR@orig@Box%
}% appto
}{}% @ifundefined
}% AtBeginDocument
%    \end{macrocode}
%
% \subsection{Cross-referencing}
%
% \cs{thref} \marg{label}
%    \begin{macrocode}
\newcommand*{\thref}[1]{\cref{#1}}%
%    \end{macrocode}
%
% \iffalse
%</ntheorem>
% \fi
%
%
%
%
%
% \iffalse
%<*octave>
% \fi
%
% \part{lwarp-octave.sty}
%
% \section{octave}
%
% \credits{Andrew A. Cashner}
%
% \DescribePackage{octave}
% \pkg{octave} is patched for use by \pkg{lwarp}.
%
% \changes{v0.62}{2018/11/12}{\pkg{octave}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{octave}[2017/10/31]
%    \end{macrocode}
%
% Remove the leading 1pt kern:
%    \begin{macrocode}
\RenewDocumentCommand{\@PrintTicks}{ m }{%
\kern-1pt%  lwarp
\@TickNum = #1%
\loop
\@Tick{}%
\advance\@TickNum by -1
\ifnum\@TickNum > 0
\repeat
}
%    \end{macrocode}
%
% Use unicode for the prime character:
%    \begin{macrocode}
\RenewDocumentCommand{\@Tick}{}{\HTMLunicode{2032}}
%    \end{macrocode}
%
% Catch the inline font:
%    \begin{macrocode}
\RenewDocumentCommand{\pitch}{ m o m }{%
\if@OctaveNumber%
{%
    \pitchfont{%
        \LWR@textcurrentfont{%  lwarp
            \MakeUppercase{#1}%
            \IfValueTF{#2}{#2}{}\textsubscript{#3}%
        }%
    }%
}%
\else%
{%
    \pitchfont{%
        \LWR@textcurrentfont{%  lwarp
            \@GetOctaveTick{#1}[#2]{#3}%
        }%
    }%
}%
\fi%
}
%    \end{macrocode}
%
% The original was hard to adapt to \pkg{lwarp}'s handling of \&.
%    \begin{macrocode}
\StartDefiningTabulars
\renewcommand{\octavetable}{%
\begin{tabular}{ll}
\octaveprimes \pitch{C}{0} & \octavenumbers \pitch{C}{0} \\
\octaveprimes \pitch{C}{1} & \octavenumbers \pitch{C}{1} \\
\octaveprimes \pitch{C}{2} & \octavenumbers \pitch{C}{2} \\
\octaveprimes \pitch{C}{3} & \octavenumbers \pitch{C}{3} \\
\octaveprimes \pitch{C}{4} & \octavenumbers \pitch{C}{4} \\
\octaveprimes \pitch{C}{5} & \octavenumbers \pitch{C}{5} \\
\octaveprimes \pitch{C}{6} & \octavenumbers \pitch{C}{6} \\
\octaveprimes \pitch{C}{7} & \octavenumbers \pitch{C}{7} \\
\end{tabular}
}
\StopDefiningTabulars
%    \end{macrocode}
%
% \iffalse
%</octave>
% \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}[2017/10/06]
%    \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
%<*pagegrid>
% \fi
%
% \part{lwarp-pagegrid.sty}
%
% \section{pagegrid}
%
% \DescribePackage{pagegrid}
% \pkg{pagegrid} is ignored.
%
% \changes{v0.49}{2018/02/15}{\pkg{pagegrid}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pagegrid}[2016/05/16]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\pagegridsetup}[1]{}
%    \end{macrocode}
%
% \iffalse
%</pagegrid>
% \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 \optn{page} disabled.}
%
% \codehtml
%    \begin{macrocode}
\DeclareOption{page}{}
\LWR@ProvidesPackagePass{pagenote}[2009/09/03]
%    \end{macrocode}
%
% \iffalse
%</pagenote>
% \fi
%
%
%
%
%
% \iffalse
%<*pagesel>
% \fi
%
% \part{lwarp-pagesel.sty}
%
% \section{pagesel}
%
% \DescribePackage{pagesel}
% \pkg{pagesel} is ignored.
%
% \changes{v0.45}{2017/12/24}{\pkg{pagesel}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pagesel}[2016/05/16]
%    \end{macrocode}
%
% \iffalse
%</pagesel>
% \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.}
% \changes{v0.56}{2018/05/06}{\pkg{paralist}: Fixes for
%   \env{compactenum}, \env{compactitem}, \env{compactdesc}.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{paralist}[2017/01/22]
%    \end{macrocode}
%
% The compact environments are identical to the regular ones:
%    \begin{macrocode}
\LetLtxMacro\compactitem\itemize
\LetLtxMacro\compactenum\enumerate
\LetLtxMacro\compactdesc\description
\LetLtxMacro\endcompactitem\enditemize
\LetLtxMacro\endcompactenum\endenumerate
\LetLtxMacro\endcompactdesc\enddescription
%    \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
%<*parnotes>
% \fi
%
% \part{lwarp-parnotes.sty}
%
% \section{parnotes}
%
% \credits{Chelsea Hughes}
%
% \DescribePackage{parnotes}
% \pkg{parnotes} is supported with some patches.
%
% \changes{v0.56}{2018/05/08}{\pkg{parnotes}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{parnotes}[2016/08/15]
%    \end{macrocode}
%
%    \begin{macrocode}
\long\def\PN@parnote@real#1#2{%
    \parnotemark{#1}%
    % Unless this is the first parnote in \PN@text, add a separator first
    \unless\ifx\PN@text\@empty\g@addto@macro\PN@text{\parnoteintercmd}\fi
    % Redefine \@currentlabel to the parnote label, so \label works
    \g@addto@macro\PN@text{%
%         \phantomsection%
        \def\@currentlabel{#1}%
        \def\cref@currentlabel{%        lwarp
            [parnotemark][\arabic{parnotemark}][]\theparnotemark%
        }%
    }%
    \g@addto@macro\PN@text{%
        \LWR@textcurrentfont{%          lwarp
            \parnotemark{#1}\nolinebreak\thinspace#2%
        }%
    }%
}

\def\PN@parnotes@real{%
    % We call \par later, so this avoids recursion with \PN@parnotes@auto
    \PN@inparnotestrue
    \unless\ifvmode\par\fi
    % Avoid page breaks between a paragraph and its parnotes
    \nopagebreak\addvspace{\parnotevskip}%
    \LWR@forcenewpage%                  lwarp
    \begin{BlockClass}{footnotes}%      lwarp
    {\parnotefmt{\PN@text}\par}%
    \end{BlockClass}%                   lwarp
    \global\def\PN@text{}%
    \addvspace{\parnotevskip}%
    %
    % These can be enabled or disabled by package options
    %
    \PN@disable@indent
    \PN@reset@optional
    \PN@inparnotesfalse
}

\AtBeginDocument{
\crefname{parnotemark}{paragraph note}{paragraph notes}%
\Crefname{parnotemark}{Paragraph note}{Paragraph notes}
}
%    \end{macrocode}
%
% \iffalse
%</parnotes>
% \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}[2001/04/09]
%    \end{macrocode}

% \iffalse
%</parskip>
% \fi
%
%
%
%
%
% \iffalse
%<*pbox>
% \fi
%
% \part{lwarp-pbox.sty}
%
% \section{pbox}
%
% \credits{Simon Law}
%
% \DescribePackage{pbox}
% \pkg{pbox} is emulated.
%
% \changes{v0.50}{2018/02/21}{\pkg{pbox}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pbox}[2011/12/07]
%    \end{macrocode}
%
%    \begin{macrocode}
\NewDocumentCommand{\pbox}{O{t} O{} O{t} m +m}{%
\global\booltrue{LWR@minipagefullwidth}%
\parbox[#1][#2][#3]{#4}{#5}%
}

\newcommand{\settominwidth}[3][\columnwidth]{%
\settowidth{#2}{#3}%
}

\newcommand{\widthofpbox}[1]{%
\widthof{#1}%
}
%    \end{macrocode}
%
% \iffalse
%</pbox>
% \fi
%
%
%
%
%
%
% \iffalse
%<*pdfcomment>
% \fi
%
% \part{lwarp-pdfcomment.sty}
%
% \section{pdfcomment}
%
% \DescribePackage{pdfcomment}
% \pkg{pdfcomment} is ignored.
%
% \changes{v0.62}{2018/11/11}{\pkg{pdfcomment}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pdfcomment}[2016/06/13]
%    \end{macrocode}
%
%    \begin{macrocode}
\newenvironment{pdfsidelinecomment}[2][]{}{}
\newcommand{\pdfcomment}[2][]{}
\newcommand{\pdfmargincomment}[2][]{}
\newcommand{\pdfmarkupcomment}[3][]{#2}
\newcommand{\pdffreetextcomment}[2][]{}
\newcommand{\pdfsquarecomment}[2][]{}
\newcommand{\pdfcirclecomment}[2][]{}
\newcommand{\pdflinecomment}[2][]{}
\newcommand{\pdftooltip}[3][]{#2}
\newcommand{\pdfcommentsetup}[2][]{}
\newcommand{\listofpdfcomments}[1][]{}
\newcommand{\setliststyle}[1]{}
\newcommand{\defineliststyle}[2]{}
\newcommand{\defineavatar}[2]{}
\newcommand{\definestyle}[2]{}
%    \end{macrocode}
%
% \iffalse
%</pdfcomment>
% \fi
%
%
%
%
%
% \iffalse
%<*pdflscape>
% \fi
%
% \part{lwarp-pdflscape.sty}
%
% \section{pdflscape}
%
% \DescribePackage{pdflscape} \pkg{pdflscape} is ignored.
%
% \changes{v0.34}{2017/08/03}{\pkg{pdflscape}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-pdflscape}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pdflscape}[2016/05/14]
%    \end{macrocode}
%
% \iffalse
%</pdflscape>
% \fi
%
%
%
%
%
%
% \iffalse
%<*pdfmarginpar>
% \fi
%
% \part{lwarp-pdfmarginpar.sty}
%
% \section{pdfmarginpar}
%
% \DescribePackage{pdfmarginpar}
% \pkg{pdfmarginpar} is ignored.
%
% \changes{v0.62}{2018/11/11}{\pkg{pdfmarginpar}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pdfmarginpar}[2011/08/05]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\pdfmarginpar}[2][]{}
\newcommand{\pdfmarginparset}[1]{}
%    \end{macrocode}
%
% \iffalse
%</pdfmarginpar>
% \fi
%
%
%
%
% \iffalse
%<*pdfpages>
% \fi
%
% \part{lwarp-pdfpages.sty}
%
% \section{pdfpages}
%
% \credits{Andreas Matthias}
%
% \DescribePackage{pdfpages}
% \pkg{pdfpages} is patched for use by \pkg{lwarp}.
%
% Option \optn{link} and \optn{linkname} work:
% \begin{Verbatim}[tabsize=4,gobble=2,frame=lines]
% \hyperlink{<filename>.pdf.<pagenubmer}}{some text}
% \hyperlink{<linkname>.<pagenubmer}}{some text}
% \end{Verbatim}
%
% Options which make no sense in \HTML\ are disabled.
%
% \changes{v0.58}{2018/06/11}{\pkg{pdfpages}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{pdfpages}[2017-10-31]
%    \end{macrocode}
%
% Disable option which have no meaning for \HTML\ output:
%    \begin{macrocode}
\define@key{pdfpages}{fitpaper}[false]{}
\define@key{pdfpages}{landscape}[false]{}
\define@key{pdfpages}{openright}[false]{}
\define@key{pdfpages}{signature}{}
\define@key{pdfpages}{signature*}{}
\define@key{pdfpages}{booklet}[false]{}
\define@key{pdfpages}{rotateoversize}[false]{}
\define@key{pdfpages}{doublepages}[false]{}
\define@key{pdfpages}{doublepagestwist}[false]{}
\define@key{pdfpages}{doublepagestwistodd}[false]{}
\define@key{pdfpages}{doublepagestwist*}[false]{}
\define@key{pdfpages}{doublepagestwistodd*}[false]{}
\define@key{pdfpages}{duplicatepages}[2]{}
\define@key{pdfpages}{thread}[false]{}
\define@key{pdfpages}{threadname}{}
\define@key{pdfpages}{linkfit}{}
\define@key{pdfpages}{linktodoc}[false]{}
\define@key{pdfpages}{linktodocfit}{}
\define@key{pdfpages}{linkfilename}{}
\define@key{pdfpages}{survey}[false]{}
\define@key{pdfpages}{survey-nolink}[false]{}
\define@key{pdfpages}{newwindow}[false]{}
%    \end{macrocode}
%
% Use print mode while measuring the page numbers:
%    \begin{macrocode}
\xpretocmd{\AM@getpagecount}{\LWR@restoreorigformatting}{}{}
%    \end{macrocode}
%
% Emulate a bit of \pkg{eso-pic}:
%    \begin{macrocode}
\newif\ifESO@texcoord

\newcommand{\ESO@HookIIBG}{}

\renewcommand{\AM@AddToShipoutPicture}{\g@addto@macro\ESO@HookIIBG}

\renewcommand{\ClearShipoutPicture}{}
%    \end{macrocode}
%
% \begin{noindmacro}{\LWR@esopic@newpage}
% At each \cs{newpage}.
%
%    \begin{macrocode}
\newcommand*{\LWR@esopic@newpage}{%
%    \end{macrocode}
%
% Is there something to draw?
%    \begin{macrocode}
\ifdefvoid{\ESO@HookIIBG}%
{}%
{%
%    \end{macrocode}
%
% If the \optn{link} option was specified, add a hyper taraget:
%    \begin{macrocode}
    \ifAM@link%
        \hypertarget{\AM@linkname.\AM@page}{}%
    \fi%
%    \end{macrocode}
%
% Draw inside a picture environment of the size of a virtual page:
%    \begin{macrocode}
    \begingroup%
    \setlength{\unitlength}{1in}%
    \begin{picture}(8,10.5)%
    \ESO@HookIIBG%
    \end{picture}%
    \endgroup%
    \global\let\ESO@HookIIBG\@empty%
}
}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\AM@output}
% Patched to use \cs{LWR@esopic@newpage}.
%    \begin{macrocode}
\xpatchcmd{\AM@output}
    {\newpage}
    {\LWR@esopic@newpage}
    {}
    {\LWR@patcherror{pdfpages}{AM@output-1}}

\xpatchcmd{\AM@output}
    {\newpage}
    {\LWR@esopic@newpage}
    {}
    {\LWR@patcherror{pdfpages}{AM@output-2}}

\xpatchcmd{\AM@output}
    {\newpage}
    {\LWR@esopic@newpage}
    {}
    {\LWR@patcherror{pdfpages}{AM@output-3}}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\includepdf} Patched to set a reasonable paper size.
%    \begin{macrocode}
\xpretocmd{\includepdf}{%
    \begingroup%
    \setlength{\paperwidth}{8in}%
    \setlength{\paperheight}{10.5in}%
}{}{}

\xapptocmd{\includepdf}{%
    \endgroup%
}{}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\includepdfmerge} Patched to set a reasonable paper size.
%    \begin{macrocode}
\xpretocmd{\includepdfmerge}{%
    \begingroup%
    \setlength{\paperwidth}{8in}%
    \setlength{\paperheight}{10.5in}%
}{}{}

\xapptocmd{\includepdfmerge}{%
    \endgroup%
}{}{}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\AM@hyper@begin@i}
% Hyper links are created by \cs{LWR@esopic@newpage},
% so don't create them here:
%    \begin{macrocode}
\renewcommand{\AM@hyper@begin@i}{}
%    \end{macrocode}
% \end{noindmacro}
%
% \iffalse
%</pdfpages>
% \fi
%
%
%
%
% \iffalse
%<*pdfprivacy>
% \fi
%
% \part{lwarp-pdfprivacy.sty}
%
% \section{pdfprivacy}
%
% \DescribePackage{pdfprivacy}
% \pkg{pdfprivacy} is ignored.
%
% \changes{v0.61}{2018/09/23}{\pkg{pdfprivacy}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pdfprivacy}[2017/12/03]
%    \end{macrocode}
%
% \iffalse
%</pdfprivacy>
% \fi
%
%
%
% \iffalse
%<*pdfrender>
% \fi
%
% \part{lwarp-pdfrender.sty}
%
% \section{pdfrender}
%
% \DescribePackage{pdfrender}
% \pkg{pdfrender} is ignored.
%
% \changes{v0.49}{2018/02/15}{\pkg{pdfrender}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pdfrender}[2016/05/17]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\pdfrender}[1]{}
\newcommand{\textpdfrender}[2]{#2}
%    \end{macrocode}
%
% \iffalse
%</pdfrender>
% \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}[2008/01/26]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\pdfsync}{}
\newcommand*{\pdfsyncstart}{}
\newcommand*{\pdfsyncstop}{}
%    \end{macrocode}
%
% \iffalse
%</pdfsync>
% \fi
%
%
%
%
% \iffalse
%<*pdftricks>
% \fi
%
% \part{lwarp-pdftricks.sty}
%
% \section{pdftricks}
%
% \credits{C. V. Rad­hakr­ish­nan, C. V. Ra­jagopal, Antoine Chambert-Loir}
%
% \DescribePackage{pdftricks}
% \pkg{pdftricks} is patched for use by \pkg{lwarp}.
%
% \limitspdftricks
%
% \changes{v0.59}{2018/08/29}{\pkg{pdftricks}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{pdftricks}[2003/08/10]
%    \end{macrocode}
%
% Reuse the print-mode images:
%    \begin{macrocode}
\def\PDFTfigname{\BaseJobname-fig\thepsfig}
%    \end{macrocode}
%
% If the \filenm{.pdf} images have not yet been converted to \filenm{.svg} then
% an error about a missing file will occur.
% Warn the user to convert the images.
%    \begin{macrocode}
\PackageWarning{lwarp-pdftricks}{
When the pdftricks images change,
remember to convert PDF images to SVG using 'lwarpmk pdftosvg *-fig.pdf',
}

\AfterEndDocument{\typeout{***}}
\AfterEndDocument{\typeout{*** Note: If pdftricks images are not found, new, or updated,}}
\AfterEndDocument{\typeout{*** \space use 'lwarpmk pdftosvg \BaseJobname-fig*.pdf'}}
\AfterEndDocument{\typeout{***}}
%    \end{macrocode}
%
%    \begin{macrocode}
%    \end{macrocode}
%
% \iffalse
%</pdftricks>
% \fi
%
%
%
%
% \iffalse
%<*pdfx>
% \fi
%
% \part{lwarp-pdfx.sty}
%
% \section{pdfx}
%
% \DescribePackage{pdfx}
% \pkg{pdfx} is ignored.
%
% \changes{v0.58}{2018/06/08}{\pkg{pdfx}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pdfx}[2017/05/18]
%    \end{macrocode}
%
% \iffalse
%</pdfx>
% \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}[1999/07/14]
%    \end{macrocode}
%
% \iffalse
%</pfnote>
% \fi
%
%
%
% \iffalse
%<*phfqit>
% \fi
%
% \part{lwarp-phfqit.sty}

% \section{phfqit}
%
% \credits{Philippe Faist}
%
% \DescribePackage{phfqit}
% \pkg{phfqit} is patched for use by \pkg{lwarp}.
%
% \changes{v0.50}{2018/02/22}{\pkg{phfqit}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{phfqit}[2017/08/16]
%    \end{macrocode}

%    \begin{macrocode}
\LetLtxMacro\LWR@origbitstring\bitstring

\renewcommand\bitstring[1]{%
\InlineClass[%
    text-decoration: overline underline ;
]{bitstring}{#1}%
% \phfqit@bitstring{#1}%
}

\appto\LWR@restoreorigformatting{%
\LetLtxMacro\bitstring\LWR@origbitstring%
}
%    \end{macrocode}

% \iffalse
%</phfqit>
% \fi
%
%
%
%
%
% \iffalse
%<*pifont>
% \fi
%
% \part{lwarp-pifont.sty}
%
% \section{pifont}
%
% \credits{Walter Schmidt}
%
% \DescribePackage{pifont}
% \pkg{pifont} is patched for use by \pkg{lwarp}.
%
% Hashed inline images are used, as there may not be Unicode support for all icons.
%
% \changes{v0.67}{2019/02/23}{\pkg{pifont}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{pifont}[2005/04/12]
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand{\Pisymbol}[2]{%
    \begin{lateximage}*[(Pisymbol)][pisymbol#1#2]%
    {\Pifont{#1}\char#2}%
    \end{lateximage}%
}

\newcommand{\LWR@HTML@Pifill}[2]{
    \Pisymbol{#1}{#2} \Pisymbol{#1}{#2} \Pisymbol{#1}{#2}
}
\LWR@formatted{Pifill}

\newcommand{\LWR@HTML@Piline}[2]{%
    \par\noindent\hspace*{0.5in}
    \Pifill{#1}{#2} \Pifill{#1}{#2} \Pifill{#1}{#2}
}
\LWR@formatted{Piline}
%    \end{macrocode}
%
% \iffalse
%</pifont>
% \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}[2005/04/18]
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\FloatBarrier}{}
%    \end{macrocode}

% \iffalse
%</placeins>
% \fi
%
%
%
%
% \iffalse
%<*plarydshln>
% \fi
%
% \part{lwarp-plarydshln.sty}
%
% \section{plarydshln}
%
% \DescribePackage{plarydshln}
% \pkg{plarydshln} is emulated by \pkg{lwarp-arydshln}.
%
% \changes{v0.65}{2018/12/17}{\pkg{plarydshln}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{plarydshln}[2018/10/20]
%    \end{macrocode}
%
%    \begin{macrocode}
\LWR@origRequirePackage{lwarp-arydshln}
%    \end{macrocode}
%
% \iffalse
%</plarydshln>
% \fi
%
%
%
%
%
% \iffalse
%<*plext>
% \fi
%
% \part{lwarp-plext.sty}
%
% \section{plext}
%
% \DescribePackage{plext}
% \pkg{plext} is preloaded by \pkg{jtarticle} and related classes.
%
% \changes{v0.65}{2017/08/27}{\pkg{plext}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@loadbefore{plext}

\LWR@ProvidesPackagePass{plext}[2017/07/21]
%    \end{macrocode}
%
% ^^A *8* if \cs{layoutfloat}, frame the next float
%    \begin{macrocode}
\let\tate\relax

\DeclareExpandableDocumentCommand{\rensuji}{s o m}{#3}

% \layoutfloat(width,height)[pos]#4
\DeclareDocumentCommand{\layoutfloat}{d() o m}{}

% \DeclareLayoutCaption{type} <dir>(width)[pos1pos2]
\DeclareDocumentCommand{\DeclareLayoutCaption}{m d<> d() o}{}

\LetLtxMacro\pcaption\caption

% \layoutcaption<dir>(width)[pos]
\DeclareDocumentCommand{\layoutcaption}{d<> d() o}{}

\let\captiondir\relax
%    \end{macrocode}
%
% Add the optional |<t/y>| direction:
%    \begin{macrocode}
\RenewDocumentEnvironment{LWR@HTML@minipage}{d<> O{t} O{} O{t} m}
    {\LWR@HTML@sub@minipage{#2}{#3}{#4}{#5}}
    {\endLWR@HTML@sub@minipage}

\RenewDocumentCommand{\LWR@HTML@parbox}{d<> O{t} O{} O{t} m +m}
{
\LWR@traceinfo{parbox of width #4}%
\begin{minipage}[#2][#3][#4]{#5}%
#6
\end{minipage}%
}

% \pbox <t/y> [width] [l/r] {contents}
\RenewDocumentCommand{\pbox}{d<> O{0pt} O{c} m}{%
\global\booltrue{LWR@minipagefullwidth}%
\parbox{#2}{#4}%
}
%    \end{macrocode}
%
% \env{picture}, as modified by \pkg{pext},
% is encapsulated by the \pkg{lwarp} core.
%
% \iffalse
%</plext>
% \fi
%
%
%
%
% \iffalse
%<*plextarydshln>
% \fi
%
% \part{lwarp-plextarydshln.sty}
%
% \section{plextarydshln}
%
% \DescribePackage{plextarydshln}
% \pkg{plextarydshln} is emulated by \pkg{lwarp-arydshln}.
%
% \changes{v0.65}{2018/12/17}{\pkg{plextarydshln}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{plextarydshln}[2018/10/20]
%    \end{macrocode}
%
%    \begin{macrocode}
\LWR@origRequirePackage{lwarp-arydshln}
%    \end{macrocode}
%
% \iffalse
%</plextarydshln>
% \fi
%
%
%
%
% \iffalse
%<*plextcolortbl>
% \fi
%
% \part{lwarp-plextcolortbl.sty}
%
% \section{plextcolortbl}
%
% \DescribePackage{plextcolortbl}
% \pkg{plextcolortbl} is emulated by \pkg{lwarp-colortbl}.
%
% \changes{v0.65}{2018/12/17}{\pkg{plextcolortbl}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{plextcolortbl}[2018/09/19]
%    \end{macrocode}
%
%    \begin{macrocode}
\LWR@origRequirePackage{lwarp-colortbl}
%    \end{macrocode}
%
% \iffalse
%</plextcolortbl>
% \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}[2009/05/29]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\PrelimText}{}
\newcommand{\PrelimTextStyle}{}
\newcommand{\PrelimWords}{}
%    \end{macrocode}
%
% \iffalse
%</prelim2e>
% \fi
%
%
%
%
%
% \iffalse
%<*prettyref>
% \fi
%
% \part{lwarp-prettyref.sty}

% \section{prettyref}
%
% \credits{Kevin S. Ruland}
%
% \DescribePackage{prettyref}
% \pkg{prettyref} is patched for use by \pkg{lwarp}.
%
% \changes{v0.45}{2017/12/11}{\pkg{prettyref}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{prettyref}[1998/07/09]
%    \end{macrocode}

%    \begin{macrocode}
\newrefformat{fig}{Figure \ref{#1}}
\newrefformat{tab}{Table \ref{#1}}
%    \end{macrocode}

% \iffalse
%</prettyref>
% \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}[2017/04/24]
%    \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
%<*psfrag>
% \fi
%
% \part{lwarp-psfrag.sty}
%
% \section{psfrag}
%
% \credits{Michael C. Grant, David Carlisle}
%
% \DescribePackage{psfrag}
% \pkg{psfrag} is patched for use by \pkg{lwarp}.
%
% \limitspsfrag
%
% \changes{v0.61}{2018/10/01}{\pkg{psfrag}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{psfrag}[1998/04/11]
%    \end{macrocode}
%
% A \env{lateximage} captures the modified image from the document.
%    \begin{macrocode}
\BeforeBeginEnvironment{psfrags}{%
    \begin{lateximage}[(-psfrags-~\packagediagramname)]%
}

\AfterEndEnvironment{psfrags}{\end{lateximage}}
%    \end{macrocode}
%
% \iffalse
%</psfrag>
% \fi
%
%
%
%
%
% \iffalse
%<*psfragx>
% \fi
%
% \part{lwarp-psfragx.sty}
%
% \section{psfragx}
%
% \credits{Pascal Kockaert}
%
% \DescribePackage{psfragx}
% \pkg{psfragx} is patched for use by \pkg{lwarp}.
%
% \changes{v0.61}{2018/10/03}{\pkg{psfragx}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{psfragx}[2012/05/02]
%    \end{macrocode}
%
% A \env{lateximage} captures the modified image from the document.
%    \begin{macrocode}
\def\pfx@includegraphicx#1#2{%
    \begin{lateximage}[(-psfragx-~\packagediagramname)]%
    \mbox{\pfx@overpix{#1}{#2}\endpfx@overpix}%
    \end{lateximage}%
}

\def\@@@overpix[#1]<#2>[#3]#4{%
    \begin{lateximage}[(-psfragx-~\packagediagramname)]%
    \pfx@overpix{#1,ovpfgd={#2},ovpbgd={#3}}{#4}%
}

\def\endoverpix{%
    \endpfx@overpix%
    \end{lateximage}%
}
%    \end{macrocode}
%
% \iffalse
%</psfragx>
% \fi
%
%
%
% \iffalse
%<*pst-eps>
% \fi
%
% \part{lwarp-pst-eps.sty}
%
% \section{pst-eps}
%
% \credits{Herbert Voß}
%
% \DescribePackage{pst-eps}
% \pkg{pst-eps} is patched for use by \pkg{lwarp}.
%
% \changes{v0.59}{2018/09/05}{\pkg{pst-eps}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{pst-eps}[2005/05/20]
%    \end{macrocode}
%
%    \begin{macrocode}
\renewenvironment{TeXtoEPS}{}{}
\renewcommand{\PSTtoEPS}[3][]{}
%    \end{macrocode}
%
% \iffalse
%</pst-eps>
% \fi
%
%
%
%
% \iffalse
%<*pstool>
% \fi
%
% \part{lwarp-pstool.sty}
%
% \section{pstool}
%
% \credits{Zebb Prime, Will Robertson}
%
% \DescribePackage{pstool}
% \pkg{pstool} is patched for use by \pkg{lwarp}.
%
% \changes{v0.61}{2018/10/02}{\pkg{pstool}: Added.}
%
% \limitspstool
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{pstool}[2018/01/20]
%    \end{macrocode}
%
% Each image is placed inside a \env{lateximage} to capture the results of \pkg{psfrag}.
%
%    \begin{macrocode}
\renewcommand\pstool@alwaysprocess[3][]{%
    \begin{lateximage}[(-pstool-~\packagediagramname)]%
    \includegraphics{#2.pdf}%
    \end{lateximage}%
}
\LetLtxMacro\pstool@neverprocess\pstool@alwaysprocess
\LetLtxMacro\pstool@maybeprocess\pstool@alwaysprocess

\renewcommand\pstool@@psfragfig[4]{%
    \begin{lateximage}[(-pstool-~\packagediagramname)]%
    \includegraphics{#2.pdf}%
    \end{lateximage}%
}
%    \end{macrocode}
%
% \iffalse
%</pstool>
% \fi
%
%
%
% \iffalse
%<*pstricks>
% \fi
%
% \part{lwarp-pstricks.sty}
%
% \section{pstricks}
%
% \credits{Timothy Van Zandt}
%
% \DescribePackage{pstricks}
% \pkg{pstricks} is patched for use by \pkg{lwarp}.
%
% \limitspstricks
%
% \changes{v0.59}{2018/09/05}{\pkg{pstricks}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{pstricks}[2018/01/06]
%    \end{macrocode}
%
%    \begin{macrocode}
\BeforeBeginEnvironment{pspicture}{\begin{lateximage}[(pspicture)]}
\AfterEndEnvironment{pspicture}{\end{lateximage}}
%    \end{macrocode}
%
% \iffalse
%</pstricks>
% \fi
%
%
%
%
%
% \iffalse
%<*pxatbegshi>
% \fi
%
% \part{lwarp-pxatbegshi.sty}
%
% \section{pxatbegshi}
%
% \DescribePackage{pxatbegshi}
% \pkg{pxatbegshi} is ignored.
%
% \changes{v0.65}{2018/12/17}{\pkg{pxatbegshi}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pxatbegshi}[2017/11/04]
%    \end{macrocode}
%
%    \begin{macrocode}
\LWR@origRequirePackage{lwarp-atbegshi}
%    \end{macrocode}
%
% \iffalse
%</pxatbegshi>
% \fi
%
%
%
% \iffalse
%<*pxeveryshi>
% \fi
%
% \part{lwarp-pxeveryshi.sty}
%
% \section{pxeveryshi}
%
% \DescribePackage{pxeveryshi}
% \pkg{pxeveryshi} is ignored.
%
% \changes{v0.65}{2018/12/17}{\pkg{pxeveryshi}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pxeveryshi}[2012/05/19]
%    \end{macrocode}
%
%    \begin{macrocode}
\LWR@origRequirePackage{lwarp-everyshi}
%    \end{macrocode}
%
% \iffalse
%</pxeveryshi>
% \fi
%
%
%
%
% \iffalse
%<*pxftnright>
% \fi
%
% \part{lwarp-pxftnright.sty}
%
% \section{pxftnright}
%
% \DescribePackage{pxftnright}
% \pkg{pxftnright} is ignored.
%
% \changes{v0.65}{2018/12/17}{\pkg{pxftnright}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pxftnright}[2017/02/28]
%    \end{macrocode}
%
%    \begin{macrocode}
\LWR@origRequirePackage{lwarp-ftnright}
%    \end{macrocode}
%
% \iffalse
%</pxftnright>
% \fi
%
%
%
%
% \iffalse
%<*pxjahyper>
% \fi
%
% \part{lwarp-pxjahyper.sty}
%
% \section{pxjahyper}
%
% \DescribePackage{pxjahyper}
% \pkg{pxjahyper} is ignored.
%
% \changes{v0.65}{2018/12/15}{\pkg{pxjahyper}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{pxjahyper}[2018/07/15]
%    \end{macrocode}
%
% \iffalse
%</pxjahyper>
% \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}[2012/10/20]
%    \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}
\begin{BlockClass}[max-width: \LWR@printlength{\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/ \\
%	\fqquad\ 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
%<*quoting>
% \fi
%
% \part{lwarp-quoting.sty}

% \section{quoting}
%
% \credits{Thomas Titz}
%
% \DescribePackage{quoting}
% \pkg{quoting} is patched for use by \pkg{lwarp}.
%
% \changes{v0.56}{2018/05/09}{\pkg{quoting}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{quoting}[2014/01/28]
%    \end{macrocode}

%    \begin{macrocode}
\xpatchcmd{\quoting}{\quo@begintext}
    {\begin{LWR@blocktextcurrentfont}\quo@begintext}
    {}
    {\LWR@patcherror{quoting}{quoting}}

\xpatchcmd{\endquoting}{\quo@endtext}
    {\quo@endtext\end{LWR@blocktextcurrentfont}}
    {}
    {\LWR@patcherror{imakeidx}{endquoting}}
%    \end{macrocode}

% \iffalse
%</quoting>
% \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.}
% \changes{v0.54}{2018/04/19}{\pkg{ragged2e}: Fix: \cs{centering}, etc.}
%

% Discard all options for \pkg{lwarp-ragged2e}:

% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{ragged2e}[2009/05/21]
%    \end{macrocode}

%    \begin{macrocode}
\LetLtxMacro\Centering\centering
\LetLtxMacro\RaggedLeft\raggedleft
\LetLtxMacro\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}.}
% \changes{v0.47}{2018/01/26}{\pkg{realscripts}: Fix: Line wrap at \HTML\ hyphen.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{realscripts}[2016/02/13]
%    \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}{%
            \LWR@print@mbox{text-align:center} ; %
        }%
    }{}%
    \ifthenelse{\equal{#1}{r}}{%
        \renewcommand{\LWR@realscriptsalign}{%
            \LWR@print@mbox{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
%<*refcheck>
% \fi
%
% \part{lwarp-refcheck.sty}
%
% \section{refcheck}
%
% \DescribePackage{refcheck}
% \pkg{refcheck} is ignored.
%
% \changes{v0.61}{2018/10/05}{\pkg{refcheck}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{refcheck}[2013/02/14]
%    \end{macrocode}
%
%    \begin{macrocode}
\def\showrefnames{}
\def\norefnames{}
\def\showcitenames{}
\def\nocitenames{}
\def\setonmsgs{}
\def\setoffmsgs{}
\def\checkunlbld{}
\def\ignoreunlbld{}
\newcommand*{\refcheckxrdoc}[2][]{}
%    \end{macrocode}
%
% \iffalse
%</refcheck>
% \fi
%
%
%
% \iffalse
%<*register>
% \fi
%
% \part{lwarp-register.sty}

% \section{register}
%
% \credits{Matthew Lovell}
%
% \DescribePackage{register}
% \pkg{register} is patched for use by \pkg{lwarp}.
%
% \changes{v0.57}{2018/06/03}{\pkg{register}: Added.}
% \changes{v0.62}{2018/11/12}{\pkg{register}: Updated to v1.8.}
% \changes{v0.66}{2019/01/04}{\pkg{register}: Verified for v1.9.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{register}[2019/01/01]
%    \end{macrocode}

%    \begin{macrocode}
\xpatchcmd{\register}
    {\centering}
    {\begin{center}\begin{lateximage}[(-register-~\packagediagramname)]}
    {}
    {\LWR@patcherror{register}{register}}

\xpatchcmd{\endregister}
    {\leftskip}
    {%
        \end{lateximage}\end{center}%
        \leftskip%
    }%
    {}
    {\LWR@patcherror{register}{endregister}}

\expandafter\xapptocmd\csname register*\endcsname
    {\begin{center}\begin{lateximage}[(-register-~\packagediagramname)]}
    {}
    {\LWR@patcherror{register}{register*}}

\expandafter\xpatchcmd\csname endregister*\endcsname
    {\leftskip}
    {%
        \end{lateximage}\end{center}%
        \leftskip%
    }%
    {}
    {\LWR@patcherror{register}{endregister*}}

\setlength{\regWidth}{5in}
%    \end{macrocode}

% \iffalse
%</register>
% \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}[2013/03/29]
%    \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
%<*repeatindex>
% \fi
%
% \part{lwarp-repeatindex.sty}
%
% \section{repeatindex}
%
% \DescribePackage{repeatindex}
% \pkg{repeatindex} is emulated for \pkg{lwarp}.
%
% \pkg{lwarp} must be used with a special style file:
% \trouble[style file]{repeatindex=\pkg{repeatindex}}
% \begin{sourcedisplay}
% \cs{usepackage}[makeindex,\textred{makeindexStyle=\{lwarp\_repeatindex\}}]\{lwarp\}
% \end{sourcedisplay}
% where \filenm{lwarp_repeatindex.ist} may be copied from the following
% modified version of \filenm{lwarp.ist}:
% \begin{Verbatim}[gobble=2,obeytabs,tabsize=4,frame=leftline]
% preamble
% "\\begin{theindex}
%   \\providecommand*\\lettergroupDefault[1]{}
%   \\providecommand*\\lettergroup[1]{%
%       \\par\\textbf{#1}\\par
%       \\nopagebreak
%   }
% "
% headings_flag 1
% heading_prefix "
%   \\lettergroup{"
% heading_suffix "}"
% delim_0 "], \\hyperindexref{"
% delim_1 ", \\hyperindexref{"
% delim_2 ", \\hyperindexref{"
% delim_n "}, \\hyperindexref{"
% delim_r "} -- \\hyperindexref{"
% delim_t "}"
% 
% item_0 "\n  \\item ["
% \end{Verbatim}
% (The modifications are the |delim_0| and |item_0| entries.)
%
% \changes{v0.58}{2018/06/21}{\pkg{repeatindex}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{repeatindex}[2001/10/13]
%    \end{macrocode}
%
% In the \pkg{lwarp} core, \cs{LWR@indexitem} is modified
% to accept the optional \cs{item} argument.
%
%    \begin{macrocode}
\RequirePackage{makeidx}
\def\entryprefix{\itshape}
\def\entrypostfix{\dots}
%    \end{macrocode}
%
% \iffalse
%</repeatindex>
% \fi
%
%
%
%
% \iffalse
%<*resizegather>
% \fi
%
% \part{lwarp-resizegather.sty}
%
% \section{resizegather}
%
% \DescribePackage{resizegather}
% \pkg{resizegather} is ignored.
%
% \changes{v0.49}{2018/02/15}{\pkg{resizegather}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{resizegather}[2016/05/16]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\resizegathersetup}[1]{}
%    \end{macrocode}
%
% \iffalse
%</resizegather>
% \fi
%
%
%
%
%
% \iffalse
%<*rmpage>
% \fi
%
% \part{lwarp-rmpage.sty}
%
% \section{rmpage}
%
% \DescribePackage{rmpage}
% \pkg{rmpage} is ignored.
%
% \changes{v0.64}{2018/12/07}{\pkg{rmpage}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{rmpage}[1997/09/29]
%    \end{macrocode}
%
% \iffalse
%</rmpage>
% \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}[2012/01/01]
%    \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}[2015/02/06]
%    \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}[2016/08/11]
%    \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}[2004/01/04]

\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}%
}%
\csletcs{sideways#1}{#1}%
\csletcs{endsideways#1}{end#1}%
%    \end{macrocode}
% Remember the float style:
% \changes{v0.57}{2018/05/14}{\pkg{rotfloat}: Added float styles.}
%    \begin{macrocode}
\csedef{LWR@floatstyle@#1}{\LWR@floatstyle}%
\csedef{LWR@floatstyle@sideways#1}{\LWR@floatstyle}%
%    \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:
% \changes{v0.57}{2018/05/14}{\pkg{rotfloat}: Fix for listof sideways floats.}
%    \begin{macrocode}
\cslet{listof#1s}\relax%
\cslet{listof#1es}\relax%
\cslet{listofsideways#1s}\relax%
\cslet{listofsideways#1es}\relax%
}
%    \end{macrocode}
% \end{macro}
%
% \iffalse
%</rotfloat>
% \fi
%
%
%
%
%
% \iffalse
%<*rviewport>
% \fi
%
% \part{lwarp-rviewport.sty}
%
% \section{rviewport}
%
% \DescribePackage{rviewport}
% \pkg{rviewport} is honored inside a \env{lateximage}, and
% otherwise ignored for \HTML\ output.
%
% If \pkg{rviewport} is important for an image, enclose the
% image inside a \env{lateximage} environment.
%
% \changes{v0.62}{2018/11/05}{\pkg{rviewport}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{rviewport}[2011/08/27]
%    \end{macrocode}
%
%    \begin{macrocode}
\define@key{igraph}{rviewport}{}
%    \end{macrocode}
%
% \iffalse
%</rviewport>
% \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}[2016/04/13]
%    \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
%<*schemata>
% \fi
%
% \part{lwarp-schemata.sty}

% \section{schemata}
%
% \credits{Charles P. Schaum}
%
% \DescribePackage{schemata}
% \pkg{schemata} is patched for use by \pkg{lwarp}.
%
% \changes{v0.50}{2018/02/23}{\pkg{schemata}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{schemata}[2016/01/25]
%    \end{macrocode}

%    \begin{macrocode}
\LetLtxMacro\LWR@schemata@origschema\schema
\LetLtxMacro\LWR@schemata@origSchema\Schema

\renewcommand{\schema}[3][open]{%
\begin{lateximage}%
\LWR@print@normalsize
\LWR@schemata@origschema[#1]{#2}{#3}%
\end{lateximage}%
}

\renewcommand{\Schema}[5][open]{%
\begin{lateximage}%
\LWR@print@normalsize
\LWR@schemata@origSchema[#1]{#2}{#3}{#4}{#5}%
\end{lateximage}%
}
%    \end{macrocode}

% \iffalse
%</schemata>
% \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.}
% \changes{v0.47}{2018/01/26}{\pkg{scrextend}: Fix: Line wrap at \HTML\ hyphen.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{scrextend}[2018/03/30]
%    \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}{\LWR@print@mbox{text-align:right}}{}{dictum}
    #2
    \IfValueT{#1}
    {
        \ifbool{FormatWP}
        {\begin{BlockClass}[\LWR@print@mbox{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}
{
\setlength{\LWR@templengthtwo}{#3}
\ifblank{#2}
{
    \begin{BlockClass}[
        \LWR@print@mbox{margin-left:\LWR@printlength{\LWR@templengthtwo}} ;
        \LWR@print@mbox{margin-right:\LWR@printlength{\LWR@templengthtwo}}
    ]{addmargin}
}
{
    \setlength{\LWR@templengthone}{#2}
    \begin{BlockClass}[
        \LWR@print@mbox{margin-left:\LWR@printlength{\LWR@templengthone}} ;
        \LWR@print@mbox{margin-right:\LWR@printlength{\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/ \\
%       \fqquad\ 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}[2018/03/30]
%    \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}[2018/03/30]
%    \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}
%    \end{macrocode}
% \changes{v0.64}{2018/12/07}{\pkg{scrlayer}: Fixes.}
%    \begin{macrocode}
\newcommand{\partmarkformat}{}
\if@chapter
\newcommand{\chaptermarkformat}{}
\fi
\newcommand{\sectionmarkformat}{}
\DeclareDocumentCommand{\GenericMarkFormat}{m}{}
%    \end{macrocode}
%    \begin{macrocode}
\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}[2018/02/02]
%    \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}[2018/03/30]
%    \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{\MakeMarkcase}{m}{#1}
\newcommand*{\defpairofpagestyles}[3][]{}
\newcommand*{\newpairofpagestyles}[3][]{}
\newcommand*{\renewpairofpagestyles}[3][]{}
\newcommand*{\providepairofpagestyles}[3][]{}
%    \end{macrocode}
% \changes{v0.64}{2018/12/07}{\pkg{scrlayer-scrpage}: Fixes.}
%    \begin{macrocode}
\newcommand*{\clearmainofpairofpagestyles}{}
\newcommand*{\clearplainofpairofpagestyles}{}
\newcommand*{\clearpairofpagestyles}{}
\newcommand*{\clearscrheadings}{}
\newcommand*{\clearscrheadfoot}{}
\newcommand*{\clearscrplain}{}
%    \end{macrocode}
%    \begin{macrocode}
\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
%<*scrpage2>
% \fi
%
% \part{lwarp-scrpage2.sty}
%
% \section{scrpage2}
%
% \credits{Markus Kohm}
%
% \DescribePackage{scrpage2}
% \pkg{scrpage2} is emulated.
%
% \testthis
%
% \changes{v0.64}{2018/12/07}{\pkg{scrpage2}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{scrpage2}[2018/03/30]
%    \end{macrocode}
%
%    \begin{macrocode}
\@ifundefined{footheight}{\newlength\footheight}{}
\NewDocumentCommand{\lehead}{o m}{}
\NewDocumentCommand{\cehead}{o m}{}
\NewDocumentCommand{\rehead}{o m}{}
\NewDocumentCommand{\lohead}{o m}{}
\NewDocumentCommand{\cohead}{o m}{}
\NewDocumentCommand{\rohead}{o m}{}
\NewDocumentCommand{\lefoot}{o m}{}
\NewDocumentCommand{\cefoot}{o m}{}
\NewDocumentCommand{\refoot}{o m}{}
\NewDocumentCommand{\lofoot}{o m}{}
\NewDocumentCommand{\cofoot}{o m}{}
\NewDocumentCommand{\rofoot}{o m}{}
\NewDocumentCommand{\ohead}{o m}{}
\NewDocumentCommand{\chead}{o m}{}
\NewDocumentCommand{\ihead}{o m}{}
\NewDocumentCommand{\ofoot}{o m}{}
\NewDocumentCommand{\cfoot}{o m}{}
\NewDocumentCommand{\ifoot}{o m}{}
\DeclareDocumentCommand{\automark}{o m}{}
\DeclareDocumentCommand{\manualmark}{}{}
\DeclareDocumentCommand{\MakeMarkcase}{m}{#1}
\NewDocumentCommand{\deftripstyle}{m o o m m m m m m}{}
\NewDocumentCommand{\defpagestyle}{s m m m}{}
\NewDocumentCommand{\newpagestyle}{s m m m}{}
\NewDocumentCommand{\renewpagestyle}{s m m m}{}
\NewDocumentCommand{\providepagestyle}{s m m m}{}
\newcommand{\partmarkformat}{}
\if@chapter
\newcommand{\chaptermarkformat}{}
\fi
\newcommand{\sectionmarkformat}{}
\newcommand{\subsectionmarkformat}{}
\newcommand{\subsubsectionmarkformat}{}
\newcommand{\paragraphmarkformat}{}
\newcommand{\subparagraphmarkformat}{}

\newcommand*{\clearscrheadings}{}
\newcommand*{\clearscrheadfoot}{}
\newcommand*{\clearscrplain}{}
%    \end{macrocode}
%
% \iffalse
%</scrpage2>
% \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
%<*sectionbreak>
% \fi
%
% \part{lwarp-sectionbreak.sty}

% \section{sectionbreak}
%
% \credits{Michal Hoftich}
%
% \DescribePackage{sectionbreak}
% \pkg{sectionbreak} is patched for use by \pkg{lwarp}.
%
% \changes{v0.47}{2018/01/25}{\pkg{sectionbreak}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{sectionbreak}[2018-01-03]
%    \end{macrocode}

%    \begin{macrocode}
\renewcommand\asterism{\HTMLunicode{2042}}

\renewcommand\pre@sectionbreak{}
\renewcommand\post@sectionbreak{}

\renewcommand\print@sectionbreak[1]{%
\begin{center}
#1
\end{center}
}

%    \end{macrocode}

% \iffalse
%</sectionbreak>
% \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}[2002/02/25]
%    \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
%<*semantic-markup>
% \fi
%
% \part{lwarp-semantic-markup.sty}
%
% \section{semantic-markup}
%
% \credits{Andrew A. Cashner}
%
% \DescribePackage{semantic-markup}
% \pkg{semantic-markup} is patched for use by \pkg{lwarp}.
%
% If using the \optn{endnotes} option, add \cs{theendnotes}
% \watchout
% where desired.
%
% \changes{v0.62}{2018/11/12}{\pkg{semantic-markup}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{semantic-markup}[2018/05/21]
%    \end{macrocode}
%
% The endnotes must be printed by the user before the end of the document,
% since the end is after the \HTML\ footer, etc.
%    \begin{macrocode}
\ifendnotes
\RenewDocumentCommand{\SetupEndnotes}{}{%
    \let\footnote=\endnote
%     \AtEndDocument{\DoBeforeEndnotes{\EndnoteFont\theendnotes}}%
}
\fi
%    \end{macrocode}
%
% \HTML\ unicode characters from \pkg{musicography} are used.
%    \begin{macrocode}
\RequirePackage{musicography}

\let\fl\musFlat
\let\sh\musSharp
\let\na\musNatural
%    \end{macrocode}
%
% The \cs{musfig} is placed inside a hashed image,
% with a simple \attribute{alt} tag.
%    \begin{macrocode}
\RequirePackage{amsmath}

\RenewDocumentCommand{\musfig}{ m m }{%
    \LWR@subsingledollar*%
        {#1/#2}% alt tag
        {musfig}% addl' hashing
        {% contents
            \LWR@origensuredmath{%
                \genfrac{}{}{0pt}{1}{\text{#1}}{\text{#2}}%
            }%
        }%
}
%    \end{macrocode}
%
% The \cs{meter} is taken from \pkg{musicography}, and becomes a hashed image
% with a simple \attribute{alt} tag.
%    \begin{macrocode}
\RenewDocumentCommand{\meter}{ m m }{%
    \musMeter{#1}{#2}%
}
%    \end{macrocode}
%
% \iffalse
%</semantic-markup>
% \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}[2011/12/19]

\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}[2003/02/19]
%    \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}[2014/09/29]
%    \end{macrocode}
%
% \cs{@wrindex} is redefined \cs{AtBeginDocument} by the \pkg{lwarp} core.
%
% \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}[2014/10/28]
%    \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}[2003/06/06]
%    \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}:
%
% \begin{noindmacro}{\sidecaption} * \oarg{entry} \oarg{offset} \marg{text}
% \changes{v0.47}{2018/01/30}{\pkg{sidenotes}: Fix for \SVG\ math in captions.}
%    \begin{macrocode}
\RenewDocumentCommand \sidecaption {s o o +m}
{
    \LWR@stoppars
    \begingroup
  \captionsetup{style=sidecaption}
  \IfBooleanTF{#1}
  { % starred
    \begin{BlockClass}[border:none ; box-shadow:none]{marginblock}
    \caption*{#4}
    \end{BlockClass}
  }
  { % unstarred
  \IfNoValueOrEmptyTF{#2}
    {\def\@sidenotes@sidecaption@tof{#4}}
    {\def\@sidenotes@sidecaption@tof{#2}}
    \begin{BlockClass}[border:none ; box-shadow:none]{marginblock}
    \caption[\@sidenotes@sidecaption@tof]{#4}
    \end{BlockClass}
  }
    \endgroup
    \LWR@startpars
}
%    \end{macrocode}
% \end{noindmacro}
%
%
%
% Borrowed from the \pkg{lwarp} version of \pkg{keyfloat}:
% \changes{v0.42}{2017/10/26}{\pkg{sidenotes}: If \progcode{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
%<*SIunits>
% \fi
%
% \part{lwarp-SIunits.sty}
%
% \section{SIunits}
%
% \credits{Marcel Heldoorn}
%
% \DescribePackage{SIunits}
% \pkg{SIunits} is patched for use by \pkg{lwarp}.
%
% It is recommended to use \cs{unit} where possible, which
% combines the entire expression into a single \env{lateximage},
% and adds the \attribute{alt} tag containing the \LaTeX\ code, allowing for
% copy/paste.  When units are used outside of the \cs{unit} macro,
% each unit macro will have its own \env{lateximage},
% and each will have the \attribute{alt} tag set to ``|(|<\cs{mathimagename}>|)|'',
% which defaults to ``|(math image)|''.
%
% \changes{v0.59}{2018/07/11}{\pkg{SIunits}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{SIunits}[2007/12/02]
%    \end{macrocode}
%
% Patched for copy/paste with the \HTML\ \attribute{alt} tag:
%    \begin{macrocode}
\DeclareRobustCommand{\unit}[2]{%
\@inunitcommandtrue%    original
\LWR@subsingledollar*%  lwarp
{% alt tag
    \textbackslash{}unit\{\LWR@HTMLsanitize{#1}\}%
        \{ \LWR@HTMLsanitize{#2}\}% extra space
}%
{SIunits}% add'l hashing
{%
    \LWR@origensuredmath{%  lwarp modification
        \SI@fstyle{#1\@qsk\period@active{#2}}%  original
    }%
}% contents
\@inunitcommandfalse%   original
}
%    \end{macrocode}
%
% \iffalse
%</SIunits>
% \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.}
% \changes{v0.50}{2018/10/23}{\pkg{siunitx}: Fix: Loads \pkg{xcolor}.}
%
% \codehtml
%
%    \begin{macrocode}
\RequirePackage{xcolor}% for \convertcolorspec

\LWR@ProvidesPackagePass{siunitx}[2018/05/17]
%    \end{macrocode}

% \changes{v0.50}{2018/02/24}{\pkg{siunitx}: Improved units.}
%    \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}}
\DeclareSIUnit\planckbar{\LWR@siunitx@textplanckbar}
}% AtBeginDocument
%    \end{macrocode}
%
% \cs{@ensuredmath} is not supported inside an \cs{hbox}, so it must
% temporarily be restored to its original.
% Similar for \cs{mbox}.
% SVG math is created explicitly when necessary, using \cs{LWR@subsingledollar}.
%
% \changes{v0.42}{2017/10/16}{\pkg{siunitx}: Improved \cs{ensuremath}.}
% \changes{v0.48}{2018/02/13}{\pkg{siunitx}: Improved \SVG\ math.}
%    \begin{macrocode}

\ExplSyntaxOn
%
%    \end{macrocode}
% Modified to set set \HTML\ \cs{textcolor} if not black:
% \changes{v0.48}{2018/02/14}{\pkg{siunitx}: Improved color output.}
%    \begin{macrocode}
\cs_undefine:N \__siunitx_print_aux:
\cs_new_protected:Npn \__siunitx_print_aux:
  {
    \text
      {
        \__siunitx_ensure_ltr:n
          {
            \color@begingroup
            \__siunitx_print_color:
            \__siunitx_font_shape:
            \__siunitx_font_weight:
            \use:c
              {
                @@_ \l__siunitx_print_type_tl _
                text \l__siunitx_font_family_tl :
              }
            \bool_if:NTF \l__siunitx_font_math_mode_bool
              { \__siunitx_print_math: }
              {
                \LWR@findcurrenttextcolor% lwarp
                \ifdefstring{\LWR@tempcolor}{000000}% lwarp
                {\__siunitx_print_text:}% lwarp
                {% lwarp
                    \LWR@textcurrentcolor{% lwarp
                        \__siunitx_print_text:
                    }% lwarp
                }% lwarp
              }
            \color@endgroup
          }
      }
  }


\cs_undefine:N \__siunitx_set_math_fam:n
\cs_new_protected:Npn \__siunitx_set_math_fam:n #1 {
  \int_new:c { c__siunitx_math #1 _int }
  \group_begin:% lwarp
    \LetLtxMacro\@ensuredmath\LWR@origensuredmath% lwarp
    \LetLtxMacro\mbox\LWR@print@mbox% lwarp
    \hbox_set:Nn \l__siunitx_tmp_box
      {
        \ensuremath
          {
            \use:c { math #1 }
              {
                \int_gset:cn { c__siunitx_math #1 _int } { \fam }
              }
          }
      }
  \group_end:% lwarp
}

\cs_undefine:N \__siunitx_combined_output:n
\cs_new_protected:Npn \__siunitx_combined_output:n #1 {
    \group_begin:% lwarp
    \LetLtxMacro\@ensuredmath\LWR@origensuredmath% lwarp
    \LetLtxMacro\mbox\LWR@print@mbox% lwarp
  \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:
%    \end{macrocode}
% For |parse-numbers=false|:
% \changes{v0.48}{2018/02/14}{\pkg{siunitx}: Improved \SVG\ math.}
% \changes{v0.50}{2018/02/24}{\pkg{siunitx}: Improved \SVG\ math \attribute{alt} tags.}
%    \begin{macrocode}
%       \__siunitx_print:nn { number } { \ensuremath {#1} }
        \LWR@subsingledollar{% lwarp
            \textbackslash( \LWR@HTMLsanitize{#1} \textbackslash)% lwarp
        }{siunitx}{%
            \__siunitx_print:nn { number } {%
                \LWR@origensuredmath{#1}%
            }%
        }% lwarp
%    \end{macrocode}
%    \begin{macrocode}
      \__siunitx_unit_output_print:
    }
    \group_end:% lwarp
}
%
%    \end{macrocode}
% For quotients, the fraction code is replaced by the symbol code:
% \changes{v0.48}{2018/02/14}{\pkg{siunitx}: Changes fraction to symbol.}
%    \begin{macrocode}
\cs_undefine:N \__siunitx_number_output_quotient_fraction:
\cs_new_protected:Npn \__siunitx_number_output_quotient_fraction: {
  \bool_set_true:N \l__siunitx_number_compound_bool
  \__siunitx_number_output_quotient_aux_i:
  \tl_set_eq:NN \l__siunitx_number_out_tl
    \l__siunitx_number_numerator_tl
  \tl_put_right:NV \l__siunitx_number_out_tl \l__siunitx_output_quotient_tl
  \tl_put_right:NV \l__siunitx_number_out_tl
    \l__siunitx_number_denominator_tl
  \__siunitx_number_output_single_aux:
}
%    \end{macrocode}
% For units, the fraction code is replaced by the symbol code:
% \changes{v0.48}{2018/02/14}{\pkg{siunitx}: Changes fraction to symbol.}
%    \begin{macrocode}
\cs_undefine:N \__siunitx_unit_format_fraction_fraction:
\cs_new_protected:Npn \__siunitx_unit_format_fraction_fraction: {
  \__siunitx_unit_format_fraction_symbol_aux:
  \int_compare:nNnT { \l__siunitx_unit_denominator_int } > { 1 }
    {
      \bool_if:NT \l__siunitx_unit_denominator_bracket_bool
        {
          \tl_put_left:NV \l__siunitx_unit_denominator_tl \l__siunitx_bracket_open_tl
          \tl_put_right:NV \l__siunitx_unit_denominator_tl \l__siunitx_bracket_close_tl
        }
    }
  \tl_set_eq:NN \l__siunitx_unit_tl \l__siunitx_unit_numerator_tl
  \tl_put_right:NV \l__siunitx_unit_tl \l__siunitx_per_symbol_tl
  \tl_put_right:NV \l__siunitx_unit_tl \l__siunitx_unit_denominator_tl
}
%    \end{macrocode}
% \changes{v0.50}{2018/02/24}{\pkg{siunitx}: Improved units.}
%    \begin{macrocode}
\cs_undefine:N \__siunitx_angle_print_astronomy_aux:
\cs_new_protected:Npn \__siunitx_angle_print_astronomy_aux: {
  \prop_get:NnNT \l__siunitx_number_out_prop { mantissa-integer }
    \l__siunitx_tmpa_tl
    { \__siunitx_print:nV { number } \l__siunitx_tmpa_tl }
 \ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}% lwarp
 {% lateximage
  \hbox_set:Nn \l__siunitx_angle_marker_box
    {
      \__siunitx_print:nn { number } { { \l__siunitx_output_decimal_tl } }
    }
  \hbox_set:Nn \l__siunitx_angle_unit_box
    {
      \__siunitx_print:nV { unit } \l__siunitx_unit_tl
      \skip_horizontal:n { -\scriptspace }
    }
  \__siunitx_angle_print_astronomy_aux:n { marker }
  \__siunitx_angle_print_astronomy_aux:n { unit }
  \hbox_set:Nn \l__siunitx_angle_marker_box
    {
      \box_use:N \l__siunitx_angle_marker_box
      \box_use:N \l__siunitx_angle_unit_box
    }
  \dim_compare:nNnTF
    { \l__siunitx_angle_marker_dim } > { \l__siunitx_angle_unit_dim }
    { \__siunitx_angle_print_astronomy_marker: }
    { \__siunitx_angle_print_astronomy_unit: }
 }% lateximage
 {% not a lateximage
      \__siunitx_print:nV { unit } \l__siunitx_unit_tl
      \__siunitx_print:nn { number } { { \l__siunitx_output_decimal_tl } }
 }% not a lateximage
  \prop_get:NnNT \l__siunitx_number_out_prop { mantissa-decimal }
    \l__siunitx_tmpa_tl
    { \__siunitx_print:nV { number } \l__siunitx_tmpa_tl }
}
%    \end{macrocode}
%
%    \begin{macrocode}
\RenewDocumentCommand \num { o m } {
  \leavevmode
  \group_begin:% lwarp
    \LetLtxMacro\@ensuredmath\LWR@origensuredmath% lwarp
    \LetLtxMacro\mbox\LWR@print@mbox% lwarp
    \bool_set_false:N \l__siunitx_font_set_bool
    \IfNoValueF {#1}
      { \keys_set:nn { siunitx } {#1} }
    \__siunitx_number_output:n {#2}
  \group_end:% lwarp
}

\RenewDocumentCommand \numrange { o m m } {
  \leavevmode
  \group_begin:% lwarp
    \LetLtxMacro\@ensuredmath\LWR@origensuredmath% lwarp
    \LetLtxMacro\mbox\LWR@print@mbox% lwarp
    \bool_set_false:N \l__siunitx_font_set_bool
    \IfNoValueF {#1}
      { \keys_set:nn { siunitx } {#1} }
    \__siunitx_range_numbers:nn {#2} {#3}
  \group_end:% lwarp
}

\RenewDocumentCommand \ang { o > { \SplitArgument { 2 } { ; } } m } {
  \group_begin:% lwarp
    \LetLtxMacro\@ensuredmath\LWR@origensuredmath% lwarp
    \LetLtxMacro\mbox\LWR@print@mbox% lwarp
    \IfNoValueF {#1}
      { \keys_set:nn { siunitx } {#1} }
    \__siunitx_angle_output:nnn #2
  \group_end:% lwarp
}

\RenewDocumentCommand \si { o m } {
  \leavevmode
  \group_begin:% lwarp
    \LetLtxMacro\@ensuredmath\LWR@origensuredmath% lwarp
    \LetLtxMacro\mbox\LWR@print@mbox% lwarp
    \bool_set_false:N \l__siunitx_font_set_bool
    \IfNoValueTF {#1}
      { \__siunitx_unit_output:nn {#2} { } }
      {
        \keys_set:nn { siunitx } {#1}
        \__siunitx_unit_output:nn {#2} {#1}
      }
  \group_end:% lwarp
}


\RenewDocumentCommand{\SIrange}{o m m m}
{%
  \leavevmode
  \group_begin:% lwarp
    \LetLtxMacro\@ensuredmath\LWR@origensuredmath% lwarp
    \LetLtxMacro\mbox\LWR@print@mbox% lwarp
    \bool_set_false:N \l__siunitx_font_set_bool
    \IfNoValueTF {#1}
      { \__siunitx_range_unit:nnnn {#4} { } {#2} {#3} }
      {
        \keys_set:nn { siunitx } {#1}
        \__siunitx_range_unit:nnnn {#4} {#1} {#2} {#3}
      }
  \group_end:% lwarp
}

\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 \progcode{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]{%
\InlineClass(letter-spacing:.2ex){letterspacing}{#1}%
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\caps} \marg{text}
%    \begin{macrocode}
\newcommand{\caps}[1]{%
    \InlineClass%
        (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}%
{%
    \InlineClass(#5){#3}{#1}%
}%
{%
    \convertcolorspec{named}{\@nameuse{#2}}{HTML}\LWR@tempcolor%
    \LWR@htmlspanclass[#5;#4:\LWR@origpound\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: auto;}%
}

\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:\LWR@origpound{}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}[2012/02/25]
%    \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 \UTF-8 encoding.
%
% \changes{v0.44}{2017/11/10}{\pkg{soulutf8}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{soulutf8}[2016/05/16]
%    \end{macrocode}
%
%
% \iffalse
%</soulutf8>
% \fi
%
%
%
%
% \iffalse
%<*splitidx>
% \fi
%
% \part{lwarp-splitidx.sty}
%
% \section{splitidx}
% \label{sec:splitidx}
%
% \credits{Markus Kohm}
%
% \DescribePackage{splitidx}
% \pkg{splitidx} is patched for use by \pkg{lwarp}.
%
% \limitssplitidx
%
% \changes{v0.58}{2018/06/30}{\pkg{splitidx}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{splitidx}[2016/02/18]
%    \end{macrocode}
%
%    \begin{macrocode}
\catcode`\_=12%
\xpatchcmd{\newindex}
    {\jobname-#2.idx}
    {\jobname-#2_html.idx}
    {}
    {\LWR@patcherror{splitidx}{@newindex}}
\catcode`\_=8%
%    \end{macrocode}
%
% Patched to use \pkg{lwarp}'s automatic indexing counter instead of \cs{thepage}:
%    \begin{macrocode}
\renewcommand*{\@wrsindex}[2][]{%
  \ifx\relax#1\relax
    \if@splitidx
      \@wrsindex[idx]{#2}%
    \else
      \def\@tempa{#2}%
      \if@verbindex\@onelevel@sanitize\@tempa\fi
      \@wrindex{\@tempa}%
    \fi
  \else
    \def\@tempa{#2}%
    \csname index@#1@hook\endcsname
%     \expandafter\ifx\csname @@wrsindex\endcsname\relax
    \addtocounter{LWR@autoindex}{1}%                    lwarp
    \LWR@new@label{LWRindex-\arabic{LWR@autoindex}}%    lwarp
%       \@@@wrsindex{#1}{{\@tempa}{\thepage}}%
      \@@@wrsindex{#1}{{\@tempa}{\arabic{LWR@autoindex}}}%
%     \else
%       \def\@tempb{\@@wrsindex{#1}}%
%       \expandafter\@tempb\@tempa||\\%
%     \fi
    \endgroup
    \@esphack
  \fi
}
%    \end{macrocode}
%
% \pkg{lwarp} defines sectioning commands with \pkg{xparse},
% so the below patches are done as temporary redefinitions instead of being \cs{let}.
%    \begin{macrocode}
\xpatchcmd{\printsubindex}
    {\let\section\subsection}
    {\renewcommand*{\section}{\subsection}}
    {}
    {\LWR@patcherror{splitidx}{printsubindex-section}}

\xpatchcmd{\printsubindex}
    {\let\chapter\section}
    {\renewcommand*{\chapter}{\section}}
    {}
    {\LWR@patcherror{splitidx}{printsubindex-chapter}}

\xpatchcmd{\printsubindex}
    {\let\@makechapterhead\section}
    {\def\@makechapterhead{\section}}
    {}
    {\LWR@patcherror{splitidx}{printsubindex-chapter}}
%    \end{macrocode}
%
% \iffalse
%</splitidx>
% \fi
%
%
%
%
% \iffalse
%<*srcltx>
% \fi
%
% \part{lwarp-srcltx.sty}
%
% \section{srcltx}
%
% \DescribePackage{srcltx}
% \pkg{srcltx} is ignored.
%
% \changes{v0.61}{2018/10/05}{\pkg{srcltx}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{srcltx}[2006/11/12]
%    \end{macrocode}
%
%    \begin{macrocode}
\newif\ifSRCOK \SRCOKfalse
\newcommand*\srcIncludeHook[1]{}
\newcommand*\srcInputHook[1]{}
\newcommand*\MainFile{}
\def\MainFile{\jobname.tex}
\newcommand*\CurrentInput{}
\gdef\CurrentInput{\MainFile}
\newcommand\Input{}
\let\Input\input
%    \end{macrocode}
%
% \iffalse
%</srcltx>
% \fi
%
%
%
%
% \iffalse
%<*srctex>
% \fi
%
% \part{lwarp-srctex.sty}
%
% \section{srctex}
%
% \DescribePackage{srctex}
% \pkg{srctex} is ignored.
%
% \changes{v0.61}{2018/10/05}{\pkg{srctex}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{srctex}[2006/11/12]
\LWR@origRequirePackage{lwarp-srcltx}
%    \end{macrocode}
%
% \iffalse
%</srctex>
% \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}[2014/03/20]
%    \end{macrocode}
%
% \oarg{vpos} \marg{colspec}
% \marginpar{\hfill {\footnotesize Env} \env{stabular}}
%    \begin{macrocode}
\newenvironment{stabular}[2][c]
{
\begin{tabular}[#1]{#2}
\renewcommand{\noalign}[1]{}
}
{\end{tabular}}
%    \end{macrocode}
%
% \marg{width} \oarg{vpos} \marg{colspec}
% \marginpar{\hfill {\footnotesize Env} \env{stabular}}
%    \begin{macrocode}
\NewDocumentEnvironment{stabular*}{m o m}
{
\begin{tabular}[#2]{#3}
\renewcommand{\noalign}[1]{}
}
{\end{tabular}}
%    \end{macrocode}
%
% \iffalse
%</stabular>
% \fi
%
%
%
%
%
%
% \iffalse
%<*stfloats>
% \fi
%
% \part{lwarp-stfloats.sty}
%
% \section{stfloats}
%
% \DescribePackage{stfloats}
% \pkg{stfloats} is ignored.
%
% \changes{v0.48}{2018/02/07}{\pkg{stfloats}: Added.}
% \changes{v0.63}{2018/11/24}{\pkg{stfloats}: Adapted to \pkg{ltj*} classes.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{stfloats}[2017/03/27]
%    \end{macrocode}
%
% \pkg{stfloats} may have been preloaded by a \pkg{ltj*} class.
%
% The following are provided in case they have not yet been defined:
%    \begin{macrocode}
\providecommand*{\fnbelowfloat}{}
\providecommand*{\fnunderfloat}{}
\providecommand*{\setbaselinefloat}{}
\providecommand*{\setbaselinefixed}{}
%    \end{macrocode}
%
% Nullified for \HTML:
%    \begin{macrocode}
\renewcommand*{\fnbelowfloat}{}
\renewcommand*{\fnunderfloat}{}
\renewcommand*{\setbaselinefloat}{}
\renewcommand*{\setbaselinefixed}{}
%    \end{macrocode}
%
% \iffalse
%</stfloats>
% \fi
%
%
%
%
%
% \iffalse
%<*struktex>
% \fi
%
% \part{lwarp-struktex.sty}
%
% \section{struktex}
%
% \credits{Jobst Hoffmann}
%
% \DescribePackage{struktex}
% \pkg{struktex} is patched for use by \pkg{lwarp}.
%
% \changes{v0.67}{2019/02/17}{\pkg{struktex}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{struktex}[2018/06/04]
%    \end{macrocode}
%
%    \begin{macrocode}
\BeforeBeginEnvironment{struktogramm}{\begin{lateximage}[(struktogramm)]}
\AfterEndEnvironment{struktogramm}{\end{lateximage}}

\newenvironment{LWR@HTML@centernss}{\begin{center}}{\end{center}}
\LWR@formattedenv{centernss}

\newcommand{\LWR@HTML@CenterNssFile}[1]{%
    \begin{center}
    \input{#1.nss}
    \end{center}
}
\LWR@formatted{CenterNssFile}

\newcommand{\LWR@HTML@centernssfile}{\LWR@HTML@CenterNssFile}
\LWR@formatted{centernssfile}
%    \end{macrocode}
%
% \iffalse
%</struktex>
% \fi
%
%
%
%
% \iffalse
%<*subcaption>
% \fi
%
% \part{lwarp-subcaption.sty}
%
% \section{subcaption}
%
% \credits{Axel Sommerfeldt}
%
% \DescribePackage{subcaption}
% \pkg{subcaption} is patched for use by \pkg{lwarp}.
%
% \changes{v0.66}{2018/12/31}{\pkg{subcaption}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{subcaption}[2018/05/01]
%    \end{macrocode}
%
% Tells \pkg{lwarp} to ignore minipage widths inside a subfigure or subtable.
% In print mode the minipages are used to place the items next to each other.
% In \HTML\ they are placed side-by-side automatically.
%    \begin{macrocode}
\ifdef{\subcaption@minipage}{
    \xpatchcmd{\subcaption@minipage}
        {\minipage}
        {\minipagefullwidth\minipage}
        {}
        {\LWR@patcherror{subcaption}{subcaption@minipage}}
}{}
%    \end{macrocode}
%
% Likewise for a \cs{subcaptionbox}:
%    \begin{macrocode}
\ifdef{\subcaptionbox}{
    \xpretocmd{\subcaptionbox}
        {\minipagefullwidth}
        {}
        {\LWR@patcherror{subcaption}{subcaptionbox}}
}{}
%    \end{macrocode}
%
% \iffalse
%</subcaption>
% \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}[2005/06/28]
%    \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}% lwarp
%    \end{macrocode}
% \changes{v0.47}{2018/01/30}{\pkg{subfig}: Fix: Support \cs{nameref}.}
%    \begin{macrocode}
\IfValueTF{#2}{%
    \LWR@setlatestname{#2}%
}{%
    \IfValueTF{#3}{%
        \LWR@setlatestname{#3}%
    }{}%
}%
\LWR@stoppars% lwarp
    \@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
%    \end{macrocode}
% \changes{v0.47}{2018/01/30}{\pkg{subfig}: Fix for \SVG\ math in captions.}
%    \begin{macrocode}
%     \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}%
%    \end{macrocode}
% Do not use boxes, which interfere with |lateximage|s:
% \changes{v0.45}{2018/01/12}{\pkg{subfig}: Fix: Math in subcaptions.}
%    \begin{macrocode}
%     \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% lwarp
% 			\box\@tempboxa
            #4
            \LWR@stoppars% lwarp
        }{%
        \LWR@startpars% lwarp
        \@ifundefined{FBsc@max}%
            {
% 				\box\@tempboxa
                #4
            }%
            {\ifx\FBsuboheight\relax
%                \box\@tempboxa
                #4
             \else
%                \vbox to \FBsuboheight{\FBafil\box\@tempboxa\FBbfil}%
                #4
             \fi}%
        \LWR@stoppars% lwarp
          \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}% lwarp
\LWR@startpars% lwarp
  \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% lwarp
  \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}% lwarp
            \LWR@figcaption% lwarp
            \caption@make
                {\@nameuse{sub\@captype name}}%
                {\@nameuse{thesub\@captype}}%
                {\LWR@isolate{#3}}%
%    \end{macrocode}
% \changes{v0.45}{2017/12/18}{\pkg{subfig}: Fix for subcaption end tag.}
%    \begin{macrocode}
            \endLWR@figcaption% lwarp
\LWR@traceinfo{sfsubcap B2}% lwarp
% 			}%
        }%
        {\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}% lwarp
               \caption@make
                   {\@nameuse{sub\@captype name}}%
                   {\@nameuse{thesub\@captype}}%
                   {#3}
\LWR@traceinfo{sfsubcap C1}% lwarp
% 			}%
%              \hss

% 			}
%           }
        }%
  \egroup
\LWR@startpars% lwarp
}
%    \end{macrocode}
% \end{noindmacro}



% \begin{noindmacro}{\subfloat@label}
% Patches for \cs{sf@sub@label}:
%    \begin{macrocode}
\def\subfloat@label{%
\LWR@ensuredoingapar% lwarp
  \@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@orig@pageref{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
%<*subfigure>
% \fi
%
% \part{lwarp-subfigure.sty}
%
% \section{subfigure}
%
% \DescribePackage{subfigure}
% \pkg{subfigure} is emulated by \pkg{subfig}.
%
% \changes{v0.45}{2017/12/02}{\pkg{subfigure}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{subfigure}[2002/03/15]
\RequirePackage{subfig}
%    \end{macrocode}
%
%    \begin{macrocode}
\LetLtxMacro\subfigure\subfloat
\LetLtxMacro\subtable\subfloat
\LetLtxMacro\Subref\subref
\@ifundefined{figuretopcaptrue}{\newif\iffiguretopcap}{}
\newif\ifsubfiguretopcap
\newif\ifsubcaphang
\newif\ifsubcapcenter
\newif\ifsubcapcenterlast
\newif\ifsubcapnooneline
\newif\ifsubcapraggedright
\newskip\subfigtopskip
\newskip\subfigcapskip
\newdimen\subfigcaptopadj
\newskip\subfigbottomskip
\newdimen\subfigcapmargin
\newskip\subfiglabelskip
\newcommand*{\subcapsize}{}
\newcommand*{\subcaplabelfont}{}
\newcommand*{\subcapfont}{}
%    \end{macrocode}
%
% \iffalse
%</subfigure>
% \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}[2004/02/20]
%    \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}%
}
%    \end{macrocode}
% \changes{v0.61}{2018/10/05}{\pkg{supertabular}: Fix for caption w/o opt arg.}
%    \begin{macrocode}
\newcommand{\tablecaption}[2][]{%
    \long\gdef\LWRST@caption{%
        \ifblank{#1}%
            {\caption{#2}}%
            {\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}%
\begin{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}%
\end{table}%
\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}[2017/06/30]
%    \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}[2016/02/03]
%    \end{macrocode}

%    \begin{macrocode}
\DeclareDocumentEnvironment{tabularx}{m o m}
{\tabular{#3}}
{\endtabular}

\DeclareDocumentEnvironment{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}[2014/06/11]
%    \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
%<*tascmac>
% \fi
%
% \part{lwarp-tascmac.sty}
%
% \section{tascmac}
%
% \DescribePackage{tascmac}
% \pkg{tascmac} is ignored.
%
% \changes{v0.65}{2018/12/21}{\pkg{tascmac}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{tascmac}[2018/03/09]
%    \end{macrocode}
%
%    \begin{macrocode}
\newenvironment*{boxnote}
    {
        \BlockClass[
            padding: .5ex ;
            border: 1px solid black ;
            border-top: 1px dashed black ;
        ]{boxnote}
    }
    {\endBlockClass}

\newenvironment*{screen}[1][]
    {
        \BlockClass[
            padding: .5ex ;
            border: 1px solid gray ;
            border-radius: 8pt
        ]{boxnote}
    }
    {\endBlockClass}

\newenvironment*{itembox}[2][]
    {
        \BlockClass[
            padding: .5ex ;
            border: 1px solid gray ;
            border-radius: 8pt
        ]{boxnote}
        \InlineClass{itemboxtitle}{#2}\par
    }
    {\endBlockClass}

\newenvironment*{shadebox}
    {
        \BlockClass[
            padding: .5ex ;
            border: 1px solid black ;
            box-shadow: 3px 3px 3px \#808080 ;
        ]{boxnote}
    }
    {\endBlockClass}

\newcommand*{\mask}[2]{%
    \InlineClass[background: lightgray]{mask}{#1}%
}

\newcommand*{\maskbox}[5]{%
    \InlineClass[background: lightgray]{mask}{#5}%
}

\newcommand*{\Maskbox}[6]{%
    \InlineClass[
        background: lightgray ;
        border: #5 solid black
    ]{mask}{#6}%
}

\newcommand*{\keytop}[2][]{%
    \InlineClass[%
        padding: .2ex ;
        border: 1px solid black ;
        border-radius: .7ex ;
    ]{keytop}{#2}%
}

\def\yen{\HTMLunicode{00A5}}

\def\return{\HTMLunicode{23CE}}

\def\Return{\HTMLunicode{23CE}}

\def\ascii{ASCII Corporation}

\def\Ascii{ASCII Corporation}

\def\ASCII{ASCII Corporation}
%    \end{macrocode}
%
% \iffalse
%</tascmac>
% \fi
%
%
%
%
%
% \iffalse
%<*textarea>
% \fi
%
% \part{lwarp-textarea.sty}
%
% \section{textarea}
%
% \credits{Alexander I. Rozhenko}
%
% \DescribePackage{textarea}
% \pkg{textarea} is ignored.
%
% \changes{v0.39}{2017/08/27}{\pkg{textarea}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{textarea}[2005/12/26]
%    \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}.}
% \changes{v0.54}{2018/04/08}{\pkg{textcomp}: Fix for \cs{textperthousand}.}
% \changes{v0.58}{2018/06/07}{\pkg{textcomp}: Improved print/\HTML\ output selection.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{textcomp}[2017/04/05]
%    \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% pdflatex or dvi latex
\newcommand*{\LWR@HTML@textdegree}{\HTMLentity{deg}}
\newcommand*{\LWR@HTML@textcelsius}{\HTMLunicode{2103}}
\newcommand*{\LWR@HTML@textohm}{\HTMLunicode{2126}}
\newcommand*{\LWR@HTML@textmu}{\HTMLunicode{00B5}}
\newcommand*{\LWR@HTML@textlquill}{\HTMLunicode{2045}}
\newcommand*{\LWR@HTML@textrquill}{\HTMLunicode{2046}}
\newcommand*{\LWR@HTML@textcircledP}{\HTMLunicode{2117}}
\newcommand*{\LWR@HTML@texttwelveudash}{\HTMLunicode{2014}}% emdash
\newcommand*{\LWR@HTML@textthreequartersemdash}{\HTMLunicode{2014}}% emdash
\newcommand*{\LWR@HTML@textmho}{\HTMLunicode{2127}}
\newcommand*{\LWR@HTML@textnaira}{\HTMLunicode{20A6}}
\newcommand*{\LWR@HTML@textpeso}{\HTMLunicode{20B1}}
\newcommand*{\LWR@HTML@textrecipe}{\HTMLunicode{211E}}
\newcommand*{\LWR@HTML@textinterrobangdown}{\HTMLunicode{2E18}}
\newcommand*{\LWR@HTML@textperthousand}{\HTMLunicode{2030}}
\newcommand*{\LWR@HTML@textpertenthousand}{\HTMLunicode{2031}}
\newcommand*{\LWR@HTML@textbaht}{\HTMLunicode{0E3F}}
\newcommand*{\LWR@HTML@textdiscount}{\%}
\newcommand*{\LWR@HTML@textservicemark}{\HTMLunicode{2120}}
\else
%    \end{macrocode}
%
% \subsubsection{\XeLaTeX\ and \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}
\newcommand*{\LWR@HTML@textdegree}{°}
\newcommand*{\LWR@HTML@textcelsius}{℃}
\newcommand*{\LWR@HTML@textohm}{Ω}
\newcommand*{\LWR@HTML@textmu}{µ}
\newcommand*{\LWR@HTML@textlquill}{⁅}
\newcommand*{\LWR@HTML@textrquill}{⁆}
\newcommand*{\LWR@HTML@textcircledP}{℗}
\newcommand*{\LWR@HTML@texttwelveudash}{—}% emdash
\newcommand*{\LWR@HTML@textthreequartersemdash}{—}% emdash
\newcommand*{\LWR@HTML@textmho}{℧}
\newcommand*{\LWR@HTML@textnaira}{₦}
\newcommand*{\LWR@HTML@textpeso}{₱}
\newcommand*{\LWR@HTML@textrecipe}{℞}
\newcommand*{\LWR@HTML@textinterrobangdown}{⸘}
\newcommand*{\LWR@HTML@textperthousand}{‰}
\newcommand*{\LWR@HTML@textpertenthousand}{‱}
\newcommand*{\LWR@HTML@textbaht}{฿}
\newcommand*{\LWR@HTML@textdiscount}{\%}
\newcommand*{\LWR@HTML@textservicemark}{℠}
\fi

\LWR@formatted{textdegree}
\LWR@formatted{textcelsius}
\LWR@formatted{textohm}
\LWR@formatted{textmu}
\LWR@formatted{textlquill}
\LWR@formatted{textrquill}
\LWR@formatted{textcircledP}
\LWR@formatted{texttwelveudash}
\LWR@formatted{textthreequartersemdash}
\LWR@formatted{textmho}
\LWR@formatted{textnaira}
\LWR@formatted{textpeso}
\LWR@formatted{textrecipe}
\LWR@formatted{textinterrobangdown}
\LWR@formatted{textperthousand}
\LWR@formatted{textpertenthousand}
\LWR@formatted{textbaht}
\LWR@formatted{textdiscount}
\LWR@formatted{textservicemark}
%    \end{macrocode}
%
%
% \subsection{\HTML\ diacritics}
%
% For \HTML, Unicode diacritical marks are used:
%    \begin{macrocode}
\newcommand*{\LWR@HTML@capitalcedilla}[1]{#1\HTMLunicode{0327}}
\newcommand*{\LWR@HTML@capitalogonek}[1]{#1\HTMLunicode{0328}}
\newcommand*{\LWR@HTML@capitalgrave}[1]{#1\HTMLunicode{0300}}
\newcommand*{\LWR@HTML@capitalacute}[1]{#1\HTMLunicode{0301}}
\newcommand*{\LWR@HTML@capitalcircumflex}[1]{#1\HTMLunicode{0302}}
\newcommand*{\LWR@HTML@capitaltilde}[1]{#1\HTMLunicode{0303}}
\newcommand*{\LWR@HTML@capitaldieresis}[1]{#1\HTMLunicode{0308}}
\newcommand*{\LWR@HTML@capitalhungarumlaut}[1]{#1\HTMLunicode{30B}}
\newcommand*{\LWR@HTML@capitalring}[1]{#1\HTMLunicode{30A}}
\newcommand*{\LWR@HTML@capitalcaron}[1]{#1\HTMLunicode{30C}}
\newcommand*{\LWR@HTML@capitalbreve}[1]{#1\HTMLunicode{306}}
\newcommand*{\LWR@HTML@capitalmacron}[1]{#1\HTMLunicode{304}}
\newcommand*{\LWR@HTML@capitaldotaccent}[1]{#1\HTMLunicode{307}}
%    \end{macrocode}
% \cs{textcircled} becomes a span with a rounded border.
% \cs{providecommand} is used to avoid conflict with \pkg{xunicode}.
% \changes{v0.62}{2018/11/17}{\pkg{textcomp}: Fix conflict with \pkg{xunicode}.}
%    \begin{macrocode}
\providecommand*{\LWR@HTML@textcircled}[1]{%
\InlineClass[border: 1px solid \LWR@currenttextcolor]{textcircled}{#1}%
}

\LWR@formatted{capitalcedilla}
\LWR@formatted{capitalogonek}
\LWR@formatted{capitalgrave}
\LWR@formatted{capitalacute}
\LWR@formatted{capitalcircumflex}
\LWR@formatted{capitaltilde}
\LWR@formatted{capitaldieresis}
\LWR@formatted{capitalhungarumlaut}
\LWR@formatted{capitalring}
\LWR@formatted{capitalcaron}
\LWR@formatted{capitalbreve}
\LWR@formatted{capitalmacron}
\LWR@formatted{capitaldotaccent}
\LWR@formatted{textcircled}
%    \end{macrocode}
% Nullify \pkg{textcomp} macros when generating filenames:
% \changes{v0.67}{2019/02/13}{\pkg{textcomp}: Nullify in filenames.}
%    \begin{macrocode}
\FilenameNullify{%
    \renewcommand*{\textdegree}{}%
    \renewcommand*{\textcelsius}{}%
    \renewcommand*{\textohm}{}%
    \renewcommand*{\textmu}{}%
    \renewcommand*{\textlquill}{}%
    \renewcommand*{\textrquill}{}%
    \renewcommand*{\textcircledP}{}%
    \renewcommand*{\texttwelveudash}{}%
    \renewcommand*{\textthreequartersemdash}{}%
    \renewcommand*{\textmho}{}%
    \renewcommand*{\textnaira}{}%
    \renewcommand*{\textpeso}{}%
    \renewcommand*{\textrecipe}{}%
    \renewcommand*{\textinterrobangdown}{}%
    \renewcommand*{\textperthousand}{}%
    \renewcommand*{\textpertenthousand}{}%
    \renewcommand*{\textbaht}{}%
    \renewcommand*{\textdiscount}{}%
    \renewcommand*{\textservicemark}{}%
    \renewcommand*{\textcircled}[1]{#1}%
    \renewcommand*{\capitalcedilla}[1]{#1}%
    \renewcommand*{\capitalogonek}[1]{#1}%
    \renewcommand*{\capitalgrave}[1]{#1}%
    \renewcommand*{\capitalacute}[1]{#1}%
    \renewcommand*{\capitalcircumflex}[1]{#1}%
    \renewcommand*{\capitaltilde}[1]{#1}%
    \renewcommand*{\capitaldieresis}[1]{#1}%
    \renewcommand*{\capitalhungarumlaut}[1]{#1}%
    \renewcommand*{\capitalring}[1]{#1}%
    \renewcommand*{\capitalcaron}[1]{#1}%
    \renewcommand*{\capitalbreve}[1]{#1}%
    \renewcommand*{\capitalmacron}[1]{#1}%
    \renewcommand*{\capitaldotaccent}[1]{#1}%
}% FilenameNullify

}% AtBeginDocument
%    \end{macrocode}
%
%
%
% \iffalse
%</textcomp>
% \fi
%
%
%
%
%
%
% \iffalse
%<*textfit>
% \fi
%
% \part{lwarp-textfit.sty}
%
% \section{textfit}
%
% \DescribePackage{textfit}
% \pkg{textfit} is emulated.
%
% Text is placed into a \element{span} of class \attribute{textfit}.
% Sizes are approximated, and also limited by browser min/max font-size settings.
%
% \changes{v0.45}{2017/12/24}{\pkg{textfit}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{textfit}[1994/04/15]
%    \end{macrocode}
%
%    \begin{macrocode}
\newsavebox{\LWR@textfitbox}

\newcommand*{\LWR@textfitscale}[2]{%
\setlength{\LWR@templengthone}{#1}%
\setlength{\LWR@templengthone}{%
    1em*\ratio{\LWR@templengthone}{\LWR@templengthtwo}%
}%
\InlineClass[font-size:\LWR@printlength{\LWR@templengthone}]{textfit}{#2}%
}

\newcommand*{\scaletowidth}[2]{%
\sbox{\LWR@textfitbox}{#2}%
\settowidth{\LWR@templengthtwo}{\usebox{\LWR@textfitbox}}%
\LWR@textfitscale{#1}{#2}%
}

\newcommand*{\scaletoheight}[2]{%
\sbox{\LWR@textfitbox}{#2}%
\settoheight{\LWR@templengthtwo}{\usebox{\LWR@textfitbox}}%
\LWR@textfitscale{#1}{#2}%
}
%    \end{macrocode}
%
% \iffalse
%</textfit>
% \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}[2016/06/07]
%    \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 \Dash \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}[2014/10/28]
%    \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}% lwarp
          }%
      {%
          \theorem@style{#1}%
          \renewcommand{\LWR@newtheoremstyle}{#1}% lwarp
      }%
      \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}% lwarp
    \@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{\@nameuse{LWR@thmstyle#1}}}% lwarp
   }}

\gdef\@ynthm#1#2{%
    \expandafter\@ifdefinable\csname #1\endcsname
   {
    \csedef{LWR@thmstyle#1}{\LWR@newtheoremstyle}% lwarp
    \@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{\@nameuse{LWR@thmstyle#1}}}% lwarp
   }}

\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}% lwarp
    \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{\@nameuse{LWR@thmstyle#1}}}% lwarp
    }%
  \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|.
% \changes{v0.46}{2018/01/22}{\pkg{theorem}: Adapt to \env{trivlist} changes.}
%    \begin{macrocode}
\gdef\th@plain{%
  \def\@begintheorem##1##2{%
        \item[
            \InlineClass{theoremheader}{##1\ ##2}
        ]
    }%
\def\@opargbegintheorem##1##2##3{%
   \item[
        \InlineClass{theoremheader}{##1\ ##2\ (##3)}
    ]
    }
}

\gdef\th@break{%
  \def\@begintheorem##1##2{%
    \item[
        \InlineClass{theoremheader}{##1\ ##2}\newline%
    ]
    }%
\def\@opargbegintheorem##1##2##3{%
  \item[
        \InlineClass{theoremheader}{##1\ ##2\ (##3)}\newline
    ]
    }
}

\gdef\th@marginbreak{%
  \def\@begintheorem##1##2{
    \item[
        \InlineClass{theoremheader}{##2	\qquad ##1}\newline
    ]
    }%
\def\@opargbegintheorem##1##2##3{%
    \item[
        \InlineClass{theoremheader}{##2	\qquad ##1\ %
        (##3)}\newline
    ]
    }
}

\gdef\th@changebreak{%
  \def\@begintheorem##1##2{
    \item[
        \InlineClass{theoremheader}{##2\ ##1}\newline
    ]
    }%
\def\@opargbegintheorem##1##2##3{%
    \item[
        \InlineClass{theoremheader}{ ##2\ ##1\ %
        (##3)}\newline
    ]
    }
}

\gdef\th@change{%
  \def\@begintheorem##1##2{
    \item[
        \InlineClass{theoremheader}{##2\ ##1}
    ]
    }%
\def\@opargbegintheorem##1##2##3{%
    \item[
        \InlineClass{theoremheader}{##2\ ##1\ (##3)}
    ]
    }
}

\gdef\th@margin{%
  \def\@begintheorem##1##2{
    \item[
        \InlineClass{theoremheader}{##2 \qquad ##1}
    ]
    }%
\def\@opargbegintheorem##1##2##3{%
    \item[
            \InlineClass{theoremheader}{##2 \qquad ##1\ (##3)}
    ]
    }
}
%    \end{macrocode}
%
% Patched for \CSS:
% \changes{v0.46}{2018/01/22}{\pkg{theorem}: Adapt to \env{trivlist} changes.}
%    \begin{macrocode}
\gdef\@thm#1#2{\refstepcounter{#1}%
\LWR@forcenewpage% lwarp
    \BlockClass{theorembody\LWR@thisthmstyle}% lwarp
   \trivlist
   \@topsep \theorempreskipamount               % used by first \item
   \@topsepadd \theorempostskipamount           % used by \@endparenv
   \@ifnextchar [%
   {\@ythm{#1}{#2}}%
   {\@begintheorem{#2}{\csname the#1\endcsname}\ignorespaces}}

\gdef\@endtheorem{%
\endtrivlist
\endBlockClass
}
%    \end{macrocode}
%
% \iffalse
%</theorem>
% \fi
%
%
%
% \iffalse
%<*thinsp>
% \fi
%
% \part{lwarp-thinsp.sty}
%
% \section{thinsp}
%
% \DescribePackage{thinsp}
% \pkg{thinsp} is emulated.
%
% \changes{v0.61}{2018/08/23}{\pkg{thinsp}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{thinsp}[2016/10/02]
%    \end{macrocode}
%
%    \begin{macrocode}
\AtBeginDocument{
\let\thinthinspace\relax% defined by some packages
\newcommand*{\thinthinspace}{\thinspace}
}

\newcommand*{\stretchthinspace}{\thinspace}
\newcommand*{\stretchthinthinspace}{\thinthinspace}
\newcommand*{\stretchnegthinspace}{\negthinspace}
%    \end{macrocode}
%
% \iffalse
%</thinsp>
% \fi
%
%
%
% \iffalse
%<*threadcol>
% \fi
%
% \part{lwarp-threadcol.sty}
%
% \section{threadcol}
%
% \DescribePackage{threadcol}
% \pkg{threadcol} is ignored.
%
% \changes{v0.61}{2018/09/23}{\pkg{threadcol}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{threadcol}[2013/01/06]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\setthreadname}[1]{}
%    \end{macrocode}
%
% \iffalse
%</threadcol>
% \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}[2003/06/13]
%    \end{macrocode}


% ^^A Broken:
% ^^A % \begin{noindmacro}{\LWR@printtablenote} \marg{text}
% ^^A %
% ^^A % Prints the table note item header inside a \CSS\ class of |tnoteitemheader|.
% ^^A %    \begin{macrocode}
% ^^A %       \newrobustcmd{\LWR@printtablenote}[1]{\InlineClass{tnoteitemheader}{#1}}
% ^^A %    \end{macrocode}
% ^^A % \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}%
%    \end{macrocode}
% ^^A broken:
% ^^A % \ltx@ifpackageloaded{enumitem}{%
% ^^A % \setlist[description]{format=\LWR@printtablenote}%
% ^^A % }{}%
%    \begin{macrocode}
\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
%<*thumb>
% \fi
%
% \part{lwarp-thumb.sty}
%
% \section{thumb}
%
% \DescribePackage{thumb}
% \pkg{thumb} is ignored.
%
% \changes{v0.60}{2018/09/19}{\pkg{thumb}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{thumb}[1997/12/24]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\Overviewpage}{}
\newlength{\thumbheight}
\newlength{\thumbwidth}
%    \end{macrocode}
%
% \iffalse
%</thumb>
% \fi
%
%
%
%
% \iffalse
%<*thumbs>
% \fi
%
% \part{lwarp-thumbs.sty}
%
% \section{thumbs}
%
% \DescribePackage{thumbs}
% \pkg{thumbs} is ignored.
%
% \changes{v0.60}{2018/09/19}{\pkg{thumbs}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{thumbs}[2014/03/09]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\addthumb}[4]{}
\newcommand{\addtitlethumb}[5]{}
\newcommand{\stopthumb}{}
\newcommand{\continuethumb}{}
\newcommand{\thumbsoverview}[1]{}
\newcommand{\thumbsoverviewback}[1]{}
\newcommand{\thumbsoverviewverso}[1]{}
\newcommand{\thumbsoverviewdouble}[1]{}
\newcommand{\thumbnewcolumn}{}
\newcommand{\addthumbsoverviewtocontents}[2]{}
\newcommand{\thumbsnophantom}{}
%    \end{macrocode}
%
% \iffalse
%</thumbs>
% \fi
%
%
%
%
%
% \iffalse
%<*tikz>
% \fi

% \part{lwarp-tikz.sty}
%
% \section{tikz}
%
% \credits{Till Tantau}
%
% \DescribePackage{tikz}
% \pkg{tikz} is supported.
%
% \limitstikz
%
% \changes{v0.24}{2017/03/11}{\pkg{tikz}: For tikz v3.0.0 or later,
%	auto-loads tikz babel library if necessary.}
%
% Accept all options for \pkg{lwarp-tikz}:
%    \begin{macrocode}
\LWR@ProvidesPackagePass{tikz}[2015/08/07]
%    \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.
% \gindex{tikz=\pkg{tikz}>dollar redefined}
% \gindex{tikz=\pkg{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/\\
%		\fqquad\ test-if-a-package-or-package-option-is-loaded}


%    \begin{macrocode}
\newbool{LWR@tikzbabel}

\@ifpackagelater{tikz}{2013/12/20}% Test for Tikz version v3.0.0
{\usetikzlibrary{babel}\booltrue{LWR@tikzbabel}}
{\boolfalse{LWR@tikzbabel}}
%    \end{macrocode}


% \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.}
% \changes{v0.51}{2018/03/06}{\pkg{tikz}: Fix for \cs{tikz} macro.}
% \changes{v0.51}{2018/03/20}{\pkg{tikz}: Fix for \env{tikz} with optional argument.}
% \changes{v0.54}{2018/04/16}{\pkg{tikz}: Fixes for \cs{pgfpicture}, minipages, fit, align, font.}
%
% \begin{noindenvironment}{pgfpicture}
% The \cs{pgfpicture} environment is enclosed inside a \cs{lateximage}.
% Enclose the low-level \cs{pgfpicture} in a \env{lateximage}.
% This is also used by the higher-level \cs{tikz} and \env{tikzpicture}.
%
%    \begin{macrocode}
\preto\pgfpicture{%
    \begin{lateximage}%
    \ifbool{LWR@tikzbabel}% Test for Tikz version v3.0.0
    {}%
    {\catcode`\$=3}% dollar sign is math shift
}

\appto\endpgfpicture{\end{lateximage}}
%    \end{macrocode}
% \end{noindenvironment}

% \tikz\ is placed inside an \SVG\ image, so use the original
% meanings of the following:
%    \begin{macrocode}
\LetLtxMacro\pgfutil@minipage\LWR@print@minipage
\let\pgfutil@endminipage\endLWR@print@minipage

\let\pgfutil@raggedleft\LWR@print@raggedleft
\let\pgfutil@raggedright\LWR@print@raggedright

\def\pgfutil@font@tiny{\LWR@printtiny}
\def\pgfutil@font@scriptsize{\LWR@printscriptsize}
\def\pgfutil@font@footnotesize{\LWR@printfootnotesize}
\def\pgfutil@font@small{\LWR@print@small}
\def\pgfutil@font@normalsize{\LWR@print@normalsize}
\def\pgfutil@font@large{\LWR@printlarge}
\def\pgfutil@font@Large{\LWR@printLarge}
\def\pgfutil@font@huge{\LWR@printhuge}
\def\pgfutil@font@Huge{\LWR@printHuge}

\def\pgfutil@font@itshape{\LWR@origitshape}
\def\pgfutil@font@bfseries{\LWR@origbfseries}

\def\pgfutil@font@normalfont{\LWR@orignormalfont}
%    \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}[2016/03/15]
%    \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 emulated.
%
% \changes{v0.34}{2017/07/26}{\pkg{titleref}: Prevented.}
% \changes{v0.45}{2018/01/03}{\pkg{titleref}: Added.}
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{titleref}[2001/04/05]

\LetLtxMacro\titleref\nameref

\providecounter{LWR@currenttitle}

\newcommand*{\currenttitle}{%
    \addtocounter{LWR@currenttitle}{1}%
    \label{currenttitle\arabic{LWR@currenttitle}}%
    \nameref{currenttitle\arabic{LWR@currenttitle}}%
}

\newcommand*{\theTitleReference}[2]{}
%    \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}[2016/03/21]
%    \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}[2011/12/15]
%    \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}[2009/09/04]
%    \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~%
%    \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%
}% \@makefntext
}
%    \end{macrocode}
% \end{macro}
%
% \begin{noindmacro}{\thanksfootmark}
% \changes{v0.51}{2018/03/05}{\pkg{titling}: Fix for \cs{thanks} mark.}
%    \begin{macrocode}
\renewcommand{\thanksfootmark}{%
%   \hb@xt@\thanksmarkwidth{\hfil\normalfont%
        \thanksscript{%
            \thanksfootpre \tamark \thanksfootpost%
        }%
%   }%
}
%    \end{macrocode}
% \end{noindmacro}
%
%\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 \cs{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 \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 \cs{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 \cs{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}
\@ifclassloaded{memoir}{
   \thanksmarkseries{arabic}
}{% not memoir
\if@titlepage
   \thanksmarkseries{arabic}
\else
   \thanksmarkseries{fnsymbol}
\fi
}% not memoir
%    \end{macrocode}
%
%
%
% \iffalse
%</titling>
% \fi
%
%
%
%
%
% \iffalse
%<*tocbasic>
% \fi
%
% \part{lwarp-tocbasic.sty}

% \section{tocbasic}
%
% \credits{Markus Kohm}
%
% \DescribePackage{tocbasic}
% \pkg{tocbasic} is nullified for \pkg{lwarp}.
% %
% \usedbykomascript
%
% \changes{v0.44}{2017/11/20}{\pkg{tocbasic}: Added.}
% \changes{v0.66}{2019/01/12}{\pkg{tocbasic}: Updated to v3.26a.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{tocbasic}[2018/12/30]
%    \end{macrocode}

%    \begin{macrocode}
\DeclareDocumentCommand{\usetocbasicnumberline}{o}{}
\DeclareDocumentCommand{\DeclareTOCStyleEntry}{o m m}{}
\DeclareDocumentCommand{\DeclareTOCStyleEntries}{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}.
%
% \limitstocbibind
%
% \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}[2010/10/13]
%    \end{macrocode}

%    \begin{macrocode}
\renewenvironment{theindex}%
{%
     \if@bibchapter
        \if@donumindex
            \chapter{\indexname}
        \else
          \if@dotocind
            \chapter*{\indexname}
            \addcontentsline{toc}{chapter}{\LWR@isolate{\indexname}}
          \else
            \chapter*{\indexname}
          \fi
        \fi
     \else
        \if@donumindex
            \section{\indexname}
        \else
          \if@dotocind
            \section*{\indexname}
            \addcontentsline{toc}{\@tocextra}{\LWR@isolate{\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}
\DeclareDocumentCommand{\simplechapter}{O{\@empty}}{%
    \def\@chapcntformat##1{%
        #1~\csname the##1\endcsname\simplechapterdelim\quad%
    }%
}

\DeclareDocumentCommand{\restorechapter}{}{%
\let\@chapcntformat\@seccntformat%
}
%    \end{macrocode}
%
% \iffalse
%</tocbibind>
% \fi
%
%
%
%
% \iffalse
%<*tocenter>
% \fi
%
% \part{lwarp-tocenter.sty}
%
% \section{tocenter}
%
% \DescribePackage{tocenter}
% \pkg{tocenter} is ignored.
%
% \changes{v0.56}{2018/04/26}{\pkg{tocenter}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{tocenter}[2004/12/09]
%    \end{macrocode}
%
%    \begin{macrocode}
\NewDocumentCommand{\ToCenter}{s o m m}{}
\NewDocumentCommand{\FromMargins}{s o m m m m}{}
%    \end{macrocode}
%
% \iffalse
%</tocenter>
% \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}[2017/08/31]
%    \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}
\providecommand*{\cftdot}{.}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftdotsep}
%    \begin{macrocode}
\providecommand*{\cftdotsep}{1}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftnodots}
%    \begin{macrocode}
\providecommand*{\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}
\DeclareDocumentCommand{\cftsetpnumwidth}{m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftsetrmarg} \marg{length}
%    \begin{macrocode}
\DeclareDocumentCommand{\cftsetrmarg}{m}{}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\cftpnumalign} \marg{alignment}
%    \begin{macrocode}
\DeclareDocumentCommand{\cftpnumalign}{m}{}
%    \end{macrocode}
% \end{noindmacro}

%    \begin{macrocode}
\LWR@providelength{\cftparskip}
%    \end{macrocode}


% The part-related items are also provided by \pkg{memoir}:
%    \begin{macrocode}
\LWR@providelength{\cftbeforepartskip}
\LWR@providelength{\cftpartindent}
\LWR@providelength{\cftpartnumwidth}
\providecommand*{\cftpartfont}{}
\providecommand*{\cftpartpresnum}{}
\providecommand*{\cftpartaftersnum}{}
\providecommand*{\cftpartaftersnumb}{}
\providecommand*{\cftpartleader}{}
\providecommand*{\cftpartdotsep}{1}
\providecommand*{\cftpartpagefont}{}
\providecommand*{\cftpartafterpnum}{}
%    \end{macrocode}
%
% \pkg{memoir} uses the full name ``chapter'' instead of ``chap'':
%    \begin{macrocode}
\LWR@providelength{\cftbeforechapskip}
\LWR@providelength{\cftchapindent}
\LWR@providelength{\cftchapnumwidth}
\newcommand*{\cftchapfont}{}
\newcommand*{\cftchappresnum}{}
\newcommand*{\cftchapaftersnum}{}
\newcommand*{\cftchapaftersnumb}{}
\newcommand*{\cftchapleader}{}
\newcommand*{\cftchapdotsep}{1}
\newcommand*{\cftchappagefont}{}
\newcommand*{\cftchapafterpnum}{}
%    \end{macrocode}
%
% The following do not appear in \pkg{memoir}:
%    \begin{macrocode}
\LWR@providelength{\cftbeforesecskip}
\LWR@providelength{\cftsecindent}
\LWR@providelength{\cftsecnumwidth}
\newcommand*{\cftsecfont}{}
\newcommand*{\cftsecpresnum}{}
\newcommand*{\cftsecaftersnum}{}
\newcommand*{\cftsecaftersnumb}{}
\newcommand*{\cftsecleader}{}
\newcommand*{\cftsecdotsep}{1}
\newcommand*{\cftsecpagefont}{}
\newcommand*{\cftsecafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\LWR@providelength{\cftbeforesubsecskip}
\LWR@providelength{\cftsubsecindent}
\LWR@providelength{\cftsubsecnumwidth}
\newcommand*{\cftsubsecfont}{}
\newcommand*{\cftsubsecpresnum}{}
\newcommand*{\cftsubsecaftersnum}{}
\newcommand*{\cftsubsecaftersnumb}{}
\newcommand*{\cftsubsecleader}{}
\newcommand*{\cftsubsecdotsep}{1}
\newcommand*{\cftsubsecpagefont}{}
\newcommand*{\cftsubsecafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\LWR@providelength{\cftbeforesubsubsecskip}
\LWR@providelength{\cftsubsubsecindent}
\LWR@providelength{\cftsubsubsecnumwidth}
\newcommand*{\cftsubsubsecfont}{}
\newcommand*{\cftsubsubsecpresnum}{}
\newcommand*{\cftsubsubsecaftersnum}{}
\newcommand*{\cftsubsubsecaftersnumb}{}
\newcommand*{\cftsubsubsecleader}{}
\newcommand*{\cftsubsubsecdotsep}{1}
\newcommand*{\cftsubsubsecpagefont}{}
\newcommand*{\cftsubsubsecafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\LWR@providelength{\cftbeforeparaskip}
\LWR@providelength{\cftparaindent}
\LWR@providelength{\cftparanumwidth}
\newcommand*{\cftparafont}{}
\newcommand*{\cftparapresnum}{}
\newcommand*{\cftparaaftersnum}{}
\newcommand*{\cftparaaftersnumb}{}
\newcommand*{\cftparaleader}{}
\newcommand*{\cftparadotsep}{1}
\newcommand*{\cftparapagefont}{}
\newcommand*{\cftparaafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\LWR@providelength{\cftbeforesubparaskip}
\LWR@providelength{\cftsubparaindent}
\LWR@providelength{\cftsubparanumwidth}
\newcommand*{\cftsubparafont}{}
\newcommand*{\cftsubparapresnum}{}
\newcommand*{\cftsubparaaftersnum}{}
\newcommand*{\cftsubparaaftersnumb}{}
\newcommand*{\cftsubparaleader}{}
\newcommand*{\cftsubparadotsep}{1}
\newcommand*{\cftsubparapagefont}{}
\newcommand*{\cftsubparaafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\LWR@providelength{\cftbeforefigskip}
\LWR@providelength{\cftfigindent}
\LWR@providelength{\cftfignumwidth}
\newcommand*{\cftfigfont}{}
\newcommand*{\cftfigpresnum}{}
\newcommand*{\cftfigaftersnum}{}
\newcommand*{\cftfigaftersnumb}{}
\newcommand*{\cftfigleader}{}
\newcommand*{\cftfigdotsep}{1}
\newcommand*{\cftfigpagefont}{}
\newcommand*{\cftfigafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\LWR@providelength{\cftbeforesubfigskip}
\LWR@providelength{\cftsubfigindent}
\LWR@providelength{\cftsubfignumwidth}
\newcommand*{\cftsubfigfont}{}
\newcommand*{\cftsubfigpresnum}{}
\newcommand*{\cftsubfigaftersnum}{}
\newcommand*{\cftsubfigaftersnumb}{}
\newcommand*{\cftsubfigleader}{}
\newcommand*{\cftsubfigdotsep}{1}
\newcommand*{\cftsubfigpagefont}{}
\newcommand*{\cftsubfigafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\LWR@providelength{\cftbeforetabskip}
\LWR@providelength{\cfttabindent}
\LWR@providelength{\cfttabnumwidth}
\newcommand*{\cfttabfont}{}
\newcommand*{\cfttabpresnum}{}
\newcommand*{\cfttabaftersnum}{}
\newcommand*{\cfttabaftersnumb}{}
\newcommand*{\cfttableader}{}
\newcommand*{\cfttabdotsep}{1}
\newcommand*{\cfttabpagefont}{}
\newcommand*{\cfttabafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\LWR@providelength{\cftbeforesubtabskip}
\LWR@providelength{\cftsubtabindent}
\LWR@providelength{\cftsubtabnumwidth}
\newcommand*{\cftsubtabfont}{}
\newcommand*{\cftsubtabpresnum}{}
\newcommand*{\cftsubtabaftersnum}{}
\newcommand*{\cftsubtabaftersnumb}{}
\newcommand*{\cftsubtableader}{}
\newcommand*{\cftsubtabdotsep}{1}
\newcommand*{\cftsubtabpagefont}{}
\newcommand*{\cftsubtabafterpnum}{}
%    \end{macrocode}

%    \begin{macrocode}
\DeclareDocumentCommand{\cftsetindents}{m m m}{}
%    \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}
\DeclareDocumentCommand{\newlistentry}{o m m m}
{%
\LWR@traceinfo{newlistentry #2 #3 #4}%
\IfValueTF{#1}%
{%
    \@ifundefined{c@#2}{%
        \newcounter{#2}[#1]%
        \expandafter\edef\csname the#2\endcsname{%
            \expandafter\noexpand\csname the#1\endcsname.\noexpand\arabic{#2}%
        }%
    }{}%
}%
{%
    \@ifundefined{c@#2}{%
        \newcounter{#2}%
    }{}%
}%
\@namedef{l@#2}##1##2{%
    \hypertocfloat{1}{#2}{#3}{##1}{##2}%
    \def\cftwhatismyname{#2}% from memoir
}%
\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{}%
\LWR@traceinfo{newlistentry done}%
}
%    \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}
\DeclareDocumentCommand{\newlistof}{o m m m}
{%
\IfValueTF{#1}
{\newlistentry[#1]{#2}{#3}{0}}
{\newlistentry{#2}{#3}{0}}
\@namedef{ext@#2}{#3}
\@ifundefined{c@#3depth}{\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}[2017/02/23]
%    \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}[2010/03/31]
%    \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}[2012/07/25]
%    \end{macrocode}
%
%    \begin{macrocode}
\if@todonotes@disabled
\else

\newcommand{\ext@todo}{tdo}

\renewcommand{\l@todo}[2]{\hypertocfloat{1}{todo}{ldo}{#1}{#2}}
%    \end{macrocode}
%
% \changes{v0.48}{2018/02/12}{\pkg{todonotes}: Improved \cs{todototoc}.}
%    \begin{macrocode}
\let\LWRTODONOTES@orig@todototoc\todototoc

\renewcommand*{\todototoc}{%
\phantomsection%
\LWRTODONOTES@orig@todototoc%
}

\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
%<*tram>
% \fi
%
% \part{lwarp-tram.sty}
%
% \section{tram}
%
% \DescribePackage{tram}
% \pkg{tram} is emulated.
%
% The \HTML\ emulation uses a \element{div}, which must not appear inside
% \trouble[block only]{tram=\pkg{tram}}
% an \HTML\ \element{span} or an \HTML\ paragraph.
% For this reason, the \env{tram} environment should only be used to
% contain paragraphs inside a \cs{parbox} or \env{minipage}.
% \env{tram} should not be used to mark up inline text.
%
% To disable \env{tram}, allowing source compatibility with inline uses:
% \begin{sourcedisplay}
% \cs{begin}\{warpHTML\} \\
% \cs{renewenvironment}\{tram\}[1][]\{\}\{\} \\
% \cs{end}\{warpHTML\}
% \end{sourcedisplay}
% \bigskip
%
% \changes{v0.62}{2018/11/15}{\pkg{tram}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{tram}[2013/04/04]
%    \end{macrocode}
%
%    \begin{macrocode}
\newenvironment{tram}[1][]%
    {\BlockClass[background:lightgray]{tram}}
    {\endBlockClass}
%    \end{macrocode}
%
% \iffalse
%</tram>
% \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.
% \trouble[Not \XeLaTeX!]{transparent=\pkg{transparent}}
%
% \changes{v0.36}{2017/08/09}{\pkg{transparent}: Added.}
%
% \codehtml
%
% Discard all options for \pkg{lwarp-transparent}:
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{transparent}[2016/05/16]
%    \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
%<*trimclip>
% \fi
%
% \part{lwarp-trimclip.sty}
%
% \section{trimclip}
%
% \DescribePackage{trimclip}
% \pkg{trimclip} is nullified.
%
% \changes{v0.57}{2018/05/26}{\pkg{trimclip}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{trimclip}[2018/04/08]
%    \end{macrocode}
%
% The third argument, the text, is not touched.
% This allows \cs{bgroup} / \cs{egroup}, and verbatim content.
%    \begin{macrocode}
\csdef{trimbox}{\@ifstar\@gobble\@gobble}
\csletcs{trimbox*}{trimbox}
\def\endtrimbox{}
\csletcs{endtrimbox*}{endtrimbox}

\csletcs{clipbox}{trimbox}
\csletcs{clipbox*}{trimbox}
\csletcs{endclipbox}{endtrimbox}
\csletcs{endclipbox*}{endtrimbox}

\csletcs{marginbox}{trimbox}
\csletcs{marginbox*}{trimbox}
\csletcs{endmarginbox}{endtrimbox}
\csletcs{endmarginbox*}{endtrimbox}
%    \end{macrocode}
%
% \iffalse
%</trimclip>
% \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.
%
%
% 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}
%
%
% Discard all options for \pkg{lwarp-trivfloat}.
% This tells \pkg{trivfloat} not to use \pkg{floatrow} or \pkg{memoir}.
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{trivfloat}[2009/04/23]
\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}
% \gindex{newfloat=\pkg{newfloat}>with \pkg{trivfloat}, \pkg{algorithmic}}
% \gindex{trivfloat=\pkg{trivfloat}>with \pkg{newfloat}, \pkg{algorithmic}}
% \gindex{algorithmic=\pkg{algorithmic}>with \pkg{newfloat}, \pkg{trivfloat}}
%
% \codeall
%    \begin{macrocode}
\begin{warpall}
%    \end{macrocode}

% \textred{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
%<*truncate>
% \fi
%
% \part{lwarp-truncate.sty}
%
% \section{truncate}
%
% \DescribePackage{truncate}
% \pkg{truncate} is ignored.
%
% \changes{v0.66}{2019/02/03}{\pkg{truncate}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{truncate}[2001/08/20]
%    \end{macrocode}
%
%    \begin{macrocode}
\providecommand{\TruncateMarker}{}
\newcommand{\truncate}[3][\TruncateMarker]{#3}
%    \end{macrocode}
%
% \iffalse
%</truncate>
% \fi
%
%
%
%
%
%
% \iffalse
%<*turnthepage>
% \fi
%
% \part{lwarp-turnthepage.sty}
%
% \section{turnthepage}
%
% \DescribePackage{turnthepage}
% \pkg{turnthepage} is ignored.
%
% \changes{v0.45}{2017/12/19}{\pkg{turnthepage}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{turnthepage}[2011/03/24]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\turnthepage}{}
%    \end{macrocode}
%
% \iffalse
%</turnthepage>
% \fi
%
%
%
%
%
% \iffalse
%<*twoup>
% \fi
%
% \part{lwarp-twoup.sty}
%
% \section{twoup}
%
% \DescribePackage{twoup}
% \pkg{twoup} is ignored.
%
% \changes{v0.62}{2018/10/16}{\pkg{twoup}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{twoup}[2007/02/26]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\cleartolastpage}{}
%    \end{macrocode}
%
% \iffalse
%</twoup>
% \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}[2018/03/30]
%    \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
%<*typicons>
% \fi
%
% \part{lwarp-typicons.sty}
%
% \section{typicons}
%
% \credits{Arthur Vigil, Xavier Danaux}
%
% \DescribePackage{typicons}
% \pkg{typicons} is patched for use by \pkg{lwarp}.
%
% If \cs{ticon} is used, the name of the icon is used in the \attribute{alt} tag.
% Otherwise, for each of the individual icon macros, a generic \attribute{alt} tag is used.
%
% \changes{v0.67}{2019/02/23}{\pkg{typicons}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{typicons}[2015/05/20]
%    \end{macrocode}
%
%    \begin{macrocode}
\LetLtxMacro\LWR@orig@symbol\symbol

\let\LWR@orig@typicon@TI\TI

\newcommand*{\LWR@typicon@symbol}[1]{%
    \begin{lateximage}*[(typicon)][typicon#1]%
    \begingroup%
    \LWR@orig@typicon@TI%
    \LWR@orig@symbol{#1}%
    \endgroup%
    \end{lateximage}%
}

\renewcommand*{\TI}{%
    \LetLtxMacro\symbol\LWR@typicon@symbol%
}

\renewcommand*{\ticon}[1]
{%
    \begin{lateximage}*[(#1 icon)][typicon#1]%
    \TI\csname ticon@#1\endcsname%
    \end{lateximage}%
}
%    \end{macrocode}
%
% \iffalse
%</typicons>
% \fi
%
%
%
%
%
%
%
% \iffalse
%<*ulem>
% \fi
%
% \part{lwarp-ulem.sty}
%
% \section{ulem}
%
% \credits{Donald Arseneau}
%
% \DescribePackage{ulem} Patched for use by \pkg{lwarp}.
%
% \changes{v0.27}{2017/04/02}{\pkg{ulem}: Added.}
% \changes{v0.62}{2018/11/16}{\pkg{ulem}: Improved compatibility with \pkg{CJKulem}.}
% \changes{v0.62}{2018/11/17}{\pkg{ulem}: Now works in a \env{lateximage}.}
%
% \codehtml
%
%
% Use the original package:
%    \begin{macrocode}
\LWR@ProvidesPackagePass{ulem}[2012/05/18]
%    \end{macrocode}
%
%
%
% Basic markup commands, using \CSS:
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@uline}{+m}{%
    \InlineClass%
        (text-decoration:underline; text-decoration-skip: auto)%
        {uline}{\LWR@isolate{#1}}%
}
\LWR@formatted{uline}

\NewDocumentCommand{\LWR@HTML@uuline}{+m}{%
    \InlineClass%
        (%
            text-decoration:underline; text-decoration-skip: auto;%
            text-decoration-style:double%
        )%
        {uuline}{\LWR@isolate{#1}}%
}
\LWR@formatted{uuline}

\NewDocumentCommand{\LWR@HTML@uwave}{+m}{%
    \InlineClass%
        (%
            text-decoration:underline; text-decoration-skip: auto;%
            text-decoration-style:wavy%
        )%
        {uwave}{\LWR@isolate{#1}}%
}
\LWR@formatted{uwave}

\NewDocumentCommand{\LWR@HTML@sout}{+m}{%
    \InlineClass%
        (text-decoration:line-through)%
        {sout}{\LWR@isolate{#1}}%
}
\LWR@formatted{sout}

\NewDocumentCommand{\LWR@HTML@xout}{+m}{%
    \InlineClass%
        (text-decoration:line-through)%
        {xout}{\LWR@isolate{#1}}%
}

\NewDocumentCommand{\LWR@HTML@dashuline}{+m}{%
    \InlineClass%
        (%
            text-decoration:underline;%
            text-decoration-skip: auto;%
            text-decoration-style:dashed%
        )%
        {dashuline}{\LWR@isolate{#1}}%
}
\LWR@formatted{xout}

\NewDocumentCommand{\LWR@HTML@dotuline}{+m}{%
    \InlineClass%
        (%
            text-decoration:underline;%
            text-decoration-skip: auto;%
            text-decoration-style: dotted%
        )%
        {dotuline}{\LWR@isolate{#1}}%
}
\LWR@formatted{dotuline}
%    \end{macrocode}
%
% Nullified/emulated macros:
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@markoverwith}{m}{}
\LWR@formatted{markoverwith}

\NewDocumentCommand{\LWR@HTML@ULon}{+m}{\uline{#1}\egroup}
\LWR@formatted{ULon}
%    \end{macrocode}
%
% \iffalse
%</ulem>
% \fi
%
%
%
%
% \iffalse
%<*umoline>
% \fi
%
% \part{lwarp-umoline.sty}
%
% \section{umoline}
%
% \credits{Hiroshi Nakashima}
%
% \DescribePackage{umoline}
% \pkg{umoline} is patched for use by \pkg{lwarp}.
%
% \changes{v0.67}{2019/02/18}{\pkg{umoline}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{umoline}[2000/07/11]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\LWR@HTML@Underline}[1]{%
    \InlineClass{uline}{#1}%
}
\LWR@formatted{Underline}

\newcommand*{\LWR@HTML@Midline}[1]{%
    \InlineClass{sout}{#1}%
}
\LWR@formatted{Midline}

\newcommand*{\LWR@HTML@Overline}[1]{%
    \InlineClass{oline}{#1}%
}
\LWR@formatted{Overline}

\newcommand*{\LWR@HTML@UMOline}[2]{%
    \InlineClass{uline}{#2}%
}
\LWR@formatted{UMOline}

\NewDocumentCommand{\LWR@HTML@UMOspace}{s m o}{\hspace*{#2}}
\LWR@formatted{UMOspace}

\NewDocumentCommand{\LWR@HTML@UMOnewline}{s}{\newline}
\LWR@formatted{UMOnewline}
%    \end{macrocode}
%
% \iffalse
%</umoline>
% \fi
%
%
%
%
% \iffalse
%<*underscore>
% \fi
%
% \part{lwarp-underscore.sty}
%
% \section{underscore}
%
% \DescribePackage{underscore}
% \pkg{underscore} is ignored.
%
% \changes{v0.56}{2018/05/09}{\pkg{underscore}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{underscore}[2006/09/13]
%    \end{macrocode}
%
% \iffalse
%</underscore>
% \fi
%
%
%
%
%
% \iffalse
%<*units>
% \fi
%
% \part{lwarp-units.sty}

% \section{units}
%
% \credits{Axel Reichert}
%
% \DescribePackage{units}
% \pkg{units} is patched for use by \pkg{lwarp}.
%
% Values are not styled by \CSS, and take the style of the surrounding \HTML\ text.
%
% Units are styled according to the print version,
% so they will be forced to upright roman in \HTML\ if the print version does so.
% It may be necessary to adjust the document's body \CSS\ to match the print version.
%
% \changes{v0.59}{2018/07/13}{\pkg{units}: Added support for \pkg{MathJax.}}
% \changes{v0.62}{2018/11/15}{\pkg{units}: Improved font control and \CSS,
%       honors \optn{loose}, \optn{tight}.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{units}[1998/08/04]
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareRobustCommand*{\LWR@HTML@unit}[2][]{%
\ifblank{#1}%
    {\LWR@textcurrentfont{#2}}%
    {%
        #1%
        \ifthenelse{\boolean{B@UnitsLoose}}{~}{\,}%
        \LWR@textcurrentfont{#2}%
    }%
}
\LWR@formatted{unit}
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareRobustCommand*{\LWR@HTML@unitfrac}[3][]{%
\ifblank{#1}%
    {%
            \nicefrac{#2}{#3}%
    }%
    {%
            #1%
            \ifthenelse{\boolean{B@UnitsLoose}}{~}{\,}%
            \nicefrac{#2}{#3}%
    }%
}

\LWR@formatted{unitfrac}
%    \end{macrocode}
%
% For Mathjax:
%    \begin{macrocode}
\CustomizeMathJax{\newcommand{\unit}[2][]{#1 #2}}
\CustomizeMathJax{\newcommand{\unitfrac}[3][]{#1 #2/#3}}
%    \end{macrocode}

% ^^A For Ka\TeX:
% ^^A %    \begin{macrocode}
% ^^A \CustomizeKaTeX{
% ^^A \gdef\unit{\@ifnextchar[{brace\LWRuniti}{nobrace\LWRunit}}
% ^^A \gdef\LWRunit#1{none #1 done}
% ^^A \gdef\LWRuniti[#1]#2{found a brace #1 between #2 done}
% ^^A }
% ^^A \CustomizeKaTeX{\gdef\unitfrac[#1]#2#3{#1 #2/#3}}
% ^^A %    \end{macrocode}


% \iffalse
%</units>
% \fi
%
%
%
%
%
% \iffalse
%<*unitsdef>
% \fi
%
% \part{lwarp-unitsdef.sty}
%
% \section{unitsdef}
%
% \credits{Patrick Happel}
%
% \DescribePackage{unitsdef}
% \pkg{unitsdef} is patched for use by \pkg{lwarp}.
%
% \changes{v0.62}{2018/11/11}{\pkg{unitsdef}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{unitsdef}[2005/01/04]
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand{\unitvaluesep}{\,}

\renewcommand{\unittimes}{\@@setunitsepfalse\HTMLunicode{22c5}}% \cdot

\renewunit{\arcmin}{%
    \ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
        {\ensuremath{{}^\prime}}%
        {\HTMLunicode{2032}}% prime
}

\renewunit{\arcsec}{%
    \ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
        {\ensuremath{{}^{\prime\prime}}}%
        {\HTMLunicode{2033}}% dbl prime
}

\renewrobustcmd{\SI}[2]{%
  \begingroup%
    \let\unit@@xspace\relax%
    \unitSIdef\selectfont%
      \LWR@textcurrentfont{#1#2}% lwarp
  \endgroup%
}
%    \end{macrocode}
%
% \iffalse
%</unitsdef>
% \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}[2007/03/14]
%    \end{macrocode}
%
%
% \iffalse
%</upref>
% \fi
%
%
%
%
%
% \iffalse
%<*url>
% \fi
%
% \part{lwarp-url.sty}

% \section{url}
%
% \credits{Donald Arseneau}
%
% \DescribePackage{url}
% \pkg{url} is patched for use by \pkg{lwarp}.
%
% \changes{v0.52}{2018/03/29}{\pkg{url}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{url}[2013/09/16]
%    \end{macrocode}

% \pkg{url} uses math mode to print its string inside a group, so the original meaning
% of math is restored first.
%    \begin{macrocode}
\LetLtxMacro\LWR@url@origUrl@FormatString\Url@FormatString

\renewcommand*{\Url@FormatString}{%
    \InlineClass{verbatim}{%
        \LWR@restoreorigformatting%
        \LWR@url@origUrl@FormatString%
    }%
}
%    \end{macrocode}

% \iffalse
%</url>
% \fi
%
%
%
% \iffalse
%<*uspace>
% \fi
%
% \part{lwarp-uspace.sty}
%
% \section{uspace}
%
% \DescribePackage{uspace}
% \pkg{uspace} is ignored.
%
% \changes{v0.61}{2018/09/23}{\pkg{uspace}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{uspace}[2016/11/06]
%    \end{macrocode}
%
% \iffalse
%</uspace>
% \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}[2009/09/04]
%    \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}\DescribeClass{memoir}\gindex{memoir=\pkg{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 \prog{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{3}{verse}%
}
%    \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}{%
\leavevmode%
\LWR@afterendverbatim{1}%
}
%    \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
%<*versonotes>
% \fi
%
% \part{lwarp-versonotes.sty}
%
% \section{versonotes}
%
% \credits{Norman Gray}
%
% \DescribePackage{versonotes}
% \pkg{versonotes} is emulated.
%
% \changes{v0.65}{2018/12/10}{\pkg{versonotes}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{versonotes}[2015/12/08]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\versonote}[1]{\marginpar{#1}}
\newdimen\versotextwidth
\newdimen\versoleftmargin
\newcommand*{\versolayout}{}
%    \end{macrocode}
%
% \iffalse
%</versonotes>
% \fi
%
%
%
%
%
% \iffalse
%<*vertbars>
% \fi
%
% \part{lwarp-vertbars.sty}
%
% \section{vertbars}
%
% \credits{Peter Wilson}
%
% \DescribePackage{vertbars}
% \pkg{vertbars} is emulated.
%
% \changes{v0.49}{2018/02/16}{\pkg{vertbars}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{vertbars}[2010/11/27]
%    \end{macrocode}
%
%    \begin{macrocode}
\newlength{\barwidth}
\setlength{\barwidth}{0.4pt}
\newlength{\barspace}
\setlength{\barspace}{1em}

\newenvironment{vertbar}{
    \LWR@forcenewpage
    \LWR@forceminwidth{\barwidth}
    \begin{BlockClass}[%
        border-left: \LWR@printlength{\LWR@atleastonept} solid black ; %
        padding-left: \LWR@printlength{\barspace}%
    ]{vertbar}
}{
    \end{BlockClass}
}
%    \end{macrocode}
%
% \iffalse
%</vertbars>
% \fi
%
%
%
%
%
% \iffalse
%<*vmargin>
% \fi
%
% \part{lwarp-vmargin.sty}
%
% \section{vmargin}
%
% \DescribePackage{vmargin}
% \pkg{vmargin} is ignored.
%
% \changes{v0.48}{2018/02/07}{\pkg{vmargin}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{vmargin}[2004/07/15]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\LWRVM@customsize}[2]{}
\newcommand*{\setpapersize}[2][]{\ifstrequal{#2}{custom}{\LWRVM@customsize}{}}
\newcommand*{\setmargins}[8]{}
\newcommand*{\setmarginsrb}[8]{}
\newcommand*{\setmargnohf}[4]{}
\newcommand*{\setmargnohfrb}[4]{}
\newcommand*{\setmarg}[4]{}
\newcommand*{\setmargrb}[4]{}
\newlength{\PaperWidth}
\setlength{\PaperWidth}{8.5in}
\newlength{\PaperHeight}
\setlength{\PaperHeight}{11in}
\newif\ifLandscape
%    \end{macrocode}
%
% \iffalse
%</vmargin>
% \fi
%
%
%
%
% \iffalse
%<*vowel>
% \fi
%
% \part{lwarp-vowel.sty}

% \section{vowel}
%
% \credits{FUKUI Rei}
%
% \DescribePackage{vowel}
% \pkg{vowel} is patched for use by \pkg{lwarp}.
%
% This package has been tested with \prog{pdflatex} and the Type 1 TIPA fonts
% using the following package load sequence:
% \begin{sourcedisplay}
% \cs{usepackage}[T3,T1]\{fontenc\} \\
% \cs{usepackage}[utf8]\{inputenc\} \\
% \cs{usepackage}[noenc]\{tipa\} \\
% \cs{usepackage}\{vowel\}
% \end{sourcedisplay}
% \bigskip
%
% \changes{v0.57}{2018/05/22}{\pkg{vowel}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{vowel}[2002/08/08]
%    \end{macrocode}

%    \begin{macrocode}
\renewenvironment{vowel}[1][]
    {%
        \begin{lateximage}[(-vowel-~\packagediagramname)]%
        \@vowel[#1]%
    }
    {%
        \@@vowel%
        \end{lateximage}%
    }
%    \end{macrocode}

% \iffalse
%</vowel>
% \fi
%
%
%
%
% \iffalse
%<*vpe>
% \fi
%
% \part{lwarp-vpe.sty}
%
% \section{vpe}
%
% \DescribePackage{vpe}
% \pkg{vpe} is ignored.
%
% \changes{v0.61}{2018/10/05}{\pkg{vpe}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{vpe}[2012/04/18]
%    \end{macrocode}
%
% \iffalse
%</vpe>
% \fi
%
%
%
% \iffalse
%<*vwcol>
% \fi
%
% \part{lwarp-vwcol.sty}
%
% \section{vwcol}
%
% \credits{Will Robertson}
%
% \DescribePackage{vwcol}
% \pkg{vwcol} is patched for use with \pkg{lwarp}.
%
% \changes{v0.49}{2018/02/16}{\pkg{vwcol}: Added.}
%
% The \optn{width} option is ignored.
% All \env{vwcol} environments adjust to 1--3 equal-width columns, depening on the
% width of the browser window.
%
% The remaining options are supported, except for |lines| and |maxrecursion|.
%
% \codehtml
%    \begin{macrocode}
\LWR@ProvidesPackagePass{vwcol}[2015/02/10]
%    \end{macrocode}
%
% Factored from \cs{vwcol}.
% Each is given a style tag to append to the final style.
%
% \begin{noindmacro}{\LWR@vwcol@addrule} \marg{style tag}
%    \begin{macrocode}
\newcommand*{\LWR@vwcol@addrule}[1]{%
    \appto{\LWR@vwcolstyle}{%
        #1: %
        \LWR@printlength{\vwcol@rule} solid \LWR@origpound\LWR@vwcol@rulecolor ; %
    }%
}
%    \end{macrocode}
% \end{noindmacro}

% \begin{noindmacro}{\LWR@vwcol@addrule} \marg{style tag}
%    \begin{macrocode}
\newcommand*{\LWR@vwcol@addgap}[1]{%
    \appto{\LWR@vwcolstyle}{%
        #1: %
        \LWR@printlength{\vwcol@sep} ; %
    }%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindenvironment}{vwcol} \marg{key/values}
%
% Redefine the environment to add a \HTML\ style.
% The style is built depending on the required options.
%    \begin{macrocode}
\renewenvironment*{vwcol}[1][]{%
%    \end{macrocode}
% New paragraph, and process the options:
%    \begin{macrocode}
\par\noindent%
\vwcolsetup{#1}%
%    \end{macrocode}
% Begin with no style:
%    \begin{macrocode}
\newcommand*{\LWR@vwcolstyle}{}
%    \end{macrocode}
% |presep| and |postsep| are created with \HTML\ \attribute{margin}s:
%    \begin{macrocode}
\if@vwcol@presep
    \appto{\LWR@vwcolstyle}{margin-left: 1em ; padding-left: .5em ; }
\fi
\if@vwcol@postsep
    \appto{\LWR@vwcolstyle}{margin-right: 1em ; padding-right: .5em ; }
\fi
%    \end{macrocode}
% |sep| becomes \attribute{column-gap}:
%    \begin{macrocode}
\ifdimgreater{\vwcol@sep}{1sp}{
    \LWR@vwcol@addgap{column-gap}
    \LWR@vwcol@addgap{-moz-column-gap}
    \LWR@vwcol@addgap{-webkit-column-gap}
}{}
%    \end{macrocode}
% |rule| become \attribute{column-rule}, while
% |prerule| and |postrule| become \HTML\ borders:
%    \begin{macrocode}
\convertcolorspec{named}{\vwcol@rulecol}{HTML}\LWR@vwcol@rulecolor%
\ifdimgreater{\vwcol@rule}{0pt}{
    \ifdimless{\vwcol@rule}{1pt}{
        \setlength{\vwcol@rule}{1pt}
    }{}
    \LWR@vwcol@addrule{column-rule}
    \LWR@vwcol@addrule{-moz-column-rule}
    \LWR@vwcol@addrule{-webkit-column-rule}
    \if@vwcol@prerule\LWR@vwcol@addrule{border-left}\fi
    \if@vwcol@postrule\LWR@vwcol@addrule{border-right}\fi
}{}
%    \end{macrocode}
% Each of the justify options becomes a \attribute{text-align}.
% Indentation is added where appropriate.
%    \begin{macrocode}
\ifdefequal{\vwcol@justify}{\RaggedRight}{
    \appto{\LWR@vwcolstyle}{text-align: left ; }
    \ifdimgreater{\vwcol@parindent}{0pt}{
        \appto{\LWR@vwcolstyle}{%
            text-indent: \LWR@printlength{\vwcol@parindent} ; %
        }
    }{}
}{}
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\vwcol@justify}{\RaggedLeft}{
    \appto{\LWR@vwcolstyle}{text-align: right ; }
}{}
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\vwcol@justify}{\Centering}{
    \appto{\LWR@vwcolstyle}{text-align: center ; }
}{}
%    \end{macrocode}
%    \begin{macrocode}
\ifdefequal{\vwcol@justify}{\justifying}{
    \appto{\LWR@vwcolstyle}{text-align: justify ; }
    \ifdimgreater{\vwcol@parindent}{0pt}{
        \appto{\LWR@vwcolstyle}{%
            text-indent: \LWR@printlength{\vwcol@parindent} ; %
        }
    }{}
}{}
%    \end{macrocode}
% Create the \element{div} with the assembled style:
%    \begin{macrocode}
\BlockClass[\LWR@vwcolstyle]{multicols}
}
%    \end{macrocode}
% When the environment ends:
%    \begin{macrocode}
{
\endBlockClass
}
%    \end{macrocode}
% \end{noindenvironment}
%
% \iffalse
%</vwcol>
% \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}[2005/01/18]
%    \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}[2004/12/09]
%    \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
%<*widows-and-orphans>
% \fi
%
% \part{lwarp-widows-and-orphans.sty}
%
% \section{widows-and-orphans}
%
% \DescribePackage{widows-and-orphans}
% \pkg{widows-and-orphans} is ignored.
%
% \changes{v0.60}{2018/09/17}{\pkg{widows-and-orphans}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{widows-and-orphans}[2018/09/01]
%    \end{macrocode}
%
%    \begin{macrocode}
\NewDocumentCommand\WaOsetup{m}{}
\NewDocumentCommand\WaOparameters{}{}
\NewDocumentCommand\WaOignorenext{}{}
%    \end{macrocode}
%
% \iffalse
%</widows-and-orphans>
% \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}[2003/01/31]
%    \end{macrocode}
%
%
% \changes{v0.42}{2017/10/26}{\pkg{wrapfig}: If \progcode{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}%
\LWR@BlockClassWP{%
    width:\LWR@printlength{\LWR@templengthone}; \LWR@wrapposition; %
    margin:10pt%
}%
{%
    width:\LWR@printlength{\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
%<*xbmks>
% \fi
%
% \part{lwarp-xbmks.sty}
%
% \section{xbmks}
%
% \DescribePackage{xbmks}
% \pkg{xbmks} is ignored.
%
% \changes{v0.61}{2018/10/05}{\pkg{xbmks}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{xbmks}[2018/07/04]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand{\xbmksetup}[1]{}
\NewDocumentCommand{\pdfbookmarkx}{o m o m}{}
\NewDocumentCommand{\currentpdfbookmarkx}{m o m}{}
\NewDocumentCommand{\subpdfbookmarkx}{m o m}{}
\NewDocumentCommand{\belowpdfbookmarkx}{m o m}{}
%    \end{macrocode}
%
% \iffalse
%</xbmks>
% \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 \progcode{none} in print mode.}
% \changes{v0.36}{2017/08/12}{\pkg{xcolor}: \cs{fcolorbox} etc. now work inside \env{lateximage}.}
%
%
% \subsection{Limitations}
%
% \limitsxcolor
%
%
% \subsection{\pkg{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 \prog{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{LWR@print@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{LWR@print@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}[2016/05/11]
%    \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\LWR@print@pagecolor\pagecolor
\LetLtxMacro\LWR@print@nopagecolor\nopagecolor
%    \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\pagecolor\LWR@print@pagecolor%
\LetLtxMacro\nopagecolor\LWR@print@nopagecolor%
}
%    \end{macrocode}
%
%
% \subsection{\HTML\ color style}
%
% \begin{noindmacro}{\LWR@findcurrenttextcolor}
% \changes{v0.44}{2017/11/10}{\pkg{xcolor}: Added \cs{LWR@findcurrenttextcolor}.}
% Sets \cs{LWR@tempcolor} to the current color.
%    \begin{macrocode}
\renewcommand*{\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@origpound\LWR@tempcolor ; }%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{macro}{\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}
\DeclareDocumentCommand{\LWR@textcurrentcolor}{m}{%
\begingroup%
\LWR@FBcancel%
\LWR@findcurrenttextcolor%
\InlineClass[color:\LWR@origpound\LWR@tempcolor]{textcolor}{%
    \renewcommand*{\LWR@currenttextcolor}{\LWR@origpound\LWR@tempcolor}%
    #1%
}%
\endgroup%
}
%    \end{macrocode}
% \end{macro}
%
%
% \begin{noindmacro}{\LWR@colorstyle} \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@origpound\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]{%
border:\LWR@printlength{\LWR@atleastonept} solid \LWR@colorstyle{#1}{#2} ; %
padding:\LWR@printlength{\fboxsep}%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \subsection{High-level macros}
%
% \label{sec:textcolor}
% \begin{macro}{\textcolor}
% \oarg{model} \marg{color} \marg{text}
%
% Converted into an \HTML\ hex color span.
%
% \changes{v0.57}{2018/06/02}{\pkg{xcolor}: New system for switching print and \HTML\ outputs.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@textcolor}{o m m}{%
\begingroup%
%    \end{macrocode}
% Set the \PDF\ color, to be picked up by \SVG\ math if possible.
%
% The print-mode \cs{color} command cannot accept the \optn{named}
% option with color mixing, but it works with no option at all.
%
% \changes{v0.51}{2018/03/14}{Fix: SVG math color.}
%    \begin{macrocode}
\IfValueTF{#1}{%
    \color[#1]{#2}%
}{%
    \color{#2}%
}%
%    \end{macrocode}
%    \begin{macrocode}
\LWR@FBcancel%
\IfValueTF{#1}{%
\InlineClass[color:\LWR@colorstyle{#1}{#2}]{textcolor}{%
\renewcommand*{\LWR@currenttextcolor}{\LWR@origpound\LWR@tempcolor}%
#3%
}%
}{%
\InlineClass[color:\LWR@colorstyle{named}{#2}]{textcolor}{%
\renewcommand*{\LWR@currenttextcolor}{\LWR@origpound\LWR@tempcolor}%
#3%
}%
}%
\endgroup%
}

\LWR@formatted{textcolor}
%    \end{macrocode}
% \end{macro}

% \begin{macro}{\pagecolor}
% \oarg{model} \marg{color}
%
% Ignored.  Use \CSS\ 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}.
%
% \changes{v0.57}{2018/06/02}{\pkg{xcolor}: New system for switching print and \HTML\ outputs.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@colorbox}{O{named} m +m}{%
\begingroup%
\LWR@FBcancel%
\InlineClass[%
background:\LWR@colorstyle{#1}{#2} ; %
padding:\LWR@printlength{\fboxsep}%
]{colorbox}{#3}%
\endgroup%
}

\AtBeginDocument{
\LWR@formatted{colorbox}
}
%    \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}.
%
% \changes{v0.57}{2018/06/02}{\pkg{xcolor}: New system for switching print and \HTML\ outputs.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@colorboxBlock}{O{named} m +m}{%
\begingroup%
\LWR@FBcancel%
%    \end{macrocode}
% \changes{v0.62}{2018/11/11}{Fix: Horiz white space.}
%    \begin{macrocode}
\LWR@stoppars%
%    \end{macrocode}
%    \begin{macrocode}
\begin{BlockClass}[%
background:\LWR@colorstyle{#1}{#2} ; %
padding:\LWR@printlength{\fboxsep}%
]{colorboxBlock}
#3
\end{BlockClass}%
\endgroup%
%    \end{macrocode}
% Prevent paragraph tags around horizontal white space
% until the start of the next paragraph:
% \changes{v0.62}{2018/11/11}{Fix: Horiz white space.}
%    \begin{macrocode}
\global\booltrue{LWR@minipagethispar}%
}

\AtBeginDocument{
\LWR@formatted{colorboxBlock}
}
%    \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.
%
% \changes{v0.57}{2018/06/02}{\pkg{xcolor}: New system for switching print and \HTML\ outputs.}
%    \begin{macrocode}
\NewDocumentCommand{\LWR@HTML@fcolorbox}{O{named} m O{named} m +m}{%
\LWR@traceinfo{HTML fcolorbox #2 #4}%
\begingroup%
\LWR@FBcancel%
\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%
}

\AtBeginDocument{
\LWR@formatted{fcolorbox}
}
%    \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{\LWR@HTML@fcolorboxBlock}{O{named} m O{named} m +m}{%
\LWR@traceinfo{HTML fcolorboxBlock #2 #4}%
\begingroup%
\LWR@FBcancel%
\LWR@forceminwidth{\fboxrule}%
%    \end{macrocode}
% \changes{v0.62}{2018/11/11}{Fix: Horiz white space.}
%    \begin{macrocode}
\LWR@stoppars%
%    \end{macrocode}
%    \begin{macrocode}
\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@origpound\LWR@tempcolortwo\ ; %
            \LWR@borderpadding{#1}{#2}%
        ]{fcolorboxBlock}
        #5
        \end{BlockClass}%
    }%
\endgroup%
%    \end{macrocode}
% Prevent paragraph tags around horizontal white space
% until the start of the next paragraph:
% \changes{v0.62}{2018/11/11}{Fix: Horiz white space.}
%    \begin{macrocode}
\global\booltrue{LWR@minipagethispar}%
\LWR@traceinfo{HTML fcolorboxBlock done}%
}

\AtBeginDocument{
\LWR@formatted{fcolorboxBlock}
}
%    \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}{%
%    \end{macrocode}
% \changes{v0.62}{2018/11/11}{Fix: Horiz white space.}
%    \begin{macrocode}
\LWR@stoppars%
%    \end{macrocode}
%    \begin{macrocode}
\begin{BlockClass}[%
#3%
\LWR@borderpadding{#1}{#2} ; %
\IfValueT{#4}{height:\LWR@printlength{\LWR@tempheight} ; }%
width:\LWR@printlength{\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{LWR@HTML@fcolorminipage}{O{named} m O{named} m O{c} o o m}
{%
\LWR@FBcancel%
\setlength{\LWR@tempwidth}{#8}%
\IfValueT{#6}{\setlength{\LWR@tempheight}{#6}}%
\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@origpound\LWR@tempcolortwo\ ; }%
            {#6}%
    }%
}%
{%
    \end{BlockClass}%
%    \end{macrocode}
% Prevent paragraph tags around horizontal white space
% until the start of the next paragraph:
% \changes{v0.62}{2018/11/11}{Fix: Horiz white space.}
%    \begin{macrocode}
    \global\booltrue{LWR@minipagethispar}%
}

\AtBeginDocument{
\LWR@formattedenv{fcolorminipage}
}
%    \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.
%
% \changes{v0.57}{2018/06/02}{\pkg{xcolor}: Fix: Colored \cs{boxframe}.}
%    \begin{macrocode}
\newcommand*{\LWR@HTML@boxframe}[3]{%
{%
\setlength{\LWR@tempwidth}{#1}%
\setlength{\LWR@tempheight}{#2}%
\addtolength{\LWR@tempheight}{#3}%
\LWR@forceminwidth{\fboxrule}%
\LWR@findcurrenttextcolor%
\InlineClass[%
display:inline-block ; %
border:\LWR@printlength{\LWR@atleastonept} solid \LWR@currenttextcolor{} ; %
width:\LWR@printlength{\LWR@tempwidth} ; %
height:\LWR@printlength{\LWR@tempheight}%
]{boxframe}{}%
}%
}

\LWR@formatted{boxframe}
%    \end{macrocode}
% \end{macro}
%
%
% \subsection{Row colors}
% \changes{v0.49}{2018/02/17}{\pkg{xcolor}: Added tabular row colors.}
%
% \begin{noindmacro}{\rowc@l@rs} \oarg{cmds} \marg{startrow} \marg{odd color} \marg{even color}
%    \begin{macrocode}
\newcommand*{\LWR@xcolortempcolor}{}

\def\rowc@l@rs[#1]#2#3#4%
{
\global\rownum=1
   \global\@rowcolorstrue
   \@ifxempty{#3}%
     {\def\@oddrowcolor{\@norowcolor}}%
     {%
        \convertcolorspec{named}{#3}{HTML}\LWR@xcolortempcolor%
        \edef\@oddrowcolor{%
            \csdef{LWR@xcolorrowHTMLcolor}{\LWR@xcolortempcolor}%
        }%
     }%
   \@ifxempty{#4}%
     {\def\@evenrowcolor{\@norowcolor}}%
     {%
        \convertcolorspec{named}{#4}{HTML}\LWR@xcolortempcolor%
        \edef\@evenrowcolor{%
            \csdef{LWR@xcolorrowHTMLcolor}{\LWR@xcolortempcolor}%
        }%
     }%
   \if@rowcmd
     \def\@rowcolors
     {%
%         #1%
        \if@rowcolors
%         \noalign{%
            \relax\ifnum\rownum<#2\@norowcolor\else
            \ifodd\rownum\@oddrowcolor\else\@evenrowcolor\fi\fi%
%          }%
        \fi%
     }%
   \else
     \def\@rowcolors
     {%
        \if@rowcolors
            \ifnum\rownum<#2%
%            \noalign{%
                \@norowcolor
%             }
            \else
%            #1%
%            \noalign{%
                \ifodd\rownum\@oddrowcolor\else\@evenrowcolor\fi%
%             }%
            \fi
        \fi%
     }%
   \fi
   \ignorespaces%
}
%    \end{macrocode}
% \end{noindmacro}
%
% \begin{noindmacro}{\@norowcolor} Turns off color for this row.
%    \begin{macrocode}
\def\@norowcolor{%
\renewcommand{\LWR@xcolorrowHTMLcolor}{}%
}
%    \end{macrocode}
% \end{noindmacro}
% 

% \begin{noindmacro}{\@rowc@lors} Executed at the end of each row.
%    \begin{macrocode}
\def\@rowc@lors{%
%   \noalign{%
        \global\advance\rownum\@ne%
%   }%
    \@rowcolors%
}
%    \end{macrocode}
% \end{noindmacro}

%
%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
% \iffalse
%</xcolor>
% \fi
%
%
%
%
%
% \iffalse
%<*xechangebar>
% \fi
%
% \part{lwarp-xechangebar.sty}
%
% \section{xechangebar}
%
% \DescribePackage{xechangebar}
% \pkg{xechangebar} is ignored.
%
% \changes{v0.62}{2018/10/18}{\pkg{xechangebar}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{xechangebar}[2017/08/03]
\LWR@origRequirePackage{lwarp-changebar}
%    \end{macrocode}
%
% \iffalse
%</xechangebar>
% \fi
%
%
%
%
% \iffalse
%<*xellipsis>
% \fi
%
% \part{lwarp-xellipsis.sty}

% \section{xellipsis}
%
% \credits{Donald P. Goodman III}
%
% \DescribePackage{xellipsis}
% \pkg{xellipsis} is patched for use by \pkg{lwarp}.
%
% When non-zero, each of the spaces is converted to an \HTML\ thin unbreakable space.
%
% \changes{v0.57}{2018/05/15}{\pkg{xellipsis}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{xellipsis}[2015/11/01]
%    \end{macrocode}

%    \begin{macrocode}
\newcommand*{\LWR@xellipsespace}[1]{%
\ifdim#1=0pt\else%
    \ifdim#1<\fontdimen2\font%
        \,%
    \else%
        ~%
    \fi%
\fi%
}

\def\xelip{%
\mbox{%
    \LWR@xellipsespace{\xelipprebef}%
    \xelipprechar%
    \LWR@xellipsespace{\xelippreaft}%
    \LWR@xellipsespace{\xelipbef}%
    \xelipchar%
    \xel@loopi = 1%
    \loop\ifnum\xelipnum>\xel@loopi%
        \advance\xel@loopi by1%
        \LWR@xellipsespace{\xelipgap}%
        \xelipchar%
    \repeat%
    \LWR@xellipsespace{\xelipaft}%
    \LWR@xellipsespace{\xelippostbef}%
    \xelippostchar%
    \LWR@xellipsespace{\xelippostaft}%
}%
}%
%    \end{macrocode}

% \iffalse
%</xellipsis>
% \fi
%
%
%
%
% \iffalse
%<*xetexko-vertical>
% \fi
%
% \part{lwarp-xetexko-vertical.sty}
%
% \section{xetexko-vertical}
%
% \credits{Dohyun Kim}
%
% \DescribePackage{xetexko-vertical}
% \pkg{xetexko-vertical} is patched for use by \pkg{lwarp}.
%
% \changes{v0.20}{2017/01/11}{\pkg{xetexko-vertical}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@loadbefore{xetexko-vertical}

\LWR@ProvidesPackagePass{xetexko-vertical}[2018/04/06]
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand{\verticaltypesetting}{}
\renewenvironment{vertical}[1]{\BlockClass{verticalrl}}{\endBlockClass}
\renewenvironment{horizontal}[1]{\BlockClass{horizontaltb}}{\endBlockClass}
\renewcommand{\vertlatin}[1]{#1}
%    \end{macrocode}
%
% \iffalse
%</xetexko-vertical>
% \fi
%
%
%
%
% \iffalse
%<*xfakebold>
% \fi
%
% \part{lwarp-xfakebold.sty}
%
% \section{xfakebold}
%
% \credits{Herbert Voß}
%
% \DescribePackage{xfakebold}
% \pkg{xfakebold} is patched for use by \pkg{lwarp},
% and additional underlying support is found in the \pkg{lwarp} core.
%
% Note that the print version resets to unbold at each page break,
% \trouble[page breaks]{xfakebold=\pkg{xfakebold}}
% whereas the \HTML\ version maintains the bold state until it is undone.
%
% \changes{v0.67}{2019/02/17}{\pkg{xfakebold}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{xfakebold}[2018/07/25]
%    \end{macrocode}
%
%    \begin{macrocode}
\let\LWR@orig@setBold\setBold
\let\LWR@orig@unsetBold\unsetBold
\renewcommand*{\setBold}{\booltrue{LWR@xfakebold}}
\renewcommand*{\unsetBold}{\boolfalse{LWR@xfakebold}}

\renewcommand*{\LWR@applyxfakebold}{%
    \ifbool{LWR@xfakebold}{\LWR@orig@setBold}{\LWR@orig@unsetBold}%
}
%    \end{macrocode}
%
% \iffalse
%</xfakebold>
% \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}[2018-08-23]
%    \end{macrocode}

% In the user's document preamble, \pkg{lwarp} should be loaded
% after font-related setup.
% \trouble[font size]{xfrac=\pkg{xfrac}}
% During \HTML\ conversion, this font is used by \pkg{lwarp}
% to generate its initial \PDF\ output containing \HTML\ tags,
% later to be converted by \prog{pdftotext} to a plain text file.
% While the text may be in any font which \prog{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.}
% \gindex{font>size>xfrac=\pkg{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}


% Instances of \pkg{xfrac} for various font choices:
% \margintag{instances}
%
% Produce \CSS\ for a small raised numerator and
% a small denominator.
%
% Scaling is turned off so that \prog{pdftotext} correctly reads the result.
%
% \changes{v0.16}{2016/04/07}{\pkg{xfrac}: Adjusted for the use of any font:}
% \changes{v0.48}{2018/02/13}{\pkg{xfrac}: Fix: Added groups around super/subscripts
%           to localize \env{LWR@nestspan} changes.}
% \changes{v0.57}{2018/06/01}{\pkg{xfrac}: Improved print/HTML \cs{scalebox} control.}
% \changes{v0.62}{2018/11/15}{\pkg{xfrac}: Improved \CSS.}
%    \begin{macrocode}
\DeclareInstance{xfrac}{default}{text}{
    numerator-format = {%
        \begingroup%
        \RenewDocumentCommand{\scalebox}{m o m}{##3}%
        \InlineClass{numerator}{#1}\,%
        \endgroup%
    },
    denominator-format = {%
        \begingroup%
        \RenewDocumentCommand{\scalebox}{m o m}{##3}%
        \InlineClass{denominator}{#1}%
        \endgroup%
    },
%    \end{macrocode}
% For \prog{pdftotext}, do not scale the text:
%    \begin{macrocode}
    scaling = false
}

\DeclareInstance{xfrac}{lmr}{text}{
    numerator-format = {%
        \begingroup%
        \RenewDocumentCommand{\scalebox}{m o m}{##3}%
        \InlineClass{numerator}{#1}\,%
        \endgroup%
    },
    denominator-format = {%
        \begingroup%
        \RenewDocumentCommand{\scalebox}{m o m}{##3}%
        \InlineClass{denominator}{#1}%
        \endgroup%
    },
%    \end{macrocode}
% For \prog{pdftotext}, do not scale the text:
%    \begin{macrocode}
    scaling = false
}

\DeclareInstance{xfrac}{lmss}{text}{
    numerator-format = {%
        \begingroup%
        \RenewDocumentCommand{\scalebox}{m o m}{##3}%
        \InlineClass{numerator}{#1}\,%
        \endgroup%
    },
    denominator-format = {%
        \begingroup%
        \RenewDocumentCommand{\scalebox}{m o m}{##3}%
        \InlineClass{denominator}{#1}%
        \endgroup%
    },
%    \end{macrocode}
% For \prog{pdftotext}, do not scale the text:
%    \begin{macrocode}
    scaling = false
}

\DeclareInstance{xfrac}{lmtt}{text}{
    numerator-format = {%
        \begingroup%
        \RenewDocumentCommand{\scalebox}{m o m}{##3}%
        \InlineClass{numerator}{#1}\,%
        \endgroup%
    },
    denominator-format = {%
        \begingroup%
        \RenewDocumentCommand{\scalebox}{m o m}{##3}%
        \InlineClass{denominator}{#1}%
        \endgroup%
    },
%    \end{macrocode}
% For \prog{pdftotext}, do not scale the text:
%    \begin{macrocode}
    scaling = false
}
%    \end{macrocode}


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


%    \begin{macrocode}
\end{warpHTML}
%    \end{macrocode}
%
% \iffalse
%</xfrac>
% \fi
%
%
%
%
%
%
% \iffalse
%<*xltabular>
% \fi

% \part{lwarp-xltabular.sty}

% \section{xltabular}
%
% \credits{Rolf Niepraschk, Herbert Voß}
%
% \DescribePackage{xltabular}
% \pkg{xltabular} is emulated by \pkg{lwarp}.
%
% \changes{v0.57}{2018/05/25}{\pkg{xltabular}: Added.}
%
% \codehtml
%
% Relies on \pkg{tabularx}.
%
% At present, an \env{xltabular} without a caption or with only a \cs{caption*}
% \trouble[table numbering]{tabular>numbering}
% \trouble{xltabular=\pkg{xltabular}>numbering}
% may be misnumbered in \HTML, so it may be necessary to place at the end
% of the table:
% \begin{sourcedisplay}
% \cs{warpHTMLonly}\{\cs{addtocounter}\{table\}\{-1\}\}
% \end{sourcedisplay}
%
%    \begin{macrocode}
\RequirePackage{tabularx}

\LWR@ProvidesPackageDrop{xltabular}[2018/05/23]

\DeclareDocumentEnvironment{xltabular}{o m m}
{\longtable{#3}}
{\endlongtable}
%    \end{macrocode}
%
%
% \iffalse
%</xltabular>
% \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}[2016/01/21]
%    \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}[2008/05/10]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*{\includexmp}[1]{}
%    \end{macrocode}
%
% \iffalse
%</xmpincl>
% \fi
%
%
%
%
% \iffalse
%<*xpiano>
% \fi
%
% \part{lwarp-xpiano.sty}

% \section{xpiano}
%
% \credits{Enrico Gregorio}
%
% \DescribePackage{xpiano}
% \pkg{xpiano} is patched for use by \pkg{lwarp}.
%
% \changes{v0.57}{2018/06/03}{\pkg{xpiano}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{xpiano}
%    \end{macrocode}

%    \begin{macrocode}
\ExplSyntaxOn
\NewDocumentCommand{\LWR@print@keyboard}{ O{}m }
{
\xpiano_keyboard:nn { #1 } { #2 }
}

\NewDocumentCommand{\LWR@HTML@keyboard}{ O{}m }
{
\begin{lateximage}*
    [(-xpiano-~\packagediagramname{}: \detokenize\expandafter{#2})]
    [\detokenize\expandafter{#1}]
\xpiano_keyboard:nn { #1 } { #2 }
\end{lateximage}
}
\ExplSyntaxOff

\LWR@formatted{keyboard}
%    \end{macrocode}

% \iffalse
%</xpiano>
% \fi
%
%
%
%
% \iffalse
%<*xpinyin>
% \fi
%
% \part{lwarp-xpinyin.sty}
%
% \section{xpinyin}
%
% \credits{Soben Lee}
%
% \DescribePackage{xpinyin}
% \pkg{xpinyin} is partly supported.
% \cs{xpinyin} and \env{pinyinscope} are nullified, but \cs{pinyin} works.
%
% \changes{v0.63}{2018/12/03}{\pkg{xpinyin}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{xpinyin}[2018/01/28]
%    \end{macrocode}
%
%    \begin{macrocode}
\RenewDocumentEnvironment{pinyinscope}{O{}}{}{}

\RenewDocumentCommand{\xpinyin}{s O{} m}{%
    \IfBooleanTF{#1}{#3}{\@firstoftwo#3}%
}

\RenewDocumentCommand{\enablepinyin}{}{}
%    \end{macrocode}
%
% \iffalse
%</xpinyin>
% \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}[2011/07/31]
%    \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}%
}
%    \end{macrocode}
% \changes{v0.61}{2018/10/05}{\pkg{xtab}: Fix for caption w/o opt arg.}
%    \begin{macrocode}
\newcommand{\tablecaption}[2][]{%
    \long\gdef\LWRXT@caption{%
        \ifblank{#1}%
            {\caption{#2}}%
            {\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
%<*xunicode>
% \fi
%
% \part{lwarp-xunicode.sty}
%
% \section{xunicode}
%
% \DescribePackage{xunicode}
% Error if \pkg{xunicode} is loaded after \pkg{lwarp}.
%
% \changes{v0.59}{2018/08/03}{\pkg{xunicode}: Added.}

% Patch \pkg{lwarp-xunicode}, but also verify that is was loaded before \pkg{lwarp}:
%
% \codehtml
%    \begin{macrocode}
\LWR@loadbefore{xunicode}%

\LWR@ProvidesPackagePass{xunicode}[2011/09/09]
%    \end{macrocode}
%
% \cs{textcircled} becomes a span with a rounded border.
% \cs{providecommand} is used to avoid conflict with \pkg{textcomp}.
% \changes{v0.62}{2018/11/17}{\pkg{xunicode}: Fix conflict with \pkg{textcomp}.}
%    \begin{macrocode}
\providecommand*{\LWR@HTML@textcircled}[1]{%
    \InlineClass[border: 1px solid \LWR@currenttextcolor]{textcircled}{#1}%
}

\LWR@formatted{textcircled}
%    \end{macrocode}
%
% Nullify \pkg{textcomp} macros when generating filenames:
% \changes{v0.67}{2019/02/13}{\pkg{xunicode}: Nullify in filenames.}
%    \begin{macrocode}
\FilenameNullify{%
    \renewcommand*{\textdegree}{}%
    \renewcommand*{\textcelsius}{}%
    \renewcommand*{\textohm}{}%
    \renewcommand*{\textmu}{}%
    \renewcommand*{\textlquill}{}%
    \renewcommand*{\textrquill}{}%
    \renewcommand*{\textcircledP}{}%
    \renewcommand*{\texttwelveudash}{}%
    \renewcommand*{\textthreequartersemdash}{}%
    \renewcommand*{\textmho}{}%
    \renewcommand*{\textnaira}{}%
    \renewcommand*{\textpeso}{}%
    \renewcommand*{\textrecipe}{}%
    \renewcommand*{\textinterrobangdown}{}%
    \renewcommand*{\textperthousand}{}%
    \renewcommand*{\textpertenthousand}{}%
    \renewcommand*{\textbaht}{}%
    \renewcommand*{\textdiscount}{}%
    \renewcommand*{\textservicemark}{}%
    \renewcommand*{\textcircled}[1]{#1}%
    \renewcommand*{\capitalcedilla}[1]{#1}%
    \renewcommand*{\capitalogonek}[1]{#1}%
    \renewcommand*{\capitalgrave}[1]{#1}%
    \renewcommand*{\capitalacute}[1]{#1}%
    \renewcommand*{\capitalcircumflex}[1]{#1}%
    \renewcommand*{\capitaltilde}[1]{#1}%
    \renewcommand*{\capitaldieresis}[1]{#1}%
    \renewcommand*{\capitalhungarumlaut}[1]{#1}%
    \renewcommand*{\capitalring}[1]{#1}%
    \renewcommand*{\capitalcaron}[1]{#1}%
    \renewcommand*{\capitalbreve}[1]{#1}%
    \renewcommand*{\capitalmacron}[1]{#1}%
    \renewcommand*{\capitaldotaccent}[1]{#1}%
}% FilenameNullify
%    \end{macrocode}

% \iffalse
%</xunicode>
% \fi
%
%
%
%
% \iffalse
%<*xurl>
% \fi
%
% \part{lwarp-xurl.sty}
%
% \section{xurl}
%
% \DescribePackage{xurl}
% \pkg{xurl} is ignored.
%
% \changes{v0.47}{2018/01/25}{\pkg{xurl}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{xurl}[2018/06/02]
%    \end{macrocode}
%
% \iffalse
%</xurl>
% \fi
%
%
%
%
%
% \iffalse
%<*xy>
% \fi
%
% \part{lwarp-xy.sty}

% \section{xy}
%
% \credits{Kristoffer H. Rose, Ross Moore}
%
% \DescribePackage{xy}
% \pkg{xy} is patched for use by \pkg{lwarp}.
%
% \cs{xypolygon} must be used inside the \env{xy} environment,
% \trouble[\cs{xypolygon}]{xy=\pkg{xy}}
%   or inside \cs{xy} \dots \cs{endxy}.
%
% \changes{v0.50}{2018/02/21}{\pkg{xy}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackagePass{xy}[2013/10/06]
%    \end{macrocode}

%    \begin{macrocode}
\AtBeginDocument{

\preto{\xy}{\begin{lateximage}[(-xy-~\packagediagramname)]}
\appto{\endxy}{\end{lateximage}}

\@ifundefined{xymatrix}{}{
\LetLtxMacro\LWR@origxymatrix\xymatrix

\renewcommand{\xymatrix}[1]{%
\begin{lateximage}[(-xy- xymatrix \packagediagramname)]
\LWR@origxymatrix{#1}
\end{lateximage}
}
}

\@ifundefined{xygraph}{}{
\LetLtxMacro\LWR@origxygraph\xygraph

\renewcommand{\xygraph}[1]{%
\begin{lateximage}[(-xy- xygraph \packagediagramname)]
\LWR@origxygraph{#1}
\end{lateximage}
}
}

}
%    \end{macrocode}

% \iffalse
%</xy>
% \fi
%
%
%
%
%
% \iffalse
%<*zhlineskip>
% \fi
%
% \part{lwarp-zhlineskip.sty}
%
% \section{zhlineskip}
%
% \DescribePackage{zhlineskip}
% \pkg{zhlineskip} is ignored.
%
% \changes{v0.63}{2018/12/02}{\pkg{zhlineskip}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\LWR@ProvidesPackageDrop{zhlineskip}[2018/11/30]
%    \end{macrocode}
%
%    \begin{macrocode}
\newcommand*\SetTextEnvironmentSinglespace[1]{}
\newcommand*\RestoreTextEnvironmentLeading{}
\newcommand*\SetMathEnvironmentSinglespace[1]{}
\newcommand*\RestoreMathEnvironmentLeading{}
%    \end{macrocode}
%
% \iffalse
%</zhlineskip>
% \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}[2013/01/13]
%    \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{\LWR@origpound\,\arabic{page}}
\ifXeTeX
\def\ifcaseZWdriver{\ifcase2}
\else
\def\ifcaseZWdriver{\ifcase1}
\fi
\DeclareRobustCommand\ZWifdriver[2]{}
%    \end{macrocode}
%
% \iffalse
%</zwpagelayout>
% \fi
%
%
%
% ^^A *komascript
%
% \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} classes 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}
%
%
% Indexing macros, simplified for \pkg{lwarp}:
% \changes{v0.58}{2018/07/06}{\pkg{lwarp-patch-komascript}: Modified indexing.}
%    \begin{macrocode}
\AtBeginDocument{

\renewcommand*{\idx@heading}{%
  \idx@@heading{\indexname}%
}

\renewenvironment{theindex}{%
  \idx@heading%
  \index@preamble\par\nobreak
    \let\item\LWR@indexitem%
    \let\subitem\LWR@indexsubitem%
    \let\subsubitem\LWR@indexsubsubitem%
}
{}

\renewcommand*\indexspace{}

}% AtBeginDocument
%    \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
%
%
%
%
%
% ^^A *memoir
%
% \iffalse
%<*patch-memoir>
% \fi
%
% \part{lwarp-patch-memoir.sty}
%
% \section{patch-memoir}
%
%
% \credits{Peter Wilson}
%
% \DescribePackage{lwarp-patch-memoir}
% Patches for \pkg{memoir} class.
%
% \testthis
%
% \pkg{lwarp} loads this package when the \pkg{memoir} class is detected.
%
% \limitsmemoir
%
% \changes{v0.45}{2017/12/03}{\pkg{lwarp-patch-memoir}: Added.}
%
% \codehtml
%
%    \begin{macrocode}
\ProvidesPackage{lwarp-patch-memoir}
%    \end{macrocode}
%
% \subsection{Packages}
% \label{sec:patch-memoir-packages}
%
% These are pre-loaded to provide emulation for many of \pkg{memoir}'s functions.
% \pkg{memoir} pretends that \pkg{abstract}, etc. are already loaded, via its
% ``emulated'' package mechanism, but \pkg{lwarp} is directly loading the ``|lwarp-|''
% version of each, which happens to avoid \pkg{memoir}'s emulation system.
%    \begin{macrocode}
\RequirePackage{lwarp-abstract}% req'd
\RequirePackage{lwarp-array}% req'd
\RequirePackage{lwarp-booktabs}% req'd
% \RequirePackage{lwarp-ccaption}% emualated below
\RequirePackage{lwarp-changepage}% req'd
\RequirePackage{lwarp-crop}
\RequirePackage{lwarp-dcolumn}% req'd
\RequirePackage{lwarp-enumerate}% req'd
\RequirePackage{lwarp-epigraph}% req'd
\RequirePackage{lwarp-fancyvrb}% req'd
\RequirePackage{lwarp-footmisc}% req'd
\RequirePackage{lwarp-framed}% req'd
\RequirePackage{lwarp-hanging}% req'd
\RequirePackage{lwarp-makeidx}% req'd
\DisemulatePackage{moreverb}
\RequirePackage{lwarp-moreverb}
\RequirePackage{lwarp-mparhack}
\RequirePackage{lwarp-needspace}% req'd
\RequirePackage{lwarp-nextpage}% req'd
\RequirePackage{lwarp-pagenote}% req'd
\RequirePackage{lwarp-parskip}
\RequirePackage{lwarp-setspace}% req'd
\RequirePackage{lwarp-showidx}
\RequirePackage{lwarp-subfigure}% red'q
\makeindex
%    \end{macrocode}
% \pkg{subfigure} is emulated via \pkg{subfig}, which pre-defines
% |subfigure| and |subtable|, but \pkg{memoir} does not, so
% they must be tested for here:
%    \begin{macrocode}
\LetLtxMacro\LWR@memorignewsubfloat\newsubfloat
\RenewDocumentCommand{\newsubfloat}{O{} m}{%
    \@ifundefined{c@sub#2}{%
        \LWR@memorignewsubfloat[#1]{#2}%
    }{}%
}

\RequirePackage{lwarp-tabularx}% req'd
\RequirePackage{lwarp-titling}% req'd
% \RequirePackage{lwarp-tocbibind}% not emulated by memoir
\RequirePackage{lwarp-tocloft}% req'd
\RequirePackage{lwarp-verse}% req'd
%    \end{macrocode}
%
%
% \subsection{Preliminary setup}
%
% Bypass the \pkg{memoir} package mechanism:
%    \begin{macrocode}
\LetLtxMacro\LWR@orig@label\@mem@old@label
%    \end{macrocode}

%
% \pkg{memoir} already set the page size to a default,
% so it must be forced large for \pkg{lwarp}'s use,
% to avoid tag overflows off the page.
%    \begin{macrocode}
\setstocksize{190in}{20in}
\setlrmarginsandblock{2in}{2in}{*}
\setulmarginsandblock{1in}{1in}{*}
%    \end{macrocode}
%
%
% \subsection{Laying out the page}
%
%    \begin{macrocode}
\renewcommand*{\stockavi}{}
\renewcommand*{\stockav}{}
\renewcommand*{\stockaiv}{}
\renewcommand*{\stockaiii}{}
\renewcommand*{\stockbvi}{}
\renewcommand*{\stockbv}{}
\renewcommand*{\stockbiv}{}
\renewcommand*{\stockbiii}{}
% \renewcommand*{\stockmetriccrownvo}{}% in docs but not in the package
\renewcommand*{\stockmlargecrownvo}{}
\renewcommand*{\stockmdemyvo}{}
\renewcommand*{\stockmsmallroyalvo}{}
\renewcommand*{\pageavi}{}
\renewcommand*{\pageav}{}
\renewcommand*{\pageaiv}{}
\renewcommand*{\pageaiii}{}
\renewcommand*{\pagebvi}{}
\renewcommand*{\pagebv}{}
\renewcommand*{\pagebiv}{}
\renewcommand*{\pagebiii}{}
% \renewcommand*{\pagemetriccrownvo}{}% in docs but not in the package
\renewcommand*{\pagemlargecrownvo}{}
\renewcommand*{\pagemdemyvo}{}
\renewcommand*{\pagemsmallroyalvo}{}

\renewcommand*{\stockdbill}{}
\renewcommand*{\stockstatement}{}
\renewcommand*{\stockexecutive}{}
\renewcommand*{\stockletter}{}
\renewcommand*{\stockold}{}
\renewcommand*{\stocklegal}{}
\renewcommand*{\stockledger}{}
\renewcommand*{\stockbroadsheet}{}
\renewcommand*{\pagedbill}{}
\renewcommand*{\pagestatement}{}
\renewcommand*{\pageexecutive}{}
\renewcommand*{\pageletter}{}
\renewcommand*{\pageold}{}
\renewcommand*{\pagelegal}{}
\renewcommand*{\pageledger}{}
\renewcommand*{\pagebroadsheet}{}

\renewcommand*{\stockpottvo}{}
\renewcommand*{\stockfoolscapvo}{}
\renewcommand*{\stockcrownvo}{}
\renewcommand*{\stockpostvo}{}
\renewcommand*{\stocklargecrownvo}{}
\renewcommand*{\stocklargepostvo}{}
\renewcommand*{\stocksmalldemyvo}{}
\renewcommand*{\stockdemyvo}{}
\renewcommand*{\stockmediumvo}{}
\renewcommand*{\stocksmallroyalvo}{}
\renewcommand*{\stockroyalvo}{}
\renewcommand*{\stocksuperroyalvo}{}
\renewcommand*{\stockimperialvo}{}
\renewcommand*{\pagepottvo}{}
\renewcommand*{\pagefoolscapvo}{}
\renewcommand*{\pagecrownvo}{}
\renewcommand*{\pagepostvo}{}
\renewcommand*{\pagelargecrownvo}{}
\renewcommand*{\pagelargepostvo}{}
\renewcommand*{\pagesmalldemyvo}{}
\renewcommand*{\pagedemyvo}{}
\renewcommand*{\pagemediumvo}{}
\renewcommand*{\pagesmallroyalvo}{}
\renewcommand*{\pageroyalvo}{}
\renewcommand*{\pagesuperroyalvo}{}
\renewcommand*{\pageimperialvo}{}

\renewcommand*{\memfontfamily}{}
\renewcommand*{\memfontenc}{}
\renewcommand*{\memfontpack}{}

\renewcommand*{\anyptfilebase}{}
\renewcommand*{\anyptsize}{10}

\renewcommand*{\setstocksize}[2]{}
\renewcommand*{\settrimmedsize}[3]{}
\renewcommand*{\settrims}[2]{}

% \newlength{\lxvchars}
% \setlength{\lxvchars}{305pt}
% \newlength{\xlvchars}
% \setlength{\xlvchars}{190pt}
\renewcommand*{\setxlvchars}[1]{}
\renewcommand*{\setlxvchars}[1]{}

\renewcommand*{\settypeblocksize}[3]{}
\renewcommand*{\setlrmargins}[3]{}
\renewcommand*{\setlrmarginsandblock}[3]{}
\renewcommand*{\setbinding}[1]{}
\renewcommand*{\setulmargins}[3]{}
\renewcommand*{\setulmarginsandblock}[3]{}
\renewcommand*{\setcolsepandrule}[2]{}

\renewcommand*{\setheadfoot}[2]{}
\renewcommand*{\setheaderspaces}[3]{}
\renewcommand*{\setmarginnotes}[3]{}
\renewcommand*{\setfootins}[2]{}
\renewcommand*{\checkandfixthelayout}[1][]{}
\renewcommand*{\checkthelayout}[1]{}
\renewcommand*{\fixthelayout}{}
% 
% \newlength{\stockheight}
% \newlength{\trimtop}
% \newlength{\trimedge}
% \newlength{\stockwidth}
% \newlength{\spinemargin}
% \newlength{\foremargin}
% \newlength{\uppermargin}
% \newlength{\headmargin}
% 
\renewcommand*{\typeoutlayout}{}
\renewcommand*{\typeoutstandardlayout}{}
\renewcommand*{\settypeoutlayoutunit}[1]{}
\renewcommand*{\fixpdflayout}{}
\renewcommand*{\fixdvipslayout}{}

\renewcommand*{\medievalpage}[1][]{}
\renewcommand*{\isopage}[1][]{}
\renewcommand*{\semiisopage}[1][]{}

\renewcommand{\setpagebl}[3]{}
\renewcommand{\setpageml}[3]{}
\renewcommand{\setpagetl}[3]{}
\renewcommand{\setpagetm}[3]{}
\renewcommand{\setpagetr}[3]{}
\renewcommand{\setpagemr}[3]{}
\renewcommand{\setpagebr}[3]{}
\renewcommand{\setpagebm}[3]{}
\renewcommand{\setpagecc}[3]{}
%    \end{macrocode}
%
% \subsection{Text and fonts}
%    \begin{macrocode}
\let\miniscule\tiny
\let\HUGE\Huge
 
\renewcommand*{\abnormalparskip}[1]{}
\renewcommand*{\nonzeroparskip}{}
\renewcommand*{\traditionalparskip}{}
 
\let\onelineskip\baselineskip
 
\let\OnehalfSpacing\onehalfspacing
\let\DoubleSpacing\doublespacing
\renewcommand*{\setPagenoteSpacing}[1]{}
\renewcommand*{\setFloatSpacing}[1]{}
\let\SingleSpacing\singlespacing
\let\setSingleSpace\SetSinglespace
\let\SingleSpace\singlespace
\let\endSingleSpace\endsinglespace
\let\Spacing\spacing
\let\endSpacing\endspacing
\let\OnehalfSpace\onehalfspace
\let\endOnehalfSpace\endonehalfspace
\csletcs{OnehalfSpace*}{onehalfspace}
\csletcs{endOnehalfSpace*}{endonehalfspace}
\let\DoubleSpace\doublespace
\let\endDoubleSpace\enddoublespace
\csletcs{DoubleSpace*}{doublespace}
\csletcs{endDoubleSpace*}{enddoublespace}
\renewcommand*{\setDisplayskipStretch}[1]{}
\renewcommand*{\memdskipstretch}{}
\renewcommand*{\noDisplayskipStretch}{}
\renewcommand*{\memdskips}{}

\renewcommand*{\midsloppy}{}
\renewenvironment*{midsloppypar}{}{}

\renewcommand*{\sloppybottom}{}
%    \end{macrocode}
%
% \subsection{Titles}
%
% \changes{v0.54}{2018/04/06}{\pkg{lwarp-patch-memoir}: Update for v3.7g.}
%    \begin{macrocode}
\csletcs{titlingpage*}{titlingpage}
\csletcs{endtitlingpage*}{endtitlingpage}
\let\titlingpageend\relax
\newcommand{\titlingpageend}[2]{}
\let\andnext\and
\renewcommand*{\thanksmarkstyle}[1]{}
\renewcommand{\thanksfootmark}{%
\thanksscript{\tamark}%
}

% \newlength{\thanksmarksep}
%    \end{macrocode}
%
% \subsection{Abstracts}
%    \begin{macrocode}
\renewcommand*{\abstractcol}{}
\renewcommand*{\abstractintoc}{}
\renewcommand*{\abstractnum}{}
\renewcommand*{\abstractrunin}{}
%    \end{macrocode}
%
% \subsection{Docment divisions}
%    \begin{macrocode}

\def\@apppage{%
    \part*{\appendixpagename}
}
\renewcommand\mempreaddapppagetotochook{}
\renewcommand\mempostaddapppagetotochook{}

\def\@sapppage{%
    \part*{\appendixpagename}
}

\csletcs{frontmatter*}{frontmatter}
\csletcs{mainmatter*}{mainmatter}
\renewcommand*{\raggedbottomsection}{}
\renewcommand*{\normalbottomsection}{}
\renewcommand*{\bottomsectionskip}{}
\renewcommand*{\bottomsectionpenalty}{}
\csletcs{appendixpage*}{appendixpage}
\renewcommand*{\namedsubappendices}{}
\renewcommand*{\unnamedsubappendices}{}
\renewcommand*{\setsecnumdepth}[1]{}% todo tocvsec2
\renewcommand*{\maxsecnumdepth}[1]{}% todo tocvsec2
\renewcommand*{\beforebookskip}{}
\renewcommand*{\afterbookskip}{}
\renewcommand*{\beforepartskip}{}
\renewcommand*{\afterpartskip}{}
\renewcommand*{\midbookskip}{}
\renewcommand*{\midpartskip}{}
\renewcommand*{\printbookname}{}
\renewcommand*{\booknamefont}{}
\renewcommand*{\booknamenum}{}
\renewcommand*{\printbooknum}{}
\renewcommand*{\booknumfont}{}
\renewcommand*{\printpartname}{}
\renewcommand*{\partnamefont}{}
\renewcommand*{\partnamenum}{}
\renewcommand*{\printpartnum}{}
\renewcommand*{\partnumfont}{}
\renewcommand*{\printbooktitle}[1]{}
\renewcommand*{\booktitlefont}{}
\renewcommand{\printparttitle}[1]{}
\renewcommand*{\parttitlefont}{}
\renewcommand*{\bookpageend}{}
\renewcommand*{\bookblankpage}{}
\renewcommand*{\nobookblankpage}{}
\renewcommand*{\partpageend}{}
\renewcommand*{\partblankpage}{}
\renewcommand*{\nopartblankpage}{}
\RenewDocumentCommand{\newleadpage}{s o m m}{}% todo
\RenewDocumentCommand{\renewleadpage}{s o m m}{}% todo
\renewcommand*{\leadpagetoclevel}{chapter}

\renewcommand*{\openright}{}
\renewcommand*{\openleft}{}
\renewcommand*{\openany}{}
\renewcommand*{\clearforchapter}{}
\renewcommand*{\memendofchapterhook}{}
\renewcommand*{\chapterheadstart}{}
% \newlength{\beforechapskip}
\renewcommand*{\afterchapternum}{}
% \newlength{\midchapskip}
\renewcommand*{\afterchaptertitle}{}
% \newlength{\afterchapskip}
\renewcommand*{\printchaptername}{}
\renewcommand*{\chapnamefont}{}
\renewcommand*{\chapternamenum}{}
\renewcommand*{\printchapternum}{}
\renewcommand*{\chapnumfont}{}
\renewcommand{\printchaptertitle}[1]{}
\renewcommand*{\chaptitlefont}{}
\renewcommand*{\printchapternonum}{}
\renewcommand*{\indentafterchapter}{}
\renewcommand*{\noindentafterchapter}{}
\renewcommand*{\insertchapterspace}{}

\renewcommand*{\chapterstyle}[1]{}
\renewcommand{\makechapterstyle}[2]{}
\renewcommand*{\chapindent}{}
\let\chapterprecis\cftchapterprecis
\let\chapterprecishere\cftchapterprecishere
\let\chapterprecistoc\cftchapterprecistoc
\renewcommand*{\precisfont}{}
\renewcommand*{\prechapterprecis}{}
\renewcommand*{\postchapterprecis}{}
\renewcommand{\precistoctext}[1]{}
\renewcommand*{\precistocfont}{}
\renewcommand*{\precistocformat}{}
% \newlength{\prechapterprecisshift}

\renewcommand*{\setbeforesecskip}[1]{}
\renewcommand*{\setaftersecskip}[1]{}
\renewcommand*{\setsecindent}[1]{}
\renewcommand*{\setsecheadstyle}[1]{}
\renewcommand*{\setbeforesubsecskip}[1]{}
\renewcommand*{\setaftersubsecskip}[1]{}
\renewcommand*{\setsubsecindent}[1]{}
\renewcommand*{\setsubsecheadstyle}[1]{}
\renewcommand*{\setbeforesubsubsecskip}[1]{}
\renewcommand*{\setaftersubsubsecskip}[1]{}
\renewcommand*{\setsubsubsecindent}[1]{}
\renewcommand*{\setsubsubsecheadstyle}[1]{}
\renewcommand*{\setbeforeparaskip}[1]{}
\renewcommand*{\setafterparaskip}[1]{}
\renewcommand*{\setparaindent}[1]{}
\renewcommand*{\setparaheadstyle}[1]{}
\renewcommand*{\setbeforesubparaskip}[1]{}
\renewcommand*{\setaftersubparaskip}[1]{}
\renewcommand*{\setsubparaindent}[1]{}
\renewcommand*{\setsubparaheadstyle}[1]{}
\renewcommand{\@hangfrom}[1]{#1}
\renewcommand{\sethangfrom}[1]{}
\renewcommand{\setsecnumformat}[1]{}

\renewcommand*{\hangsecnum}{}
\renewcommand*{\defaultsecnum}{}

\renewcommand*{\sechook}{}
\renewcommand{\setsechook}[1]{}
\renewcommand*{\subsechook}{}
\renewcommand{\setsubsechook}[1]{}
\renewcommand*{\subsubsechook}{}
\renewcommand{\setsubsubsechook}[1]{}
\renewcommand*{\parahook}{}
\renewcommand{\setparahook}[1]{}
\renewcommand*{\subparahook}{}
\renewcommand{\setsubparahook}[1]{}

\RenewDocumentCommand{\plainbreak}{s m}{\begin{center}~\end{center}}

\RenewDocumentCommand{\fancybreak}{s +m}{%
\begin{center}#2\end{center}%
}

\RenewDocumentCommand{\plainfancybreak}{s m m +m}{%
\begin{center}#4\end{center}%
}

\RenewDocumentCommand{\pfbreak}{s}{%
\begin{center}
\pfbreakdisplay
\end{center}
}

% \newlength{\pfbreakskip}
\renewcommand{\pfbreakdisplay}{*\quad*\quad*}

\renewcommand{\makeheadstyles}[2]{}
\renewcommand*{\headstyles}[1]{}
%    \end{macrocode}
%
% \subsection{Pagination and headers}
%    \begin{macrocode}
\renewcommand*{\savepagenumber}{}
\renewcommand*{\restorepagenumber}{}
\renewcommand*{\uppercaseheads}{}
\renewcommand*{\nouppercaseheads}{}

\renewcommand*{\bookpagemark}[1]{}
\renewcommand*{\partmark}[1]{}
\renewcommand*{\bibmark}{}
\renewcommand*{\indexmark}{}
\renewcommand*{\glossarymark}{}

\LWR@origpagestyle{empty}
\renewcommand*{\ps@empty}{}
\renewcommand*{\makepagestyle}[1]{}
\renewcommand*{\emptypshook}{}%
% \renewcommand*{\empty@oddhead}{}
% \renewcommand*{\empty@oddfoot}{}
% \renewcommand*{\empty@evenhead}{}
% \renewcommand*{\empty@evenfoot}{}
\renewcommand*{\@oddhead}{}
\renewcommand*{\@oddfoot}{}
\renewcommand*{\@evenhead}{}
\renewcommand*{\@evenfoot}{}
\renewcommand*{\aliaspagestyle}[2]{}
\renewcommand*{\copypagestyle}[2]{}

\renewcommand*{\makeevenhead}[4]{}
\renewcommand*{\makeoddhead}[4]{}
\renewcommand*{\makeevenfoot}[4]{}
\renewcommand*{\makeoddfoot}[4]{}
\renewcommand*{\makerunningwidth}[3]{}
% \newlength{\headwidth}
\renewcommand*{\makeheadrule}[3]{}
\renewcommand*{\makefootrule}[3]{}
\renewcommand*{\makeheadfootruleprefix}[3]{}
% \newlength{\normalrulethickness}
% \setlength{\normalrulethickness}{.4pt}
% \newlength{\footruleheight}
% \newlength{\footruleskip}
\renewcommand*{\makeheadposition}[5]{}
\renewcommand{\makepsmarks}[2]{}
\renewcommand*{\makeheadfootstrut}[3]{}

\renewcommand{\createplainmark}[3]{}
\renewcommand{\memUChead}[1]{}
\renewcommand{\createmark}[5]{}
\renewcommand*{\clearplainmark}[1]{}
\renewcommand*{\clearmark}[1]{}
\renewcommand{\addtopsmarks}[3]{}
\renewcommand{\ifonlyfloats}[2]{#2}
\renewcommand*{\mergepagefloatstyle}[3]{}

\renewcommand*{\framepichead}{}
\renewcommand*{\framepictextfoot}{}
\renewcommand*{\framepichook}{}
\renewcommand*{\showheadfootlocoff}{}
\renewcommand*{\showtextblocklocoff}{}
%    \end{macrocode}
%
% \subsection{Paragraphs and lists}
%    \begin{macrocode}
\renewcommand{\hangfrom}[1]{#1}
\let\centerfloat\centering
\renewcommand*{\raggedyright}[1][]{}
% \newlength{\ragrparindent}
\renewcommand{\sourceatright}[2][]{\attribution{#2}}
\let\memorigdbs\LWR@endofline
\let\memorigpar\par
\let\atcentercr\LWR@endofline

\renewcommand*{\linenottooshort}[1][]{}
\renewcommand*{\russianpar}{}
\renewcommand*{\lastlinerulefill}{}
\renewcommand*{\lastlineparrule}{}
\renewcommand*{\justlastraggedleft}{}
\renewcommand*{\raggedrightthenleft}{}
\renewcommand*{\leftcenterright}{}

\renewcommand{\leftspringright}[4]{%
\begin{minipage}{#1\linewidth}#3\end{minipage}\qquad%
\begin{minipage}{#2\linewidth}\begin{flushright}#4\end{flushright}\end{minipage}%
}

\renewenvironment*{blockdescription}
{\LWR@descriptionstart\LWR@origdescription}
{\enddescription}
\renewcommand*{\blockdescriptionlabel}[1]{\textbf{#1}}
\renewenvironment*{labelled}[1]{\begin{description}}{\end{description}}
\renewenvironment*{flexlabelled}[6]{\begin{description}}{\end{description}}
\renewcommand*{\tightlists}{}
\renewcommand*{\defaultlists}{}
\RenewDocumentCommand{\firmlists}{s}{}
\renewcommand*{\firmlist}{}
\renewcommand*{\tightlist}{}
\renewcommand*{\zerotrivseps}{}
\renewcommand*{\savetrivseps}{}
\renewcommand*{\restoretrivseps}{}
%    \end{macrocode}
%
% \subsection{Contents lists}
%    \begin{macrocode}
\csletcs{tableofcontents*}{tableofcontents}
\csletcs{listoffigures*}{listoffigures}
\csletcs{listoftables*}{listoftables}
\renewenvironment{KeepFromToc}{}{}
\renewcommand*{\onecoltocetc}{}
\renewcommand*{\twocoltocetc}{}
\renewcommand*{\ensureonecol}{}
\renewcommand*{\restorefromonecol}{}
\renewcommand*{\doccoltocetc}{}
\renewcommand*{\maxtocdepth}[1]{}% tocvsec2
\renewcommand*{\settocdepth}[1]{}% tocvsec2

\renewcommand{\tocheadstart}{}
\renewcommand{\printtoctitle}[1]{}
\renewcommand{\tocmark}{}
\renewcommand{\aftertoctitle}{}
\renewcommand{\lofheadstart}{}
\renewcommand{\printloftitle}[1]{}
\renewcommand{\lofmark}{}
\renewcommand{\afterloftitle}{}
\renewcommand{\lotheadstart}{}
\renewcommand{\printlottitle}[1]{}
\renewcommand{\lotmark}{}
\renewcommand{\afterlottitle}{}

\renewcommand*{\setpnumwidth}[1]{}
\renewcommand*{\setrmarg}[1]{}
\renewcommand*{\cftbookbreak}{}
\renewcommand*{\cftpartbreak}{}
\renewcommand*{\cftchapterbreak}{}
%    \end{macrocode}

%    \begin{macrocode}
% \newlength{\cftbeforebookskip}
% \newlength{\cftbookindent}
% \newlength{\cftbooknumwidth}
\renewcommand*{\cftbookfont}{}
\renewcommand*{\cftbookname}{}
\renewcommand*{\cftbookpresnum}{}
\renewcommand*{\cftbookaftersnum}{}
\renewcommand*{\cftbookaftersnumb}{}
\renewcommand*{\cftbookleader}{}
\renewcommand*{\cftbookdotsep}{1}
\renewcommand*{\cftbookpagefont}{}
\renewcommand*{\cftbookafterpnum}{}
\renewcommand*{\cftbookformatpnum}[1]{}
\renewcommand*{\cftbookformatpnumhook}[1]{}
%    \end{macrocode}
% 
% Part is already defined by \pkg{tocloft}.
% 
%    \begin{macrocode}
% \newlength{\cftbeforechapterskip}
% \newlength{\cftchapterindent}
% \newlength{\cftchapternumwidth}
\renewcommand*{\cftchapterfont}{}
\renewcommand*{\cftchaptername}{}
\renewcommand*{\cftchapterpresnum}{}
\renewcommand*{\cftchapteraftersnum}{}
\renewcommand*{\cftchapteraftersnumb}{}
\renewcommand*{\cftchapterleader}{}
\renewcommand*{\cftchapterdotsep}{1}
\renewcommand*{\cftchapterpagefont}{}
\renewcommand*{\cftchapterafterpnum}{}
\renewcommand*{\cftchapterformatpnum}[1]{}
\renewcommand*{\cftchapterformatpnumhook}[1]{}
%    \end{macrocode}
%
% ^^A *8* probably redundant:
%    \begin{macrocode}
% \newlength{\cftbeforesectionskip}
% \newlength{\cftsectionindent}
% \newlength{\cftsectionnumwidth}
\renewcommand*{\cftsectionfont}{}
\renewcommand*{\cftsectionname}{}
\renewcommand*{\cftsectionpresnum}{}
\renewcommand*{\cftsectionaftersnum}{}
\renewcommand*{\cftsectionaftersnumb}{}
\renewcommand*{\cftsectionleader}{}
\renewcommand*{\cftsectiondotsep}{1}
\renewcommand*{\cftsectionpagefont}{}
\renewcommand*{\cftsectionafterpnum}{}
\renewcommand*{\cftsectionformatpnum}[1]{}
\renewcommand*{\cftsectionformatpnumhook}[1]{}
%    \end{macrocode}

%    \begin{macrocode}
% \newlength{\cftbeforesubsectionskip}
% \newlength{\cftsubsectionindent}
% \newlength{\cftsubsectionnumwidth}
\renewcommand*{\cftsubsectionfont}{}
\renewcommand*{\cftsubsectionname}{}
\renewcommand*{\cftsubsectionpresnum}{}
\renewcommand*{\cftsubsectionaftersnum}{}
\renewcommand*{\cftsubsectionaftersnumb}{}
\renewcommand*{\cftsubsectionleader}{}
\renewcommand*{\cftsubsectiondotsep}{1}
\renewcommand*{\cftsubsectionpagefont}{}
\renewcommand*{\cftsubsectionafterpnum}{}
\renewcommand*{\cftsubsectionformatpnum}[1]{}
\renewcommand*{\cftsubsectionformatpnumhook}[1]{}
%    \end{macrocode}

%    \begin{macrocode}
% \newlength{\cftbeforesubsubsectionskip}
% \newlength{\cftsubsubsectionindent}
% \newlength{\cftsubsubsectionnumwidth}
\renewcommand*{\cftsubsubsectionfont}{}
\renewcommand*{\cftsubsubsectionname}{}
\renewcommand*{\cftsubsubsectionpresnum}{}
\renewcommand*{\cftsubsubsectionaftersnum}{}
\renewcommand*{\cftsubsubsectionaftersnumb}{}
\renewcommand*{\cftsubsubsectionleader}{}
\renewcommand*{\cftsubsubsectiondotsep}{1}
\renewcommand*{\cftsubsubsectionpagefont}{}
\renewcommand*{\cftsubsubsectionafterpnum}{}
\renewcommand*{\cftsubsubsectionformatpnum}[1]{}
\renewcommand*{\cftsubsubsectionformatpnumhook}[1]{}
%    \end{macrocode}

%    \begin{macrocode}
% \newlength{\cftbeforeparagraphskip}
% \newlength{\cftparagraphindent}
% \newlength{\cftparagraphnumwidth}
\renewcommand*{\cftparagraphfont}{}
\renewcommand*{\cftparagraphname}{}
\renewcommand*{\cftparagraphpresnum}{}
\renewcommand*{\cftparagraphaftersnum}{}
\renewcommand*{\cftparagraphaftersnumb}{}
\renewcommand*{\cftparagraphleader}{}
\renewcommand*{\cftparagraphdotsep}{1}
\renewcommand*{\cftparagraphpagefont}{}
\renewcommand*{\cftparagraphafterpnum}{}
\renewcommand*{\cftparagraphformatpnum}[1]{}
\renewcommand*{\cftparagraphformatpnumhook}[1]{}
%    \end{macrocode}

%    \begin{macrocode}
% \newlength{\cftbeforesubparagraphskip}
% \newlength{\cftsubparagraphindent}
% \newlength{\cftsubparagraphnumwidth}
\renewcommand*{\cftsubparagraphfont}{}
\renewcommand*{\cftsubparagraphname}{}
\renewcommand*{\cftsubparagraphpresnum}{}
\renewcommand*{\cftsubparagraphaftersnum}{}
\renewcommand*{\cftsubparagraphaftersnumb}{}
\renewcommand*{\cftsubparagraphleader}{}
\renewcommand*{\cftsubparagraphdotsep}{1}
\renewcommand*{\cftsubparagraphpagefont}{}
\renewcommand*{\cftsubparagraphafterpnum}{}
\renewcommand*{\cftsubparagraphformatpnum}[1]{}
\renewcommand*{\cftsubparagraphformatpnumhook}[1]{}
%    \end{macrocode}

%    \begin{macrocode}
% \newlength{\cftbeforefigureskip}
% \newlength{\cftfigureindent}
% \newlength{\cftfigurenumwidth}
\renewcommand*{\cftfigurefont}{}
\renewcommand*{\cftfigurename}{}
\renewcommand*{\cftfigurepresnum}{}
\renewcommand*{\cftfigureaftersnum}{}
\renewcommand*{\cftfigureaftersnumb}{}
\renewcommand*{\cftfigureleader}{}
\renewcommand*{\cftfiguredotsep}{1}
\renewcommand*{\cftfigurepagefont}{}
\renewcommand*{\cftfigureafterpnum}{}
\renewcommand*{\cftfigureformatpnum}[1]{}
\renewcommand*{\cftfigureformatpnumhook}[1]{}
%    \end{macrocode}

%    \begin{macrocode}
% \newlength{\cftbeforesubfigureskip}
% \newlength{\cftsubfigureindent}
% \newlength{\cftsubfigurenumwidth}
\newcommand*{\cftsubfigurefont}{}
\newcommand*{\cftsubfigurename}{}
\newcommand*{\cftsubfigurepresnum}{}
\newcommand*{\cftsubfigureaftersnum}{}
\newcommand*{\cftsubfigureaftersnumb}{}
\newcommand*{\cftsubfigureleader}{}
\newcommand*{\cftsubfiguredotsep}{1}
\newcommand*{\cftsubfigurepagefont}{}
\newcommand*{\cftsubfigureafterpnum}{}
\newcommand*{\cftsubfigureformatpnum}[1]{}
\newcommand*{\cftsubfigureformatpnumhook}[1]{}
%    \end{macrocode}

%    \begin{macrocode}
% \newlength{\cftbeforetableskip}
% \newlength{\cfttableindent}
% \newlength{\cfttablenumwidth}
\renewcommand*{\cfttablefont}{}
\renewcommand*{\cfttablename}{}
\renewcommand*{\cfttablepresnum}{}
\renewcommand*{\cfttableaftersnum}{}
\renewcommand*{\cfttableaftersnumb}{}
\renewcommand*{\cfttableleader}{}
\renewcommand*{\cfttabledotsep}{1}
\renewcommand*{\cfttablepagefont}{}
\renewcommand*{\cfttableafterpnum}{}
\renewcommand*{\cfttableformatpnum}[1]{}
\renewcommand*{\cfttableformatpnumhook}[1]{}
%    \end{macrocode}

%    \begin{macrocode}
% \newlength{\cftbeforesubtableskip}
% \newlength{\cftsubtableindent}
% \newlength{\cftsubtablenumwidth}
\newcommand*{\cftsubtablefont}{}
\newcommand*{\cftsubtablename}{}
\newcommand*{\cftsubtablepresnum}{}
\newcommand*{\cftsubtableaftersnum}{}
\newcommand*{\cftsubtableaftersnumb}{}
\newcommand*{\cftsubtableleader}{}
\newcommand*{\cftsubtabledotsep}{1}
\newcommand*{\cftsubtablepagefont}{}
\newcommand*{\cftsubtableafterpnum}{}
\newcommand*{\cftsubtableformatpnum}[1]{}
\newcommand*{\cftsubtableformatpnumhook}[1]{}
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand*{\booknumberline}[1]{}
\renewcommand*{\partnumberline}[1]{}
\renewcommand*{\chapternumberline}[1]{}
\renewcommand*{\numberlinehook}[1]{}
% \renewcommand*{\cftwhatismyname}{}%
\renewcommand*{\booknumberlinehook}[1]{}
\renewcommand*{\partnumberlinehook}[1]{}
\renewcommand*{\chapternumberlinehook}[1]{}
\renewcommand{\numberlinebox}[2]{}
\renewcommand{\booknumberlinebox}[2]{}
\renewcommand{\partnumberlinebox}[2]{}
\renewcommand{\chapternumberlinebox}[2]{}
% 
% \newlength{\cftparfillskip}
\renewcommand*{\cftpagenumbersoff}[1]{}
\renewcommand*{\cftpagenumberson}[1]{}
\renewcommand*{\cftlocalchange}[3]{}
\renewcommand*{\cftaddtitleline}[4]{}
\renewcommand*{\cftaddnumtitleline}[4]{}
\renewcommand{\cftinsertcode}[2]{}
\renewcommand{\cftinserthook}[2]{}
\renewcommand{\settocpreprocessor}[2]{}
\DeclareRobustCommand{\cftpagenumbersoff}[1]{}
\DeclareRobustCommand{\cftpagenumberson}[1]{}
%    \end{macrocode}
%
% \subsection{Floats and captions}
%
% \begin{noindmacro}{\newfloat} \oarg{1: within} \marg{2: type}
%                           \marg{3: ext} \marg{4: capname}
%    \begin{macrocode}
\RenewDocumentCommand{\newfloat}{o m m m}{%
\IfValueTF{#1}%
{\DeclareFloatingEnvironment[fileext=#3,within=#1,name={#4}]{#2}}%
{\DeclareFloatingEnvironment[fileext=#3,name={#4}]{#2}}%
%    \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.
% ^^A *8* keep the following?
%    \begin{macrocode}
\cslet{listof#2s}\relax%
\cslet{listof#2es}\relax%
}
%    \end{macrocode}
% \end{noindmacro}
%
%
% \begin{noindmacro}{\newlistof} \oarg{within} \marg{type} \marg{ext} \marg{listofname}
%
% Emulated through the \cs{newfloat} mechanism.
% Note that \pkg{memoir} uses a different syntax than \pkg{tocloft} for the name.
%    \begin{macrocode}
\RenewDocumentCommand{\newlistof}{o m m m}
{%
\IfValueTF{#1}
{\newlistentry[#1]{#2}{#3}{0}}
{\newlistentry{#2}{#3}{0}}
\@namedef{ext@#2}{#3}%
\@ifundefined{c@#3depth}{\newcounter{#3depth}}{}%
\setcounter{#3depth}{1}%
\@namedef{#3mark}{}%
\@namedef{#2}{\listof{#2}{#4}}
\@namedef{@cftmake#3title}{}
\@ifundefined{cftbefore#3titleskip}{
    \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{macrocode}
\renewcommand{\setfloatadjustment}[2]{}
%    \end{macrocode}
%
% Borrowed from the \pkg{lwarp} version of \pkg{keyfloat}:
%    \begin{macrocode}
\NewDocumentEnvironment{KFLTmemoir@marginfloat}{O{-1.2ex} m}
{% start
\LWR@BlockClassWP{float:right; width:2in; margin:10pt}{}{marginblock}%
\captionsetup{type=#2}%
}
{%
\endLWR@BlockClassWP%
}

\DeclareDocumentEnvironment{marginfigure}{o}
  {\begin{KFLTmemoir@marginfloat}{figure}}
  {\end{KFLTmemoir@marginfloat}}

\DeclareDocumentEnvironment{margintable}{o}
  {\begin{KFLTmemoir@marginfloat}{table}}
  {\end{KFLTmemoir@marginfloat}}
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand{\setmarginfloatcaptionadjustment}[2]{}
\renewcommand{\setmpjustification}[2]{}
\renewcommand*{\mpjustification}{}
\renewcommand*{\setfloatlocations}[2]{}
\DeclareDocumentCommand{\suppressfloats}{o}{}
\renewcommand*{\FloatBlock}{}
\renewcommand*{\FloatBlockAllowAbove}{}
\renewcommand*{\FloatBlockAllowBelow}{}
\renewcommand*{\setFloatBlockFor}{}

\renewcommand{\captiontitlefinal}[1]{}

\renewcommand{\flegtable}{\tablename}
\renewcommand{\flegfigure}{\figurename}
\renewcommand{\flegtoctable}{}
\renewcommand{\flegtocfigure}{}


\renewcommand{\subcaption}[2][]{%
\ifblank{#1}{\subfloat[#2]{}}{\subfloat[#1][#2]{}}%
}

\renewcommand{\contsubcaption}{\ContinuedFloat\subcaption}

\LetLtxMacro\subcaptionref\subref

\renewcommand*{\tightsubcaptions}{}
\renewcommand*{\loosesubcaptions}{}

\renewcommand*{\subcaptionsize}[1]{}
\renewcommand*{\subcaptionlabelfont}[1]{}
\renewcommand*{\subcaptionfont}[1]{}
\renewcommand*{\subcaptionstyle}[1]{}

\renewcommand*{\hangsubcaption}{}
\renewcommand*{\shortsubcaption}{}
\renewcommand*{\normalsubcaption}{}

\RenewDocumentEnvironment{sidecaption}{o m o}
{}
{
\IfValueTF{#1}{\caption[#1]{#2}}{\caption{#2}}%
\IfValueT{#3}{\label{#3}}%
}

% \newlength{\sidecapwidth}
% \newlength{\sidecapsep}
\renewcommand*{\setsidecaps}[2]{}
\renewcommand*{\sidecapmargin}[1]{}
% \newif\ifscapmargleft
\scapmargleftfalse
\renewcommand*{\setsidecappos}[1]{}

\RenewDocumentEnvironment{sidecontcaption}{m o}
{}
{%
\ContinuedFloat%
\caption{#1}%
%    \end{macrocode}
% Without \cs{@captype}, the section is referred to instead.
%    \begin{macrocode}
\IfValueT{#2}{\label[\@captype]{#2}}%
}
%    \end{macrocode}
% \cs{sidenamedlegend} does not appear to use the \TOC\ argument.
%    \begin{macrocode}
\renewenvironment{sidenamedlegend}[2][]{
\begin{center}
\@nameuse{\@captype name}\CaptionSeparator#2
\end{center}
}
{}

\renewenvironment{sidelegend}[1]
{\begin{center}
#1

}
{\end{center}}

\renewcommand*{\sidecapstyle}{}
\renewcommand*{\overridescapmargin}[1]{}
% \newlength{\sidecapraise}
\renewcommand*{\sidecapfloatwidth}{\linewidth}

\LetLtxMacro\ctabular\tabular
\LetLtxMacro\endctabular\endtabular

\renewcommand{\autorows}[5][]{%
#5
}

\renewcommand{\autocols}[5][]{%
#5
}
%    \end{macrocode}
%
% \subsection{Page notes}
%
%    \begin{macrocode}
\renewcommand*{\feetabovefloat}{}
\renewcommand*{\feetbelowfloat}{}
\renewcommand*{\feetatbottom}{}

\renewcommand*{\verbfootnote}[2][]{
\PackageError{lwarp,memoir}
{Verbatim footnotes are not yet supported by lwarp.}
{This may be improved some day.}
}

\renewcommand*{\plainfootnotes}{}
\renewcommand*{\twocolumnfootnotes}{}
\renewcommand*{\threecolumnfootnotes}{}
\renewcommand*{\paragraphfootnotes}{}
\renewcommand*{\footfudgefiddle}{}

\renewcommand*{\newfootnoteseries}[1]{
\PackageError{lwarp,memoir}
{Memoir footnote series are not yet supported by lwarp.}
{This may be improved some day.}
}

\renewcommand*{\plainfootstyle}[1]{}
\renewcommand*{\twocolumnfootstyle}[1]{}
\renewcommand*{\threecolumnfootstyle}[1]{}
\renewcommand*{\paragraphfootstyle}[1]{}

\renewcommand*{\footfootmark}{}
\renewcommand*{\footmarkstyle}[1]{}

% \newlength{\footmarkwidth}
% \newlength{\footmarksep}
% \newlength{\footparindent}

\renewcommand*{\foottextfont}{}

\renewcommand*{\marginparmargin}[1]{}
\renewcommand*{\sideparmargin}[1]{}

\LetLtxMacro\sidepar\marginpar
\renewcommand*{\sideparfont}{}
\renewcommand*{\sideparform}{}
\LWR@providelength{\sideparvshift}

\renewcommand*{\parnopar}{}

\renewcommand{\sidebar}[1]{\begin{quote}#1\end{quote}}
\renewcommand*{\sidebarmargin}[1]{}
\renewcommand*{\sidebarfont}{}
\renewcommand*{\sidebarform}{}
% \newlength{\sidebarhsep}
% \newlength{\sidebarvsep}
% \newlength{\sidebarwidth}
% \newlength{\sidebartopsep}
\renewcommand{\setsidebarheight}[1]{}
\renewcommand*{\setsidebars}[6]{}
\renewcommand*{\footnotesatfoot}{}
\renewcommand*{\footnotesinmargin}{}

\LetLtxMacro\sidefootnote\footnote
\LetLtxMacro\sidefootnotemark\footnotemark
\LetLtxMacro\sidefootnotetext\footnotetext

\renewcommand*{\sidefootmargin}[1]{}
% \newlength{\sidefoothsep}
% \newlength{\sidefootvsep}
% \newlength{\sidefootwidth}
% \newlength{\sidefootadjust}
% \newlength{\sidefootheight}
\renewcommand*{\setsidefootheight}[1]{}
% \renewcommand*{\sidefootfont}{}% in docs but not in the package
\renewcommand*{\setsidefeet}[6]{}
\renewcommand*{\sidefootmarkstyle}[1]{}
\renewcommand*{\sidefoottextfont}{}
\renewcommand*{\sidefootform}{}

\renewcommand*{\continuousnotenums}{\pncontopttrue}% from pagenote
\renewcommand*{\notepageref}{}
\renewcommand*{\prenotetext}{}
\renewcommand*{\postnotetext}{}
\renewcommand*{\idtextinnotes}[1]{}
\renewcommand*{\printpageinnotes}[1]{}
\renewcommand*{\printpageinnoteshyperref}[1]{}
\renewcommand*{\foottopagenote}{}
\renewcommand*{\pagetofootnote}{}
%    \end{macrocode}
%
% \subsection{Decorative text}
%
%    \begin{macrocode}
\renewcommand*{\epigraphposition}[1]{}
\renewcommand*{\epigraphtextposition}[1]{}
\renewcommand*{\epigraphsourceposition}[1]{}
\renewcommand*{\epigraphfontsize}[1]{}
\renewcommand*{\epigraphforheader}[2][]{}
\renewcommand*{\epigraphpicture}{}
%    \end{macrocode}
%
% \subsection{Poetry}
%
%    \begin{macrocode}
\renewcommand*{\vinphantom}{}
\renewcommand*{\vleftofline}[1]{#1}
% \let\linenumberfrequency\poemlines
% \renewcommand*{\linenumberfont}[1]{}

\DeclareDocumentCommand{\PoemTitle}{s o o m}{%
\IfValueTF{#2}%
{\poemtitle[#2]{#4}}%
{\poemtitle{#4}}%
}

\renewcommand*{\NumberPoemTitle}{}
\renewcommand*{\PlainPoemTitle}{}
\renewcommand*{\poemtitlepstyle}{}
\renewcommand*{\poemtitlestarmark}[1]{}
\renewcommand*{\poemtitlestarpstyle}{}
\renewcommand*{\PoemTitleheadstart}{}
\renewcommand*{\printPoemTitlenonum}{}
\renewcommand*{\printPoemTitlenum}{}
\renewcommand*{\afterPoemTitlenum}{}
\renewcommand*{\printPoemTitletitle}[1]{}
\renewcommand*{\afterPoemTitle}{}
\newlength{\midpoemtitleskip}
\renewcommand*{\PoemTitlenumfont}{}
\renewcommand*{\PoemTitlefont}{}
%    \end{macrocode}
%
% \subsection{Boxes, verbatims and files}
%
%    \begin{macrocode}
\renewenvironment{qframe}{\framed}{\endframed}
\renewenvironment{qshade}{\shaded}{\endshaded}
%    \end{macrocode}
%
% Use the \pkg{comment} package:
%    \begin{macrocode}
\renewcommand*{\commentsoff}[1]{\includecomment{#1}}
\renewcommand*{\commentson}[1]{\excludecomment{#1}}
\LetLtxMacro\renewcomment\commentson

\renewcommand*{\setverbatimfont}[1]{}
\renewcommand*{\tabson}[1]{}
\renewcommand*{\tabsoff}{}
\renewcommand*{\wrappingon}{}
\renewcommand*{\wrappingoff}{}
\renewcommand*{\verbatimindent}{}
\renewcommand*{\verbatimbreakchar}[1]{}
%    \end{macrocode}
%
%    \begin{macrocode}
\DefineVerbatimEnvironment{fboxverbatim}{Verbatim}{frame=single}
%    \end{macrocode}
%
% \env{boxedverbatim} is already defined by \pkg{moreverb}.
% \env{boxedverbatim*} does not appear to work at all, even in a minimal print
% \pkg{memoir} document.
%
%    \begin{macrocode}
\renewcommand*{\bvbox}{}
\renewcommand*{\bvtopandtail}{}
\renewcommand*{\bvsides}{}
\renewcommand*{\nobvbox}{}
% \newlength\bvboxsep
\renewcommand*{\bvtoprulehook}{}
\renewcommand*{\bvtopmidhook}{}
\renewcommand*{\bvendrulehook}{}
\renewcommand*{\bvleftsidehook}{}
\renewcommand*{\bvrightsidehook}{}
\renewcommand*{\bvperpagetrue}{}
\renewcommand*{\bvperpagefalse}{}
\renewcommand{\bvtopofpage}[1]{}
\renewcommand{\bvendofpage}[1]{}
\renewcommand*{\linenumberfrequency}[1]{}
\renewcommand*{\resetbvlinenumber}{}
\renewcommand*{\setbvlinenums}[2]{}
\renewcommand*{\linenumberfont}[1]{}
\renewcommand*{\bvnumbersinside}{}
\renewcommand*{\bvnumbersoutside}{}
%    \end{macrocode}
%
% \subsection{Cross referencing}
%
%    \begin{macrocode}
\renewcommand*{\fref}[1]{\cref{#1}}
\renewcommand*{\tref}[1]{\cref{#1}}
\renewcommand*{\pref}[1]{\cpageref{#1}}
\renewcommand*{\Aref}[1]{\cref{#1}}
\renewcommand*{\Bref}[1]{\cref{#1}}
\renewcommand*{\Pref}[1]{\cref{#1}}
\renewcommand*{\Sref}[1]{\cref{#1}}
\renewcommand*{\figurerefname}{Figure}
\renewcommand*{\tablerefname}{Table}
\renewcommand*{\pagerefname}{page}
\renewcommand*{\bookrefname}{Book~}
\renewcommand*{\partrefname}{Part~}
\renewcommand*{\chapterrefname}{Chapter~}
\renewcommand*{\sectionrefname}{\S}
\renewcommand*{\appendixrefname}{Appendix~}
\LetLtxMacro\titleref\nameref
\renewcommand*{\headnameref}{}
\renewcommand*{\tocnameref}{}

\providecounter{LWR@currenttitle}

\renewcommand*{\currenttitle}{%
    \addtocounter{LWR@currenttitle}{1}%
    \label{currenttitle\arabic{LWR@currenttitle}}%
    \nameref{currenttitle\arabic{LWR@currenttitle}}%
}

\renewcommand*{\theTitleReference}[2]{}
\renewcommand*{\namerefon}{}
\renewcommand*{\namerefoff}{}
%    \end{macrocode}
%
% \subsection{Back matter}
% \label{sec:memoirbackmatter}
%
% Redefined to write the |LWR@autoindex| counter instead of |page|.
% Note that \pkg{memoir} has two versions, depending on the use of \pkg{hyperref}.
%    \begin{macrocode}
\AtBeginDocument{

\def\@@wrindexhyp#1||\\{%
    \addtocounter{LWR@autoindex}{1}%
    \LWR@new@label{LWRindex-\arabic{LWR@autoindex}}%
%     \ifshowindexmark\@showidx{#1}\fi
    \protected@write\@auxout{}%
    {\string\@@wrindexm@m{\@idxfile}{#1}{\arabic{LWR@autoindex}}}%
    \endgroup
    \@esphack}%
%    \end{macrocode}
%
% \label{sec:specialindex}
% \cs{specialindex} behaves like a regular \cs{index}, pointing to where
% \cs{specialindex} is used.
% If \cs{specialindex} is used inside a figure or table after the \cs{caption},
% then the hyperlink will be given the name of that particular figure or table.
% \changes{v0.58}{2018/06/22}{\pkg{lwarp-patch-memoir}: Fix for \cs{specialindex}.}
%    \begin{macrocode}
\def\@@wrspindexhyp#1||\\{%
    \addtocounter{LWR@autoindex}{1}%
    \LWR@new@label{LWRindex-\arabic{LWR@autoindex}}%
%     \ifshowindexmark\@showidx{#1}\fi
    \protected@write\@auxout{}%
    {%
%         \string\@@wrindexm@m{\@idxfile}{#1}{\@nameuse{the\@sptheidx}}%
        \string\@@wrindexm@m{\@idxfile}{#1}{\arabic{LWR@autoindex}}%
    }%
    \endgroup
    \@esphack}%

}% \AtBeginDocument
%    \end{macrocode}

% Patched to use |_html| filename and \cs{BaseJobname}:
% \changes{v0.58}{2018/06/22}{\pkg{lwarp-patch-memoir}: Fix for multiple indexes.}
%    \begin{macrocode}
\catcode`\_=12%
\renewcommand*{\makeindex}[1][\BaseJobname]{%
  \if@filesw
    \def\gindex{\@bsphack%
      \@ifnextchar [{\@index}{\@index[\BaseJobname]}}
    \def\specialindex{\@bsphack\@spindex}%
    \makememindexhook
    \expandafter\newwrite\csname #1@idxfile\endcsname
    \expandafter\immediate\openout \csname #1@idxfile\endcsname #1_html.idx\relax
    \typeout{Writing index file #1_html.idx }%
  \fi}
\catcode`\_=8%
%    \end{macrocode}

% Patched to use |_html| filename and \cs{BaseJobname}.
% This will later be patched by the \pkg{lwarp} core.
% \changes{v0.58}{2018/06/22}{\pkg{lwarp-patch-memoir}: Fix for multiple indexes.}
%    \begin{macrocode}
\catcode`\_=12%
\renewcommand{\printindex}[1][\BaseJobname]{\@input@{#1_html.ind}}
\catcode`\_=8%
%    \end{macrocode}
%
%    \begin{macrocode}
\DeclareDocumentCommand{\newblock}{}{}
% 
\renewcommand*{\showindexmarks}{}
\renewcommand*{\hideindexmarks}{}

\renewcommand*{\xindyindex}{}
%    \end{macrocode}
%
% \subsection{Miscellaneous}
%
%    \begin{macrocode}
\renewcommand*{\changemarks}{}
\renewcommand*{\nochangemarks}{}
\renewcommand*{\added}[1]{}
\renewcommand*{\deleted}[1]{}
\renewcommand*{\changed}[1]{}

\renewcommand*{\showtrimsoff}{}
\renewcommand*{\showtrimson}{}
\renewcommand*{\trimXmarks}{}
\renewcommand*{\trimLmarks}{}
\renewcommand*{\trimFrame}{}
\renewcommand*{\trimNone}{}
\renewcommand*\trimmarkscolor{}
\renewcommand*{\trimmarks}{}
\renewcommand*{\tmarktl}{}
\renewcommand*{\tmarktr}{}
\renewcommand*{\tmarkbr}{}
\renewcommand*{\tmarkbl}{}
\renewcommand*{\tmarktm}{}
\renewcommand*{\tmarkmr}{}
\renewcommand*{\tmarkbm}{}
\renewcommand*{\tmarkml}{}
\renewcommand*{\trimmark}{}
\renewcommand*{\quarkmarks}{}
\renewcommand*{\registrationColour}[1]{}

\renewcommand*{\leavespergathering}[1]{}

\renewcommand*{\noprelistbreak}{}

\renewcommand*{\cleartorecto}{}
\renewcommand*{\cleartoverso}{}

\renewenvironment{vplace}[1][]{}{}
%    \end{macrocode}
%
%
% \subsection{\pkg{ccaption} emulation}
%
%    \begin{macrocode}
\renewcommand*{\captiondelim}[1]{\renewcommand*{\CaptionSeparator}{#1}}
\renewcommand*{\captionnamefont}[1]{}
\renewcommand*{\captiontitlefont}[1]{}
\renewcommand*{\flushleftright}{}
\renewcommand*{\centerlastline}{}
\renewcommand*{\captionstyle}[2][]{}
\DeclareDocumentCommand{\captionwidth}{m}{}
\renewcommand*{\changecaptionwidth}{}
\renewcommand*{\normalcaptionwidth}{}
\renewcommand*{\hangcaption}{}
\renewcommand*{\indentcaption}[1]{}
\renewcommand*{\normalcaption}{}
\renewcommand{\precaption}[1]{}
\renewcommand{\postcaption}[1]{}
\renewcommand{\midbicaption}[1]{}
\renewcommand{\contcaption}[1]{%
% \ContinuedFloat%
% \caption{#1}%
\begin{LWR@figcaption}% later becomes \caption*
\LWR@isolate{\@nameuse{\@captype name}}~%
\thechapter.\the\value{\@captype}\CaptionSeparator\LWR@isolate{#1}%
\end{LWR@figcaption}
}
%    \end{macrocode}

%    \begin{macrocode}
\newlength{\abovelegendskip}
\setlength{\abovelegendskip}{0.5\baselineskip}
\newlength{\belowlegendskip}
\setlength{\belowlegendskip}{\abovelegendskip}
%    \end{macrocode}

% The extra |\\| here forces a \element{br} in \HTML\ when \cs{legend} is
% used in a \cs{marginpar}.
%    \begin{macrocode}
\renewcommand{\legend}[1]{\begin{center}#1\\\end{center}}

\renewcommand{\namedlegend}[2][]{
\begin{center}
\@nameuse{fleg\@captype}\CaptionSeparator#2\\
\end{center}
\@nameuse{flegtoc\@captype}{#1}
}

\renewcommand{\newfixedcaption}[3][\caption]{%
  \renewcommand{#2}{\def\@captype{#3}#1}}
\renewcommand{\renewfixedcaption}[3][\caption]{%
  \renewcommand{#2}{\def\@captype{#3}#1}}
\renewcommand{\providefixedcaption}[3][\caption]{%
  \providecommand{#2}{\def\@captype{#3}#1}}

\renewcommand{\bitwonumcaption}[6][]{%
\ifblank{#2}{\caption{#3}}{\caption[#2]{#3}}%
\addtocounter{\@captype}{-1}%
\begingroup%
\csdef{\@captype name}{#4}%
\ifblank{#5}{\caption{#6}}{\caption[#5]{#6}}%
\endgroup%
\ifblank{#1}{}{\label{#1}}%
}

\LetLtxMacro\bionenumcaption\bitwonumcaption% todo

\renewcommand{\bicaption}[5][]{%
\ifblank{#2}{\caption{#3}}{\caption[#2]{#3}}%
\begin{LWR@figcaption}% later becomes \caption*
\LWR@isolate{#4} \thechapter.\the\value{\@captype}\CaptionSeparator\LWR@isolate{#5}%
\end{LWR@figcaption}
\ifblank{#1}{}{\label{#1}}%
}

\renewcommand{\bicontcaption}[3]{%
\contcaption{#1}%
\begingroup%
\csdef{\@captype name}{#2}%
\contcaption{#3}%
\endgroup%
}
%    \end{macrocode}
% ^^A *8* todo:
%    \begin{macrocode}
% only in ccaption, not in memoir:
% \LetLtxMacro\longbitwonumcaption\bitwonumcaption%
% \LetLtxMacro\longbionenumcaption\bitwonumcaption%
% \LetLtxMacro\longbicaption\bicaption%

\RenewDocumentCommand{\subtop}{O{} O{} m}{%
\subfloat[#1][#2]{#3}%
}

\RenewDocumentCommand{\subbottom}{O{} O{} m}{%
\subfloat[#1][#2]{#3}%
}

\renewcommand{\contsubtop}{%
\ContinuedFloat\addtocounter{\@captype}{1}%
\subtop}

\renewcommand{\contsubbottom}{%
\ContinuedFloat\addtocounter{\@captype}{1}%
\subbottom}

\renewcommand{\subconcluded}{}

\let\subfigure\subbottom
\let\subtable\subtop

\let\contsubtable\contsubtop
\let\contsubfigure\contsubbottom
%    \end{macrocode}
% ^^A *8* todo:
% ^^A tocloft stuff
%    \begin{macrocode}
\newcommand{\newfloatentry}[4][\@empty]{TODO: newfloatentry}
\newcommand{\newfloatlist}[5][\@empty]{TODO: newfloatlist}
\newcommand{\newfloatenv}[4][\@empty]{TODO: newfloatenv}
\DeclareRobustCommand{\newfloatpagesoff}[1]{}
\DeclareRobustCommand{\newfloatpageson}[1]{}
\newcommand{\setnewfloatindents}[3]{}
%    \end{macrocode}
%
%
% \subsection{Final patchwork}
%
%    \begin{macrocode}
\newlistof{tableofcontents}{toc}{\contentsname}
\newlistof{listoffigures}{lof}{\listfigurename}
\newlistof{listoftables}{lot}{\listtablename}
%    \end{macrocode}
%
% \iffalse
%</patch-memoir>
% \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]
% 
%
% \Finale
%
%
%
%
%
\endinput





