# Latex Spotlight Importer

This page contains information about a small project I have been doing on the side. A Mac OS X spotlight importer for Latex source code. There seem to be a few similar projects out there, and one such importer is bundled with texShop. Still they are not very satisfying as they usually simply index the latex source code.

My goal was to have something more advanced that simply importing the raw source text. I have written a small component that does rudimentary latex parsing and indexes the text content. It has the following features:

• Does not require any Latex installation.
• Extracts the title and the authors.
• Tries to guess the encoding from the inputenc package.
• Indexes the list of publications keys.
• Full text indexing. The latex code is converted to plain text and indexed.
• Command substitution. Certainc commands are substituted for a unicode string for instance \delta becomes δ. This can be customized using a standard property list.
• Command copying. The parameter of certain commands is simply copied, for instance the content of the \textsf command is simply copied. Again, this can be customized.

The importer works on the limited number of papers I tried it on. If you want to try it out, you can download it. Please consider this as a really alpha version, the code is still very raw, and it is probably quite slow, as there are still at lot of logging statements. If you are interested in the source code, please contact me.

To use the importer, simply unzip it and put into ~/Library/Spotlight/. Normally, the importer is activated automatically, if not, you can type /usr/bin/mdimport -r ~/Library/Spotlight/LatexImporter.mdimporter to force the activation. To see what the plugin actually indexes for a given tex document, type in the following command mdimport -d bla.tex where blah is the tex document. You will get all the log messages and the values that have been extracted.

The source code for the importer is now GitHub.

## 2 thoughts on “Latex Spotlight Importer”

1. I was trying this one today; it doesn’t seem to work.
running mdimport -d File.tex, gives me some lists: I dont see your importer listed there.

-d debugLevel Integer between 1-4
-g plugin Import files using the listed plugin, rather than the system installed plugins.
-p Print out performance information gathered during the run
-A Print out the list of all of the attributes and exit
-X Print out the schema file and exit
-L Print out the List of plugins that we are going to use and exit
-r Ask the server to reimport files for UTIs claimed by the listed plugin.
-n Don’t send the imported attributes to the data store.
-o path Write the imported attributes to a file, instead of sending them to the server.

2. Can’t help you much here, this code is old, and I have not used Latex in a decade…

This site uses Akismet to reduce spam. Learn how your comment data is processed.