# Aligning limits of multiple summations

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}


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?

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

\documentclass{article}
\usepackage{mathtools}% loads amsmath'
\begin{document}
\begin{align}
\end{align}
\end{document}


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.

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}


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}


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. Sep 15, 2018 at 0:18
• @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`.
– user121799
Sep 15, 2018 at 0:27