Author's details

Date registered: August 26, 2011

Latest posts

  1. No escape — November 15, 2011
  2. Blech — August 26, 2011
  3. Gaining real estate on my SL MBP — April 25, 2011
  4. Current state of LaTeX on the iPad — March 28, 2011
  5. Sending EagleFiler metadata to BibDesk — October 31, 2010

Author's posts listings

No escape

At first glance, it seemed that everything worked ok in my migration of this blog from one machine to another. But, there does seem to be one thing that didn’t make the transition well. Most of my \ characters disappeared. I’ve gone back and fixed a few obvious places where they should have been. But there may be some uncompilable TeX left here and there.


The Lingtech blog has taken on a whole new look, and it’s not really intentional. It is being hosted on entirely new hardware running a newer version of both Linux and WordPress, so there are bugs left to work out. I think at least most of the old URLs should still point where they are supposed to, and I’ll work on the theme and so forth later. I’m mainly posting this now to (a) test MarsEdit and (b) point out that the change of look was not exactly intended.

Addendum: I’ve now done a little bit of fiddling, and the current theme is better. So, the comments above referred to the theme I got by default. This one isn’t so bad.

Gaining real estate on my SL MBP

I have a very busy menubar, lots of menubar extras, and it’s annoying that many of them wind up being covered up by the actual menus on my 13″ MacBook Pro. I used to use Unsanity’s Silk to reduce the font size (I was using Arial Narrow), but Silk even now hasn’t been updated to work in Snow Leopard.

However, I came across a “ported font” called Greyscale on the macthemes.net site, and installed it. So far, so good.

[Note! I haven’t even tried this after switching to Lion, I used the TinkerTool trick in footnote 2 instead.]

My menubar now looks like this:

Greyscale menubar

Below I outline what I did. I have had it running for something like an hour, with no real ill effects. But, pulling this off is a deep, dirty OS hack. If you do this, you’re doing it at your own risk.1

The procedure is: Get a copy of Onyx if you don’t have it already (this is to clear the font caches). Download the Greyscale.zip file from the forum link given above, open up the Protected and System folder aliases contained within. From the ProtectedFonts folder, move the LucidaGrande font to somewhere else for safekeeping (system password needed), move the LucidaGrande font from within the Greyscale archive into the ProtectedFonts folder (system password needed), move the LucidaGrande font from within the Fonts folder to the trash (system will alert you that this is weird). Then, in Onyx, go to the Cleaning tab, Fonts panel, ensure that System and Users is checked, and Execute. Restart.

Note: As far as I understand it, this will not work properly if you try to replace the font file in ProtectedFonts. Move it out and move the new one in, don’t just move the new one in overtop the old one.

What is happening here is this: The systemwide font that Snow Leopard uses for the menu bar, Lucida Grande, is being replaced. This is an important font, and SL protects itself against losing it by keeping a “repair kit” version of it in ProtectedFonts. So, first, we swap in our own font to its repair kit, then we remove the system font (causing it to repair itself, but with our new font instead). Cleaning the caches and restarting helps make sure no remnants of the old Lucida Grande are still in memory.

To undo this, repeat the same steps, only move the original file (that you kept for safekeeping) back into the ProtectedFonts folder after moving out the faux-LucidaGrande.

It’s not necessarily all flowers and bunnies, though. This really is completely replacing Lucida Grande. We’re not changing the font in the menu bar, we’re hiding another font in there under the name Lucida Grande. What this means is that everything that would have used Lucida Grande will now use Greyscale (though it will think it’s using Lucida Grande). And if you try this, you’ll see that Lucida Grande is used all over the place. Window titles, source sidebars, Growl notifications, everywhere, everywhere, everywhere. I’d really prefer it if it were possible to selectively replace the menu bar font alone, but this is apparently quite difficult to pull off.2

Still, I have more room now, and I can still read my screen.

1Another much less intrusive option is to use something like AccessMenuBarApps, which is not much more than a little app you can bring to the front with a hotkey or gestures and which has a very very small native menu bar app, leaving maximum space for menu bar icons. Of course any app with a small menu bar footprint can serve this purpose, but AccessMenuBarApps is pretty convenient.

