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.

When I use different summation indices in a double sum the limits are not vertically aligend, for instance:

\begin{equation}
\Delta K_T^i = \sum_{t=1}^{T}\sum_{k=1}^{m}{\Delta K_t^{i,k}} = \sum_{t=1}^{T} {\Delta K_t^k}
\end{equation}

and

\begin{equation}
\Delta K_T^k =\sum_{t=1}^{T}\sum_{i = 1}^{n}{\Delta K_t^{i, k}} = \sum_{t=1}^{T}{\Delta K_t^i}
\end{equation}

The limits below the summation symbol are misaligned vertically while the superscripts seem ok. Also the misalignment is bigger in the first example than in the second one.

If I use the same letter as subscript index the alignment works as expected.

\begin{equation}
\Delta K_T^i = \sum_{t=1}^{T}\sum_{t=1}^{m}{\Delta K_t^{i,t}} 
\end{equation}

I use the following packages, could any of these be the cause, or is this a bug/feature that could be handled in any way? I am using MikTex 2.9

\documentclass[a4paper,twoside,10pt]{article}
\usepackage[swedish]{babel} 
\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
share|improve this question
    
Welcome to TeX.sx! –  Andrew Swann Feb 15 '13 at 11:02
1  
It's not a strange behavior; TeX doesn't want to leave too much space between the summation symbol and the lower limit, but it can't know whether you want two consecutive summations, so a bit of help is needed. –  egreg Feb 15 '13 at 11:13
    
@AndrewSwann: Thnx! –  Mikael Däckfors Feb 15 '13 at 13:07
    
@egreg: I will provide the help :-) –  Mikael Däckfors Feb 15 '13 at 13:08

2 Answers 2

up vote 4 down vote accepted

The reason is the different height of the subscripts, t is smaller than k. One way to fix this (not beautiful, I know) is to put an invisible k below the first sum via \vphantom:

\begin{equation}
\Delta K_T^i = \sum_{\vphantom{k}t=1}^{T}\sum_{k=1}^{m}{\Delta K_t^{i,k}} = \sum_{t=1}^{T} {\Delta K_t^k}
\end{equation}
share|improve this answer
    
Thnx! Strange behaviour, I would have expected TeX to handle this, but thanks for the work-around. –  Mikael Däckfors Feb 15 '13 at 10:25

Short answer: You can use \adjustlimits from the mathtools package as Stefan Kottwitz explains in this answer.


This is an interesting observation! As egreg indicates in his comment, the slight misalignment appears to be by design. There has to be some compromise between variation in the vertical position and variation in the distance between subscript and summation sign.

For the standard CM fonts, the design is such that the vertical position will usually vary no more than 0.52776pt. This is coded in the \fontdimen parameters 10 and 12 of \textfont3: \fontdimen10 is 1.66666pt by default and gives the minimum distance between subscript and summation sign, \fontdimen12 is 6pt by default and gives the minimum distance between the baseline of the subscript and the summation sign. Thus, subscripts with a height of less than 4.33334pt (coming from 6-1.66666) are perfectly aligned, but the k is 4.8611pt high, which is 0.52776pt more.

To obtain perfect alignment also for higher subscripts like k, you can modify the \fontdimen parameters. The price you pay is of course that the distance between subscript and summation sign will vary more. Here's a suggestion that's just enough for the usual letters:

\documentclass{article}
\makeatletter
\AtBeginDocument{%
  \check@mathfonts
  \fontdimen10\textfont3=1.4pt
  \fontdimen12\textfont3=6.2611pt
  }
\makeatother
\begin{document}
\begin{equation}
\Delta K_T^i = \sum_{t=1}^{T}\sum_{k=1}^{m}{\Delta K_t^{i,k}} = \sum_{t=1}^{T} {\Delta K_t^k}
\end{equation}
\end{document}
share|improve this answer
    
Excellent explanation. So if I define \fontdimen10 and \fontdimen12 with a distance of (at least) 4.8611 the k subscript will fit, and the value of either one of the parameter 10 or 12 will decide how far below the subscript will end up. Did I understand you correctly? –  Mikael Däckfors Feb 15 '13 at 13:05
    
@Mikael: Yeah, that's right. –  Hendrik Vogt Feb 15 '13 at 14:06
    
@Mikael: See also my edit. –  Hendrik Vogt Feb 15 '13 at 20: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.