Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I try to use TeX4ht and Calibre to create an ebook that I can read with an iPad. I use the following command: htlatex file.tex "xhtml, jsmath""-cmozhtf". The result with Calibre is correct except for some mathematical formulas.

For example, the equation : $ x ^ 2 - 6x +6 = 0$ , we obtain : {x} ^ {2} - 6x + 6 = 0.

To : \ [B (x) =-x ^ 2 + 60x-500, \ quad \ textrm {where $ x $ belongs to the interval $ \ left [0 \, 60 \ right] $.} \] we obtain : B (x) = - {x} ^ {2} + 60x - 500, \ quad \ textrm {where $ x $ belongs to the interval $ \ left [0 \ kern 1.81503pt, 60 \ right] $ .}

For : $ T_1 $, we obtain : {T} _ {1}.


First question :

Why, in this code, formulas framed dollars are not transformed into images (and the record is best !)?

\documentclass[a4paper,11pt]{article} 

\usepackage[utf8]{inputenc} 
\usepackage{amsmath,amsfonts} 

\begin{document} 

\section*{Sample French Text}

Lucie, étudiante des États-Unis, vient d'arriver à Charles de
Gaulle, l'aéroport qui accueille chaque jour à Paris, 1 million de
visiteurs. Paris. Enfin. Ça a toujours été le rêve de Lucie : vivre
dans la Ville lumière, la ville des beaux arts, du quartier latin, du
vin, et qui sait, peut-être la ville d'une petite histoire d'amour.

\section*{Math Part}
Numbered equation:
\begin{equation} 
P_{r-j}= 
\begin{cases} 
0 & \text{si $r-j$ est impair,} \\ 
r! \, (-1)^{(r-j)/2} & \text{si $r-j$ est pair.} 
\end{cases} 
\end{equation} 
Un-numbered equation:
\begin{equation*} 
P_{r-j}= 
\begin{cases} 
0 & \text{si $r-j$ est impair,} \\ 
r! \, (-1)^{(r-j)/2} & \text{si $r-j$ est pair.} 
\end{cases} 
\end{equation*} 
Inline equation: 
$ x ^ 2 - 6x +6 = 0$ and $B (x) =-x ^ 2 + 60x-500, \quad
\textrm{where $ x $ belongs to the interval $ [0 \, ; 60 ] $.}$ 

Eqnarray
\begin{eqnarray} 
P_{r-j}&=& 
\begin{cases} 
0 & \text{si $r-j$ est impair,} \\ 
r! \, (-1)^{(r-j)/2} & \text{si $r-j$ est pair.} 
\end{cases} \\
P_{r-j}&=& 
\begin{cases} 
0 & \text{si $r-j$ est impair,} \\ 
r! \, (-1)^{(r-j)/2} & \text{si $r-j$ est pair.} 
\end{cases} 
\end{eqnarray} 
Starred eqnarray
\begin{eqnarray*} 
P_{r-j}&=& 
\begin{cases} 
0 & \text{si $r-j$ est impair,} \\ 
r! \, (-1)^{(r-j)/2} & \text{si $r-j$ est pair.} 
\end{cases} \\
P_{r-j}&=& 
\begin{cases} 
0 & \text{si $r-j$ est impair,} \\ 
r! \, (-1)^{(r-j)/2} & \text{si $r-j$ est pair.} 
\end{cases} 
\end{eqnarray*} 

\end{document}

Second question : I followed the method described in the link, and the pictures are better but in my opinion, too small. How to resize images ?

Third question : I tried to put the images in svg format, but it does not work:

   Erreur d'analyse XML : mal formé
   Emplacement : file:///home/fab/der1x.svg
   Numéro de ligne 1, Colonne 2 :
   %!PS-Adobe-3.0
   -^

Here are the contents of tex4ht.env modified and the file contents myconfig.cfg :

     <dvipng>
    G.png
    Gdvipng -T tight -x 1400 -D 72 -bg Transparent -pp %%2:%%2 %%1 -o %%3
    G.gif
    Gdvipng -T tight -x 1400 -D 72 -bg Transparent -gif -pp %%2:%%2 %%1 -o %%3
    G.
    Gdvips -Ppdf -mode ibmvga -D 110 -f %%1 -pp %%2 > zz%%4.ps
    Gconvert -crop 0x0 -density 110x110 -transparent '#FFFFFF' zz%%4.ps %%3
    Grm zz%%4.ps
    G.svg
    Gdvisvgm -n -p %%2 -c 1.2,1.2 -s %%1 > %%3
     </dvipng

    \Preamble{xhtml}
    \Configure{Picture}{.svg}
    \begin{document}
    \EndPreamble

Fourth question : use MathJax with TeX4ht gives a very good result in the test.html that the iPad opens without problems, but if you use Calibre to get an ebook, the result is very bad ! The only small problem is that with this little script accented characters are replaced by question marks :

   #!/bin/bash

    if [ $1 ]
    then
    NAME=`echo $1 | sed 's/.tex//g'`
    htlatex $1 "ht5mjlatex.cfg" "-cmozhtf"
    iceweasel $NAME.html;
    exit
    fi

It will be difficult to make an ebook using TeX4ht. I tried to install TeX4ebook, but there is an installation problem :

  fab@debian:~$ texlua /home/fab/texmf/tex/latex/tex4ebook-master /tex4ebook.lua
  /home/fab/texmf/tex/latex/tex4ebook-master/tex4ebook.lua:113: invalid  escape sequence near '\$'
share|improve this question
    
