[tex4ht] \texttt bug caused by \usepackage{times}
Francis Wright
f.j.wright at live.co.uk
Thu Jan 16 18:51:31 CET 2025
Using \usepackage{times} can prevent \texttt from switching to a monospace font. Here is a MWE:
- - -
\documentclass{article}
\usepackage{times} % Causes problem with \texttt{}
\begin{document}
The word \texttt{minimize} should be in a monospace font.
\end{document}
- - -
I put the above 5 lines in a file called "bug.tex". Formatting it using "pdflatex bug.tex" is OK, but if I format it using
"htlatex bug.tex" then the word "minimize" is displayed using the same font as the rest of the text. The reason is that TeX4ht formats the word "minimize" as
<span class="pcrr7t-">minimize </span>
and in "bug.css" it defines the class "pcrr7t-" as
.pcrr7t-{ font-family: 'Nimbus Mono L', serif;}
The problem is the fall-back font, which should be monospace, not serif. 'Nimbus Mono L' would probably be fine, but I don't have it installed on my computer!
This example also illustrates another problem, which is that if I fix the font problem (say, by editing "bug.css" by hand) then the space after the word "minimize" is too long, i.e. noticeably longer than the space before the word, which looks quite ugly. I presume this is because the </span> follows the space after the word, whereas is should precede it, as in the source file.
I was actually trying to track down a slightly different bug affecting the use of \texttt in a large document. For that document, TeX4ht generates invalid CSS such as
.pcrr8t-x-x-109{font-weight: monospaced;}
I will try to find a MWE for that.
Best wishes,
Francis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/tex4ht/attachments/20250116/9ead15b6/attachment.htm>
More information about the tex4ht
mailing list.