2Something kind of like this can be accomplished by using TinkerTool and setting all of the configurable fonts to something other than Lucida Grande. I went in and changed everything that was Lucida Grande to Arial Narrow, and that works pretty well. The problem I have with Greyscale is that it is very hard to see the distinction between the numerals six and eight. If someone has converted Arial Narrow to be in the right format to drop it in, I’d probably do that instead of dropping in Greyscale. [Later note: One downside to using Arial Narrow (at least in Lion) is that it does not have the right characters to display the modifiers for keyboard shortcuts, so they wind up being displayed with characters like Ý. To solve this, I left my System font set to Lucida Grande, though it is a tradeoff between space and having the shortcut symbols.]

Current state of LaTeX on the iPad

Susan Donovan posted a review of the current state of things in the quest to do LaTeX on the iPad: Using LaTeX on the iPad: The best and worst apps for writing mathematics.

I haven’t tried most of these, I haven’t gotten much beyond installing TexTouch and playing with it a little bit. However, most of the alternatives that Susan reviews are really only alternatives if what you want to do is typeset mathematical formulas for papers or emails, being LaTeX-powered equation editors. I’d find such a thing potentially useful if it allowed drawing trees in emails (which is what I sometimes use LaTeXiT on the Mac for), but that’s not going to happen without pretty much a full local installation of LaTeX (so I can include pstricks and pst-jtree).

The remote compilation that TexTouch does, particularly since you can set it up against your own installation on a desktop machine synced with Dropbox, still seems like a pretty optimal solution for using full-blown TeX. Even if Apple’s guidelines didn’t prohibit it, I’m not at all convinced that I actually want a full TeX install on my iPad proper. My desktop machine has much more disk space and computational prowess, and I’m rarely using the iPad in a situation where it isn’t connected to the net.

Sending EagleFiler metadata to BibDesk

I have a big EagleFiler archive in which I hold all of my PDFs, and as I add papers, I generally fill the “Title” field with the paper title and the “From name” field with the authors, as well as assign tags, etc. EagleFiler is generally my first stop when I acquire a new PDF. Plus, my EagleFiler library lives in my Dropbox, so I can get at these files from my iDevices as well.

However, when I want to add one of these papers to my bibliography, I have to go to BibDesk, make a new record, retype the title and author, and attach the PDF. And then I think: I should automate the export of the metadata someday.

Happily, that someday is today.

I have put together a simple Applescript that will look at the record(s) selected in EagleFiler, and create a corresponding new BibDesk record for each of them. It fills in the title, author, and source URL information from the EagleFiler metadata, attaches the file to the BibDesk record, and then does a couple of other things that are idiosyncratic to my particular filing system. In particular, it looks in the path to see if it is inside a “Journals” folder (in which case it is an article), or in “Monographs” (in which case it is a book), etc. It also looks to see if a tag called “look” was assigned in EagleFiler, and marks the “Read” flag in BibDesk if the tag is found. Obviously, these parts are only useful if you file things the way I do. But even if you don’t, it might be interesting to see how the script works.

I am no Applescript genius. In my initial tests, this ran kind of slowly, and there are probably better or more efficient ways it could be written, but it does seem to work.

Once a BibDesk record is created, the publication window is opened, and generally there needs to be some tweaking: fixing quotation marks, protecting capitals, fixing author lists to use “and” as separators, but it still saves some double-entry.

One installs Applescripts like this into ~/Library/Scripts/Applications/EagleFiler and then they are available via the scripts menu in the menubar.

-- Create a new BibDesk record from EagleFiler record
-- Paul Hagstrom, November 2010
-- This is probably kind of idiosyncratic.
-- My filing procedure is to have PDFs in EagleFiler with the
-- title in title
-- authors in from
-- There is very little chance that it will work without any need to edit
-- Maybe later I'll try to figure out how to tag things so that they'll
-- detect the right reference type, etc.

