Multiplication Formatting

It looks like he used array, which is more or less the same as tabular but in math mode. I would prefer it without all the spaces.

\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}

enter image description here


Here's another array-based solution. The array features a total of 9 columns: 5 columns for the powers of x and 4 columns for the + and - symbols, which are thus vertically aligned with each other.

An \rlap instruction is used to make the final . (period) and the QED-symbol protrude beyond the right-hand edge of the array.

enter image description here

\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}

I propose another solution, based on 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}

enter image description here

Tags:

Formatting