Is it possible to automatically "add" \left and \right commands in front of all brackets? The source code should be left intact, but LaTeX should interpret every pair of brackets as if they were preceded by such commands. This is because adding \left and \right commands is time consuming and makes source code longer and less readable. I considered defining new commands such as \lb and \rb for \left( and \right), but it doesn't seem very elegant to me: what if I also want to add square brackets for example?

Any ideas? Thanks.


9 Answers 9


The \DeclarePairedDelimiter command from mathtools is useful. For example defining an absolute value macro;


gives also a starred version with \left and \right


and the unstarred version takes an optional argument that can be \big, \Big, etc

  • 5
    I'd like to congratulate you for understanding what the user wants!!! This "automatic" left/right discussion survives like forever, because when the user says s/he wants automatic left/right, what s/he actually means is that the user should not be supposed to choose sizes manually, or decide when to use or not "left/right" based on its broken implementation "side effects". TeX people keep answering the "written question", without considering what the OP really wants. They keep saying "don't do it", without taking into consideration the user needs... :-( Commented Aug 30, 2021 at 13:46

Adding \left and \right to all delimiters is difficult and likely not to yield the desired result in many places.

The nath package aims at making \left and \right obsolete. From the readme:

delimiters adapt their size to the material enclosed, rendering \left and \right almost obsolete.


Edit: I'm leaving this answer up for “academic purposes” but, consider Lev Bishop's answer for an easier solution than mine.

Over the years I've evolved my own solution which I think turned out quite nice. It gives you a command which you can call like


which in turn will define for you a \parens command which you can then use as \parens{thing} to produce something like (thing) where, moreover, the parenthesis automatically resize. In fact you can use the command in three different ways

\parens{thing}       % automatic resize
\parens*{thing}      % no resize
\parens[big]{thing}  % use the specified size

For the latter option you can use auto (the default), base (no resize), or one of the sizes: big, Big, bigg, Bigg.

Furthermore, inside of thing you can use the commands \ldelim, \rdelim, and \mdelim to create even more delimiters with the appropriate size selected by the given options. This allows, for example, to use \mdelim to automagically resize a “middle” bar. (See example at the end of the code).

For this to work you have to drop the following code in a .sty file and include it in your main .tex file with \usepackage.


% delim sizing options
\let\delim@autol\left  \let\delim@autor\right \let\delim@autom\middle
\let\delim@basel\relax \let\delim@baser\relax \let\delim@basem\relax
\let\delim@bigl\bigl   \let\delim@bigr\bigr   \let\delim@bigm\big
\let\delim@Bigl\Bigl   \let\delim@Bigr\Bigr   \let\delim@Bigm\Big
\let\delim@biggl\biggl \let\delim@biggr\biggr \let\delim@biggm\bigg
\let\delim@Biggl\Biggl \let\delim@Biggr\Biggr \let\delim@Biggm\Bigg

% default definitions

