Posts tagged ‘lyx’
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).
Misc Links
| Gabriel |
- Useful detailed overview of Lion. The user interface stuff doesn’t interest me nearly as much as the tight integration of version control and “resume.” Also, worth checking if your apps are compatible. (Stata and Lyx are supposed to work fine. TextMate is supposed to run OK with some minor bugs. No word on R. Fink doesn’t work yet). It sounds good but I’m once again sitting it out for a few months until the compatibility bugs get worked out. Also, as with Snow Leopard many of the features won’t really do anything until developers implement them in their applications.
- I absolutely loved the NPR Planet Money story on the making of Rihanna’s “Man Down.” (Not so fond of the song itself, which reminds me of Bing Crosby and David Bowie singing “Little Drummer Boy” in matching cardigans). If you have any interest at all in production of culture read the blog post and listen to the long form podcast (the ATC version linked from the blog post is the short version).
- Good explanation of e, which comes up surprisingly often in sociology (logit regression, diffusion models, etc.). I like this a lot as in my own pedagogy I really try to emphasize the intuitive meaning of mathematical concepts rather than just the plug and chug formulae on the one hand or the proofs on the other.
- People are using “bimbots” to scrape Facebook. And to think that I have ethical misgivings about forging a user-agent string so wget looks like Firefox.
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.]
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.
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" }
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.
Texcount.pl
| Gabriel |
Somebody recently asked me for a projected word count of my manuscript (which is in Lyx) and to answer this question I found the amazingly useful script texcount.pl. If you just run “wc” (or the equivalent in a text editor) on a tex or lyx file you count all the plain text and the markup code. Not only does this script screen out the meta-text, but it can give you detailed breakdowns of words, figures, and captions — all broken out by section.
I like to keep scripts in “~/scripts/” so to make this script readily accessible from the command-line I entered the command:
echo "alias texcount='perl ~/scripts/TeXcount_2_2/texcount.pl'" >> ~/.bashrc
Now to run the command I just go to the terminal and type
texcount foo.tex
You should really check out the options if you have a long and complex document. My favorite option is “-sub”. This gives a detailed breakdown of word count, figure count, etc, by chapter, section, or whatever.
texcount -sub foo.tex
Remember that if you always use a certain option, you can write it into the alias command.
Lyx has a similar basic command built in (Tools/Statistics), but it doesn’t give as much information and doesn’t break out the data by section. To use texcount with lyx files, you first need to export Lyx to Latex which you can do from the GUI (File/Export/Latex), but if you’re using texcount anyway you should just use the command line.
lyx --export latex foo.lyx
That works for Linux but on a Mac this will work more consistently
exec '/Applications/Lyx.app/Contents/MacOS/lyx' --export latex foo.lyx
That’s a long command, so on my Mac I created an alias as “lyx2tex”
echo "alias lyx2tex='exec /Applications/Lyx.app/Contents/MacOS/lyx --export latex'" >> ~/.bashrc
Note that all this works on POSIX but may require some modification to work with Windows (unless it has CygWin).
Why I’m not upgrading to Snow Leopard (yet)
[Update 10/28/09, I’ve upgraded to Snow Leopard and Lyx works fine if, as a commenter suggested, you “get info” then click the “Rosetta” option. I’ve had no other issues with Snow Leopard and can recommend it, even for people who use Lyx a lot].
[Update 12/7/09, The current version of Lyx works fine running as Intel native].
| Gabriel |
Snow Leopard was primarily aimed at cutting out the kruft and both speeding up key apps (e.g., a much faster Finder and Mail client) and providing opportunities for application developers to get even more juice out of it in the future (e.g., Grand Central and OpenCL). I think it’s totally laudable that Apple (and for that matter, Microsoft with Windows 7) is taking a step back from the relentless march of bloatware to emphasize core performance issues and take advantage of new hardware architecture (esp. multicore and big GPUs). Unfortunately this low-level stuff can create some incompatibilities, especially if there is a debate between the OS and app developer over API standards or the app developer just decided to ignore API standards.
The issue that kills it for me is that Lyx is unstable under OS X 10.6. So my choices are to a) give up Lyx and write raw LaTex b) run Lyx in a Ubuntu virtual machine or c) hold off on upgrading to Snow Leopard until Lyx gets patched, which should take a few months because this is low-level stuff and their team doesn’t have many Mac people. (Note that I’m not complaining, the Lyx team is generally very good about providing up-to-date Mac binaries rather than the usual thing of just directing you to the gruesome twosome of Fink+X11). Although it breaks my geeky heart, the obvious answer is “c, stick with 10.5 for now.” I’d consider the virtual machine work-around for something I use once in awhile, but I use Lyx several hours a day and that’s just too much hassle / performance hit to deal with.
Fortunately Stata (10 and 11), TextWrangler, TextMate, Smultron, R, and Crossover are all reported to work perfectly. If you don’t use Lyx (or anything else that’s buggy under 10.6, like SPSS 17), it’s probably a good idea to upgrade as it looks like a great version of the OS. However if it would break your favorite app, just wait it out. This especially makes sense given that all you’re getting right now is fairly small things like a faster Finder, better VPN+Entourage support, and snazzier QuickTime — the really amazing features of 10.6 (OpenCL+GrandCentral) won’t actually do anything until application developers rewrite their code to take advantage of them.
Recent Comments