10

I have the following code to align several equations:

\begin{aligned}
s_{1} & :=\sum_{1 \leq j \leq m} X_{j} \\
s_{2} & :=\sum_{1 \leq j<k \leq m} X_{j} \cdot X_{k} \\
      & \vdots \\
s_{k} & :=\sum_{1 \leq j_{1}<j_{2}<\cdots<j_{k} \leq m} X_{j_{1}} \cdot X_{j_{2}} \cdot \cdots \cdot X_{j_{k}} \\
      & \vdots \\
s_{m} & :=X_{1} X_{2} \cdots X_{m}
\end{aligned}

LaTeX output of above code with only minimal.cls and amsmath.sty

I would like to ask why the colon does not align with the vdots and a solution for it.

11

Welcome to TeX-SE! It does not align because a colon is a relation, i.e. of the \mathrel type. If you want to align it "by hand" you could just make the \vdots of that type, too.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\begin{aligned}
s_{1} & :=\sum_{1 \leq j \leq m} X_{j} \\
s_{2} & :=\sum_{1 \leq j<k \leq m} X_{j} \cdot X_{k} \\
      & \mathrel{\vdots} \\
s_{k} & :=\sum_{1 \leq j_{1}<j_{2}<\cdots<j_{k} \leq m} X_{j_{1}} \cdot X_{j_{2}} \cdot \cdots \cdot X_{j_{k}} \\
      & \mathrel{\vdots}\\
s_{m} & :=X_{1} X_{2} \cdots X_{m}
\end{aligned}\]
\end{document}

enter image description here

  • 1
    Your solutions is elegant and works perfectly. Thank you so much! – Abstract Analysis Jun 6 at 3:07
13

I don't think these should align on the dots of :=, but rather should be centered with respect to either the s_k or perhaps the relation :=. The dots in := serve a different function to those in \vdots. The package mathtools provides the command \vdotswithin{...} for centering such \vdots with respect to the material ...; it also provides \coloneqq for a better version of :=:

Sample outpu

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{align*}
  s_{1} &\coloneqq\sum_{1 \leq j \leq m} X_{j} \\
  s_{2} &\coloneqq\sum_{1 \leq j<k \leq m} X_{j} \cdot X_{k} \\
  \vdotswithin{s_{k}}& \\
  s_{k} &\coloneqq\sum_{1 \leq j_{1}<j_{2}<\cdots<j_{k} \leq m}
          X_{j_{1}} \cdot X_{j_{2}} \cdot \cdots \cdot X_{j_{k}} \\
  \vdotswithin{s_{k}}& \\
  s_{m} &\coloneqq X_{1} X_{2} \cdots X_{m}
\end{align*}

\begin{align*}
  s_{1} &\coloneqq\sum_{1 \leq j \leq m} X_{j} \\
  s_{2} &\coloneqq\sum_{1 \leq j<k \leq m} X_{j} \cdot X_{k} \\
        &\vdotswithin{\coloneqq} \\
  s_{k} &\coloneqq\sum_{1 \leq j_{1}<j_{2}<\cdots<j_{k} \leq m}
          X_{j_{1}} \cdot X_{j_{2}} \cdot \cdots \cdot X_{j_{k}} \\
        &\vdotswithin{\coloneqq} \\
  s_{m} &\coloneqq X_{1} X_{2} \cdots X_{m}
\end{align*}

\end{document}
  • 1
    I was thinking the same (I prefer the dots centered on the equals sign). Assuming the colons are necessary (they aren't, in my opinion), the vertical dots meaning ellipsis have nothing to do with those colons, so aligning them is out of question. – egreg Jun 6 at 6:36
4

My interpretation of changing of the answer given by the user @marmot using:

  • The macro \coegual instead of := simply because it provides the perfect alignment between : and =;
  • Using the negative space with the command \mkern I tried to bring the products of the elements close to the summation because I do not like them distant;
  • I have used \substack command because the subscripts on the summation did not bring me the products far away.

enter image description here


\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\newcommand{\coegual}{\mathrel{\mathop:}=}
\begin{document}
\[
\begin{aligned}
s_{1} & \coegual \sum_{1 \leq j \leq m} X_{j} \\
s_{2} & \coegual \sum_{1 \leq j < k \leq m} \mkern-5mu X_{j} \cdot X_{k}  \\
      & \mathrel{\vdots} \\
s_{k} & \coegual 
\sum_{\substack{1 \leq j_{1}< j_{2} <\cdots\\ \cdots< j_{k} \leq m}} \mkern-15mu X_{j_{1}} \cdot X_{j_{2}} \cdot \cdots \cdot X_{j_{k}} \\
      & \mathrel{\vdots}\\
s_{m} & \coegual X_{1} X_{2} \cdots X_{m}
\end{aligned}
\]
\end{document}

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.