One thing that can be hard to adjust to for new LaTeX users is not being able to easily get a word count relative to other programs. Now there is a solution, thanks to Matthias Orlowski and Alex Iliopoulos. I share Matthias’s instructions here, with a couple notes of my own at the end.
1. Check whether Perl is installed by typing “which perl” in Terminal. That should be the case since Mac OS X ships with an installation of Perl.
2. Check whether texcount is installed by typing “which texcount” to Terminal. That should also be the case if you installed MacTex recently. If not, install it via TeXLive.
3. Copy the code below to your Preferences.el file which should be located at ~/Library/Preferences/Aquamacs Emacs
; count words in latex docs (defun latex-word-count () (interactive) (shell-command (concat "PATH " "-inc "; texcount option (set to count documents included via \input) (buffer-file-name)))) ; that's [ctrl-c w] as the hotkey (global-set-key (quote [f6]) 'latex-word-count)
“PATH ” is the path returned by ‘which texcount’ in (2), and the space at the end is important.
4. Restart Aquamacs and open a Tex file. Hit F6 and see the magic happen!
Now, obviously these instructions are only for OS X, but I would be happy to share Windows instructions if someone wants to adapt them. The first thing to look out for is that on recent OS X Macbooks the default for F6 is to brighten the keyboard backlight. You can change this by going into the Keyboard section on System Preferences and selecting “Use all F1, F2, etc. keys as standard function keys.” The second potential problem is if the path of the Tex file you are using includes spaces; this can possibly be addressed by putting a forward slash (\) instead of the space, but I cannot verify that from experience.
If you run into other issues with this script, or have new adaptations of it, feel free to leave them in the comments.