bugtex4ht - Bugs: bug #485, tex4ht does not handle...

 
 
Show feedback again

You are not allowed to post comments on this tracker with your current authentification level.

bug #485: tex4ht does not handle \ifdefined\HCode in mathjax mode when inside equation

Submitted by:  Nasser M. Abbasi <nma123>
Submitted on:  Fri Oct 2 03:59:00 2020  
 
Category: NonePriority: 5 - Normal
Severity: 5 - NormalStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Closed

Fri Oct 2 09:08:57 2020, comment #1:

Hi Nasser,

I've provided my answer on TeX.sx: https://tex.stackexchange.com/a/565047/2891

In short, you can use a custom macro that takes two parameters, one for normal LaTeX and one for MathJax. You can then provide different definitions of that macro to LaTeX and MathJax.

Michal Hoftich <michal_h21>
Project Member
Fri Oct 2 03:59:00 2020, original submission:

Screen shots at:

https://tex.stackexchange.com/questions/565039/tex4ht-does-not-handle-ifdefined-hcode-in-mathjax-mode

This is the first time I found where tex4ht does not process \ifdefined\HCode.

I put \ifdefined\HCode inside an equation, since I need different code for HTML vs. pdf mode.

tex4ht does not process the ifdefined and leave it there. When mathjax sees it, it complains since mathjax offcourse does not know anything about ifdefined\HCode.

When the code is compiled not using mathjax it works OK. But I need to use mathjax.

Here is MWE

=================
\documentclass[12pt]{article}
\usepackage{array}
\begin{document}
\[
\ifdefined\HCode
\left[
\begin{array}{ccc}
\else
\left[
\begin{array}{@{}cc|c@{}}
\fi
3 i&-3 &0\\
3 &3 i &0
\end{array}
\right]
\]
test
\end{document}
=======================

The above compiled OK using lualatex foo3.tex and gives
[PIC]

This is the raw HTML. it shows the \ifdefined\HCode was not processed and left in there

=================
<!DOCTYPE html>
<html lang="en-US" xml:lang="en-US" >
<head><title></title>
<meta charset="utf-8" />
<meta name="generator" content="TeX4ht (https://tug.org/tex4ht/)" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" type="text/css" href="foo3.css" />
<meta name="src" content="foo3.tex" />
<script>window.MathJax = { tex: { tags: "ams", inlineMath: [ ["\\\(","\\\)"] ], displayMath: [ ['$$','$$'], ["\\[","\\]"] ], processEscapes: true, processEnvironments: true, packages: ['base', 'color', 'ams'] }, loader: { load: ['[tex]/color', '[tex]/ams'] } }; </script>
<script type="text/javascript" async="async" id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js"></script>
</head><body

>

<!--l. 23--><p class="noindent" >\[ \ifdefined \HCode \left [ \begin{array}{ccc} \else \left [ \begin{array}{@{}cc|c@{}} \fi 3 i&amp;-3 &amp;0\\ 3 &amp;3 i &amp;0 \end{array} \right ] \]
</p><!--l. 25--><p class="indent" > test
</p>

</body>
</html>
===========================

Compiled using make4ht -ulm default -a debug foo3.tex "htm" works with no problem

The problems seems that tex4ht does not look inside the equation to see that there is something to do, and just passes the whole thing to mathjax.

TL 2020

Nasser M. Abbasi <nma123>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by michal_h21 (Posted a comment)
  • -unavailable- added by nma123 (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    1 latest change follows.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri Oct 2 09:08:57 2020michal_h21Open/ClosedOpen=>Closed
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup+gray