I am trying to create a long multiplication (like here
http://mathworld.wolfram.com/LongMultiplication.html) and vertical form addition http://mathworld.wolfram.com/Addition.html but I don't know how to do this cleanly in Latex. I used \begin{array} but it doesn't looks very nice. Do you have any suggestions?
General ⇒ Long Multiplication
NEW: TikZ book now 40% off at Amazon.com for a short time.
Long Multiplication
Hi,
using tabular environments could be an option:
Some features provided by the array package were used; please refer to the package documentation for further information.
using tabular environments could be an option:
Code: Select all
\documentclass{article}
\usepackage{array}
% command that will typeset the carriage
% syntax: \mycarr{<value>} or \mycarr (default carriage=1)
\newcommand\mycarr[1][1]{\scriptstyle #1\rule{8pt}{0pt}}
\begin{document}
{\setlength\arrayrulewidth{.8pt}
\setlength\tabcolsep{4pt}
\begin{tabular}{*{5}{>{$}c<{$}}}
&& 3 & 8 & 4\\
\times &&& 5 & 6 \\\hline
& 2 & 3 & 0 & 4\\
1 & 9 & 2 & 0 &\\\hline
2 & 1 & 5 & 0 & 4
\end{tabular}}
\vspace{1cm}
{\setlength\arrayrulewidth{.8pt}
\setlength\tabcolsep{4pt}
\begin{tabular}{*{4}{>{$}c<{$}}>{$}l<{$}>{\bfseries}l}
& \mycarr & \mycarr && \leftarrow & carries\\[-4pt]
& 1 & 5 & 8 & \leftarrow & adddend1\\
+ & 2 & 4 & 9 & \leftarrow & adddend2 \\\cline{1-4}
& 4 & 0 & 7 & \leftarrow & sum\\
\end{tabular}}
\vspace{1cm}
{\setlength\arrayrulewidth{.8pt}
\setlength\tabcolsep{4pt}
\begin{tabular}{*{4}{>{$}c<{$}}>{$}l<{$}>{\bfseries}l}
& \mycarr[2] & \mycarr[2] & & \leftarrow & carries\\[-4pt]
& 9 & 9 & 9 & \leftarrow & adddend1\\
& & 9 & 9 & \leftarrow & adddend2\\
+ & & 9 & 9 & \leftarrow & adddend3 \\\cline{1-4}
1 & 1 & 9 & 7 & \leftarrow & sum\\
\end{tabular}}
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...