# tex4ht compile error using mathml switch using multline with pmatrix and easybmat

It took me a long time to find this and be able to make a MWE. I hope someone has an idea what is causing it and if there is a work around. This problem shows up in this small example, only when I use the mathml switch in tex4ht. Which is really strange. I've had problems before using tex4ht with mathml, but these show up in the HTML file, never in the actual compile stage.

I was trying to use a solution to add dashed lines to a matrix as shown is it possible to add dashed lines between rows/column of pmatrix from amsmath?

\documentclass{article}
\usepackage{amsmath}
\usepackage{easybmat}
\begin{document}

\begin{multline*}
\bgroup
\renewenvironment{pmatrix}{\left(\begin{BMAT}(@){c.c}{c.c}}
{\end{BMAT}\right)}
\begin{pmatrix}
A & B\\
C & D
\end{pmatrix}
\egroup
\end{multline*}
\end{document}


compiles with no problem with pdflatex

But gives this error with tex4ht

htlatex foo.tex "htm,mathml"

(/usr/local/texlive/2013/texmf-dist/tex/generic/tex4ht/html-mml.4ht)
(/usr/local/texlive/2013/texmf-dist/tex/generic/tex4ht/html4-uni.4ht))
(./foo.aux)
l.16 --- TeX4ht warning --- \halign translated into linear text ---
! Missing # inserted in alignment preamble.
&
l.16 \end{multline*}
?


but using this command, it now compiles fine and the HTML file displays fine with the dashed lines in the matrix.

htlatex foo.tex "htm"  %ok


If I remove the multline* environment, it now works ok in both modes

\documentclass{article}
\usepackage{amsmath}
\usepackage{easybmat}
\begin{document}
$\bgroup \renewenvironment{pmatrix}{\left(\begin{BMAT}(@){c.c}{c.c}} {\end{BMAT}\right)} \begin{pmatrix} A & B\\ C & D \end{pmatrix} \egroup$
\end{document}

htlatex foo.tex "htm"   %ok
htlatex foo.tex "htm,mathml"  %ok compile, but wrong HTML display on firefox


The above code was small fragment from large file. Any idea what is causing this error and is there a workaround it? I'd like to use mathml since I use mathjax for final display (in this small example, I did not show this) and like to keep using mathml. I also need to use \usepackage{easybmat}.

One final fact point: If I remove the easybmat part, then it works OK again:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{multline*}
\begin{pmatrix}
A & B\\
C & D
\end{pmatrix}
\end{multline*}
\end{document}

htlatex foo.tex "htm,mathml"  %ok
htlatex foo.tex "htm"  %ok


But I need to use easybmat to add the dashed lines as explained in the question here

So the problem shows up, only when using easybmat with multline. Fyi, here is a question also on error using multline with pmatrix, not sure if it is related Error with pmatrix inside multline* inside minipage inside tabular

texlive 2013, on linux mint 16

tex4ht.c (2012-07-25-19:36 kpathsea)

• the configuration for easybmat doesn't exist. probably easiest fix would be to provide new environment for matrixes instead of redefining pmatrix, in the case of pdf generation, use version with BMAT, and for html, use normal pmatrix, you can add lines with css – michal.h21 Mar 5 '14 at 9:42

I don't have a solution for easybmat support, but in your particular case you can simplify your code and use different, supported by tex4ht, matrix environment . dashed lines can be added with css.

First, simplified document:

\documentclass{article}
\usepackage{nasser}
\begin{document}
\begin{multline*}%
\begin{fourmatrix}
A & B\\
C & D
\end{fourmatrix}
\end{multline*}
\end{document}


fourmatrix environment is used instead of explicit BMAT, resp. pmatrix. It is defined in nasser.sty package:

\ProvidesPackage{nasser}
\RequirePackage{amsmath}
\RequirePackage{easybmat}

\newenvironment{fourmatrix}{%
\left(\begin{BMAT}(@){c.c}{c.c}}
{\end{BMAT}\right)}


note that there is no need to redefine pmatrix environment, you can use BMAT directly. Now definition for tex4ht, nasser.4ht:

\renewenvironment{fourmatrix}{\begin{pmatrix}}{\end{pmatrix}}
\ConfigureEnv{fourmatrix}{\HCode{<mrow class="fourmatrix">}}{\HCode{</mrow>}}{}{}

\Css{.fourmatrix mtable{
border-collapse: collapse;
}}

\Css{.fourmatrix mtd{
border-right:1px dashed black;
}}

\Css{.fourmatrix mtd:last-child{
border-right: none;
}}

\Css{.fourmatrix mtr{
border-bottom: 1px dashed black;
}}

\Css{.fourmatrix mtr:last-child{
border-bottom:none;
}}


fourmatrix is redefined to use pmatrix, which is supported by tex4ht instead of BMAT. Additional <mrow class="fourmatrix"> element is added to support styling with css.

Result:

• Thanks! Do I need to put the .sty and .4ht files somewhere special for this to work? I put them in same folder as the .tex file, and pdflatex took them and compiled ok. But when I did htlatex foo.tex and looked at the html file generated (no errors btw during compiling), I do not see the dashes in the matrix. I see the matrix only. Screen shot: !Mathematica graphics I am using tex4ht 2014. screen shot of the folder !Mathematica graphics screen shot of HTML !Mathematica graphics – Nasser Jun 24 '14 at 19:35
• @Nasser you can use these files from same folder as your TeX document, but if you want to use them from several projects in different folders, you should place it to \$TEXMFHOME/tex/latex/nasser. see dickimaw-books.com/latex/novices/html/installsty.html – michal.h21 Jun 24 '14 at 19:55
• @Nasser this workaround is for mathml, it won't work for picture math – michal.h21 Jun 24 '14 at 19:56
• I see. No problem, thank you anyway. I use picture math now, since there are issues with mathml+mathjax as you know, we talked about that before. But will keep this solution for the day I switch back to mathml. – Nasser Jun 24 '14 at 19:59