3

I would like to use the method \adjustlimits from the mathtools package in conjunction with the \smashoperator method. In the MWE I don't know how and where to use the \adjustlimits method. Trying to write it at the beginning with and without parentheses always produces errors.

MWE

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[
  \smashoperator{\sum_{i \in X \colon i \neq 5}} \, x_i  - \smashoperator{\sum_{i \in \bar{X} \colon i \neq 8}} \, y_i
\]
\end{document}
2
  • Sorry, but I believe you can't use \adjustlimits along with \smashoperator.
    – egreg
    Mar 7 '15 at 10:17
  • @egreg Is there any other trick to align the limits? It must be something to fake the height of the X in the first sum to be the same height as the \bar{X} in the second sum. Mar 7 '15 at 10:20
4

The \adjustlimits operation requires the operators to be at the same brace level, which is not possible with \smashoperator. In this case you can easily adjust things manually:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[
\smashoperator{\sum_{i \in X \colon i \neq 5\vphantom{\bar{X}}}} \, x_i  -
\smashoperator{\sum_{i \in \bar{X} \colon i \neq 8}} \, y_i
\]
\end{document}

enter image description here

The \vphantom with the highest object as argument will adjust the size.

However, the documentation of mathtools specifies that operators should immediately follow one another, in order for \adjustlimits to work, so this approach would not work anyway, because of the x_i- between the summation operators.

Here's how I would set this, with \substack:

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\[
\sum_{\substack{i \in X\vphantom{\bar{X}} \\ i \neq 5}} x_i  -
\sum_{\substack{i \in \bar{X} \\ i \neq 8}} y_i
\]
\end{document}

enter image description here

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.