1

I'm using Hevea to translate TeX to HTML. I want to convert all the formulas enclosed by $ ... $ to images. But I'm trying to avoid the using of:

\begin{toimage} 
  $ ... $ 
\end{toimage} \imageflush

There is some way to redefine the dollar sign, (perhaps using a \hevea macro) so as append all the toimage environments in a transparent way? I mean just using the dollar sign. Nothing else.

I've tried the approach described in here but the macro cannot be parsed by hevea.

Example added:

I just want to translate everything like (this is an example, I want every formula written in math mode to be modified).

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\begin{document}        
    $ \textbf{\overrightarrow{x}} = ( \frac{3}{2} x,y,z) $
\end{document}

to

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\begin{document}
    %\begin{toimage} 
    $ \textbf{\overrightarrow{x}} = ( \frac{3}{2} x,y,z) $
    %\end{toimage} \imageflush
\end{document}

Because is the way I know to make hevea translates something written in math mode to an image. Hevea parse that commets %\begin{toimage}, etc and generate the images. I don't know is there a options of hevea to make that. But i couldn't find it so i try this approach, i.e. modifying the dollar sign.

1 Answers1

1

I do not have a clue how hevea works, what it does and how to use it, but the following MWE does get compiled by pdfLaTeX.

It would be easier to do, if you use the LaTeX macros \( and \) for inline math and \[ and \] for display math.

Code

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{hevea}
\catcode`$=\active
\makeatletter
\begingroup
    \catcode`\"=3
    \protected\gdef${\@ifnextchar$\@doubledollar\@singledollar}
    \gdef\@doubledollar$#1$${\begin{toimage}""#1""\end{toimage}}%        display math
    \gdef\@singledollar#1${\begin{toimage}"#1"\end{toimage}\imageflush}% inline math
\endgroup
\makeatother

\begin{document}
    $ \vec{x} = \left( \frac{3}{2} x,y,z\right) $
\end{document}
Qrrbrbirlbel
  • 119,821
  • Thanks for the answer. That code fails with hevea because it could not understand the \active command. I think you are right, it going to be easier rewriting the \( and \). Hevea almost understand the translation but fails too, (less catastrophically although, the translation finishes throwing some warnings).

    I used this macro

    `\let\oldO\(
    \let\oldC\)
    \renewcommand{\(}{ %\begin{toimage} 
                  \oldO }
    \renewcommand{\)}{ \oldC      %
    \end{toimage}}`
    
    

    I'm going to write in their mailing list, to see if they can help me.

    – Luciano Lorenti Mar 04 '13 at 19:52
  • @LucianoLorenti Does your solution work? Post it as an answer than. Self-answers are perfectly admissible, and a well-written answer may earn you reputation. If it does not work edit your approach in your question. (I will delete my answer soon.) – Qrrbrbirlbel Mar 04 '13 at 20:59