## Emacs Local Variables

If you use Emacs to edit your LaTeX files, then you want to know about Local Variables. They are “comments” that you write at the end of a file, say in this example:

`blah blah`

``` ```

```% Local variables: % mode: latex % TeX-master: "main.tex" % End:```

The purpose of local variables is to allow you to give Emacs extra customization when you load a file. In this example, we want Emacs to switch to latex mode and set the `TeX-master` variable to “soda.tex”. `mode` is actually a special variable controlling the major mode of the file. The `TeX-master` variable is used by AUCTeX so that when you invoke LaTeX on the current buffer (Ctrl-C Ctrl-C), it will instead invoke LaTeX on the “master” file. This is crucial when you break the paper into multiple files and use `\input` to string them together because this alleviates the need to switch to the master file before you invoke LaTeX.

There is also another way to specify local variables by putting them in the beginning of a file. Here is how our example would look like:

`% -*- mode: latex; TeX-master: "main.tex"; -*-`

``` ```

`blah blah`

There is also a special local “variable” call `eval`. The value for that variable is simply evaluated as an expression, and hence it can actually be somewhat dangerous. Fortunately Emacs also provides `enable-local-eval` to let you catch the `eval`s.

Happy TeXing in Emacs!