2014
10.26

So, writing in latex is sometime a low level affair. One of the irritating thing about latex is its handling of resizable parentheses. The default way to do this is quite tedious:
$ \left( whatever \right) $
The true LaTeX believers think one should never use this directly – instead one should use the amsmath \bigl(, \Bigl(, \Biggl(, \bigr),... commands, and handling resizing of parentheses explicitly, because it looks better (especially for summations with subscripts, automatic resizing of parentheses results in monstrously large parentheses).

Nevetheless, if you are lazy like me, the natural thing is to write a little macro:
\newcommand{\pth}[1]{\left( #1 \right) }
Usage: $\pth{ whatever } $

Which works great, except that it doesn’t:
$$\text{With pth: }f\left( x \right)\text{ compared to regular }f(x).$$ This demonstrates the problem with the spacing generated – latex adds a tiny space before a left command.

There is a tedious way to solve this, but it involves adding negative space to the macro, and then being careful to remove this space when using \pth in a subscript (which is what I was doing for a long time). Luckily, there is a latex package that solves this problem: mleftright. Doing:

\usepackage{mleftright}
...
\newcommand{\pth}[1]{\mleft( #1 \mright) }
...

Works correctly in all situations (at least so far).

  1. you need the mathtools package: http://www.olivierverdier.com/posts/2013/07/15/modern-latex/

    • Except that mathtools solution does not resize in subscripts, which is not quite right…

  2. Thank you.