# How can I get a smooth nice math font in LaTeX?April 6, 2009 3:24 AM   Subscribe

Why are LaTeX math fonts so terrible? Or am I missing something? I want to get some nice titles on a legend for a Matlab figure, and I have to use the LaTeX interpreter for some accents, but when I import the figure into Word the resulting font is very pixelated and just plain garbage. How do I get smooth and clear math fonts out of LaTeX?

I am bound to using the LaTeX interpreter and  delimiters in order to get a dot above a Q, ie: $\dot{Q}$. But the default, italicized font is blurry and pixelated. Even when I use, say $\mathrm{\dot{Q}}$ its still pixelated. And \mathtt gets rid of the dot.

I'm printing the figure to BMP and inserting into the Word document... I have to use Word even though I'd rather be using LaTeX. Any suggestions are appreciated!
posted by molecicco to Computers & Internet (22 answers total) 2 users marked this as a favorite

Best answer: It's not the font. It's the BMP you're producing. Basically, you're going from a beautiful font with infinite (unblurred, unpixelated) detail and rasterizing it to (a nominal) 72 dpi. This works about as well as you can expect a vector->raster conversion to turn out. If you're using one of the standard Microsoft "print to file" options, that could be sapping some quality during the rasterization process as well.

So, then you paste the crappy picture into a Word document, and it's not going to look anything like as good as the vector-based TrueType fonts that the rest of the document is made of.

Unfortunately, unless you can find a way to work in a vector format (e.g. pdf, ps, or svg), you're going to have degraded quality. You might have better luck with a better LaTeX->raster renderer, but I wouldn't count on it.
posted by Netzapper at 3:30 AM on April 6, 2009

Response by poster: Hmmm. I thought it might be that. I am using Matlab's "print" function, and you can specify the format. svg is in fact an option... however whenever I insert any non-BMP object into the document, I get an icon (even JPG, TIFF, anything!)

But since I am using the printed object at 100% size, I still think I should be able to get a decent enough looking BMP out of it, no?
posted by molecicco at 3:35 AM on April 6, 2009

But since I am using the printed object at 100% size, I still think I should be able to get a decent enough looking BMP out of it, no?

No. The pixelation is an artifact of the transition from vector to raster. Having written some of these myself, I assume that the Matlab print code makes an assumption of 72 dpi and rasterizes on such a grid. Good-looking font requires sub-pixel rendering.

The fact that you then embed the 72-dpi image into something
smarter/prettier is irrelevant. At that point, the rasterization has occurred, blurring your font.

Here's something you might try: output as an SVG (and hope it actually saves vectors and not an embedded raster in an SVG wrapper), open in inkscape or freehand or illustrator or something like that, and go through an export step properly setting up the rasterization resolution and all of that.
posted by Netzapper at 3:42 AM on April 6, 2009 [1 favorite]

Response by poster: ok! I am downloading inkscape, so let's see how it turns out. But it is really unfortunate that there is not a simpler way to include decent (ie professional-looking) Matlab-generated images into a Word document.
posted by molecicco at 3:57 AM on April 6, 2009

If you are using Windows, then in Inkscape, there is a file format called EMF that works well with Word documents (I think it's the open format of Word's WMF); it scales nicely. On a Mac, you're out of luck.

Also, when you say you just get an icon for a jpeg file in Word, is it true also if you print the document? Sometimes, Word won't render the images on screen, but they will print.

I feel your pain, though. I'm writing my dissertation in Word rather than Latex because my thesis advisor wants me to -- it sucks.
posted by bluefly at 4:04 AM on April 6, 2009

however whenever I insert any non-BMP object into the document, I get an icon (even JPG, TIFF, anything!)

You might mess around with this: I can take some math from LaTeX (TeXShop, specifically), save it out as a .pdf, and then drag and drop it into a Word document (Word 2008, piece of garbage that it is) and have it appear as an image.

I don't think this has much to do with LaTeX as such.
posted by leahwrenn at 4:08 AM on April 6, 2009

Can Matlab output images as 300 or 600 dpi? Tecplot can do that, and that is how I generate images to import into Word documents.

You can also try to export as WMF or EMF from Matlab.
posted by hariya at 4:10 AM on April 6, 2009

Response by poster: Yeah, while I'm waiting for the inkscape installer to download I've been playing with the resolution. At 600 dpi, the image is huge and clear... but then I manually shrink it and it gets blurry. At 200 dpi it is clear, and the correct size, but pixelated.

Yeah, bluefly, I'm writing up my thesis and my supervisor insists on Word. Same boat. Yeah, Matlab can print to EMF, and I really thought that would be the best option, but the icon business made me abandon that path. I will see if the icon business is only on-screen. But that's still kind of a hassle since the size of the final image is different than the icon size.
posted by molecicco at 4:16 AM on April 6, 2009

Response by poster: Aha! OK, thank you everyone for the feedback. I think my main problem is that you can only insert BMP images as file-linked objects in Word 2007. "Insert -> Picture" works with EMF, Tiff, JPEG, etc.... so I am inserting my images like that now, and using EMF files since they actually look nice.

