Wednesday, November 25, 2009

Accent marks in JabRef

I have a lot of PDFs with authors that have accent marks in their names, such as Ekström. I had thought that using the LaTeX code for the letter in my JabRef entries might work since the database is just a BibTex file. No such luck. Turns out you can just use the regular keyboard shortcuts for Mac/Win in JabRef to get the right letters. For a guide to the keyboard shortcuts, check out this link.

JabRef might complain about not being able to encode certain characters when you go to save your database. If so, just chose UTF-8 for the character encoding option. UTF-8 will preserve any letters with accents, as well as foreign characters you might have (e.g. Greek letters in the abstracts).

Zotero AND JabRef: how to make both work for you

So yesterday I posted about how I switched over to JabRef reference software, mainly because it allows relative links, but also because it easily lets you see and edit the BibTex entry, which as a LaTeX user, is very helpful. There are two things JabRef does not really do that Zotero does that I find really useful:

1) Zotero can easily capture reference information from a variety of website formats, even if no Bibtex or RIS entry is provided

2) You can drop a pdf directly into Zotero, index it, and then retrieve the reference information automatically, assuming the article is online somewhere

If the article's webpage has a BibTex or RIS entry available for download, you can simply download this and import it into your JabRef database, but I have noticed some journals still do not offer this service (shame on them!)

So this morning I have been happily using Zotero to collect reference information I find online and to auto-generate some entries based off some PDFs I already had. Once I am done, I can export to a RIS file and then import that RIS file to my current JabRef database. My BibTex keys are automatically generated on import, so I simply select the new entries, go to Tools -> Scan Database -> Sync Files and any new PDFs I obtained during the day will be linked to their entry in JabRef.

I keep my Main.bib file that is my current JabRef database inside my folder with all my reference PDFs. At the end of the day, I can simply commit the whole folder to subversion. Everything is not only backed up, but when I checked out the folder on my Windows machine, all my PDF links will work perfectly and I won't have to tweak my database one bit!

I used to hesitate putting all my PDFs in svn, but our school server is pretty huge and the 1 GB or so of PDFs that I have now does not even make a dent. Plus, after hearing from a friend how he lost his whole PDF database and had to go download or even scan (yikes!) all his references again, I decided backing up all my articles in svn was not only OK, but necessary!

Tuesday, November 24, 2009

Zotero to JabRef: switching reference software

If you know the academic me, you know I love, and regularly tout, using Zotero to manage my ever-growing bibliography. There is one problem with Zotero, however, that I just cannot move past: its inability to use relative links for linking to files.

update: I edited the following paragraph to clear up some confusion pointed out in a posted comment. I should also point out that on Zotero's website, there are numerous posts from users requesting relative links, but with absolutely no reply from Zotero. This again makes me think that the way Zotero is written, relative links are not possible. Otherwise, they would have it, wouldn't they?

I love being able to sync my Zotero database between my personal Mac and school PC, but the syncing breaks the file links. If you sync your database to a second computer, it shows the links as still being there, but if you try to click on a file to open it within Zotero you get an error message saying Zotero cannot find it. You can tell Zotero where the file is, but you would have to do this for every file in the database. I am guessing this has something to do with Zotero running as a FireFox plug-in. When you add a PDF from another directory, Zotero copies it into its own internal structure, which is confusing and involves folders with random letter names. This is just not working for me. I want to be able to sync my database between my computers, and have functional links to the associated files.

I just switched today to JabRef and love it. It is free, works on Windows, Linux, and Mac, and let's you use relative links. It is simply a frontend for your BibTex file, but it has some really cool tricks:

1. It can autogenerate bibtex keys based on a format you specify
2. It can automatically link entries to files in any directory you specify based on the bibtex keys.
3. It is all stored in a small, easily transferable, BibTex file
4. It supports online searches so you can find and easily capture references online
5. It supports field-based views, but let's you view and directly edit the BibTex code as well as
4. I am sure there are a ton more, but I just started using it today

There are a couple tricks to switching over, so here is what I did:

1. Export the Zotero library in RIS format (my BibTex format export from Zotero caused issues with JabRef)

2. Import the RIS file into a new database in JabRef and save it

3. The internal PDF links from Zotero were written out to the URL field, meaning there are now a bunch of broken URL links in JabRef. To fix this, I navigated to the location of my new database file via terminal (or Cygwin in Windows) and did the following:

egrep -v "internal-pdf" original.bib > new.bib

This will delete all those pesky broken URLs that think they are internal PDF links, but still keep any legit URL links

4. Open the new.bib with JabRef (you can close out the old database now).

5. Under Options -> Preferences -> External Programs: Set the file and PDF directories to whatever directories you are already using (ex: /Users/mwolfson/Documents/School/Articles). Also check the "Autolink files with names starting with BibTex Key" option

6. Under the BibTex Key generator options, setup your BibTex key to match how you name your PDFs. My PDFs are named: author_year.pdf. So my BibTex Keys were set to [auth]_[year].

7. Select all your entries in your database, then go to Tools -> autogenerate BibTex Keys (let it overwrite old keys if necessary). Now all your entries should have the proper BibTex Key appended to them

