Posts tagged ‘typesetting’

ASA style cites in Lyx

| Gabriel |

LaTeX makes beautiful output and Lyx makes it relatively easy to do so by obviating the need to learn a markup language, but woah be it unto him who needs the document to look a particular way that goes against the defaults. In particular, the people who wrote this software seemed to have no idea of ASA style. Here’s how you get the citations to meet ASA style.

Under “Document/Settings” menu select the “Bibliography” tab and choose “Natbib” and style of “Author-year.”
lyx_docsettings_biblio

Unfortunately this defaults to “X leads to Y (Author, 2013)” instead of “X leads to Y (Author 2013).” After years of just living with the superfluous comma, I finally realized there’s an easy fix, just paste this into the “LaTeX Preamble” tab of Document Settings.

\setcitestyle{aysep=}

When you create the bibliography make sure you use the asr.bst file. It’s not a standard part of the TeX install so save it locally then navigate to it from inside the Lyx bibliography dialog.
biblio_dialog

That will get your document to have ASA style cites. As far as the overall style, I usually just go with the basic “article” document class unless the journal provides a cls file (which most of them don’t in sociology, although Sociological Science will do so for accepted manuscripts).

Advertisements

September 6, 2013 at 11:14 am

Which of my cites is missing?

| Gabriel |

I was working on my book (in Lyx) and it drove me crazy that at the top of the bibliography was a missing citation. Finding the referent to this missing citation manually was easier said than done and ultimately I gave up and had the computer do it. These suggestions are provided rather inelegantly as a “log” spread across two languages. However you could pretty easily work them into an argument-passing script written in just one language. Likewise, it should be easy to modify them for use with plain vanilla LaTeX if need be.

First, I pulled all the citations from the book manuscript and all the keys from my Bibtex files.

grep '^key ' book.lyx | sort | uniq -u | perl -pe 's/^key "([^"]+)"/$1/' > cites.txt
grep '^\@' ~/Documents/latexfiles/ghrcites_manual.bib | perl -pe 's/\@.+{(.+),/$1/' > bibclean.txt
grep '^\@' ~/Documents/latexfiles/ghrcites_zotero.bib | perl -pe 's/\@.+{(.+),/$1/' >> bibclean.txt

Then in Stata I merged the two files and looked for Bibtex keys that appear in the manuscript but not the Bibtex files. [Update, see the comments for a better way to do this.] From that point it was easy to add the citations to the Bibtex files (or correct the spelling of the keys in the manuscript).

insheet using bibclean.txt, clear
tempfile x
save `x'
insheet using cites.txt, clear
merge 1:1 v1 using `x'
list if _merge==1

June 1, 2011 at 4:37 am 2 comments

Lyx 2.0

| Gabriel |

Lyx 2.0 is now in official release. I’ve been using it in beta for about six months and I find that it’s a big improvement. The thing that initially attracted me to it is the better spell checker integration in OS X. (In 1.6 it was so bad I’d run a Ubuntu VM just to get the spell checker to work). After a few months of regular usage, I can say that the biggest advantage to me is the document navigation sidebar (activated by the toolbar’s speedometer icon or “Navigate/ List of Figures/ Open Navigator”) , which lets you jump by TOC headings, figure, equation, footnote, or citations. This is of great advantage in a long complex document, like a book.

I highly recommend Lyx 2.0 to people who already use Lyx 1.6 or who are interested in LaTeX but are put-off by having to learn a new markup language. However Lyx/LaTeX has a lot of network externalities associated with it so think twice if you belong to a discipline (like sociology) where editors/collaborators expect MS Word files and it’s hard to find “.cls” and “.bst” files for your journals’ house style.

[Update: I forgot to mention that the new version has a new version of “diff” that in practice behaves like the Word “track changes” feature. It’s pretty elegant and should work well for collaborations.]

May 12, 2011 at 4:41 am 4 comments

Diacriticals in Zotero and Bibtex

| Gabriel |

I collect citations in Zotero (which is great for scraping citations from worldcat, jstor, etc.) but because I use Lyx rather than Word, I actually use citations in Bibtex. Unfortunately this creates some problems with diacriticals (aka, accent marks). I had been temporarily solving this by simplifying the offending characters to be plain ASCII characters but I figured out that I can solve things by hand-editing the Bibtex files.

For instance, consider these citations:

Dávila, Arlene. 2001. Latinos, Inc.: The Marketing and Making of a People. Berkeley CA: University of California Press.

Denrell, Jerker, and Balázs Kovács. 2008. “Selective Sampling of Empirical Settings in Organizational Studies.” Administrative Science Quarterly 53:109-144.

Zotero can handle both of them natively, but when you export to Bibtex the author fields appear like this:

	author = {Arlene Da ́vila},
	author = {Jerker Denrell and Balázs Kovács},