well there are extra unneeded {} there but that is OK is it not? (jsmath is no longer really supported and is replaced by mathjax (by the same author) –  David Carlisle Jul 26 '13 at 22:46
    
@DavidCarlisle What I mean is that if the mathematical formula of the source file is $ x ^ 2 -6 x+6 = 0$ , I want to get the output: x ² - 6x + 6 = 0, and not: {x} ^ {2} - 6x + 6 = 0 If I understand, so I do: htlatex file.tex "xhtml, mathjax", "-cmozhtf". –  Fabrice Jul 26 '13 at 23:29
1  
@Fabrice: Can you post a Minimal Working Example (MWE) with \documentclass{...} ... \end{document}. It will help us to help you! –  Jagath AR Jul 27 '13 at 3:28
    
@Jagath AR The objective is to convert this file : \documentclass[a4paper,11pt]{article} \usepackage[utf8]{inputenc} \usepackage{amsmath,amsfonts} \usepackage[frenchb]{babel} \begin{document} \begin{equation} P_{r-j}= \begin{cases} 0 & \text{si $r-j$ est impair,} \ r! \, (-1)^{(r-j)/2} & \text{si $r-j$ est pair.} \end{cases} \end{equation} \end{document} I compile with: htlatex file.tex "xhtml, mathjax", "-cmozhtf" and I use Calibre to convert the html file into an epub file.The formula appears like in the source file ! –  Fabrice Jul 27 '13 at 23:57
1  
you have selected jsmath output. jsmath requires tex syntax in the web page, which is then rendered by javascript/css –  David Carlisle Jul 28 '13 at 21:34

1 Answer 1

As per the comment, some equations appear correctly after converting. This means that, these equations are converted as image by tex4ht's post process. One way to make other equation to appear correctly is to make them image as well. A sample TeX file with possible type of equations and some text added:

\documentclass[a4paper,11pt]{article} 

\usepackage[utf8]{inputenc} 
\usepackage{amsmath,amsfonts} 

\begin{document} 
\Configure{$}{\PicMath}{\EndPicMath}{}%$
\def\,{\ }

\section*{Sample French Text}

Lucie, étudiante des États-Unis, vient d'arriver à Charles de
Gaulle, l'aéroport qui accueille chaque jour à Paris, 1 million de
visiteurs. Paris. Enfin. Ça a toujours été le rêve de Lucie : vivre
dans la Ville lumière, la ville des beaux arts, du quartier latin, du
vin, et qui sait, peut-être la ville d'une petite histoire d'amour.

\section*{Math Part}
Numbered equation:
\begin{equation} 
P_{r-j}= 
\begin{cases} 
0 & \text{si $r-j$ est impair,} \\ 
r! \, (-1)^{(r-j)/2} & \text{si $r-j$ est pair.} 
\end{cases} 
\end{equation} 
Un-numbered equation:
\begin{equation*} 
P_{r-j}= 
\begin{cases} 
0 & \text{si $r-j$ est impair,} \\ 
r! \, (-1)^{(r-j)/2} & \text{si $r-j$ est pair.} 
\end{cases} 
\end{equation*} 
Inline equation: 
\( x ^ 2 - 6x +6 = 0\) and $B (x) =-x ^ 2 + 60x-500, \quad
\textrm{where $ x $ belongs to the interval $ [0 \, 60 ] $.}$ 

Un-numbered displayed equation: 
\[
B (x) =-x ^ 2 + 60x-500, \quad \textrm{where $ x $ belongs to the interval $ \left [0 \, 60 \right] $.} 
\]
and
$$
B (x) =-x ^ 2 + 60x-500, \quad \textrm{where $ x $ belongs to the interval $ \left [0 \, 60 \right] $.} 
$$
Eqnarray
\begin{eqnarray} 
P_{r-j}&=& 
\begin{cases} 
0 & \text{si $r-j$ est impair,} \\ 
r! \, (-1)^{(r-j)/2} & \text{si $r-j$ est pair.} 
\end{cases} \\
P_{r-j}&=& 
\begin{cases} 
0 & \text{si $r-j$ est impair,} \\ 
r! \, (-1)^{(r-j)/2} & \text{si $r-j$ est pair.} 
\end{cases} 
\end{eqnarray} 
Starred eqnarray
\begin{eqnarray*} 
P_{r-j}&=& 
\begin{cases} 
0 & \text{si $r-j$ est impair,} \\ 
r! \, (-1)^{(r-j)/2} & \text{si $r-j$ est pair.} 
\end{cases} \\
P_{r-j}&=& 
\begin{cases} 
0 & \text{si $r-j$ est impair,} \\ 
r! \, (-1)^{(r-j)/2} & \text{si $r-j$ est pair.} 
\end{cases} 
\end{eqnarray*} 

\end{document}

After \begin{document} I have added \Configure{$}{\PicMath}{\EndPicMath}{}%$ which will convert all the inline equations to image.

You need to give the following command line to generate html:

htlatex <filename> "xhtml" "-cmozhtf"

Note: I have removed \usepackage[frenchb]{babel} and added some French text in the sample TeX.

Disclaimer: I have not tested the conversion using Calibre. Hope this will work.

share|improve this answer
    
Your approach works fine, but why did you choose the html rather than xhtml option ? I also find that the images of the equations are not very good and too small if we viewed ebook (obtained with Calibre) with an Ipad. Can we improve all to have a very good record on an IPad ? Can we get pictures in svg format ? Can I use MathJax for not having images for equations ? –  Fabrice Jul 28 '13 at 11:33
1  
@Fabrice: You can use xhtml. It was a typo. I've corrected it. Better quality of image can be obtained by using dvipng instead of convert, which can be enabled by reading this link. SVG is also possible, but MathJax is better choice though. But I am afraid how Calibre convert the xhtml with MathML (MathJax) to epub. BTW why can't you try this, Calibre not required here –  Jagath AR Jul 28 '13 at 13:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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