How to generate nice nomenclatures in LaTeX

If you have to write up your model results, often you have to write down the model documentation. My colleague at work pointed me to a great package in LaTeX that can make your life easier with respect to the nomenclature used. It allows you to produce a glossary with all your variables, parameters and acronyms without much extra work. The package is called “nomencl” and here is an example of a pdf generated with LaTeX:

As you can see, I have acronyms, parameters and variables as well as the reference to where they are used for the first time (if you only use variables and parameters you can even refer to the equation they are used for the first time).

Using this package is quite easy:

and

to print the nomenclature.

Symbols can be added in the text like follows (after the equation they appear the first time):

\nomenclature{$vw$}{ Time cost multiple for walking time}

To generate the nomenclature you have to give a specific command. In Emacs you can add the following code to your .emacs-file

When you now hit C-c C-c you can choose the option “Nomenclature” and the necessary files are generated.

If you want to have the distinction between several groups, you just add the following code in your preamble and change the second part according your preferences:

To produce an entry for paramters, you just add [P] in front of the normal entry

One last remark: The entries might not be aligned properly. For this you can add in your preamble:

and choose the width accordingly. The nomenclature entries have rather much vertical space between them. This can be changed by adding one of the following lines to your preamble:

Switching between Emacs color themes

Emacs has lots of different color-themes. Depending on the light and my own mood, I would like to change between my two favorite themes, the “standard” light theme and a dark one.
This is the color-theme I use for my LaTeX files (“sitaramv-nt”):
But for my model files, I like the dark color-theme (“dark-laptop”), but sometimes the light one.
I searched the internet and found some code that allows me to switch easily between the themes using F11:

Integrating Emacs in your file explorer

Sometimes I have files that I want to open with Emacs, but I haven’t set the program to open to Emacs (for example, a log-file or .emacs). I found a nice hack for Windows machines in the internet (http://www.johndcook.com/emacs_windows.html#explorer).
Just create a file emacs.reg with the following text and adjust the path to your settings.
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\Shell\Open In Emacs\Command]
@
@=”\”C:\\bin\\Emacs-23.1\\bin\\emacsclientw.exe\” -a \”C:\\bin\\Emacs-23.1\\bin\\runemacs.exe\” \”%1\””
Before you double click on this file, save your registry (you never know…). After double clicking you will have a extra option in your right-click menu in your explorer, which starts Emacs, if Emacs is not running and start the client if it is already running.

Using more than one Dropbox folder using Dropboxifier

