6
\documentclass{amsart}
\DeclarePairedDelimiter{\pr}{\left(}{\right)}

\begin{document}
$\pr{x,y}$

\end{document}

I found the commands \left( \right) quite flexible and hence useful; but I am not sure how to write them in one command. The attempt shown above has proved wrong.

Yes
  • 1,639
  • Use \pr*{x,y} if you want \left and \right, after properly defining \DeclarePairedDelimiter{\pr}{(}{)}. Of course you don't need \left and \right in this case. And there are several reasons for not generally using them: use them only when they are really necessary, which means quite rarely. – egreg Oct 20 '15 at 13:44

2 Answers2

10

You can use \newcommand to define new command and fit with what you want:

\documentclass{amsart}
\newcommand{\pr}[1]{\left(#1\right)}

\begin{document}
\pr{x,y}

\end{document}
Romain Picot
  • 6,730
  • 4
  • 28
  • 58
9

Contrary to your opinion, \left and \right are quite rigid and unflexible: they don't provide the right size in many cases. The usual example is a summation, where

\[
\left( \sum_{k=1}^{n} x_{k} \right)
\]

produces too large delimiters. The right size in this case is obtained with

\[
\biggl(\, \sum_{k=1}^{n} x_{k} \biggr)
\]

Here's a visual comparison: left the \left-\right version; note the \, for avoiding the clash, which should also be used after \left( anyway.

enter image description here

This said, you're free not to follow the advice. In this case, define properly \pr and use the *-variant

\documentclass{amsart}
\usepackage{mathtools}

\DeclarePairedDelimiter{\pr}{(}{)}

\begin{document}
$\pr*{x,y}$

\end{document}

Of course in this case the parentheses don't grow, so there's no point in using \pr* instead of \pr. Here's the output of $\pr*{x,y}\quad\pr{x,y}$:

enter image description here

egreg
  • 1,121,712
  • Thank you! What in your opinion is the most flexible command without sacrificing spacing? Thanks. – Yes Oct 20 '15 at 13:58
  • @GudsonChou Using \pr as defined is good; just don't use the * when it's not necessary. You also have \pr[\big] for slightly bigger parentheses, for instance. – egreg Oct 20 '15 at 14:00