What are your favorite LaTeX macros?

I have quite a few collaborative writing projects going on in parallel now. One side-benefit of collaborating is that you learn neat LaTeX macros that your co-authors have developed that end up saving lots of time (or making the TeX equations more readable). Some people invent a whole set of macros for each paper (so that the macros stand for semantic concepts like “input variable”), but I do that mainly for small stuff, like different epsilons. What I do have are macros for are

  • font types and weights : using \mathrm{}, \mathcal{}, etc. is for the birds
  • functions : KL-divergence, mutual information, conditional mutual information etc. I get in trouble sometimes because I use the I(X \wedge Y) instead of I(X; Y) for mutual information, but we can change that in the macro!
  • norms, inner products : these are just functions anyway
  • epsilons : this helps keep different epsilons clearer, actually, and makes debugging proofs a little simpler.

I somehow never get around to making macros like \cX for \mathcal{X}, but maybe that would make my life easier. The nice thing about macros for functions is you can put in auto-sizing delimiters in the macro, saving some \left and \right‘s. What are your favorite things to make into macros?


9 thoughts on “What are your favorite LaTeX macros?

  1. 2 words: Scientific Workplace.

    For the most part WYSIWYG and inserting math in so easy but I am sure die-hard latex editing types will never like it :).

    Lazily yours,

  2. To suck all the extra space out of an itemized list:

    } %% END \def\listOPT

    \item First item

    Its very useful if your NeTS proposal is due in two days and 15 pages is problematic.

    I also use a newcommand for PDFs and CDFs, PMFs etc. Something like


    I admit I am sometimes disconcerted that $\ipdf{X}$ and $\ipdf{x}$ produce the same output.

    Lalitha: I think we’ve already debated the merits of Scientific Workplace. Once again, you have ignored my gentle advice 🙂

  3. Expectation is my favorite! You get to use \left[ and \right], and the \mathbb{E} is so pretty!


    makes iterated expectations so darn nice as well.

    The indicator function is a must-have. And I also have different macros for log_2 and ln (with \left and \right of course, and that makes fractions in logs easy as well):


      • I use \E but I dohave to hold the shift key for that. In some cases of inline math like $\E{\tilde{X}}$, the \left and \right cause the brackets to be too big and the line gets additional unattractive vertical whitespace.

      • Ken Thompson was once asked what he would do differently if he were redesigning the UNIX system. His reply: “I’d spell creat with an e.”

        * Kernighan, Brian W.; Pike, Rob (1984). The UNIX programming environment. Prentice-Hall. ISBN 0139376992. OCLC 10269821. , p. 20

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s