I can't figure out how to display a multiline addition in latex with carried numbers... Could anyone show me how to do this neatly? (Happy)

Printable View

- November 13th 2010, 08:24 AMJodlesMultiline addition with carries
I can't figure out how to display a multiline addition in latex with carried numbers... Could anyone show me how to do this neatly? (Happy)

- November 13th 2010, 12:32 PMJodles
I figured out how to do the numbers that are carried over by using \overset{}, but how do I get a shorter line between the added number and the result? Now it fills all the page from left to middle....

Here's the code (I just posted it like this since it didn't render with the math tags..):

\begin{align*}

& \overset{1}{\ }\overset{1}{{1}}\overset{1}{0}\overset{1}{{1}}1_{ 2}\\

+ & \ \ \ 111_{2}\\

\hline & 10010\end{align*} - November 13th 2010, 12:39 PMJodles
Ok I figured I could just do this:

\begin{minipage}[t]{40pt}%

\begin{align*}

& \overset{1}{\ }\overset{1}{{1}}\overset{1}{0}\overset{1}{{1}}1_{ 2}\\

+ & \ \ \ 111_{2}\\

\hline & 10010\end{align*}

%

\end{minipage}

Not the most elegant solution, so if anyone has a better way to do this (there must be, this is simple maths!!:P)... - November 13th 2010, 01:10 PMOpalg
Simple maths doesn't necessarily mean simple LaTeX! This is also not elegant LaTeX, but it produces a fairly neat result:

Code:`\begin{array}{c@{\:}c@{\:}c@{\:}c@{\:}c@{\,}c}`

^{^1}&^{^1}&^{^1}&^{^1}\vspace{-2ex}\\

&1&0&1&1&_2\\

\llap{+}&&1&1&1&_2\\

\hline

1&0&0&1&0\\

\end{array}

- November 13th 2010, 01:23 PMJodles
Many thanks, Opalg!

That produces a much more cleaner result!

Sometimes the simplest things seem the most difficult... - November 13th 2010, 02:16 PMJodles
While we're on it. I modified the above for subtraction:

But how would I be able to show that the borrowed 10's are striked out? I tried with \sout{}, but that oddly enough adds a line under the number instead of through... - November 13th 2010, 02:18 PMJodles
I shouldn't be so quick to ask.. In math environment: \usepackage{cancel}, and \cancel{24324}, instead of \sout{}.