4

I am trying to typeset the value of a function $f$ for $x = \frac{y}{2}$ (or something other which requires more vertical space). To get properly sized parentheses I tried:

f\left(\frac{y}{2}\right)

which gives me bad spacing. For example,

\documentclass{article}
\begin{document}
\noindent 
$f\left(\frac{y}{2}\right)$

$f(x)$
\end{document}

gives:

Output

So what's the correct way to typeset this?

1
6

A comment up front: Auto-sized parentheses do not always have the typographically correct size.

  • For example,

    \[ \left( \sum_{i=1}^N f_i \right) \]
    

    generates parentheses that are far too large since they also enclose the sum's limits of summation. It's much better to write \[ \biggl( \sum_{i=1}^N f_i \biggr) \], i.e., to set the size of the parentheses manually.

  • Take another example: the goal of typing $f\left(a+b(x)\right)$ is presumably to have the outer pair of parentheses typeset a bit larger than the inner parentheses. However, this fails because the material being enclosed by the left/right pair isn't "large". Thus, the outer pair of parentheses will be no larger than is the inner pair. In this case, it's again necessary to use an explicit (manual) sizing directive: $f\bigl(a+b(x)\bigr)$.

That said, most of the time the vertical sizing generated by left/right pairs is indeed typographically correct. However, as you've discovered, the \left and \right instructions insert a bit of whitespace which again needn't be correct.

There are (at least) two remedies available: The \mleft and \mright macros of the mleftright package and the \genfrac macro of the amsmath package. Their operation is illustrated in the following table.

  • One notices that the spacing generated by \mleft and \mright is just about the same as if one had chosen to size the fences by hand (\big in the case of textstyle-math, \Big in the case of displaystyle-math).

  • In contrast, the spacing generated by \genfrac is quite a bit tighter; you may (or may not...) like this look. Observe that the vertical height of the parentheses generated by \genfrac seems a bit larger than is minimally necessary. However, this outcome may be specific to the symbols contained in the expression.

In summary, I don't think you'll go wrong if you use the \mleft/\mright method to typeset auto-sized parentheses around fraction terms. To save yourself some time typing in these expression, do consider creating and using a macro such as \newcommand{\pfrac}[2]{\mleft(\frac{#1}{#2}\mright)}.

enter image description here

\documentclass{article}
\usepackage{amsmath,mleftright,array}
\newcommand{\tbs}{\textbackslash} % a shorthand macro...
\renewcommand{\arraystretch}{2}
\newcommand{\pfrac}[2]{\mleft(\frac{#1}{#2}\mright)}
\newcommand{\gfrac}[2]{\genfrac{(}{)}{}{}{#1}{#2}}

\begin{document}
\begin{tabular}{>{\ttfamily}l 
                >{$\textstyle}l<{$} 
                >{$\displaystyle}l<{$}}
Method & \text{textstyle} & \text{displaystyle}\\[0.5ex]
\tbs left, \tbs right 
    & f\left(\frac{y}{2}\right)g(z) & f\left(\frac{y}{2}\right)g(z)\\
\tbs mleft, \tbs mright 
    & f\pfrac{y}{2}g(z) & f\pfrac{y}{2}g(z)\\
\tbs [bB]igl, \tbs [bB]igr
    & f\bigl(\frac{y}{2}\bigr)g(z) & f\Bigl(\frac{y}{2}\Bigr)g(z)\\
\tbs genfrac 
    & f\gfrac{y}{2}g(z) & f\gfrac{y}{2}g(z)\\
\end{tabular}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.