8. While still selecting all records, Tools -> Scan Database -> Synchronize File Links (they have a specific PDF link, which works, but does not add the PDF icon to the entries for some reason -- perhaps because it uses a special pdf = {} in the bibtex code instead of file = {} -- so there is no way to know which entries have PDFs and which don't). Allow overwriting and hit OK. Now, if your PDF/file names in the specified directory match any of the BibTex keys, they will be auto-linked to the JabRef entry. Entries with linked PDFs should now show a PDF icon next to it.

update: There is an option under preferences to "show PDF/PS column" which would then, in fact, display the PDF icon if you choose to PDF sync rather than File sync. I have heard PDF/PS sync is being phased out since File sync handles these file types and more though, so I still recommend using File sync instead.

Viola! You should now have a working BibTex database in JabRef with all your articles linked. If you work across multiple computers like me, simply open up this database in JabRef on the new machine, set up your file directories to point to the appropriate files, and you are done. All your PDF links will work because the links themselves are relative! This is especially awesome when working cross-platform between Windows, Linux, and Mac.

Here is a screen grab showing what JabRef looks like running on my Mac:

If you get stuck feel free to drop me a comment and I'll try to help.

Monday, November 2, 2009

Installing GMT under Cygwin

I just struggled through installing GMT under Cygwin, and since I not only had to rely on piecing together information from out-of-date online tutorials, but also on direct help from Kurt, I figured I would write everything down here for future reference and to also hopefully make someone else's life easier.

First things first, check your home directory:

Always check your home directory in cygwin to see if it is actually what it should be. When you install Fledermaus on your machine, it sets a 'HOME' variable that is Program File/IVS/Fledermaus. Now Cygwin thinks this is its home as well. The CCOM wiki offers this solution:

To resolve this, you can create a system-wide HOME area that may be more suitable for any/all programs. To do this, create (or decide) the folder you'd like to be your Cygwin home area. Once you have the folder, edit the HOME variable in the Advanced System properties in Windows and specify that folder. Finally, copy the contents of the previously specified home area into your new home area folder. This will prevent IVS or GMT from breaking. This situation may not be limited to these two products, so it's important to check your 'HOME' environment variable before installing Cygwin software.

Once you are happy with your home directory, here are the steps I followed to successfully install GMT:

1) Make sure you have bzip2 installed. You will also need the 'make' utility and a good C++ compiler (I have a couple different ones, including the gcc one. netcdf will fail to compile without the right one, so if it fails, try grabbing another C compiler. I think gcc is the one to have).

2) Go to the GMT webpage and create an install parameter file. Save this as GMTparams.txt in your usr/local/ directory under your cygwin directory. (If you do not have netcdf already, make sure to let GMT get it and install it for you)

3) Get the GMT install file here, and save it as install_gmt to usr/local/

4) Under cygwin, navigate to usr/local/ and type the following command (this may fail, but this is okay):

./install_gmt GMTparams.txt > install.log

5) If it failed, you probably got a message about a missing -lnetcdf file. This is because netcdf is bad, and uses a .lib extension rather than .a. To fix this, you can just create a symbolic link:

navigate to usr/local/netcdf-xxx/lib
type ln -s libnetcdf.lib libnetcdf.a

Now modify your GMTparams.txt so that netcdf is not downloaded or installed again. You can also modify not to download the GMT files again.

6) navigate back to usr/local/ and rerun ./install_gmt GMTparams.txt >install.log. This should complete without failing, though you may see warnings scroll by.

7) Once it is installed, you must edit your .bashrc or .bash_profile. Cygwin, by default, does not create a .bashrc or .bash_profile in your home directory, so you may need to create one from scratch. GMT looks for a .bash_profile, so if you use .bashrc, make sure you create a .bash_profile that points to it. I'll share mine below:

my .bashrc file (all are needed for GMT to work):

export PATH=/usr/local/gmt/bin:$PATH
export NETCDFHOME=/usr/local/netcdf
export GMTHOME=/usr/local/gmt
export MANPATH=/usr/local/gmt/man:$MANPATH
export DISPLAY=:0

my .bash_profile file:

if [ -f ~/.bashrc ]; then
. ~/.bashrc

export BASH_ENV=$HOME/.bashrc

8) Now you may notice that my paths in .bashrc do not seem to be correct. I use "gmt" and "netcdf" instead of "GMT4.5.1" and "netcdf-3.6.3." This is because I want to be able to update both of these in the future without having to edit any scripts or my .bashrc every time. Therefore I set up the following symbolic links:

navigate to usr/local/ and then type the following commands:

ln -s GMT4.5.1 gmt
ln -s netcdf-3.6.3 netcdf

9) You should be good to go!

To test one of the examples GMT runs upon successful install, you can navigate to any one of the examples found in /GMT4.5.1/share/doc/gmt/examples/. Each ex directory will contain the example scripts, necessary files, and the resulting postscript. I found that to view these files, I need to make sure the X-windows environment is up and running (from cygwin command prompt, type startx). Then I use ghostview (gs) to view the ps:


here is the result:

Fun with Apple Terminal

I am starting to do more and more stuff on my Mac via the Apple Terminal, so I decided to spruce mine up a bit.

Using Fink I first installed "fortune-mod" (the program that actually displays the fortunes) and then installed "fortunes" (the fortunes themselves).

Next I simply added "/sw/bin/fortune" to my .bashrc file.

Now, whenever I open a new terminal window, I am greeted with a fun fortune. Most of the time, these seem to be just silly sayings, such as this:

Old programmers never die, they just become managers.

but every now and then you get something unexpected, such as a recipe for Glogg (a traditional Scandinavian holiday drink).