# Convert all formulas to image hevea

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.

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.

-
Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Qrrbrbirlbel Mar 4 '13 at 3:50

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}

-
@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 4 '13 at 20:59