Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

One of the difficulties I have with writing formulas in LaTeX is that the standard sizing tools for the variable-size operators (parentheses, etc.) do not account for "high" symbols and "low" symbols separately. Thus, for instance, if you write something like
\[ \left( \sum_{\substack{ 0\le i\le m\\ 0<j<n}} P(i,j) \right) \]
which (using amsmath) produces a summation symbol with two lines of subscript, the top of the enclosing parentheses extend well above the top of the text:

rendering of the example

Things get vastly worse if you try to enclose a commutative diagram in parentheses.

Is there any way to make the size vary asymmetrically? I.e., so that the parentheses could extend far down without having to extend far up, and vice versa.

share|improve this question
2  
Hmm, is it just me, or doesn't the above look typographically correct? –  morbusg Aug 26 '11 at 20:56

3 Answers 3

up vote 13 down vote accepted

There's probably a package to do this ... but in the meantime, here's a way to do it that keeps the baseline correct. It lowers the line by a specified amount just before the opening parenthesis and then raises it back to where it should be just after. Then it does the same again the other end. One could add additional options to have one command deal with all styles of parenthesis and to deal with inline versus displaystyle (this is for displaystyle) - I'd wait to see if there's a package before tackling that! The drawback of this is that you have to decide what the "drop" should be for yourself. A more sophisticated approach would compute that for you.

\documentclass{article}
\usepackage{amsmath}

\newcommand{\lowerparen}[2]{%
  \raisebox{-#1}{\(\displaystyle\left(\raisebox{#1}{\(\displaystyle #2\)}\right)\)}}

\begin{document}
\[
  Y = \lowerparen{6pt}{\sum_{\substack{0 \le i \le m \\ 0 < j < m}}X}
\]

\end{document}

Here's a slightly fuller solution, based on the above but with a little more flexibility with regard to mathmodes (thanks to this question on mathmodes).

\documentclass{article}

\newlength{\parenheight}
\newlength{\parendepth}
\newlength{\parendrop}

\newcommand{\paren}[4]{%
\settoheight{\parenheight}{\(#4 #2\)}%
\settodepth{\parendepth}{\(#4 #2\)}
\addtolength{\parendepth}{.5ex}
\addtolength{\parenheight}{-.5ex}
\addtolength{\parenheight}{\parendepth}
\addtolength{\parendepth}{-.5\parenheight}
\setlength{\parendrop}{-.5\parenheight}
\addtolength{\parendrop}{.5ex}
\raisebox{-\parendepth}{\(#4
\left#1%
\rule[\parendrop]{0pt}{\parenheight}%
\right.\)}
#2
\raisebox{-\parendepth}{\(#4
\left.%
\rule[\parendrop]{0pt}{\parenheight}%
\right#3\)}
}

\def\myleft#1#2\myright#3{%
\mathchoice{%
\paren{#1}{#2}{#3}{\displaystyle}%
}{%
\paren{#1}{#2}{#3}{\textstyle}%
}{%
\paren{#1}{#2}{#3}{\scriptstyle}%
}{%
\paren{#1}{#2}{#3}{\scriptscriptstyle}%
}%
}

\begin{document}


\(
  \myleft(\prod_{{s = 0 \atop s \ne 3}} X_s\myright)^2 \left(A\right) \left(x\right)
\)

\[
  \myleft(\prod_{{s = 0 \atop s \ne 3}} X_s\myright)^2 \left(A\right) \left(x\right)
\]

\end{document}

I haven't tested it very much. I suspect that something will break with the way I've coded the 'left-right' matching. The main point is to get the heights lined up.

(As this answer has been accepted, I don't feel I should simply replace the original answer with this new one but it's only a little development of the original so doesn't really deserve a new answer. So I'm posting it as an addendum.)

share|improve this answer
    
I'm inclined to accept this, but then, I felt the same way about Stefan Kottwitz's answer until you pointed out the issue with the baseline, so I'll wait and see if someone has something even better. If not, I'll accept. –  Charles Staats Aug 4 '10 at 16:00
1  
Definitely wait! It sounds like the sort of thing that there'd be a package for, but I tend to prefer hacking something than searching CTAN (I can never figure out how best to find something there). I'll be interested to see if there is a package. –  Loop Space Aug 4 '10 at 16:41
    
Yes, andrew is known to provide snippets of custom code to do just about anything =)))) –  Dima Aug 29 '10 at 22:38

Another option is the nath package which does the "right thing" without any user intervention

\documentclass{article}
\usepackage{nath}

\begin{document}
\begin{equation}
( \sum_{0\le i\le m\\ 0<j<n} P(i,j)) 
\end{equation}
\end{document}

Notice, no \left \right tags, no \substack, and even then you get the correct scaling of delimiters. Unfortunately, nath does not work well with amsmath. I hope that someone will separate the nath "goodies" from nath display math features, so that the former work with amsmath.

share|improve this answer
3  
Shame about the amsmath incompatibility, but otherwise looks interesting. –  Loop Space Aug 4 '10 at 17:47
    
I tried this out. In my compiler, the parentheses do not extend down to cover the subscripts. In addition, the package is incompatible with xypic, so I could not even test how it works with commutative diagrams. –  Charles Staats Aug 6 '10 at 15:24
3  
Actually, nath goes to a great deal of trouble to ensure that the brackets do not extend to cover all the subscripts. It is not considered a good style (although I cannot find a reference for that right now). –  Aditya Aug 30 '10 at 17:35

Using an array environment would be an easy way to achieve vertically centered alignment:

\[
\left(\begin{array}{c}\displaystyle%
\sum_{\substack{ 0\le i\le m\\ 0<j<n}} P(i,j)%
\end{array}\right)
\]
share|improve this answer
    
This shifts the baseline, so if there's other stuff on the line then it looks a little odd. However, if the parentheses are the outermost bits then I'd go for this. –  Loop Space Aug 4 '10 at 15:46
    
Another thing is that it adds in some extra space for padding. I found that adding \mspace{-9mu} on either side of the middle line more or less corrected this. In any case, it's a vast improvement. –  Charles Staats Aug 4 '10 at 15:52
    
How about just changing the array column specification to @{}c@{}? –  TH. Aug 30 '10 at 4:13
    
Or using \begin{pmatrix} and \end{pmatrix} instead of \left(\begin{array}{c} and \end{array}\right). –  Bruno Le Floch Jan 25 '11 at 17:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.