In the case of Kovács the diacriticals are already applied to the vowels and in the case of Dávila the diacritical mark is after the vowel instead of before and isn’t backslashed. If you render this, “Da ́vila” crashes LaTeX and “Kovács” renders but looks like comic strip profanity rather than “Kovács.”

The best solution is to handle entries with diacriticals in a hand-edited Bibtex file. In particular, the two entries should look like this:

	author = {Arlene D\'avila},
	author = {Jerker Denrell and Bal\'azs Kov\'acs},

It renders beautifully and you don’t have to insult speakers of Spanish or Magyar by dropping the diacriticals.

January 18, 2011 at 5:22 am 5 comments

Lyx and UltraEdit

| Gabriel |

I’ve been using the beta of Lyx 2.0 for a few weeks now. The first beta was unstable but the second beta has yet to crash or otherwise give me problems so I’ve gone ahead and committed to the new file format (which is still a dialect of TeX, just a slightly different one). I generally find it to be a big improvement in all sorts of subtle ways, particularly how it resolves subtle dependency issues. For instance, I could never get Lyx 1.6.x to recognize the Aspell dictionary on my Mac so I’d have to run a Ubuntu VM to check my spelling. Lyx 2.0 automatically reads the Mac OS X dictionary.There’s also an amazing “compare documents” feature that lets you diff any two files but instead of standard diff output it gives you something that looks a lot like “track changes” in Word. The full list of features is here.

You can download the beta here. Note that this is an ftp not web link and some browsers don’t do FTP so either use an FTP compatible browser like Chrome, an FTP enabled file manager, or a dedicated FTP client. The “dmg” link is for Macs and the “exe” link is for Windows. Note that the Lyx 2.0.x file format is not backwards compatible with Lyx 1.6.x software although Lyx 2.0 beta can export to the old format.

The other software I’ve been playing with is UltraEdit for Mac, for which I was a beta tester. Overall it strikes me as a very good editor and they’ve made admirable efforts to make it Mac native but it still looks like Windows software because it has one big window with internal demarcation rather than lots of floating pallettes, etc. Anyway I’m going to stick with TextMate (which has better language support for the languages I care about) and TextWrangler (which I find more intuitive for batch cleaning files) but I think people transitioning from Windows to Mac might be well served by UltraEdit, especially if they used it (or similar software like Notepad++) on Windows.

December 21, 2010 at 4:13 am

PDF DRM and CUPS-PDF

| Gabriel |

A lot of PDFs are intentionally crippled by DRM (digital rights management). I’ve found this is common with any PDF that requires forms and many PDFs you get from publishers for peer review, page proofs, and the like. Anything involving FDF or Locklizard is going to be DRM’d. These DRM restrictions prevent you from saving annotations, viewing outside of a certain date window, and various other forms of hassle that obstruct a paperless workflow.

Fortunately, the DRM usually retains printing privileges. This implies an incredibly simple solution for Mac/Linux users — “print” the document to a PDF file on disk using CUPS-PDF. This driver works at a really low level so the application sees CUPS-PDF as just another postscript printer, which means that it works even when the Preview/PDF button in the Mac print dialog is disabled. In an earlier post I gave instructions on how to install CUPS-PDF (in color) on a Mac.

November 19, 2010 at 5:20 pm

Zotero’s Bibtex export filter

| Gabriel |

Two issues with Zotero’s export filter to BibTex.

First, in the new version they broke backwards compatibility (a little) so you can get some missing citation errors if you try to use Lyx/Latex files that you originally wrote based on BibTex files generated by older versions of Zotero. Specifically, the new version handles colons in the title differently when generating the BibTex key. The old version left the colon out, the new version keeps it in. I had to go through my book manuscript and change all the BibTex keys for which this makes a difference. An alternate approach would be to freeze your Zotero library folder and use the last export created with the old version and start a new Zotero library folder for citations you collect from here on out.

Second, while it is possible to create a BibTex “author” field that TeX doesn’t read as “Last, First,” you can’t do it from Zotero. This is a problem as you end up getting ridiculous bibliography entries like “Bureau, US Census”. To get these and similar cases formatted correctly, the easiest thing is just to delete them from Zotero and put them in a hand-coded BibTex file. (Don’t worry, a single TeX document can draw citations from multiple .bib files so you don’t have to commit to hand-coding everything or merging your hand-coded file into the Zotero-generated file). The trick is that you use quotes (not curly brackets as with Zotero’s export) for the field delimiters and then use curly brackets inside quotes to tell BibTex “don’t break this.” For instance, here’s my entry for the Statistical Abstract of the United States:

@book{u.s._census_bureau_statistical_2007,
	address = "Washington, DC",
	edition = "127",
	title = "Statistical Abstract of the United States, 2008.",
	isbn = "9780160795848",
	publisher = "{U.S.} Census Bureau",
	author = "{U.S. Census Bureau}",
	year = "2007"
}

September 21, 2010 at 11:31 pm

Older Posts


The Culture Geeks