Showing posts with label BibTeX. Show all posts
Showing posts with label BibTeX. Show all posts

Sunday, January 6, 2008

SEEing LaTeX 24: For Completeness, BibTeX

I guess the right solution is to add a menu item for running bibtex, and that's it. Since I don't use makeindex myself, I'll leave that aside, unless someone wants to contribute scripts or just examples of use. I'd guess that the scripts would be easy enough, just adapt the ones I'll present for BibTeX.

Here's the AppleScript:
checkSaveStatus without updating
set bibScript to join of {modeEnvironment(), quotedForm for "$SEE_MODE_RESOURCES/bin/runbibtex.sh", quotedForm for documentPath()} by space
do shell script bibScript

on seescriptsettings()
    return {displayName:"Run BibTeX"}
end seescriptsettings

include(`SubEthaEditTools.applescript')


And here's the shell script that it calls:
#!/bin/sh

#$Id: runbibtex.sh,v 1.1 2008/01/06 19:09:49 mjb Exp $

PATH="$PATH:/usr/texbin:/usr/local/bin"
export PATH

BIBTEX=${SEE_BIBTEX:-'bibtex "$(basename $FILE .tex)"'}
FILE="$(basename "$1")"
DIRNAME="$(dirname "$1")"

cd "$DIRNAME"
eval $BIBTEX

Monday, July 2, 2007

SEEing LaTeX 4: More on Completions

Earlier, I took a look at using BibDesk to get SubEthaEdit to complete citations in LaTeX files. After working with it a few days, I've learned a few more things about BibDesk. Unfortunately, not all good.

There seems to be a rather unpleasant interaction between BibDesk's completions and SubEthaEdit's completions. Normally, SubEthaEdit injects some mode-dependent terms into the completion dictionary. For some modes, like Python, this is no big deal; most of the keywords in Python are normal English words, so they would be completed by the standard completion dictionary. For other modes, e.g., the Objective-C mode, it can make a more significant contribution; the Objective-C mode defines a large number of Cocoa class names, which you can see by typing NS and pressing F5. Also, and maybe more importantly, SubEthaEdit will search through the current file to find matches, so, e.g., variables you've defined will be completed. For LaTeX, that provides a way to have the labels for equations, figures, and the like to be completed; for user-defined macros to be easily referenced; and for names and technical terms that don't appear in the standard dictionaries to be completed.

Using BibDesk's Autocompletion input manager disables SubEthaEdit's Autocompletion features. Apparently, any input manager that extends completions will have this effect, as the SubEthaEdit FAQ notes that TextExtras will stop SubEthaEdit's Autocompletions from working. With TextExtras, that wouldn't be so bad, since it provides completions of its own, but the tradeoff with BibDesk is more extreme. You can have citations and, interestingly, the \ref and \pageref commands for cross-references completed, but lose completion of the terms in the document, whether it be LaTeX or something else. Or, you can have autocompletion of the terms in the document, but lose autocompletion of citations (cross-reference completion is handled just fine by completion of terms from the document).

An early idea on how to resolve this was that I could install TextExtras, and use its completions. I used to use it, and liked it a lot, but gave up on it some time ago. I'm not sure exactly why, now, but I think it was because an earlier version of TextExtras conflicted with the then-new autocompletions in Mac OS X 10.3 Panther. Unfortunately, I haven't been able to connect to the TextExtras page to download it since coming up with the idea!

In the end, I disabled BibDesk's Autocompletion input manager, it simply comes at too high of a cost. BibDesk has a number of system services, which allow citations to be inserted that way. It will have to do for now. A solution using AppleScript to get completions from BibDesk looks possible, but it seems best to make the issue clear now and solve it later.

This is definitely a strike against using SubEthaEdit for LaTeX.

Update: The same thing happens when BibDesk's input manager is loaded into other editors, too. In Smultron, you lose completion of words from the document; I'm not so familiar with Smultron, so I don't know if there are other features that get lost. It is truly a shame that one of the coolest features of BibDesk is also one that I just don't want to use.

Friday, June 29, 2007

SEEing LaTeX 1: Citations

As a first step towards turning SubEthaEdit into a capable LaTeX editing machine, let's address citations. Citations are a challenge to keep consistent and accurate, so mechanized assistance is quite useful. For LaTeX, that means BibTeX. BibTeX separates content from presentation in much the way that TeX does. Considering the many different formatting styles for bibliographies and citations that are required by different journals, this is something that I won't give up on -- I'll type the citation keys by hand if needed.

Fortunately, getting citation support in SubEthaEdit is trivial! Just install BibDesk, if you're not already using it, and set up autocompletion for SubEthaEdit. Inside a \cite, hit F5 or command-escape, and you get a list of completions for a partial citation key. This works really well. I hadn't used BibDesk for that for a while, since TextMate had its own method (not that it has worked in recent versions), so I'd forgotten how slick this is.

Completions in general, not just for citations, can be made a little bit easier. In your user Library folder, there may be a KeyBindings folder; if not, create it. Create a file DefaultKeyBinding.dict in the KeyBindings folder. The file is an XML file with a list of key-action pairs; bind the escape key to a string "complete:" (with the colon, without the quotes). The Property List Editor works nicely for doing this. The end result is that you just press escape instead of command-escape to get a completion. It doesn't cause any problems for using escape to, say, select cancel in dialogs, so there's no down side, just completions that are easier to activate.