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.”
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.
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).
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
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.]
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.
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.
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.
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" }
Zotero Hint: Empty the trash
| Gabriel |
I use Zotero to scrape/manage my citations and then I export them to Bibtex for use with Lyx/LaTex. I noticed some phantom citations in the Bibtex file (and by extension, in Lyx) that didn’t appear in Zotero. For instance, I had two versions of the Espeland and Sauder AJS 07 cite, one of which misspelled “Sauder” as “Saunder,” but only the correct spelling appeared in Zotero. After puzzling over this for a bit, I realized that Zotero has a “trash” folder within “My Library” and for some reason it was including the contents of the trash when I exported to Bibtex. Empty the trash and problem solved.
Really big headers
| Gabriel |
I recently submitted a manuscript for review and they were gracious enough to accept a PDF instead of Word as long as I blinded the meta-data and inserted their warning header. Because LaTeX assumes headers are short, getting it to accommodate a paragraph of legal boilerplate required using the “fancyhdr” package, which is included in most TeX distros.
In Lyx go to the “Page Layout” tab of the “Document Settings” dialog and choose “fancy”. Or if you’re using raw LaTeX you type:
\usepackage{fancyhdr} \pagestyle{fancy}
Then regardless of whether you’re using Lyx or raw LaTeX, you put something like this in the document preamble:
\lhead{\textbf{HEY REVIEWER} \\ We at \emph{American Journal of Sociological Review} are giving you manuscript \#10-001 to review and that's it. Don't even think about doing anything sketchy like circulating this manuscript or plagiarizing it or anything like that. } \rhead{} \headheight 72pt
If the journal also wants a watermark there are a few LaTeX packages that can do it (fancybox, watermark, wallpaper) but if you have a Mac it’s probably easier to use Automator.
Diacriticals in Lyx
| Gabriel |
I just learned a good way to set diacriticals in Lyx. I just type ctrl-x to bring up a Lyx function command line, then type the function, which for the accents is simply “accent-type vowel.” So to type “Michele Lamont” in proper francophone orthography, I’d type “Mich”, hit ctrl-x, type “accent-grave e”, hit return then ctrl-x, and type “le Lamont”.
Previously, I had been inserting ERT and typing the raw LaTeX for the accent. For example “Mich(ERT=\`e)le Lamont”. This is actually fairly quick to type and it renders properly in the PDF, but it’s distracting in Lyx to have ERT boxes sprinkled through the document.
Recent Comments