1

I am trying lwarp package to compare its performance with tex4ht on large files.

I have small question that I could not find an answer for searching.

I want to use \begin{dmath*} environment when compiling with lualatex only, since lwarp with mathjax does not handle the breqn package. But I do not know how to tell it something like the following

\iflwarp% is there similar command??
   \begin{align*}.....\end{align*}
\else
   \begin{dmath*}.....\end{dmath*}
\fi

Similar to how I do when using tex4ht

\ifdefined\HCode
   \begin{align*}.....\end{align*}
\else
   \begin{dmath*}.....\end{dmath*}
\fi

Right now, when I compile the dmath environment, the math does not display in HTML since mathjax does not know about this environment. It only knows align environment.

Here is MWE

\documentclass{book}
\usepackage[mathjax]{lwarp}
\usepackage{amsmath} 
\usepackage{breqn}

\begin{document}
\begin{dmath*}
y = \sin x
\end{dmath*}
\end{document}

Compiled using

lualatex foo.tex
lualatex foo.tex
lwarpmk html

The above ofcourse does not work

enter image description here

How to handle this? How do I run some Latex code only when using lualatex and other code when using lwarp? I found also some other packages and commands do not work in lwarp, so I need to be able to do this type of conditional for other purposes also and not just for the example above.

reference lwarp package

On page 233 of the above document I see \warpHTMLonly {⟨contents⟩}

 Only process the contents if producing HTML output.

But how to do the else part using the above?

Update

I found that the following works. But I am not sure if this is the correct way to do it.

\documentclass{book}
\usepackage[mathjax]{lwarp}
\usepackage{amsmath} 

%use breqn with lualatex only
\ifbool{warpingHTML}{}{\usepackage{breqn}}

\begin{document}

\ifbool{warpingHTML}
{
\begin{align*}
y = \sin x
\end{align*}
}
{
\begin{dmath*}
y = \sin x
\end{dmath*}
}
\end{document}

And now compiling using

lualatex foo.tex
lualatex foo.tex
lwarpmk html

gives the web page

enter image description here

So it worked. Is this the recommend way then to do conditional in lwarp?

1
  • \warpprintonly Sep 23, 2022 at 15:12

1 Answer 1

3

This works for me:

\documentclass{book}
\usepackage[mathjax]{lwarp}
\usepackage{amsmath} 

\begin{warpprint}
\usepackage{breqn}
\end{warpprint}

\begin{document}

\begin{warpHTML}
  \begin{align*}
    y = \sin x
  \end{align*}
\end{warpHTML}
\begin{warpprint}
  \begin{dmath*}
    y = \sin x
  \end{dmath*}
\end{warpprint}

\end{document}

This is documented in section 7.10 of the manual.

There is also a warpMathJax environment for alternatives to constructs that do not play well with MathJax but are OK for SVG mathematics.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .