# How can I insert the minus symbol in this array?

I want to insert minus symbol like this picture

I tried

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{fourier}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\makeatletter
\newcommand*{\overtabline}{%
\noalign{%
\vskip-.5\dimexpr\ht\@arstrutbox+\dp\@arstrutbox\relax

\vskip10pt\relax
\hrule
\vskip-0.5pt\relax
\vskip0.5\dimexpr\ht\@arstrutbox+\dp\@arstrutbox\relax
}%
}
\begin{document}
\begin{align*}
\begin{array}{c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}cccc}
S &=&{} ab + & (a+d) bq&+& (a+2d) bq^2 &+&  \cdots &+& (a+nd)bq^n \\
qS &=& & a b q &+& (a+d)bq^2&+&\cdots &+& (a+(n-1)d)bq^n &+& (a+nd)bq^{n+1}\\
\overtabline
S(1-q) &=& ab + &dbq &+& dbq^2 &+& \cdots &+& dbq^n &-& (a+nd)bq^{n+1}
\end{array}
\end{align*}
\end{document}


Assuming that the minus should be between the lines and extra long as in your picture, you might do

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{fourier}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\makeatletter
\newcommand*{\overtabline}{%
\noalign{%
\vskip-.5\dimexpr\ht\@arstrutbox+\dp\@arstrutbox\relax

\vskip10pt\relax
\hrule
\vskip-0.5pt\relax
\vskip0.5\dimexpr\ht\@arstrutbox+\dp\@arstrutbox\relax
}%
}
\begin{document}
\begin{align*}
\begin{array}{c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}c@{\,}cccc}
S &=&{} ab + & (a+d) bq&+& (a+2d) bq^2 &+&  \cdots &+& (a+nd)bq^n \\
\smash{\makebox[0pt][r]{\raisebox{8pt}{---}}}qS &=& & a b q &+& (a+d)bq^2&+&\cdots &+& (a+(n-1)d)bq^n &+& (a+nd)bq^{n+1}\\
\overtabline
S(1-q) &=& ab + &dbq &+& dbq^2 &+& \cdots &+& dbq^n &-& (a+nd)bq^{n+1}
\end{array}
\end{align*}
\end{document}


Here's a different solution, which (a) places the large minus symbol to the left of the second row, (b) right-aligns the column contents for better readability (in terms of powers of $q$), and (c) replaces \overtabline with \cmidrule (from the booktabs package).

\documentclass[12pt,a4paper]{article}
%\usepackage[utf8]{inputenc} % this the default with up-to-date LaTeX formats since Apr. 2018
\usepackage{amsmath,fourier}
\usepackage[margin=2cm]{geometry}
\usepackage{booktabs,array,relsize} % <-- new
\newcolumntype{C}{>{{}}c<{{}}} % for +, -, and = columns
\begin{document}
$\setlength\arraycolsep{0pt} \begin{array}{@{} l *{6}{rC} r @{}} & S &=& ab &+& (a+d) bq &+& (a+2d)bq^2 &+& \cdots &+& (a+nd)bq^n \\ \mathlarger{\mathlarger{\mathlarger{-}}} & qS &=& && abq &+& (a+d)bq^2 &+& \cdots &+& (a+(n-1)d)bq^n &+& (a+nd)bq^{n+1}\\ \cmidrule{2-14} & S(1-q)&=& ab &+& dbq &+& dbq^2 &+& \cdots &+& dbq^n &-& (a+nd)bq^{n+1} \end{array}$
\end{document}

• Thank you for your answer. Can I put minus like my picture? – minhthien_2016 Jun 6 '18 at 6:01
• @minhthien_2016 - If this were my document, I would not raise the enlarged minus symbol. However, there's nothing stopping you from using @marmot's method, i.e., writing \smash{\makebox[0pt][r]{\raisebox{8pt}{$\mathlarger{\mathlarger{\mathlarger{-}}}$}}}, right? – Mico Jun 6 '18 at 6:59
• Thank you for your comment. I use your answer for my document. – minhthien_2016 Jun 6 '18 at 7:31
• Please explain for me mean of the line \begin{array}{@{} l *{6}{rC} r @{}}. I understand that, all columns are right-aligns? If I want to align of each column, for example, first column if left, second in center, ... How can I do? – minhthien_2016 Jun 19 '18 at 6:35
• @minhthien_2016 - Your code is missing three instances of &. Change all 3 instances of S=& to S&=&. You should also change \cmidrule{2-17} to \cmidrule{2-18}. – Mico Aug 22 '18 at 11:08