6

I am trying to write a formula. But both substack and array cannot fulfil my needs (as far as I know how to use them).

formulae

The first is how I want it to look like. But I need an i'\neq i below the summation part.

The second is tried with \substack and the third is tried with array and both are unsatisfactory to me. Firstly, the i'\neq i is too big. Secondly, the a_{ii'} is misaligned.

Most preferable would be to maintain the size of the \sum. But if that is not possible, any compromise is okay.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation}
\sum\limits_{i=1}^{I}\sum\limits_{i'=1}^{I}a_{ii'} + \sum\limits_{i=1}^{I}b_{i}
\end{equation}
\begin{equation}
\substack{\sum\limits_{i=1}^{I}\sum\limits_{i'=1}^{I}\\i'\neq i}a_{ii'} + \sum\limits_{i=1}^{I}b_{i}
\end{equation}
\begin{equation}
\begin{array}{@{}c@{}}\sum\limits_{i=1}^{I}\sum\limits_{i'=1}^{I}\\i'\neq i \end{array}a_{ii'}+ \sum\limits_{i=1}^{I}b_{i}
\end{equation}

\end{document}
  • I would use \sum_{\substack{1\le i,i'\le I\\i\ne i'}} rather than two summation symbols. – egreg Jul 6 '13 at 7:19
8

You can use \mathop to "define" a math operator that allows stacking of super-/subscripts inside a display:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}

\begin{equation}
\sum\limits_{i=1}^{I}\sum\limits_{i'=1}^{I}a_{ii'} + \sum\limits_{i=1}^{I}b_{i}
\end{equation}
\begin{equation}
\substack{\sum\limits_{i=1}^{I}\sum\limits_{i'=1}^{I}\\i'\neq i}a_{ii'} + \sum\limits_{i=1}^{I}b_{i}
\end{equation}
\begin{equation}
\begin{array}{@{}c@{}}\sum\limits_{i=1}^{I}\sum\limits_{i'=1}^{I}\\i'\neq i \end{array}a_{ii'}+ \sum\limits_{i=1}^{I}b_{i}
\end{equation}
\begin{equation}
\mathop{\sum_{i = 1}^I \sum_{i' = 1}^I}_{i' \neq i} a_{ii'} + \sum_{i = 1}^I b_{i}
\end{equation}

\end{document}
  • This is undoubtedly the best answer. Neat and simple. – elwc Jul 6 '13 at 7:38
4

Probably an overkill, but an opportunity for \tikzmark:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand\tikzmark[1]{%
  \tikz[remember picture,overlay]\node[inner sep=0pt] (#1) {};}

\begin{document}

\begin{equation}
\sum\limits_{\tikzmark{a}\smash[t]{i=1}}^{I}\sum\limits_{\smash[t]{i'=1}\tikzmark{b}}^{I}a_{ii'} + \sum\limits_{i=1}^{I}b_{i}
\end{equation}

\begin{tikzpicture}[remember picture,overlay]
\node[yshift=-6pt] at ( $ (a)!0.5!(b) $ ) {$\scriptstyle i'\neq i$};
\end{tikzpicture}

\end{document}

enter image description here

And since the tikzmark library is available in TeX Live2013, the code simplifies to:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,tikzmark}

\begin{document}

\begin{equation}
\sum\limits_{\tikzmark{a}\smash[t]{i=1}}^{I}\sum\limits_{\smash[t]{i'=1}\tikzmark{b}}^{I}a_{ii'} + \sum\limits_{i=1}^{I}b_{i}
\end{equation}

\begin{tikzpicture}[remember picture,overlay]
\node[yshift=-6pt] at ( $ (pic cs:a)!0.5!(pic cs:b) $ ) {$\scriptstyle i'\neq i$};
\end{tikzpicture}

\end{document}

Since some calculations are performed, the code needs two or three runs to stabilize.

  • Your solution solves the problem regardless of whether it is overkill. I have several other equations that need this adjustment. I will spend sometime to study your solutions and if it is good and flexible enough, I will take this as an answer. Unless someone has a better solution to this... – elwc Jul 6 '13 at 4:40
  • 1
    @elwc Since I've used this approach so many times in answers, I tend now to forget to add some explanation. Let me correct that: the idea is to put some marks using \tikzmark and then, in this case, to use this marks to place the desired material at the desired location using as reference points the marks. – Gonzalo Medina Jul 6 '13 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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