
答案1
這是另一個array
基於 - 的解決方案。此array
函數共有 9 列:5 列表示 的冪x
,4 列表示+
和-
符號,因此彼此垂直對齊。
指令\rlap
用於使末尾.
(句號)和 QED 符號突出到 的右側邊緣之外array
。
\documentclass{article}
\usepackage{array} % for "\newcolumntype" macro
\usepackage{booktabs}% for "\midrule" macro
\usepackage{amsthm} % for "\qedsymbol" macro
\newcolumntype{C}{>{{}}c<{{}}}
\newcommand{\ltimes}{\multicolumn{1}{l}{\times}}
\begin{document}
\[
\setlength\arraycolsep{0pt}
\renewcommand\arraystretch{1.5}
\begin{array}{*{4}{rC}r}
& & & - & 3x^2 & + & 2x & - & 4 \\
& &\ltimes& & 5x^2 & & & + & 3 \\
\midrule
& & & - & 9x^2 & + & 6x & - & 12\\
-15x^4 & + & 10x^3 & - & 20x^2 \\
\midrule
-15x^4 & + & 10x^3 & - & 29x^2 & + & 6x & - & 12\rlap{.\quad\qedsymbol}\\
\end{array}
\]
\end{document}
答案2
看起來他使用了,這與數學模式下的但array
或多或少相同。tabular
我更喜歡沒有所有空格的情況。
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{displaymath}
\begin{array}{*{5}{@{}r@{}}}
& & -3x^2 & {}+2x & {}-4\\
& \times & 5x^2 & & {}+3\\\midrule
& & -9x^2 & {}+6x & {}-12\\
-15x^4 & {}+10x^3 & {}-20x^2\\\midrule
-15x^4 & {}+10x^3 & {}-29x^2 & {}+6x & {}-12
\end{array}
\end{displaymath}
\end{document}
答案3
我提出另一個解決方案,基於alignedat
:
\documentclass{article}
\usepackage{booktabs}
\usepackage{mathtools}
\begin{document}
\[ \begin{array}{@{}c@{}}
\begin{alignedat}{5}
& & & & -3&x^2 & {}+2&x & {}-4& \\
& & & &{}\times 5&x^2 & & & {}+3 & \\\midrule[0.4pt]
& & & & -9 & x^2 & {}+6 &x & {}-12& \\
-15 & x^4 & {}+10 & x^3 &{}-20 & x^2\\\midrule[0.4pt]
-15 & x^4 & {}+10 & x^3 & {}-29&x^2 & {}+6 &x & {}-12&
\end{alignedat}
\end{array} \]
\end{document}
答案4
autoaligne
在技巧的幫助下https://tex.stackexchange.com/a/339525/4427
\documentclass{article}
\usepackage{autoaligne}
%% A trick for an empty delimiter
\newcommand{\makeempty}[1]{%
\begingroup\lccode`~=`#1 \lowercase{\endgroup\def~}{\mathbin{\phantom{+}}}%
\mathcode`#1="8000
}
\begin{document}
\[
\setlength{\medmuskip}{18mu}
\makeempty{V}
\definirseparateurs{\\}{+||-||V}{}
\autoaligne{
+- 3x^2 + 2x - 4 \\
V \times\hfill V 5x^2 ++ 3 \\
\noalign{\vspace{3pt}\hrule\vspace{3pt}}
+- 9x^2 + 6x - 12 \\
\-15x^4 + 10x^3 - 20x^2 \\
\noalign{\vspace{3pt}\hrule\vspace{3pt}}
\-15x^4 + 10x^3 - 29x^2 + 6x - 12
}
\]
\end{document}
如果您想讓它更緊湊,請刪除該\setlength
行:
這是對原件的更準確的渲染。
\documentclass{article}
\usepackage{amsthm,array}
\begin{document}
\[
\setlength{\extrarowheight}{1ex}
\begin{array}{@{}rclcrcrclll}
&&& - & 3x^2 & + & 2x & - & 4 \\[1ex]
&& \times & & 5x^2 &&& + & 3 \\[1ex]
\cline{1-10}
&&& - & 9x^2 & + & 6x & - & 12 \\[1ex]
-15x^4 & + & 10x^3 & - & 20x^2 \\[1ex]
\cline{1-10}
-15x^4 & + & 10x^3 & - & 29x^2 & + & 6x & - & 12 && \qedsymbol
\end{array}
\]
\end{document}