4

I am writing a math paper and I have a lot of complicated expressions some with fractions or absolute values, some with normal symbols some with larger symbols etc. So when I use \left( or \right) for parenthesis, they are too big a lot of times (They have other issues of spacing as well which is handled in the mathtools package. But the size is still a problem).

Of course one way out is to manually enter \Big, \big etc. but this becomes problematic as then it is very difficult to be consistent across the document (For e.g. in one formula I use \Big and 20 pages later I use \bigg as I have completely forgotten that I used \Big earlier on).

So is there a way to write a macro that will check the size of the input and then put brackets as either (), \big( \big), \Big( \Big), \bigg( \bigg) or \Bigg( \Bigg)?. Any help would be appreciated!

Edit: See this code for a sample problem

\documentclass{amsart}
\usepackage{mathtools}

\DeclarePairedDelimiter\paren{\lparen}{\rparen}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}

\begin{document}

The parentheses and absolute value are too big
\[
\int\abs*{\partial_{\alpha '}\frac{1}{Z_{\alpha '}}}^2 \text{ and } \int\paren*{\partial_{\alpha '}\frac{1}{Z_{\alpha '}}}^2
\]

compared to 
\[
\int\abs[\Big]{\partial_{\alpha '}\frac{1}{Z_{\alpha '}}}^2 \text{ and } \int\paren[\Big]{\partial_{\alpha '}\frac{1}{Z_{\alpha '}}}^2
\]

\end{document}
Troy
  • 13,741
skf23852
  • 229
  • Anyway it should be \bigl( and \bigr). AFAIK, there are no automatically calculating algorithms other than \left and \right. What you see there are the drawbacks of such algorithms. About consistency: you should always get the parenthesis which looks right. There's not a consistency issue imo. – Moriambar Apr 13 '17 at 20:12
  • I still think there should be a way to do this. I mean if I could get a handle on the size of the input, then I could just write an if then else code which does this job. Latex definitely calculates these sizes, though I don't know how to access them or what they are called. Having such a code makes life infinitely simpler and elegant as compared to manually entering. – skf23852 Apr 13 '17 at 21:17
  • left and right calculate the sizes by creating a subformula, around which they wrap (as far as I understand). Unfortunately, the subformula includes all of the sub elements (how is LaTeX gonna know if something is too high or too low to be comprised in parentheses?) This yields unwanted results, such as the limits of a sum to be comprised by the parentheses, which in turn make the parentheses too big – Moriambar Apr 13 '17 at 21:20
  • Have you seen the solutions here? https://tex.stackexchange.com/q/360996/117534. Otherwise, please give an example of when and how \left( and \right) are not satisfactory. – Troy Apr 14 '17 at 06:51
  • I saw the answers. All automatic sizing of () have the same height as that of \left( \right), in all the posts that I have ever seen. – skf23852 Apr 14 '17 at 16:35
  • @Siddhant because that is the way that TeX does it when automatically calculating the subformula's height – Moriambar Apr 14 '17 at 16:37
  • Duplicate? https://tex.stackexchange.com/questions/267171/nested-mathematical-functions. For example, \documentclass{article} \usepackage{scalerel,stackengine} \stackMath \ignoremathstyle \newcommand\Comp[1]{\scaleleftright{(}{\addstackgap[1pt]{#1}}{)}} \begin{document} $f\Comp{g(x)}$ \[ p\Comp{ q\Comp{ \displaystyle\frac{x}{y}\Comp{g\Comp{h(x)} } } } \] \end{document} – Steven B. Segletes Apr 14 '17 at 16:39
  • Is it possible to redefine the subformula's height? – skf23852 Apr 14 '17 at 16:39
  • @Siddhant no. To understand what's going on when typesetting formulas I advise you to read Chapter 17 and Appendix G of the TeX Book – Moriambar Apr 14 '17 at 16:40
  • @Moriambar As far as I can tell from reading the appendix, it seems that the only control we have is that of \delimiterfactor and \delimitershortfall which is clearly not enough to create such a macro. Is my understanding right? or is it possible to have more control that these two parameters – skf23852 Apr 14 '17 at 19:19
  • @Siddhant no more control, afaik. All of the spacing and boxing is computed in the 18 previous steps using font properties but no macros – Moriambar Apr 14 '17 at 19:24
  • @Moriambar Thanks! I will give up on trying to do something like this and just put brackets manually. Can you post this as an answer so that I can accept it and close this question? – skf23852 Apr 14 '17 at 19:29
  • @Siddhant Working on it – Moriambar Apr 14 '17 at 19:31
  • Somewhat related: https://tex.stackexchange.com/questions/1742/automatic-left-and-right-commands – user202729 May 15 '22 at 03:36

1 Answers1

2

The (La)TeX way to typeset autoscaled delimiters is \left and \right. mathtools package provides the \DeclarePairedDelimiter command which corrects their spacing a bit, but still uses them in background

As detailed in Appendix G of the TeX book, there is no margin for the user to meddle with TeX way of handling the transformation of a mathematical list to a box, at least reagarding the boundaries.

I strongly recommend to use

  • \bigl, \biggl and similar command for left (i.e. Opening) delimiters
  • \bigr, \biggr and such for right (i.e. closing) delimiters

and manually scale them. Only this way you can guarantee an acceptable and good typographical look.

Please do not be concerned about consistency throughout your book: manually scaling the delimiters will yield the best in each case.

Moriambar
  • 11,466