However, it is a major pain in the ass. I create my images in batches, and during the writing process will update the images as a batch frequently. So "Insert Object -> Create from file" with the "link to file" box checked is perfect for that, since new images are updated automatically. By choosing "Insert -> Picture" I have to go through and manually replace every image when it changes. Boo.
posted by molecicco at 4:37 AM on April 6, 2009

Really the unfortunate thing about LaTeX nowadays, and the reason I think it's dying out a bit, is because it hasn't been adapted as much as it should have for transfer between formats. I watched a friend of mine try using LaTeX for a web page once, and let me tell you... not a good idea. Rasterization is the only option, and it's not pretty.

A propos of nothing... I was shocked, shocked to discover that

.

Q

isn't supported by unicode. What the hell is that about? So I can make ♠ ♣ ♥ ♦ all the different little suits on the back of a deck of cards, but I can't represent rate of heat transfer? My condolences.

This is a fudgy solution, but were it my thesis, I'd probably find myself doing it with a pen. Kudos to you for trying to do it right.
posted by koeselitz at 5:19 AM on April 6, 2009

Are you sure you can't embed epdf or eps files into word documents? I just talk my supervisor into letting me use latex.
posted by jeffburdges at 5:54 AM on April 6, 2009 [1 favorite]

Best answer: koeselitz: Re unicode - there is COMBINING DOT ABOVE (U+0307).

molecicco: Do you have to actually SEE the images while editing? I remember from ages ago that you could insert EPS files into word, where they would not be visible, but they would actualize on printing the document.
posted by themel at 6:00 AM on April 6, 2009 [1 favorite]

Response by poster: I discovered that I CAN embed EPS, EMF, JPEG, etc etc. BUT, I can not "link to file". At this stage, that is an acceptable solution for me, but while working on the document linking to file was pretty necessary.

Combining dot above... very interesting. Good to know!
posted by molecicco at 6:37 AM on April 6, 2009

bluefly, molecicco:

posted by ROU_Xenophobe at 6:49 AM on April 6, 2009

Yeah, EPS -- embedded PostScript -- is almost certainly the way to go.

If MSFT Word can't grok EPS, then you should work up enough rage to try OpenOffice for a few minutes to see if it's good enough for you.
posted by cmiller at 7:13 AM on April 6, 2009

So your adviser is, presumably, in your field. If he insists on using Word but needs LaTex for precision, then he must surely have come across problems like this before. Could you ask him how he does it? Perhaps, you could broach the subject by saying "Hey I figured out how to do this, but it's a bit of pain. Do you have an easy way to do it?"
posted by oddman at 7:26 AM on April 6, 2009

So your adviser is, presumably, in your field. If he insists on using Word but needs LaTex for precision, then he must surely have come across problems like this before. Could you ask him how he does it?

I laughed so hard when I read this. I don't think my advisor has formatted a paper in years. That's what grad students and post-docs are for. He just likes Word because it's easy to edit the text (for him) -- it's my responsibility to make it look good.

I'd never seen that link to file thing before. I might try that with some .bmp files.
posted by bluefly at 7:34 AM on April 6, 2009

You might also try MathType or Equation Editor.
posted by likedoomsday at 9:18 AM on April 6, 2009

themel: koeselitz: Re unicode - there is COMBINING DOT ABOVE (U+0307).

Yes, I know. But it can be very wonky, and it apparently doesn't really work with Q.
posted by koeselitz at 11:33 AM on April 6, 2009

I generally don't trust those damned unicode 'combining accents' very much at all if I'm working with capitals, anyhow - no worky.
posted by koeselitz at 11:36 AM on April 6, 2009

I laughed so hard when I read this. I don't think my advisor has formatted a paper in years. That's what grad students and post-docs are for. He just likes Word because it's easy to edit the text (for him) -- it's my responsibility to make it look good.

This actually raises a good point.

Why not typeset the thing in LaTeX? Use the crappy BMP outputs from Matlab during the editing process when your prof is actually doing something, and then once the text and everything is finalized, typeset the document in LaTeX.

That's really how this work-flow is supposed to go anyway. Work out the actual content in a word processor (Word), and then once that's finalized, typeset it and insert final versions of figures (in LaTeX).
posted by Netzapper at 6:47 PM on April 6, 2009

Response by poster: Long time since the post but to wrap it up - EMF was the winner here as far as image formats go. My problem was that I wanted to insert images as 'objects' and link to them - and the only image format you can do that with in Word is BMP (linking to the image means that when you edit the image, it is automatically updated in the file, and this can be quite useful).

So, I had to forego image linking and just drop a nice, non-rasterized image onto the Word document, and for me EMF was the best format to use.

Also, combinging dot above was a godsend!
posted by molecicco at 2:57 AM on May 13, 2009

« Older What's the difference between a chinese potato and...   |   Extreme (bus) makeover- ideas required Newer »