4

Is there a way to adjust the size of the parentheses in such a way that they automatically adjust to the height of the formula? This seems easy but I cannot find anything on this. With \left( .. \right) the parenthesis center on the fraction but I would like it to adjust to the actual height because it results in 'empty space' on the upper side of the fraction. Adjusting the size with \big code results in the same problem; and the same is true for the methodology used here: About big parenthesis larger than Bigg .

Current code with a picture that illustrates the problem:

\begin{equation}
   \left(\frac{\ln{x}}{\left(\frac{\sum\limits_{i=1}^{n} \ln{x}}{\frac{n}{x}}       \right)} \right)=x
  \end{equation}

formula

5
  • 4
    Rewrite it, hardly any of those fractions are needed
    – daleif
    Feb 28, 2016 at 20:23
  • 1
    maybe the answers to this question help you ... Feb 28, 2016 at 20:29
  • Are you counting on your readers not figuring out that \sum\limits_{i=1}^{n} \ln{x}=n x?
    – Mico
    Feb 28, 2016 at 20:49
  • 1
    The formula is just for illustrative purposes Feb 28, 2016 at 21:11
  • I think you want something like the \LEFTRIGHT macro of Math Times Professional 2 fonts.
    – User
    Feb 28, 2016 at 21:51

3 Answers 3

3

Looking up in the TeXbook I've found the \vcenter vbox which does exactly what we need.

\documentclass{article}

\usepackage{amsmath}        

\newcommand\leftright[3]{\left#1\vcenter{\hbox{$#3$}}\right#2}

\newcommand\parens[1]{\leftright(){#1}}

\newcommand\LEFTRIGHT[3]{\leftright{#1}{#2}{\displaystyle#3}}

\newcommand\PARENS[1]{\parens{\displaystyle#1}}



\begin{document}


\[
\parens{\frac{\ln x}{\parens{\frac{\sum\limits_{i=1}^n\ln x}{\frac nx}}}}=x
\]


\[
\PARENS{\frac{\ln x}{\PARENS{\frac{\sum\limits_{i=1}^n\ln x}{\frac nx}}}}=x
\]


\[
\leftright\{\}{\frac{\ln x}{\leftright[]{\frac{\sum\limits_{i=1}^n\ln x}{\frac nx}}}}=x
\]


\[
\LEFTRIGHT\{\}{\frac{\ln x}{\LEFTRIGHT[]{\frac{\sum\limits_{i=1}^n\ln x}{\frac nx}}}}=x
\]


\end{document}

enter image description here

The uppercase versions of \leftright and \parens add only the \displaystyle command, and so look more similar to the one in mtp2 outlined in my previous answer.

Actually the macros present in the Math Time package are far more complicated, because they select individually designed parenthesis instead of extensible ones.

In my opinion, in any case, it's better to avoid such unbalanced constructions when possible, by reordering the terms of the equation.

8
  • @AppleCinnamon. I'm happy you find this useful. BTW, if this is what you were looking for, you should mark this answer as accepted
    – User
    Mar 1, 2016 at 10:57
  • Well, actually there is still one issue for me; when I switch the numerator and denominator of the example, the inner brackets remain in the denomenator but they have to move upwards to the numerator. I am not sure why this is the case as I have no experience with the new command. Mar 1, 2016 at 23:48
  • Also, as this is not coded as an equation I noticed that there is no equation number. I will try to look up how to create this manually, because putting all of this in equation format does not work. But as you may notice my experience with Latex is very limited so any help is appreciated. Mar 2, 2016 at 0:15
  • @AppleCinnamon. To get the numbering simply enclose the formula in the equation environment: substitute \[ with \begin{equation} and \] with \end{equation}. I can't understand the inversion of the fraction part: what have you written?
    – User
    Mar 2, 2016 at 17:09
  • I see thanks. This is what I have got: [ \PARENS{\frac{\ln x}{\PARENS{\frac{\sum\limits_{i=1}^n\ln x}{\frac nx}}}} ... \PARENS{\frac{\frac{\sum\limits_{i=1}^n\ln x}{\frac nx}}{\PARENS{\ln x}}} ] Mar 2, 2016 at 21:27
1

If you wanted the primary fraction bar to remain on the math axis, then this approach could work, using \scaleleftright[<width>}{<l-delim>}{<content>}{<r-delim>}. (Note I have replaced \sum\limits with \displaystyle\sum)

\documentclass{article}
\usepackage{scalerel,amsmath}
\begin{document}
\begin{equation}
   \scaleleftright[2.5ex]{(}{
     \frac{\ln{x}}{\scaleleftright[2ex]{(}{
       \dfrac{\displaystyle\sum_{i=1}^{n} \ln{x}}{\dfrac{n}{x}}
     }{)}}
   }{)}=x
  \end{equation}
\end{document}

enter image description here

0

If you use the Math Time Professional II fonts, then you have the \PARENS construction.

\documentclass{article}

\renewcommand{\rmdefault}{ptm}      
\usepackage{amsmath}        

\usepackage[subscriptcorrection,nofontinfo]{mtpro2}


\begin{document}

\[
   \PARENS{\frac{\ln x}{\PARENS{\frac{\sum\limits_{i=1}^n\ln x}{\frac nx}}}}=x
\]

\end{document}

enter image description here

There is also a \LEFTRIGHT construction which is more general and allows to use also different delimiters.

Unfortunately this requires you to use the Math Times Professional II fonts, so this is not properly an answer to your question. Maybe someone could write some similar macros that work with any font (I do not know TeX enough to do it).

2
  • Yes, this is exactly what I want; too bad it is only in the package. Thanks anyway Feb 28, 2016 at 23:19
  • @AppleCinnamon. Someone who knows TeX better than me should take this macros from the package and make them usable with any font. Math Time fonts use individually designed parentesis for each size, not extensible parenthesis, so also some modification to the macros must be made
    – User
    Feb 28, 2016 at 23:25

You must log in to answer this question.

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