bugtex4ht - Bugs: bug #337, tex4ht changes \_ in math mode to...

 
 
Show feedback again

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

bug #337: tex4ht changes \_ in math mode to X in HTML when not including \usepackage[T1]{fontenc}

Submitted by:  Nasser M. Abbasi <nma123>
Submitted on:  Wed Jul 27 20:57:31 2016  
 
Category: NonePriority: 5 - Normal
Severity: 5 - NormalStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Closed

Thu Aug 11 23:14:43 2016, comment #3:

committed to tex live, closing. thanks.

Karl Berry <karl>
Project Administrator
Wed Aug 10 09:29:25 2016, comment #2:

Better solution is provided in my updated answer on TeX.sx. In LaTeX sources, \_ macro is defined as:

\DeclareRobustCommand{\_}{%
\ifmmode\nfss@text{\textunderscore}\else\textunderscore\fi}

as you can see, \textunderscore is used also in math mode. I've modified it to use \mathunderscore, for which I also mathml fix.

I've updated the sources.

Michal Hoftich <michal_h21>
Project Member
Tue Aug 9 17:59:13 2016, comment #1:

The problem is clearly this definition from latex.4ht:

\NewConfigure{textundescore}[1]{\expandafter
\def\csname ?\string\textunderscore\endcsname{\leavevmode#1}}
\Configure{textundescore}{\HChar{95}}

\HChar includes special instruction for tex4ht DVI processor to replace next character (which is X) with character with value 95. As math is converted to image by other DVI processor (DVIPS or DVIPNG), which doesn't understand this instruction, the character which should be removed, X, remains here instead of _. we need to disable the use of \HChar in mathmode, use \mathunderscore instead.

As a workaround, you can try the following:

\documentclass[11pt]{article}

\ifdefined\HCode
\usepackage[utf8]{luainputenc}
% \usepackage[T1]{fontenc} %do not use. Make tex4ht \verb not accept different fonts
\else
\usepackage{fontspec}
\fi

\usepackage{amsmath,mathtools}

\begin{document}

\def\myunderscore{\ifmmode \mathunderscore\else\HChar{95}\fi}
\let\_=\myunderscore
\[
y = \_C1
\]

hello \_C1
\end{document}

Michal Hoftich <michal_h21>
Project Member
Wed Jul 27 20:57:31 2016, original submission:

This looks like a bug to me, but if it is not, this can be closed.

I also posted this with screen shots here
http://tex.stackexchange.com/questions/321259/tex4ht-changes-in-math-mode-to-x-in-html-when-not-including-usepackaget1f

tex4ht changes \_ to X when not including \usepackage[T1]{fontenc}

Here is MWE

\documentclass[11pt]{article}

\ifdefined\HCode
\usepackage[utf8]{luainputenc}
%\usepackage[T1]{fontenc} %do not use. Make tex4ht \verb not accept different fonts
\else
\usepackage{fontspec}
\fi

\usepackage{amsmath,mathtools}

\begin{document}
\[
y = \_C1
\]
\end{document}

Compiled using make4ht --lua -u foo.tex and looking at the HTML shows \_ was changed to X

TL 2016 on Linux mint 64 bit

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 karl (Posted a comment)
  • -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
    Thu Aug 11 23:14:43 2016karlOpen/ClosedOpen=>Closed
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup+gray