Category Archives: LaTeX

Managing Citations in Word Using Zotero

I am a LaTeX user. However, the unfortunate reality is that Microsoft Word is in very common use and if you’re collaborating with other people, one of your collaborators is going to insist on using Word. The EUSES group at Oregon State University has traditionally used Word on most of their projects.

BibDesk Screenshot

BibDesk

One thing that I like about LaTeX is that its citation management is quite good – it’s easy to add references, move them around, and have the Bibliography build properly. Right now, I use BibDesk for much of my reference management. It’s extremely lightweight, stores data in BibTeX format, and is quite portable across systems.

The Need to Keep Files

One of the limitations of BibDesk is that it doesn’t handle files very well. You have to often add them manually to each entry, and it doesn’t keep them organized nicely on the file system. One may wonder – why keep files at all? Can’t you just grab them from the ACM Digital Library when you need them?

Well, yes, but I like files. If I have them, I can work offline. I can use Spotlight (rather than Google) to look for files on my hard drive. I also need files so I can transfer them to my iPad and iPhone. There are also a number of references that simply aren’t on the digital library and have taken a bit of effort to acquire, so I’d rather not lose them.

This led me on a quest to find a slightly better reference management system.

Endnote? Mendeley? Papers?

There’s actually no lack of citation managers out there. Endnote is a relatively long-standing program that is known for providing citation management to Word. Papers is an award-winning paper management program for Mac OS X. Mendeley is a free cross-platform solution that can scan PDF files and automatically fill in a citation with data online.

Collaboration with Mendeley

Mendeley Desktop Screenshot

Mendeley Desktop. Notice how OMGHUGE it is.

My choice for about the past year was Mendeley. It is a closed-source program that has an online web presence and a sync server, meaning that once you put your papers into the software, it can display them for you on the web, or sync them onto a new computer. You can also share groups of citations with others – great when you’re surveying literature.

However, the program is big, slow, and uses tons of screen space. I’ve also been experiencing issues with it recently of it not quite finding the right information based on a search of the title. When it was given the paper’s title, it was often filling in the journal with “Society” or something ridiculous like that. It was also not recognizing conference papers as such, often leaving them as the default “Article”.

I began to search for something more robust.

Enter Zotero

I had actually heard of Zotero about the same time I acquired Mendeley (thanks Neil!), but I hadn’t ever bothered to figure it out. Then, I heard that there was a plugin to Microsoft Word that helped you manage references.

What?

Zotero Panel

Zotero, Firefox Extension

Zotero is a free Firefox add-on. It lives and dies with the web browser, and by default is a little panel at the bottom of your browser window. It, like Mendeley and BibDesk, has the three-panel layout that is “Citation groups”, “Citation list” and “Citation details”.

However, I never really figured out Zotero until I learned about this button that doesn’t exist in the “proper” Zotero panel:

Zotero Add to Library Button

The Zotero Add to Library Button

The “Automatically Capture Bibliographic Information From The Web” button (it doesn’t have a name in the Zotero documentation) appears on pages like ACM Digital Library, IEEE Xplore, and Amazon, where information about references is displayed. When you click this button, it creates an entry for you and populates it with the correct information. Suddenly, I realised that this is a tool that I’ve wanted for a while, because where do I get most of my scientific articles from? I get them from the Web. So, rather than having to copy and paste the BibTex entry into BibDesk (annoying but doable) or downloading the PDF and dragging and dropping it into Mendeley (and then having Mendeley get the information with a 70% chance of it succeeding), I can just skip the process and import it all directly.

Microsoft Word Integration

In addition to being able to import references from the web, Zotero integrates with Word. You need to follow the instructions for installing it which includes downloading Zotero, a Python plugin, and the Word add-on. If you’re using the latest-and-greatest version of Firefox, you might have to also download the Mozilla Add-on Compatibility Reporter to force the Word extension to load (it turns itself off because it’s not certified with the latest version of Firefox, but I force-loaded it and so far don’t have any problems).

