4

For instance, given this:

((a+b)c)^d

I'd like it to show:

\big((a+b)c\big)^d

but without the need to explicitly state \big

japseow
  • 161
  • 1
    Welcome to TeX.SX! There are \left(...\right) etc. which you could nest, but it is not always advisable to use those. – TeXnician Sep 18 '17 at 09:24
  • 2
    @TeXnician Well, $\left(\left(a+b\right)c\right)^d$ would not use larger parentheses for the outer ones; only unwanted spaces would be added. – egreg Sep 18 '17 at 09:27
  • Thanks! I've tried \left(\right), however, they only resize when the middle part gets larger. If it stays the same size, there's no size difference.

    @egreg lol, yea my bad on that part

    – japseow Sep 18 '17 at 09:27
  • 2
    @japseow In general, there's no need to grow the outer parentheses large, so there's no automatic way to do it, because judgment is required. In any case, you should use \bigl( and \bigr). – egreg Sep 18 '17 at 09:28
  • But, i have these predicates & quantifiers that requires a lot of () pathConnected((M, \mathcal{O}), ()) \iff \forall_{p, q \in M} \exists_{\gamma} (continuous(\gamma, (([0, 1], \mathcal{O}_{standard}|_{[0 ,1]}), (M, \mathcal{O}))) \land \gamma(0) = p \land \gamma(1) = q) What should I do with them? – japseow Sep 18 '17 at 09:33

3 Answers3

9

I suggest you load the mleftright package, issue the directive \mleftright (to avoid the unwanted insertion of extra whitespace), and issue the instruction \delimitershortfall-1sp. That way, the auto-sized parentheses will grow in size automatically, even if the enclosed material isn't "tall".

enter image description here

\documentclass{article}
\delimitershortfall-1sp
\usepackage{mleftright}
\mleftright % make \left & \right behave like \mleft & \mright 
\begin{document}
\[
\left(\left\langle\left\{\left[\left(\left(a+b%
 \right)c\right)\right]\right\}\right\rangle\right)
\]
\end{document}

If you were to comment out the instruction \delimitershortfall-1sp, you'd get

enter image description here

Mico
  • 506,678
1

I want to add another solution, because a negative \delimtershortfall can look a bit unpleasant.

What I do is declaring a parenthis-function that uses \vphantom with \raisebox to add extra height to the outer delimiter.

The solution is not pretty:

  • I use \mathop because else \vphantom does not work and then add negative space to counter the extra space that \mathop adds.

  • Also inside \raisebox you need to use \( \) to get into mathmode and \displaystyle to get the right virtual height

But it works for me and you can still tweak \delimtershortfall and \delimiterfactor to your liking (if you then also adjust the raise in \raisebox). Also you can change the value in \raisebox to adjust the growth of the delimiters.

For further reading I recommend this post: automatic size adjustment for nested parentheses

\documentclass[12pt,a4paper]{article}
\usepackage{mleftright}

\global\delimitershortfall=5.5pt \global\delimiterfactor=880 \renewcommand{\left}{\mleft} \renewcommand{\right}{\mright} \newcommand{\braced}[1] { \left( #1 \right) \mskip-1.5mu \vphantom{ \mathop{ \raisebox{3pt}{ (\left(\displaystyle #1 \right)) } } } }

\begin{document} [ \braced{ x + \braced{\braced{ y }} } ] \end{document}

Example

S. Kohl
  • 111
  • 1
  • 5
0

Update:

I ended up just using a python script that searches for nested parenthesis and replaces it with \left, \right. I used \pr for parenthesis in my case.

tex = re.sub(r"\(([^()\n]*?)\((.*?)\)([^()\n]*?)\)", r"\\pr{\1(\2)\3}", tex)

japseow
  • 161