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.

I'd like to make my summations adjust in size just as brackets and parenthesis do when using \left and \right - in principle, something like this:

\left\sum_i \frac{a+b}{x+y}\right.

This example, however, doesn't compile.

I've seen this question, and others like it, that detail how to make the summation sign larger, but it's not dynamic. Is there a way to do this dynamically?

share|improve this question
2  
Have you seen my answer to the linked question? The macro \resum{<stuff>} kind of re-sizes to <stuff> but could probably be written more robust. –  Qrrbrbirlbel Feb 13 '13 at 15:19
2  
I would just like to point out that this is not a good idea. As copy editor of a scientific journal I would definitely reject such feature for "bad typography". –  tohecz Feb 25 '13 at 20:08
add comment

1 Answer

Does this work for you? A command \scalerel intended for math mode that takes two arguments. It scales the first argument's height to match that of the second argument. It also vertically shifts the first argument to match the bounds of the second.

\documentclass{article}
\usepackage{calc}
\usepackage{graphicx}

\global\newlength\thewidth
\global\newlength\theheight
\global\newlength\blobheight
\global\newlength\blobdepth
\newsavebox{\prebox}

\newcommand\finddims[1]{\setbox0\hbox{#1}}

\newcommand\scalerel[2]{%
  \sbox{\prebox}{$#1$}%
  \finddims{$#2$}%
  \setlength\blobheight{\ht0+\dp0}%
  \setlength\blobdepth{\dp0}%
  \finddims{$#1$}%
  \setlength\thewidth{\wd0*\ratio{\blobheight}{\ht0+\dp0}}%
  \setlength\theheight{\ht0*\ratio{\blobheight}{\ht0+\dp0}}%
  \raisebox{-\blobdepth+\dp0*\ratio{\blobheight}{\ht0+\dp0}}%
           {\resizebox{\thewidth}{\theheight}{\usebox{\prebox}}}#2%
}

\begin{document}

\def\preblob{\displaystyle\sum_{i=0}^3}
\def\blob{\displaystyle\frac{\displaystyle\frac{x^3}{z+r^3}}%
          {\displaystyle\frac{y}{x^2}}%
}

Unscaled: $\preblob\blob$\rule{20ex}{0ex}%
Scaled: $\scalerel{\preblob}{\blob}$

\vspace*{1em} Of course, this can be take to crazy extremes

$\scalerel{i}{\blob}$
\end{document}

enter image description here

share|improve this answer
    
A more generalized version of the \scalerel command given above has been bundled with several other related routines into a new package called scalerel. It was submitted to CTAN on 2013-02-27 –  Steven B. Segletes Feb 27 '13 at 11:46
add comment

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.