5

I have an optimisation problem wherein I have some trouble with the alignment of the limits of consecutive summations.

\begin{align}
\max \sum\limits_{k\in K}\sum\limits_{a\in A^{k,V}_{L}(f,v)}x^{k}_{a}
\end{align}

enter image description here

As you can observe, there seems to be a problem with the alignment of the limits. How can I align them so that the limits appear to be in the same line throughout the equation?

9

The \adjustlimits command from the mathtools package is designed for this:

\documentclass{article}
\usepackage{mathtools}% loads `amsmath'
\begin{document}
\begin{align}
\max \adjustlimits\sum_{k\in K} \sum_{a\in A^{k,V}_{L}\!(f,v)}x^k_a
\end{align}
\end{document}

limits adjustment

I also added a negative “kern” between the A^{k,V}_{L} and the (f,v): Feel free to remove it if you don’t like the result.

5

Use a \vphantom.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
\max \sum\limits_{\vphantom{A^{k,V}_{L}} k\in K}\sum\limits_{a\in A^{k,V}_{L}(f,v)}x^{k}_{a}
\end{align}
\end{document}

enter image description here

Here is an alternative, however, I am not sure if I would go for it.

\documentclass{article}
\usepackage{amsmath}
\newcommand{\climits}[1]{\limits_{\strut #1}}
\begin{document}
\begin{align}
\max \sum\climits{k\in K}\sum\climits{a\in A^{k,V}_{L}(f,v)}x^{k}_{a}
\end{align}
\end{document}

enter image description here

One can produce even more complicated macros. The danger with those is that you may drown in your own macros and eventually, when you share your TeX files with others, these things will become very cumbersome, especially if your collaborators also have their own macros or very specialized packages.

  • Though the solution seems nice, its a tedious process expecially when we have multiple summations such as those above and also the readability of the code appears reduced. – crypto Sep 15 '18 at 0:18
  • 1
    @crypto Yes. Alternatively you could just insert a \strut everywhere: \max \sum\limits_{\strut k\in K}\sum\limits_{\strut a\in A^{k,V}_{L}(f,v)}x^{k}_{a} or even define your version of \limits in such a way that it injects a \strut. – marmot Sep 15 '18 at 0:27

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.