on run
	tell application "EagleFiler"
		set _records to selected records of browser window 1
		repeat with _record in _records
			set theTitle to _record's title
			set theAuthor to _record's from name
			set theSource to _record's source URL
			set theFile to _record's file
			set thePath to theFile's POSIX path
			set theNote to _record's note text
			-- special handling based on my idiosyncratic organization
			-- look at the path to see if it is a journal or what
			set theType to "article"
			if thePath contains "Journals" then
				set theType to "article"
			end if
			if thePath contains "Monographs" then
				set theType to "book"
			end if
			if thePath contains "Dissertations" then
				set theType to "phdthesis"
			end if
			if thePath contains "Edited" or thePath contains "WPL" or thePath contains "Conferences" then
				set theType to "incollection"
			end if
			-- special handling of tags.  If something is tagged "look" it goes on the reading list.
			set theRead to false
			set _tags to _record's assigned tags
			repeat with _tag in _tags
				if _tag's name is "look" then
					set theRead to true
				end if
			end repeat
			tell application "BibDesk"
				tell document 1
					set thePub to make new publication at the beginning of publications
					set type of thePub to theType
					set title of thePub to theTitle
					--at some point I might try to replace commas with "and"
					--and if theAuthor starts with "ed." put it in the editor
					--field instead, since that is my general convention in EF.
					set value of field "Author" of thePub to theAuthor
					tell thePub
						add (POSIX file thePath) to beginning of linked files
						if theRead then
							set value of field "Read" to 1
						end if
						make new linked URL with data theSource at end of linked URLs
						--at some point I might try to parse my filenames
						--they are generally authorYear-source.pdf
						--set value of field "Journal" to theJournal
						--set publication year to theYear
						set cite key to get generated cite key
					end tell
					show thePub
				end tell
			end tell
		end repeat
	end tell
end run

Dotless i with ogonek.

I was asked how to do a dotless i with an ogonek. Unicode doesn’t have a character for this, and the combining ogonek doesn’t line up reliably with a dotless i. But I got a pretty reasonable one in Word by doing the following.

Insert field…, and type eq o(a,b). Right click on the field and toggle field codes so you can see { eq o(a,b) }. Remove the spaces inside the braces (yielding {eq o(a,b)}), and then select the a, open the Character Viewer (in the international/input menu bar widget, turn it on in System Preferences on Mac OS X), and replace “a” with a dotless i, and replace “b” with a (non-combining) ogonek. Right-click, toggle field codes. You can now copy and paste it wherever it is needed.

This will undoubtedly come in handy regularly. For example, if you need to render Piglet in text.


A possibly better way to customize the TextMate LaTeX plugin

In the aftermath my recent adventures with a development version of a TextMate LaTeX bundle, I wound up reinstalling the original LaTeX bundle, but in the process lost my customizations for special citations and idiosyncratic inline linguistic examples.

I could have re-edited the bundle (that’s why I posted the instructions here, after all, so I could remember what I did), but I discovered a better way, looking at the TextMate manual section on language grammars and on the TextMate wiki: create my own language, subclassing the language from the LaTeX bundle, with just my additions. The advantage of this is that if I ever update the LaTeX bundle, the additions will continue to be mixed in.

This is in fact how the LaTeX Beamer language definition works, so there’s a ready-made example to look at. It defines a couple of special beamer-related things (frame and frametitle), and then includes the regular LaTeX language. So, I am doing just that. Note, though, that if I want to include the beamer specials, I need to include the beamer class. Since I don’t see any real harm in doing so all the time, I am extending that class which itself extends LaTeX.

Here’s how to do this: Go to Bundles > Bundle Editor > Edit Languages…, open up the LaTeX bundle and select the LaTeX Beamer language. Hit the duplicate button in the lower left corner to duplicate it. Then hit the add button and add a new bundle, call it something, and then drag the beamer duplicate into it. Name your duplicate something better, and click on it to edit it. Change scopeName to text.tex.latex.custom. You probably want to get rid of the firstLineMatch line as well, and change fileTypes to ( 'tex' );. The idea is that it will pick up any file with the .tex extension, without checking to see if it is a beamer file.

Then, just put in the additions. I left the beamer additions in, since I use those too. I couldn’t get an include line to work with text.tex.latex.beamer, maybe TextMate doesn’t allow nested includes. Even including both the beamer addition and the main LaTeX language didn’t work, in either order. So, I just left the beamer additions in.

For completeness, this is what I ended up with:

