# Including pstex_t figures when using htlatex

I am trying to create html file from my test.tex document including a .pstex_t file that include a .ps  figure. Here is my test.tex file

\documentclass[12pt,a4paper]{article}
\usepackage[francais]{babel}
\usepackage[latin1]{inputenc}
\usepackage{lmodern}
\usepackage{graphicx,color,float}
\usepackage{amsmath,amsthm}
\title{Test}
\author{S.~Oulhoussine}
\begin{document}
$$\displaystyle \sum_{i=1}^{n}{i^2+\sqrt{i}}$$
\begin{figure}[H]
\centering
\input{invariant.pstex_t}
\caption{Ensemble borné.} \label{f:snlbf}
\end{figure}
\end{document}


The .ps an .pstex_t files are here in the link below invariant.ps and invariant.pstex_t The .pstex_t is created using Winfig from a winfig figure including math formulaes in Latex. All is going ok to create .dvi  file. To convert to .html , I use tex4ht  with my.cfg configuration file listed below

\Preamble{xhtml,mathml}
\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-
MML_HTMLorMML"\Hnewline
></script>\Hnewline}}
.MathJax_MathML {text-indent: 0;}\Hnewline
</style>\Hnewline}}
\begin{document}
\EndPreamble


I used this command line htlatex test.tex "my.cfg" Here is my html file test.html

As you can see, the figure does not appear in the .html file. How to include .pstex_tusing tex4ht please ?

• Welcome to TeX.SE. Can you edit your question with a clear explanation, please? Apr 6 '20 at 17:34
• I think we will need some example. TeX4ht can include PS files, but I haven't heard about pstex_t before and cannot find a sample file online, so I cannot came with a solution at the moment. Apr 6 '20 at 19:12
• I updated my Question and added files. Apr 6 '20 at 19:30

So, the .pstex_t file looks like this:

\begin{picture}(0,0)%
\includegraphics{invariant.ps}%
\end{picture}%
%
%  Created by WinFIG version 4.9
%
\setlength{\unitlength}{3947sp}%
%
\begingroup\makeatletter\ifx\SetFigFont\undefined%
\gdef\SetFigFont#1#2#3#4#5{%
\reset@font\fontsize{#1}{#2pt}%
\fontfamily{#3}\fontseries{#4}\fontshape{#5}%
\selectfont}%
\fi\endgroup%
\begin{picture}(2865,1549)(2382,-1432)
\put(4725,-814){\makebox(0,0)[lb]{\smash{{\SetFigFont{12}{14.4}{\rmdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$x(t_0)$}%
}}}}
\put(3184,-764){\makebox(0,0)[lb]{\smash{{\SetFigFont{12}{14.4}{\rmdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$x(t)$}%
}}}}
\put(5018,-56){\makebox(0,0)[lb]{\smash{{\SetFigFont{12}{14.4}{\rmdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$\mathcal{M}$}%
}}}}
\end{picture}%


It is just regular LaTeX code that includes a PS image and then uses picture mode to draw some math over the image.

TeX4ht provides the \Picture+{} ... \EndPicture environment which can be used to convert the enclosed content to picture. We just need to insert it somehow to the document. The best way is to provide a custom command for the pstex_t image inclusion, to be used instead of usual \input. It can look like this:

\newcommand\inputpstex[1]{\input{#1.pstex_t}}


The image will be then included using:

\inputpstex{invariant}


In the .cfg file, we will redefine this command to use the \Picture+ command:

\let\originputpstex\inputpstex
\renewcommand\inputpstex[1]{\Picture+{}\originputpstex{#1}\EndPicture}


The full example:

% https://tex.stackexchange.com/q/537131/2891
\documentclass[12pt,a4paper]{article}
\usepackage[francais]{babel}
\usepackage[latin1]{inputenc}
\usepackage{lmodern}
\usepackage{graphicx,color,float}
\usepackage{amsmath,amsthm}
\newcommand\inputpstex[1]{\input{#1.pstex_t}}
\title{Test}
\author{S.~Oulhoussine}
\begin{document}
$$\displaystyle \sum_{i=1}^{n}{i^2+\sqrt{i}}$$
\begin{figure}[H]
\centering
\inputpstex{invariant}
\caption{Ensemble borné.} \label{f:snlbf}
\end{figure}
\end{document}


Configuration file:

\Preamble{xhtml,mathml,mathjax}
.MathJax_MathML {text-indent: 0;}\Hnewline
</style>\Hnewline}}
\let\originputpstex\inputpstex
\renewcommand\inputpstex[1]{\Picture+{}\originputpstex{#1}\EndPicture}
\begin{document}
\EndPreamble


(I've simplified it a bit, we now have built-in support for MathJax in TeX4ht)

 make4ht -c my.cfg test.tex