LaTeX forum ⇒ Math & ScienceEqual Length for Number Digits

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
QwareeqMathematics
Posts: 68
Joined: Mon Jul 06, 2009 7:44 pm

Equal Length for Number Digits

Postby QwareeqMathematics » Sat Dec 08, 2012 3:58 pm

Hi all,

I have the following code for some equation :

  1. \begin{array}{rcl}
  2. a_1 &=& \underbrace{0 \ldots 0}_{n-1}1\\
  3. a_2 &=& \underbrace{0 \ldots 0}_{\lfloor {\lfloor n / 2\rfloor} / 2 \rfloor\ }\underbrace{1 \ldots 1}_{\lceil n/2 \rceil}\underbrace{0 \ldots 0}_{\lceil {\lfloor n / 2 \rfloor} / 2 \rceil -1}1 \\
  4. a_3 &=& \underbrace{1 \dots 1}_{\lceil n/2 \rceil}\underbrace{0 \dots 0}_{\lfloor n/2 \rfloor}\\
  5.  
  6. a_4 &=& \underbrace{1 \ldots 1}_{\lfloor {\lfloor n / 2\rfloor} / 2 \rfloor\ + 1}\underbrace{0 \ldots 0}_{\lceil n/2 \rceil\ - 2}\underbrace{1 \ldots 1}_{\lceil {\lfloor n / 2 \rfloor} / 2 \rceil}0 \\
  7. a_5 &=& 0\underbrace{ 1\ldots 1}_{\lfloor {\lfloor n / 2\rfloor} / 2 \rfloor\ - 1}\underbrace{0 \ldots 0}_{\lceil n/2 \rceil}\underbrace{1 \ldots 1}_{\lceil {\lfloor n / 2\rfloor} / 2 \rceil}
  8. \end{array}


which gives :
digits.gif
digits.gif (4.39 KiB) Viewed 896 times


Now the numbers a_1,a_2,\ldots have the same number of digits ( n -digit).

How could I make the numbers to be in the same length and start/end from the same place.

I tried this :

  1. \begin{array}{rcll}
  2. a_1 &=& \underbrace{0 \ldots \ldots\ldots\ldots\ldots\ldots\ldots\ldots\ldots\ldots \ldots\ldots 0}_{n-1}1\\
  3. a_2 &=& \underbrace{0 \ldots\ldots\ldots\ldots 0}_{\lfloor {\lfloor n / 2\rfloor} / 2 \rfloor\ }\underbrace{1 \ldots\ldots\ldots1}_{\lceil n/2 \rceil}\underbrace{0 \ldots\ldots\ldots 0}_{\lceil {\lfloor n / 2 \rfloor} / 2 \rceil -1}1 \\
  4. a_3 &=& \underbrace{1 \ldots\ldots\ldots\ldots\ldots\ldots 1}_{\lceil n/2 \rceil}\ \ \underbrace{0 \ldots\ldots\ldots\ldots\ldots 0}_{\lfloor n/2 \rfloor}\\
  5. a_4 &=& \underbrace{1 \ldots\ldots\ldots 1}_{\lfloor {\lfloor n / 2\rfloor} / 2 \rfloor\ + 1}\underbrace{0 \ldots\ldots\ldots 0}_{\lceil n/2 \rceil\ - 2}\underbrace{1 \ldots\ldots\ldots\ldots 1}_{\lceil {\lfloor n / 2 \rfloor} / 2 \rceil}0 \\
  6. a_5 &=& 0\underbrace{ 1\ldots\ldots\ldots 1}_{\lfloor {\lfloor n / 2\rfloor} / 2 \rfloor\ - 1}\underbrace{0 \ldots\ldots\ldots 0}_{\lceil n/2 \rceil}\underbrace{1\ldots\ldots\ldots \ldots 1}_{\lceil {\lfloor n / 2\rfloor} / 2 \rceil}
  7. \end{array}


But, I'm wondering if there is a nice way, because I have a lot of numbers like those and I need to save time .

thank you all
Last edited by localghost on Sun Dec 09, 2012 1:39 pm, edited 1 time in total.
Reason: Preferably no external links (see Board Rules). Attachments go onto the forum server where possible.

Tags:

Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 4 guests