Dropbox is a nice tool for synchronizing files over different computers. One problem is that you have to put your files in the Dropbox folder. I often make small changes to my settings in Emacs, so I used to have my home directory for Emacs in my Dropbox folder.
You can choose where to put your Dropbox folder on your machine, however, you can only have one Dropbox folder. What to do, if you want to synchronize your whole Emacs program directory (or any other directory you don’t want to move to your Dropbox folder)?
There is a nice open source utility called dropboxifier (http://dropboxifier.codeplex.com/) that allows you to put a symbolic link in your Dropbox folder. The folder remains in the original position but Dropbox treats it as if it is in the Dropbox folder. This utility can also be used for Skydrive or Google Drive.

Examples of my use of dropboxifier:
• As you probably know, you can easily copy your Emacs directory to another computer. If the home directory on the other computer is properly set, you can start directly working with it. Using dropboxifier I nowadays sync the whole Emacs directory and don’t have to bother, when I update or add packages on one computer.  They are automatically installed on the other computer.

Note that I don’t use this for my project directories and files, because for this task I use my version control system.

Presentation, Article and Notes in one run using Beamer

Still using Powerpoint for your presentation? Consider using LaTeX with the Beamer package.

Tom Rutherford taught me how to build an efficient stream for a presentation or lecture:
1. generate the presentation with beamer,
2. generate the presentation as an article and
3. clean up all the stuff
All this in one batch file. The presentation is projected on the big screen and the article is used for preparation and for notes, I use during my prepartation (I have a printout of the article next to my laptop during the presentation)

The batch (build.bat) file looks like this:

@echo off
pdflatex beamer
pdflatex beamer
pdflatex print
pdflatex print
del *.toc
del *.log
del *.out
del *.nav
del *.snm
del *.vrb
del *.synctex
del *.aux
cd auto
del *.*
cd..
rd auto /Q

and after finishing my slides, I just run it from my shell or my explorer.

The latex commands are run twice, so if there are citations, bibtex is run. I give a serie of lectures and for every lecture I have three files:
1. lecture.tex:    all the slides to be presented
2. beamer.tex:   the preamble for generating the lecture as beamer presentation
3. print.tex:        the preamlbe for generating the lecture as article.

Beamer tex looks like this:
It gets the lecture.tex file as input and grabs the style.tex file for “styling” my presentation.

Setting a directory for all my figures and for my style file:
I use import, so I can set a directory for all my figures (instead of having them in the same direcotry as my tex files). The directory is set in the lecture.tex file:

\graphicspath{./figures/}

The style file resides in its own directory, so I do not have to replicate it and changes are easy done in just one file.

Comments not showing in my presentation, but in my article:
I use the package comment to add notes to my presentation. Beamer allows you to make notes, that will be shown as a parallel slide, so you can have your presentation projected and the other half on your notebook monitor (split screen). This seems to work fine on a Mac or under Linux, but is almost impossible on a Windows machine (there is ony very basis and not very satisfactorysolution called presenter-pdf). I just use the comment package that allows you to add notes that are printed in my article version of my presentation but do not show up in my beamer presentation. In beamer.tex I give the commend to not show the comments:

A comment in the lecture.tex follows an \end{frame} command and could look like this:

In the article version, the comments are red and start with a bold “NOTES” above them, so I can concentrate on them, when I am presenting.

Size of graphics
I use the width option for included graphics, so figures also fit if the format of my paper in beamer (landscape) is changed to portrait (article). Example:  [width=0.8\textwidth].

Here you see the presentation:

And here the article format (in the right margin, you see the number of the lecture as well as the slide number).

Outlining in Gams-Mode: Org-Mode for Gams

The new version of Gams-mode has a new feature that I like very much. It allows you to use an outline-mode in your gams files. It is called org-mode, which is a major mode in Emacs.

You can outline your Gams file using sections, subsections, etc. You define sections using the following notation:

*@

or for subsections

*@@, *@@@, etc.

Let us have a look at the file org-minor-mode.gms. This file can be found in your gams-mode directory. This file contains all the help for gams-mode. All the help topics have a section title that starts with *@.
Here is an overview of the contents of this file:

This is great! Now, instead of scrolling or searching, you can just cycle through the different display possibilities using Shift-Tab (org-global-cycle), or if you want to see or hide the content of a certain section, hit Tab (org-cycle).

Here, I used Tab to show the subsections of the section “Process handling”

And if I hit Tab again on the first subsection, it shows the contents :

Todo's from Everywhere

I use Emacs for taking notes and project management using Remember-Mode and Org-Mode (see my blog entries Capturing and More. However, if I am working in Excel or reading a pdf , More and I want to make a note or I suddenly have a thought about a feature that I want to add to my model, I have to jump to Emacs,hit some keys, enter the note or the task and navigate back to the program I was working in.
Not much of a hassle, but inefficient as it really interrupts my work flow too much.
No problem, if you use some macro scripting tool (for example winautomation or autohotkey) it is rather easy.
Here is the macro in Winautomation:
In step 1 the macro saves the location of the active window (for example Excel). In the next step it jumps to Emacs, followed by sending the keys C-c r  which asks me for a template:
I then choose the template (for example t for ToDo) and enter the information. I quit with C-c C-c and my entry is saved. Then I hit Ctrl-g (which is the Emacs command for “break” and in this case does nothing and if I change my mind and don’t want to save the note or tasks it stops the remember mode). This keystroke combination is used as a trigger for the Winautomation macro to return to the macro. In the last step the focus jumps back to the program I was working with.
The macro is started when I hit the hokey “Ctrl-Shift+F11”, which I defined in Winautomation.
As I have the professional version of Winautomation, I can generate an executable and send it to you. Just mail me at renger(at)modelworks.ch.
The only thing you have to do, is add a keyboard trigger like Win+…
For this you can use free programs like winkey (on Win32)  or HotkeyBind (I did not test these programs).

Viewing all the objects in R in a buffer in Emacs

You also probably did not read the complete Emacs-Speaks-Statistics manual… ? By chance, I discovered a nice feature, called Rdired.
This command gives you a dired-buffer with all your objects. In this buffer you can view, edit and plot your R-objects. It is documented in chapter 12.9 of the manual.

Here is small example: In the buffer in the middle, you see the original code taken from the manual. I invoked ess-rdired and the lower buffer is shown. I then put the cursor on the line with the parameter s and hit “v”. This gave me the upper buffer with all the values. Then I hit the “p” and a nice plot is shown. With “d” you could delete the object.

You have to put the following lines in your .emacs file:

Auto-Completion in Emacs, LaTeX and Gams

The fun with Emacs is that you can discover new (or old) stuff that makes your life much easier on an almost weekly base. I was reading the manual on Emacs Speaks Statistics and discovered that there is a mode called auto-completion. I googled it, installed it and after some experimenting, I got it running. You can find it here. It comes with autocompletion for some programming languages (Python, Ruby, C+, etc.) but not for LaTeX, so I googled further and discovered an extension called auto-complete-latex (you can download it here.
Here are some screenshots: You just start typing and it suggests a keyword or if you wait a little bit longer it gives you a dropdown llist. You can jump to the next suggestions using the tab-key.
It doesn’t matter if you use capitals or not:
and it also keeps track of words in the actual document. Here an example of my paper on parking. As you see the word “Parking appears, when I typ “par”.
For Gams there is no dictionary, so I wrote one myself and added it to the dictionaries. I only did not manage to start auto-complete for Gams automatically. But this can be done with M-x auto-complete-mode.
Update:
;; ac-modes – major modes ac can run on