1

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}
\begin{equation}
\displaystyle \sum_{i=1}^{n}{i^2+\sqrt{i}}
\end{equation}
\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}}
\Configure{@HEAD}{\HCode{<script type="text/javascript"\Hnewline
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS- 
MML_HTMLorMML"\Hnewline
></script>\Hnewline}}
\Configure{@HEAD}{\HCode{<style type="text/css">\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 ?

3
  • 1
    Welcome to TeX.SE. Can you edit your question with a clear explanation, please?
    – Sebastiano
    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.
    – michal.h21
    Apr 6 '20 at 19:12
  • I updated my Question and added files. Apr 6 '20 at 19:30
0

So, the .pstex_t file looks like this:

\begin{picture}(0,0)%
\includegraphics{invariant.ps}%
\end{picture}%
%
%  Created by WinFIG version 4.9 
%  METADATA <version>1.0</version> 
%
\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)
%  METADATA <id>4</id> 
\put(4725,-814){\makebox(0,0)[lb]{\smash{{\SetFigFont{12}{14.4}{\rmdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$x(t_0)$}%
}}}}
%  METADATA <id>6</id> 
\put(3184,-764){\makebox(0,0)[lb]{\smash{{\SetFigFont{12}{14.4}{\rmdefault}{\mddefault}{\updefault}{\color[rgb]{0,0,0}$x(t)$}%
}}}}
%  METADATA <id>8</id> 
\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}
\begin{equation}
\displaystyle \sum_{i=1}^{n}{i^2+\sqrt{i}}
\end{equation}
\begin{figure}[H]
\centering
\inputpstex{invariant}
\caption{Ensemble borné.} \label{f:snlbf}
\end{figure}
\end{document} 

Configuration file:

\Preamble{xhtml,mathml,mathjax}
\Configure{@HEAD}{\HCode{<style type="text/css">\Hnewline
.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)

Compile your document using:

 make4ht -c my.cfg test.tex

This is the result:

enter image description here

2
  • Thank you undeed micha.h21. It worked nice. Apr 6 '20 at 21:33
  • @SaïdOulhoussine that's great! :)
    – michal.h21
    Apr 6 '20 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.