Archive for May, 2010

Fix matlab and latex file associations on KDE

KDE (and linux) in general has a very elaborate system of guessing the file type of your file, that depends on both the file extension and the file contents. In 99% of the cases these rules work, unfortunately the other 1% has been annoying me for quite some time.
If you create a matlab m-file that starts with comments (% some comment), KDE will think the file is a latex file and insist on opening it with a dedicated latex editor.
This behaviour can be changed by modifying the mime type definitions.
Open /usr/share/mime/packages/freedesktop.org.xml in your favourite text editor as root.
Find the node <mime-type type="text/x-tex">. This will have a subnode that looks like:

<magic priority="10">
   <match value="%" type="string" offset="0"/>
</magic>

Change the priority to something smaller than 10, so it has a lower priority than the matlab magic rule.
Now run

sudo update-mime-database /usr/share/mime

And that’s it. KDE will now see all your m-files as matlab scripts even if they start with a comment.

Advertisements

Import latex formulas into inkscape

Getting nice looking formulas in your presentations / posters is always a problem. Latex is great at producing nice looking formulas and text, but for presentations and posters it’s not really equipped.

You could however write your formulas in a latex document, then import the pdf into inkscape and cut out the formulas. Unfortunately, inkscape will insist on treating your formulas as text, and mess them up in the process.
With a minor sidestep to acrobat professional we can get around this in five easy steps:

1. Open the pdf in acrobat professional.
2. Add a watermark using Document -> Watermark -> add. Set its opacity to 0%
3. Open advanced -> Printing Production -> Flattener Preview
4. Check “convert text to paths” and hit apply
5. Save your pdf

The text has now been converted to a vector drawing, and can now be imported into inkscape without problems.
If you don’t add the watermark in acrobat professional, it’ll just ignore the “convert text to paths” option (don’t ask why). This trick can be used to import any fancy formatted text without running into font problems. (You do lose the ability to edit the actual text though)

Enjoy your nicely formatted formulas in your presentations / posters