Zotero in Microsoft Word

Zotero in Microsoft Word. There is a toolbar as well as a "Script" menu item in Mac OS X.

When you restart Word, you’ll get a little toolbar as well as a script menu. The script menu contains items that are relatively self-explanatory. You can add citations, add the bibliography, edit the citations and bibliography, refresh the document if you change the database from Zotero, and set your preferences (i.e. your citation format).

One reason why I like this tool is that it’s very lightweight. You can send this version of the document to someone without Zotero, and as long as they don’t try editing all of the fields, they will see the references just fine. This enables you to collaborate with them without having to worry about getting the references out of format (which was something that happened a lot in EndNote X2).

However, Zotero also has cloud-based sync and group-sharing features like Mendeley does, so you can use those features as well to keep your computers in order, and to share citations with your collaborators.

Right now I’m pretty sold on this tool. It is cross-platform (though unfortunately tied to Firefox, but I hear there are Chrome and Safari alphas), syncs documents, imports data automatically, keeps files organized (it saves them in your Mozilla Profile unless you tell it otherwise), and integrates with Word. And, it costs no money. It even imports and exports BibTeX, meaning that I don’t have to give up or even migrate from BibDesk.

If you’re struggling with reference management then I think Zotero is something you might want to try. Happy citing!

Advertisements

Enabling the LaTeX Master File on Mac OS X (and also some general Mac OS X LaTeX notes)

First of all, what is LaTeX? LaTeX is a typesetting tool. It allows you to type stuff and then formats it all together for you into a nice pretty document, usually in PDF. In this respect, it’s quite similar to Microsoft Word. The differences between the two, however, are in the way that you format the document.

Microsoft Word is visual. That is, if you want to adjust something, you usually have to do it manually. You drag a figure into the right spot, you drag the margin to the right width, or  you drag the paragraph into the correct location. Anyone who’s worked with Word for any amount of time though has encountered issues with formatting, especially when moving things around. You add a paragraph and boom, suddenly your pictures are all off of the edge of your screen!

LaTeX works differently because you specify the behaviour and the appearance of the document in addition to the text. LaTeX extensively uses templates to format your document so that you get a document that looks great no matter what you put into it. In this respect, it’s a little like HTML in that what you type into the screen doesn’t look like the final product – you need another program to make it look like the final result.

Anyway, this isn’t a LaTeX tutorial so to speak. What I really wanted to talk about are a couple of options for LaTeX on Mac OS X.

TeXShop

TeXShop is a simple GUI that allows you to easily type and compile your LaTeX.

For a long time, I used TexShop as my main LaTeX editor for the Mac. It’s a pretty nifty editor – it has good support for common LaTeX templates, it allows you to click back and forth between the rendered PDF and the position in your document to edit, and it’s very clean and simple to use. If you are looking to get up and running quickly, I highly recommend it.

The complete package for Mac is located here: http://www.tug.org/mactex

I am pretty sure that when you install MacTex, you get it by default, but if you don’t, you can get it here. http://pages.uoregon.edu/koch/texshop/

TextMate

I bought TextMate for myself a few years ago but haven’t really used it for LaTeX until recently. I began to write my thesis, and it involved many files in the project. TextMate has a nice drawer that lists the files in the project and therefore is easier to manage than multiple TeXShop windows. For this reason, I began to move to TextMate.

However, TextMate needs a little bit of modification to make it work with the ease of TeXShop.

Textmate and Skim

Skim and TextMate. The project drawer is only one reason why TextMate is a strong editor for LaTeX.

PDFSync and TextMate

To get pdfsync working, which allows you to click between your rendered PDF file and the text file in which you’re editing that text, you should get Skim. Skim is an alternative PDF viewer that was originally designed to effectively export PDF annotations. There are a few options in the LaTeX bundle in TextMate to make pdfsync work with Skim, and an option in Skim to have it work with TextMate.

Download Skim here. It’s open-source.

The LaTeX Master file: Compile a Project from any File

