I would suggest something like using a style to set the image size relatively close to the text size. Change the height to get your best match.
Something like:
Code:
.formula {
height: 1.5em;
width: auto;
}
And in the text files, use something similar to the following:
<img alt="formula name" class="formula" src="../Images/formula002.jpeg">
I suspect that Regex will be your best friend for this task.