Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm doing various operations with binary numbers for my Discrete Mathematics hw and I'm not quite sure how to render it because I need to show my work.

This is an image of something I've been trying to show:

screenshot

I am also trying to add and multiply numbers and show work. I appreciate all of your help!

share|improve this question
add comment

1 Answer 1

There are probably lots of different ways of doing this- the solution below uses a simple array environment.

screenshot

The only subtle thing is that I've used the optional [t] argument to specify the vertical alignment. I've also used the enumitem to format the enumerate environment to have roman numbers (some might call it overkill).

MWE

\documentclass{article}
\usepackage{enumitem}   % for customizing list environments
\begin{document}

\begin{enumerate}[label*=\roman*.]
  \item $\begin{array}[t]{r}
        2012\\
        -1024\\\hline
        988\\
        -512\\\hline
        476\\
        -256\\\hline
        220\\
        -128\\\hline
        92\\
        -64\\\hline
        28\\
        -16\\\hline
        12
      \end{array}$
    \item $\begin{array}[t]{c|c|c|c}
        11  &   111 &   011 &   100 \\
        3   &   7   &   3   &   4
      \end{array}$
\end{enumerate}
\end{document}

Putting two such calculations side by side

Following the comment, there are lots of ways to put two such arrays side by side. You could use a minipage, but that might require some width calculations, so an easy solution is to use a tabular and then nest the arrays inside

enter image description here

\documentclass{article}
\usepackage{enumitem}   % for customizing list environments
\begin{document}

\begin{enumerate}[label*=\roman*.]
  \item \begin{tabular}[t]{ll}
        $\begin{array}[t]{r}
        2012\\
        -1024\\\hline
        988\\
        -512\\\hline
        476\\
        -256\\\hline
        220\\
        -128\\\hline
        92\\
        -64\\\hline
        28\\
        -16\\\hline
        12
      \end{array}$
      &
        $\begin{array}[t]{r}
        2012\\
        -1024\\\hline
        988\\
        -512\\\hline
        476\\
        -256\\\hline
        220\\
        -128\\\hline
        92\\
        -64\\\hline
        28\\
        -16\\\hline
        12
      \end{array}$
    \end{tabular}
    \item $\begin{array}[t]{c|c|c|c}
        11  &   111 &   011 &   100 \\
        3   &   7   &   3   &   4
      \end{array}$
\end{enumerate}
\end{document}

Or, you might prefer to use the aligned environment from the amsmath package; the output is the same as the tabular solution, but it might give you an advantage with 'global' alignment if you have a lot of these calculations- take your pick :)

  \item $\begin{aligned}[t]
        \begin{array}[t]{r}
        2012\\
        -1024\\\hline
        988\\
        -512\\\hline
        476\\
        -256\\\hline
        220\\
        -128\\\hline
        92\\
        -64\\\hline
        28\\
        -16\\\hline
        12
      \end{array}
      & &
        \begin{array}[t]{r}
        2012\\
        -1024\\\hline
        988\\
        -512\\\hline
        476\\
        -256\\\hline
        220\\
        -128\\\hline
        92\\
        -64\\\hline
        28\\
        -16\\\hline
        12
      \end{array}
    \end{aligned}$
share|improve this answer
    
How do you align two of these arrays side by side (to save space, for example) –  Arjun Sep 24 '12 at 0:22
    
@Arjun see my update :) –  cmhughes Sep 24 '12 at 1:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.