One of the great things with LaTeX is the use of a “LaTeX Master File”. This allows you to specify what the “main file” is of your project so you don’t have to select it every time you want to compile your LaTeX project. In my example, the master file is “IrwinKwan_PhD_Dissertation.tex” and it imports the other files. There is an option in the LaTeX bundle of TextMate to set the master file but that isn’t enough.

In TexShop or any other Editor

To use a master file setting in any LaTeX project, put the following in every one of your .tex files:

%!TEX root=your_master_file.tex

where “your_master_file.tex” should be the actual name of the master file of your project. This works in TeXShop, in TextMate, or in any other text editor.

But, you can also do this in TextMate in a more specific matter as I’ve written below.

Setting the Master File in TextMate

What you need to do is to set an environment variable. Do that as follows.

The Textmate Info Box

Click on the "Info" box. Don't forget to de-select any files you might have selected first.

First, deselect files in the drawer view. To do this click on some white space below the drawer. If you need to, resize your window so you can reach it.

Second, click on the little “I” at the bottom of the drawer.

You’ll get a new window that asks for Environment Variables. Add a variable using the little “+” icon. The variable should be labelled TM_LATEX_MASTER. Give it the value equivalent to the full path of your LaTeX Master file. In my case, that’s “/Users/irwink/uvic/research/thesis/trunkIrwinKwan_PhD_Dissertation.tex”.

Setting variables in the variables window

Add the TM_LATEX_MASTER variable. The value is the full path to your master file.

Once you do that, you can then press Command-R and compile your project from any file you select (except for the master one, ironically). That was a real time-saver for me and allowed me to preview my changes from any file I was working on.

Some LaTeX Code to Help Track Your Work

Here are a few LaTeX snippets that I am using in my thesis to help me keep track of things.

A Reading Marker to help with ProofReading

I use this to highlight where in my document I’ve managed to edit up to.

% A reading marker, to help proofreading
\providecommand{\readhere}[2]{\texttt{\hl{\emph{#1:} #2}}\\
\rule{\textwidth}{0.5pt}\\%
}

A “To Do” Marker

This one makes a note in the paragraph margins and marks it with a “TODO”. Some of the code is reused from here.

% Make the fonts small
\setlength{\marginparwidth}{1.3in}
\let\oldmarginpar\marginpar
\renewcommand\marginpar[1]{\-\oldmarginpar[\raggedleft\footnotesize #1]%
{\raggedright\footnotesize #1}}

% Put the margins on the left side
\reversemarginpar

% My TODO macro
\newcommand{\TODO}[1]{%
\marginpar{\textbf{TODO:} \emph{#1}}%
}%

Putting a LaTeX header on top of your manuscript

If you’re like me, you’ll have a lot of draft versions of your documents that you print out, and then you lose track of which version is the latest one. Wouldn’t it be nice to have the date and time of your document on the top of each page?

Using LaTeX’s fancyhdr package, as well as the time package, it’s pretty easy to put in a header the date and time at which the document was generated at the top of every page. Use the code below at the top of your document.

Just make sure you comment out the appropriate lines (\pagestyle{fancy} and \thispagestyle{fancy} before you make a camera-ready version.

\usepackage{fancyhdr}
\usepackage{time}

%-------------------------------------------------------------------------
% take the % away on next line to produce the final camera-ready version
% Be sure to remove \thispagestyle{fancy} as well after the \maketitle.
%\pagestyle{empty}
\pagestyle{fancy}

\newcommand\myTime{\now}
\fancyhead{}
\fancyhead[CO, CE]{\texttt{-Manuscript Draft-}}
\fancyhead[RO, RE]{\texttt{\today, \myTime}}
\setlength{\headheight}{2\baselineskip}
\renewcommand{\headrulewidth}{0pt}
%-------------------------------------------------------------------------

\begin{document}
\title{My paper's title}
\author{Author's name}
\maketitle

% You need this here, or else the first page won't have a header.
\thispagestyle{fancy}

\begin{abstract}
Abstract goes here
\end{abstract}