Math & ScienceEqual Length for Number Digits

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

Equal Length for Number Digits

Post by QwareeqMathematics »

Hi all,

I have the following code for some equation :

Code: Select all

\begin{array}{rcl} 
a_1 &=& \underbrace{0 \ldots 0}_{n-1}1\\
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 \\
a_3 &=& \underbrace{1 \dots 1}_{\lceil n/2 \rceil}\underbrace{0 \dots 0}_{\lfloor n/2 \rfloor}\\

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 \\
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}
\end{array}
which gives :
digits.gif
digits.gif (4.39 KiB) Viewed 1858 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 :

Code: Select all

\begin{array}{rcll} 
a_1 &=& \underbrace{0 \ldots \ldots\ldots\ldots\ldots\ldots\ldots\ldots\ldots\ldots \ldots\ldots 0}_{n-1}1\\
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 \\
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}\\
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 \\
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}
\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.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
Post Reply