% the actual command
\newcommand\delim@command[4]{{%   #1 size #2 ldelim #3 rdelim #4 content
  \def\ldelim{\csname delim@#1l\endcsname}%
  \def\rdelim{\csname delim@#1r\endcsname}%
  \def\mdelim{\csname delim@#1m\endcsname}%

% a factory to define new delimiter commands
\newcommand{\newdelimcommand}[3]{% #1 name #2 ldelim #3 rdelim
  \expandafter\newcommand\csname delim@#1@st\endcsname[1]{% ##1 content
  \expandafter\newcommand\csname delim@#1@ns\endcsname[2][auto]{%
    % ##1 size ##2 content
    \@ifstar{\csname delim@#1@st\endcsname}{\csname delim@#1@ns\endcsname}%

% syntactically named delimiters

% semantically named delimiters

% Automagic `such that' for set comprehension. Inside an automagic
% delimiter command, the vertical bar will resize appropriately
% Example:
%   \set{ x \in W \st x > 0 }

I've been thinking to eventually release this (and other bits of code) as a proper style file. But for the time being here it is for you to copy&paste. :)

  • 6
    This looks very much like \DeclarePairedDelimiter from mathtools, except that the meaning of starred and unstarred is reversed.
    – Lev Bishop
    Commented Aug 15, 2010 at 13:00
  • Reading this question I wondered if it was possible to make use of \mleft and \mright in this code. I prefer this over mathtools because the meaning of starred and unstarred is reversed and because the manual input is easier ([bigg] vs. [\bigg]). Any ideas?
    – Manuel
    Commented Jan 12, 2013 at 20:02
  • I guess you could just drop \mleft instead of \left, etc. But probably you want it to sometimes use \left and sometimes \mleft, right? Then you have to come up with an interface that allows you to select between the two. Commented Jan 12, 2013 at 20:37
  • @JuanA.Navarro no, I always would like to use \mleft. I tried loading \usepackage{mleftright}\mleftright, where the latter command changes the meaning of \left to \mleft, before your code. But it doesn't work.
    – Manuel
    Commented Jan 15, 2013 at 16:21
  • I've just tried it now and it does seem to compile fine without problems. Are you getting some errors or unexpected behaviour? Commented Jan 15, 2013 at 19:31

To make auto-sized bracketing as painless and concise as possible, here's what I do:




$$\br{\frac{1}{2}} + \br{1} - \br{\frac{\int_0^{2\pi} f(x)}{\sqrt[2]{\frac{1}{2}}}}$$

enter image description here


I use the following newcommands:


Hence, in the text, f\of{x} will appear as f(x), M\ast\offf{g\off{x}+h\off{x}} will appear as M*{g[x]+h[x]}, etc. with the \left and \right commands automatically built-in.

  • 6
    you might find that \mathopen{}\left(, etc., gives you better spacing (but that might be a personal preference). Commented Sep 2, 2010 at 1:15

There is another possibility to do it, if the automatic size should be the default (as here) and explicit sizes should be easier to remember (numbers 0 till 4 instead of exotic names)



% Enable the new LaTeX 3 commands.

% Provide the \alias command substituting the \let command by working with optional arguments.

% Define a clear and useful programming interface. You should define \new, \renew and \provide similarly and use the correct one below.

% Fix the spacing around \left and \right: https://tex.stackexchange.com/questions/2607/spacing-around-left-and-right

% Usage: \newdelimited{functionName}{left delimiter}{right delimiter}
% Example: \newdelimited{parens}{(}{)}
% Usage of inner command: \functionName[explicit size]{delimited content}
% An auto sized delimiter is used, if no explicit size is given. Explicit sizes range from 0 (small) to 4 (huge)
% Examples: \parens{x}, \parens{\frac{x}{y}}, \parens[3]{x}, \parens[0]{\frac{x}{y}}
            \left#2 ##2 \right#3%
            % Use the amsmath delimiter sizes to have proper scaling all the time.
                #2 ##2 #3%
            \or \bigl#2 ##2 \bigr#3%
            \or \Bigl#2 ##2 \Bigr#3%
            \or \biggl#2 ##2 \biggr#3%
            \or \Biggl#2 ##2 \Biggr#3%
            \else \PackageError{newdelimited}{Only optional values 0, 1, 2, 3 and 4 are supported.}%

    $\parens{x}, \parens{\frac{M}{W}}, \parens[3]{x}, \parens[0]{\frac{M}{W}}$

The result looks like this:
enter image description here


It seems to me that it's easy to do exactly what you say, but you might not really want that; see the caveat below.


The catch: There are some obvious disadvantages to this, such as that parentheses now only work in math mode; any text-mode or un-stretchy parentheses have to be entered as \lparen\rparen. You may be willing to do this in your own code, but you'll have to be quite careful about any external packages you include. (If you were really dedicated, you could have something like a \stretchparens / \plainparens pair to turn this behaviour on and off.)

I wonder if those wiser than I could comment on subtler disadvantages?

  • 5
    Parentheses are widely used in text, so this approach is not recommendable; rather make the parentheses math active (mathcode "8000). My opinion is that automatically providing \left and \right is A Bad Thing.
    – egreg
    Commented May 7, 2012 at 6:43

I always use some commands. For example:

\newcommand{\angles}[1]{\left\lange #1 \right\rangle}%      ⟨⟩
\newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}%     {}
\newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}%     []
\newcommand{\pars}[1]{\left( #1 \right)}%                   ()
\newcommand{\partiald}[3][]{{\partial^{#1}#2 \over \partial {#3}^{#1}}}%

It works like this:

  • \pars{\Huge A}
  • \partiald[3]{y\pars{x,t}}{t}
  • A\\+
  • etc.

You can leave them in a file (for example myMacros.tex) and use \input in the main document: \input{pathToFile/myMacros.tex}.


Why has no one metioned \qty? It comes in physics package


\qty{curly braces}\\
\qty|Vertical bars|

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .