6

I'm trying to place 3 equations with some dots between them and I don't know why only the first \cdots is right aligned and the others are a mess. This is the code:

\begin{equation}
\begin{aligned}
    (\mathcal{H}_{11}- &S_{11}E_i)c_{1i}+(\mathcal{H}_{12}- &S_{12}E_i)c_{2i}+ &\cdots+(\mathcal{H}_{1n}- &S_{1n}E_i)c_{ni}=0\\
    (\mathcal{H}_{21}- &S_{21}E_i)c_{1i}+(\mathcal{H}_{22}- &S_{22}E_i)c_{2i}+ &\cdots+(\mathcal{H}_{2n}- &S_{2n}E_i)c_{ni}=0\\
                                        &\cdots&\cdots&\cdots&\cdots\\
    (\mathcal{H}_{n1}- &S_{n1}E_i)c_{ni}+(\mathcal{H}_{n2}- &S_{n2}E_i)c_{2i}+ &\cdots+(\mathcal{H}_{nn}- &S_{nn}E_i)c_{ni}=0\\
\label{eq:secular}
\end{aligned}
\end{equation}

Thank you very much

Edit: Thanks everyone for the help, maybe an image about what i'm trying to obtain would be better than words:

if they are \cdots or \vdots doesn't matter

  • 3
    You have to think on it like this: You need a & for each alignment point, and a & between each set of alignments (left and right pairs around an alignment &), so you need to figure out which &'s does what. It is not clear to me which parts should be aligned in your example. – daleif Apr 8 '16 at 11:49
5

(Edited to provide a few more \vdots instructions, per the OP's updated request)

Instead of using an aligned environment, I would use a basic array environment to align the various parts of the equation. This way, it's straightforward to align all + and = symbols as well as the remaining constituent parts of the system of equations. Observe also the four \vdots instructions in the third row.

enter image description here

\documentclass{article}
\usepackage{array}
\begin{document} 
\begin{equation} \label{eq:secular}
\setlength\arraycolsep{0pt}
\renewcommand\arraystretch{1.25}
\begin{array}{*{4}{c >{{}}c<{{}}} c}
(\mathcal{H}_{11}- S_{11}E_i)c_{1i} & + &
   (\mathcal{H}_{12}- S_{12}E_i)c_{2i} & + & 
   \cdots & + &
   (\mathcal{H}_{1n}- S_{1n}E_i)c_{ni} & = & 0\\
(\mathcal{H}_{21}- S_{21}E_i)c_{1i} & + &
   (\mathcal{H}_{22}- S_{22}E_i)c_{2i} & + & 
   \cdots & + &
   (\mathcal{H}_{2n}- S_{2n}E_i)c_{ni}& = & 0\\
\vdots & & \vdots & & \vdots & & \vdots & &  \\
(\mathcal{H}_{n1}- S_{n1}E_i)c_{ni}& + &
   (\mathcal{H}_{n2}- S_{n2}E_i)c_{2i}& + & 
   \cdots& + &
   (\mathcal{H}_{nn}- S_{nn}E_i)c_{ni}& = & 0 \\
\end{array}
\end{equation}
\end{document}
2

You can do it with alignedat with a couple of tricks.

  1. I locally define \2 to provide a double index as wide as nn so the alignment will be automatic between the variables; the \2 macro will only be available in that equation environment.

  2. I use the low level instruction \multispan to insert a row of dots.

Full code

\documentclass{article}
\usepackage{amsmath,calc}

\begin{document}

\begin{equation}
\label{eq:secular}
\newcommand{\2}[1]{%
  _{\makebox[\widthof{$\scriptstyle nn$}][l]{$\scriptstyle #1$}}%
}
\begin{alignedat}{4}
(\mathcal{H}\2{11}- S\2{11}E_i)c\2{1i}
  &+(\mathcal{H}\2{12}-S\2{12}E_i)c\2{2i}
  &&+\dotsb
  &&+(\mathcal{H}\2{1n}-S\2{1n}E_i)c\2{ni}
  &&=0\\
(\mathcal{H}\2{21}-S\2{21}E_i)c\2{1i}
  &+(\mathcal{H}\2{22}-S\2{22}E_i)c\2{2i}
  &&+\dotsb
  &&+(\mathcal{H}\2{2n}-S\2{2n}E_i)c\2{ni}
  &&=0\\
\multispan{8}{\dotfill}\\[1ex]
%&\dotsb&\dotsb&\dotsb&\dotsb\\
(\mathcal{H}\2{n1}-S\2{n1}E_i)c\2{ni}
  &+(\mathcal{H}\2{n2}-S\2{n2}E_i)c\2{2i}
  &&+\dotsb
  &&+(\mathcal{H}\2{nn}-S\2{nn}E_i)c\2{ni}
  &&=0
\end{alignedat}
\end{equation}

\end{document}

enter image description here

1

You also can do that with the alignedat environment. I propose two codes: the first aligns the + and = signs, and the first , the second aligns all signs, at the cost of some slightly distorted space:

         \documentclass[a4paper, 11pt]{book}
        \usepackage[utf8]{inputenc}
        \usepackage{fourier, erewhon}

        \usepackage{mathtools}

        \begin{document}

\begin{equation}
\begin{alignedat}{4}
    (\mathcal{H}_{11}&-S_{11}E_i)c_{1i} & & +(\mathcal{H}_{12} -S_{12}E_i)c_{2i} & + \cdots & +(\mathcal{H}_{1n} - S_{1n}E_i)c_{ni} & =0\\
    (\mathcal{H}_{21}&-S_{21}E_i)c_{1i} & & +(\mathcal{H}_{22}-S_{22}E_i)c_{2i} & + \cdots & +(\mathcal{H}_{2n}- S_{2n}E_i)c_{ni} & =0\\
     % &\cdots&\cdots&\cdots&\cdots\\
    (\mathcal{H}_{n1}&-S_{n1}E_i)c_{ni} & & +(\mathcal{H}_{n2}-S_{n2}E_i)c_{2i} & +\cdots & +(\mathcal{H}_{nn} - S_{nn}E_i)c_{ni} &= 0
\label{eq:secular}
\end{alignedat}
\end{equation}

\begin{equation}
\begin{alignedat}{6}
    (\mathcal{H}_{11} & -S_{11}E_i)c_{1i} & & {} +(\mathcal{H}_{12} & & {}-S_{12}E_i)c_{2i} &{} + \cdots & +(\mathcal{H}_{1n} && {} - S_{1n}E_i)c_{ni} & =0\\
    (\mathcal{H}_{21} & -S_{21}E_i)c_{1i} & & {} +(\mathcal{H}_{22}& & {}-S_{22}E_i)c_{2i} &{} + \cdots & +(\mathcal{H}_{2n} && {} - S_{2n}E_i)c_{ni} & =0\\
     % &\cdots&\cdots&\cdots&\cdots\\
    (\mathcal{H}_{n1} & -S_{n1}E_i)c_{ni} & & {} +(\mathcal{H}_{n2}& & {}-S_{n2}E_i)c_{2i} &{} + \cdots & +(\mathcal{H}_{nn} && {} - S_{nn}E_i)c_{ni} &= 0 
\label{eq:secular}
\end{alignedat}
\end{equation}

        \end{document} 

enter image description here

  • You have two unnecessary trailing \\. – Manuel Apr 9 '16 at 19:35
  • Oh! yes. They come from the O.P.'s post. Thanks for pointing it. – Bernard Apr 9 '16 at 19:50

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.