• Nov 13th 2010, 08:24 AM
Jodles
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)
• Nov 13th 2010, 12:32 PM
Jodles
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*}
• Nov 13th 2010, 12:39 PM
Jodles
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)...
• Nov 13th 2010, 01:10 PM
Opalg
Quote:

Originally Posted by Jodles
Not the most elegant solution, so if anyone has a better way to do this (there must be, this is simple maths!!:P)...

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}
$\displaystyle \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}$
• Nov 13th 2010, 01:23 PM
Jodles
Many thanks, Opalg!

That produces a much more cleaner result!

Sometimes the simplest things seem the most difficult...
• Nov 13th 2010, 02:16 PM
Jodles
While we're on it. I modified the above for subtraction:
$\displaystyle \begin{array}{c@{\:}c@{\:}c@{\:}c@{\:}c@{\:}c@{\:} c@{\:}c@{\,}c} ^{^{}}&^{^{}}&^{^{}}&^{^{10}}&^{^{10}}&^{^{10}}&^{ ^{10}}\vspace{-2ex}\\ 1&0&1&1&0&0&0&_2\\ \llap{-}0&0&0&1&0&1&1&_2\\ \hline 1&0&0&1&1&0&1_2\\ \end{array}$

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...
• Nov 13th 2010, 02:18 PM
Jodles
I shouldn't be so quick to ask.. In math environment: \usepackage{cancel}, and \cancel{24324}, instead of \sout{}.