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 27 Jul 2016 11:57:31 PM EEST  
 
Category: NonePriority: 5 - Normal
Severity: 5 - NormalStatus: None
Privacy: PublicAssigned to: None
Open/Closed: Closed

Fri 12 Aug 2016 02:14:43 AM EEST, comment #3:

committed to tex live, closing. thanks.

Karl Berry <karl>
Project Administrator
Wed 10 Aug 2016 12:29:25 PM EEST, 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 09 Aug 2016 08:59:13 PM EEST, 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 27 Jul 2016 11:57:31 PM EEST, 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
    Fri 12 Aug 2016 02:14:43 AM EESTkarlOpen/ClosedOpen=>Closed
    Show feedback again

    Back to the top


    Powered by Savane 3.1-cleanup+gray