What is your favorite Emacs and/or AUCTeX command/trick?

Finding tips

It is hard to say what the best tips is for you. Especially if you do not give a more detailed description of your workflow. The best way to find this might be to read the manual from cover to cover. Also make sure to read the RefTeX manual since it is included in AUCTeX and you should use its commands for handling citations and cross-references. Other places to find tips is to peek at other peoples .emacs and go through emacs, auctex, reftex and the equivalent tags on Stack Overflow and Super User.

Learning and configuring Emacs is a never-ending process as described in A simpleton's guide to (...)TeX workflow with emacs. Thus, you will learn more and more as you go. That you learn something new is not necessarily a sign of that you have been inefficient before that.

My tips

The following are some that tips I would like to share. They might be irrelevant for you and therefore the advice above might be the best.

  • Find the AUCTeX and RefTeX commands that are useful for you and learn them, see Useful shortcuts or key bindings or predefined commands for emacs+AUCTeX.

  • Use folding to fold macros and environments and it will be easier to focus on the content of your document. To use folding you have to activate TeX-fold-mode. This can be done by either activating it temporarily, by M-x TeX-fold-mode, or permanently, by placing the following in your .emacs

    (add-hook 'TeX-mode-hook #'TeX-fold-mode) ;; Automatically activate TeX-fold-mode.
    

    In both cases you have to also do C-c C-o C-b to fold every item in the buffer (there are other commands to fold parts of buffers). Here follows a simple buffer without folding:

    A simple LaTeX buffer with unfolded items

    The following is the same buffer but with folding. If the cursor is placed on a folded item it is unfolded, e.g. if the cursor is placed on an emphasized part it unfolds to \emph{an emphasized part}.

    A simple LaTeX buffer with folded items

  • Use the function to expand " into csquotes macros (see also AUCTeX's csquotes integration does not work together with babel).

  • Use AUCTeX's integration with language packages, see How can I make AUCTeX use the spelling dictionary in the same language as babel is loaded with? and How can I make AUCTeX use the spelling dictionary in the same language as polyglossia is loaded with?

  • Use LaTeX-math-mode for efficient insertion of math as described in https://stackoverflow.com/a/8055820/789593 under "AUCTeX's LaTeX-math-mode".

  • Do not use AUCTeX only. Use YASnippet to make it easier to insert often inserted structures, see Working with templates. Draft with Org-mode as described in Everyday LaTeX and workflow?


Org-mode's radio tables are an easy, simple and fast way to create tables within Emacs/AUCTeX. They offer all of the calculation capabilities of the org-mode spreadsheets, which can be very convenient if need simple, auto-updating data.

The source org-table can be placed within a comment environment using the comment package, or after \end{document}. The radio table can be placed anywhere in the document by surrounding it with

% BEGIN RECEIVE ORGTBL table_name
% END RECEIVE ORGTBL table_name

The table will be automatically generated in LaTeX format within those two tags and will be updated every time the org-table is updated. Activating the orgtbl-mode (minor mode) will make it easier to edit the org-table within AUCTeX.

Radio Tables explanation

As requested, a brief explanation of what radio tables are and a link to where more info can be found:

Radio tables are a way of using Org-mode's tables in any mode within Emacs. The idea behind them is that one should be able to create a table in any mode (i.e. LaTeX-mode) while still using Org's syntax in a minor orgtbl-mode AND without generating errors with the major mode. This means that there will be a "source table" in Org syntax, a "target table" in the required syntax (i.e. LaTeX syntax) and a translator function to convert from one to the other and to place the table in the proper place. In a sense, the table is sent to its final place via the translator function, much like a radio signals are sent from the transmitter to the receptor.

In the case of radio tables, the "receptor" is defined by two lines that are comments in the major mode that we are working in. For LaTeX mode, those two lines take the form written above. Then, the source table is created elsewhere, with a special line atop of it, in the form of

#+ORGTBL: SEND table_name translation_function arguments....

Now, if the source table in Org syntax will definitely cause errors if placed as-is within the LaTeX document, so two ways to deal with this are to either send it past the \end{document} line, grouping all the source tables towards the end of the document and separating them from their target tables, or wrapping them in a comment environment, defined by the comment package, which would allow to keep the source tables close to the targets.

As for the translator function, Org-mode provides a very basic generic translator function that will give good enough tables. This translator function can be modified to fit the user's need.

Here's a link to the official documentation: http://www.gnu.org/software/emacs/manual/html_node/org/Radio-tables.html#Radio-tables


This is a very sensible question! You know, there are many tricks to discover, which make live easier. My top 3 list:

  1. M-q: Justify the current paragraph (or region if set), with respect to the fill-column variable [Couldn't do without, but it took me weeks to discover]
  2. C-l: Recenter the cursor (one hit puts the current line in the center of the screen, next hit will put it on the top of the screen, next it at the bottom). [learned it in the tutorial; nice, don't want to write on the bottom of screen]
  3. M-x align-current: Emacs aligns the table, mostly it becomes better, if not, use C-x u to undo.

Besides that: When I'm writing complicated stuff while thinking about it, I'm using org-mode.