我试过
\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}
答案1
假设减号应该在两行之间,并且像图片中那样很长,那么你可能会这样做
\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}
答案2
这是一个不同的解决方案,其中(a)将大减号放在第二行的左侧,(b)将列内容右对齐以提高可读性(就的幂而言$q$
),以及(c)\overtabline
用\cmidrule
(来自包booktabs
)替换。
\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}