title: How can I mix LaTeX in with Markdown?
body: <p>I've been using Markdown for class notes, and it's great.  I even do some preprocessing on the Markdown so I can do things like tables.  But this term I'm teaching a class with a lot of math, and I'd love to be able to put LaTeX formulas with Markdown, something like this:</p>
  
  <pre class="lang-latex prettyprint-override"><code>The refinement relation is written $a \sqsubseteq b$, which can be 
  pronounced "$a$ approximates $b$" or "$b$ is at least as defined as $a$".
  </code></pre>
  
  <p>I'd like to be able to take each fragment of LaTeX and preprocess it into a nice antialiased PNG file which I could then include in my Markdown via the HTML <code>&lt;img&gt;</code> tag.  But I have absolutely no idea how to take a fragment of LaTeX and get a nice image that</p>
  
  <ul>
  <li>Has the right bounding box</li>
  <li>Is antialiased</li>
  </ul>
  
  <p>All I know how to do is get full pages in DVI, PostScript, or PDF formats.</p>
  
  <p>I'm sure this problem has been addressed, but I haven't been able to guess the right search terms.  Any suggestions how to solve it or where to look for an existing solution?</p>
  
  <hr>
  
  <p><strong>EDIT</strong>: Having installed mathTeX, I can say that the code is inflexible, that it violates the Linux Filesystem Hierarchy standard, and that it is amateur work&mdash;in both the good and bad senses of that word.  The code is so complex that there are no obvious faults.  I will be looking for alternatives.</p>
  
  <p>Also, it's clear that at bottom, solutions are based on <a href="http://savannah.nongnu.org/projects/dvipng/" rel="noreferrer"><code>dvipng</code></a>.</p>
  
  <hr>
  
  <p><strong>ONE YEAR LATER</strong>: I never did get the seamless integration I had been hoping for, but I am limping along on a script of my own devising.  It turns out that instead of <code>dvipng</code> it is a little easier to use <code>dvips -E</code> and the <code>convert</code> program of ImageMagick.  The benefits are slightly more control of things like scaling, and ease of making a transparent background.
  The curious can inspect <a href="http://www.cs.tufts.edu/comp/105-2011s/notes.html" rel="noreferrer">this example</a>.  </p>
  
  <p>I can't recommend this solution to anyone.  But I can't recommend MathTeX either.</p>