{	scopeName = 'text.tex.latex.custom';
	firstLineMatch = '^\documentclass([.*])?{beamer}';
	fileTypes = ( 'tex' );
	foldingStartMarker = '\begin{.*}|%.*(fold)s*$';
	foldingStopMarker = '\end{.*}|%.*(end)s*$';
	patterns = (
		{	name = 'meta.function.mot.latex';
			contentName = 'string.quoted.mot.latex';
			comment = 'Added by Paul Hagstrom';
			begin = '((\)mot)({)';
			end = '}';
			beginCaptures = {
				1 = { name = 'support.function.mot.latex'; };
				2 = { name = 'punctuation.definition.function.latex'; };
				3 = { name = 'punctuation.definition.mot.begin.latex'; };
			endCaptures = { 0 = { name = 'punctuation.definition.mot.end.latex'; }; };
			patterns = ( { include = '$base'; } );
		{	name = 'meta.citation.latex';
			begin = '(?x)
						(\)										# Marker
						(?:foot)?(?:full)?(?:no)?(?:short)?(?:poss)?(?:pg)?		# Function Name
						*?											# Optional Unabreviated
					(?:([)[^]]*(]))?								# Optional
					(?:([)[^]]*(]))?								#   Arguments
					({)											# Opening Bracket
			end = '}';
			captures = {
				1 = { name = 'keyword.control.cite.latex'; };
				2 = { name = 'punctuation.definition.keyword.latex'; };
				3 = { name = 'punctuation.definition.arguments.optional.begin.latex'; };
				4 = { name = 'punctuation.definition.arguments.optional.end.latex'; };
				5 = { name = 'punctuation.definition.arguments.optional.begin.latex'; };
				6 = { name = 'punctuation.definition.arguments.optional.end.latex'; };
				7 = { name = 'punctuation.definition.arguments.latex'; };
			endCaptures = { 0 = { name = 'punctuation.definition.arguments.latex'; }; };
			patterns = (
				{	name = 'constant.other.reference.citation.latex';
					match = '[w:.]+';
		{	name = 'meta.function.environment.frame.latex';
			begin = '(?:s*)((\)begin)({)(frame)(})';
			end = '((\)end)({)(frame)(})';
			captures = {
				1 = { name = 'support.function.be.latex'; };
				2 = { name = 'punctuation.definition.function.latex'; };
				3 = { name = 'punctuation.definition.arguments.begin.latex'; };
				4 = { name = 'variable.parameter.function.latex'; };
				5 = { name = 'punctuation.definition.arguments.end.latex'; };
			patterns = ( { include = '$self'; } );
		{	name = 'meta.function.frametitle.latex';
			match = '((\)frametitle)({)(.*)(})';
			captures = {
				1 = { name = 'support.function.frametitle.latex'; };
				2 = { name = 'punctuation.definition.function.latex'; };
				3 = { name = 'punctuation.definition.arguments.begin.latex'; };
				4 = { name = 'entity.name.function.frame.latex'; };
				5 = { name = 'punctuation.definition.arguments.end.latex'; };
		{	include = 'text.tex.latex'; },

Tex Touch: LaTeX on the iPad that doesn’t even hurt much

I just took Tex Touch for a spin on the iPad, and actually did some substantial editing on a paper. It’s not as fast to type on an iPad as it is on a real keyboard, of course, but I’m pretty impressed with how it works.

The fundamental problem with TeX on an iDevice is that Apple forbids any kind of code compilation on the device itself, and so one couldn’t even in principle do a TeX install on the iPad (at least without jailbreaking, I don’t know what options are open for a jailbroken iPad). So, the only way to make it work is to do the compiling remotely. However, TexTouch makes the process pretty transparent.

Tex Touch allows you to connect yourself to a folder in your Dropbox account (and for the space you need, the free account will suffice), and then it will use that folder as a way to connect to your desktop machine, which needs to be running a program that will watch the folder and compile any TeX files that find themselves there. When the compilation is done, and the PDF file is produced, TexTouch picks it up and allows you to display it on the iPad. The folder watching function is accomplished either by the developer’s own program or by using Ramón Figueroa-Centeno’s LaTeXMe script. LaTeXMe is a Mac program, but Tex Touch itself is intended to also work with a Windows machine on the remote compiler end.

Once you have it set up, you barely realize that it’s being compiled remotely. You hit the “TeX!” button and the file is uploaded, it sits for a little bit, then downloads the PDF (or gives you access to the log).

The editor itself is nice too. No syntax coloring yet, but it has support for templates, and it has an elaborate keyboard setup that allows pretty simple access to brackets and slashes and commonly used LaTeX commands and symbols. After working with it briefly, I found it quite acceptable.

I’m looking forward to seeing how it develops, but this looks like the perfect solution for my own setup. I already keep all of my TeX work in my Dropbox folder anyway, so it’s pretty straightforward to copy over a file I want to work on when I’m away from my computer and get still something done. The only problem that I have had so far is that it didn’t find my bibliography file when it was remotely compiling, but I’m sure that (a) this is pretty easily solvable by adding a path to something somewhere, and (b) I’m unlikely to produce the final version of the PDF this way anyway, so I’ll always have a chance to recompile when I get back to my computer.

A nicer LaTeX bundle for TextMate

When a document I was trying to compile kept alerting me to fatal errors, but scouring the log file failed to reveal anything that should count, I decided I’d poke around a little bit to see if there were any updates to the LaTeX bundle for TextMate. I found, first, that it seemed to have actually disappeared from the TextMate svn repository, but, second, that there is a relatively nice version maintained by Adam Strzlecki on github. I haven’t done a great deal of exploration, but it does seem to be a bit faster, and there are a few added niceties to the autocompletion mechanisms.

I updated to the new bundle, but since I had made some changes to the old one (see Adding a little bit to TextMate’s LaTeX bundle and More TextMate LaTeX language editing), I decided to fork the existing repository and add those in as well.

Additionally, at present, the current bundle chokes a little bit on files that are within folders that contain spaces in their names. Compilation still works, but the links to errors that you should get in the status window are broken, as is the “jump to corresponding location in the PDF” command. I’ve fixed both of these problems in my fork of the bundle (though it is possible that there are hidden problems I’ve introduced, particularly in the thing that processes error links, I haven’t tried it with a complex master document).

Update: The sad truth is, this is not ready for prime time yet, at least not for me. I rely heavily on the dvi-ps-pdf pathway, and this bundle seems to have disabled it. I tried for a while to re-enable it, but it just wasn’t cooperating. Maybe in the lazy days of Thanksgiving break, but for now I would recommend against installing this bundle.

To install my fork of the TextMate LaTeX bundle, you need to remove the old one (maybe just put it somewhere safe in case you want to go back to it) from ~/Library/Application Support/TextMate/Bundles/ (maybe also check in /Library), and disable or remove the built-in LaTeX bundle. (I, perhaps unwisely, just pulled it out of the .app: right-click on the TextMate application, show package contents, open Contents, Shared Support, and Bundles, wherein is LaTeX.tmbundle.)

To install the new bundle, you need to have git installed. If you don’t, there is some information at github about installing git on Mac OS X.

That done, open a Terminal window and type thusly:

cd ~/Library/Application Support/TextMate/Bundles/
git clone git://github.com/paulhagstrom/LaTeX.tmbundle.git

The next time you start TextMate, the new bundle should be active.

Now, back to that paper.

Printing handouts from the T

Once again, I arrive at the T stop just to see the train I needed to get to class on time pulling away. I still need to print my handouts, but I am barely going to be able to be physically there by the time the class is scheduled to start.

What to do?

Well, I have 20 minutes on the T, and my handout files are kept in my Dropbox folder, which means that my handout is actually on my office computer’s hard drive. And I have an iPhone on which I have installed iSSH. iSSH is a fabulous app, complete with VNC capability, so I figured: I’ll just put my office computer’s desktop on my phone, open the handout, and print.

Except something is configured wrong, or I’ve forgotten the VNC password, something is preventing me from bringing up my office computer’s screen on my phone. I can, however, still ssh in to the command line on that computer.

So: how to print from the command line?

Although there is rarely call to use it, it is relatively straightforward to send things to the printer, and the CUPS printing system installed as part of Mac OS X is smart enough to know what to do with PDF files, and can send options to the printer like: print double-sided, staple, print 2-up, etc. You just use the lp command. Here is the specific command I used.

lp -d printer_name -n 15 -o Collate=True -o Staple=1PLB -o number-up=2 -o sides=two-sided-long-edge ~/Dropbox/.../handout.pdf

Of course, this won’t work for everyone’s printer setup, one needs to know what the printer’s name is, and what options are available. But these are fairly easy to determine, based on things I learned from this page of the CUPS documentation.

If you need to find out what printers your computer knows about, enter lpstat -p -d at the command line. In the print command I gave above, I pretended that one of the printers was called printer_name, although really it was named after its IP address on the network. The number 15 I put there after the -n option is the number of copies to print. The options indicated with -o are printer-specific options for stapling, printing n-up, etc. You can find what options your printer supports using lpoptions -p printer_name -l.

So, as long as there is paper in the printer, and there are no forthcoming paper jams, it is possible to make the printer do its thing all on its own, so that I can pick them up when I get there and go to class. Fairly nerdy, but pretty cool. And occasionally practical.

Older posts «