1

For the sake of example, how can I construct (line by line) two Pascal triangles that are next to each other?

Here is an example of how I need to position parts of AMS equation (either multiline or single line but I'm looking for a way that would be flexible enough to work for both types):

                  1                                  1
                 1 1                                1 1
                1 2 1                              1 2 1
               1 3 3 1                            1 3 3 1

As you can see I can't afford using alignment operator (&) because it would ruin the centering. I also have no clue how to divide a line in two independent parts. Any suggestions are appreciated. Thanks for your time.

Ben
  • 501

1 Answers1

3

The simplest way to do this is to use an array inside your math environment with centered columns.

\documentclass{article}
\begin{document}
\[
\setlength{\arraycolsep}{3em}
\begin{array}{c c}
1                   & 1                   \\
1\quad1             & 1\quad1             \\
1\quad2\quad1       & 1\quad2\quad1       \\
1\quad3\quad3\quad1 & 1\quad3\quad3\quad1 \\
\end{array}
\]
\end{document}

Output:

array

If you really want or need to use the align environment here is another solution. I defined a new macro that shifts its content by half its width to the left. The output looks basically like the output of the second solution.

\documentclass{article}
\usepackage{amsmath}

\newlength{\contentwidth}
\newcommand\centerwithin[1]{%
    \settowidth{\contentwidth}{\ensuremath{#1}}\relax%
    \hspace{-0.5\contentwidth}#1%
}

\begin{document}
\begin{align*}
    &\centerwithin{1}                   & &\centerwithin{1}                   \\
    &\centerwithin{1\quad1}             & &\centerwithin{1\quad1}             \\ 
    &\centerwithin{1\quad2\quad1}       & &\centerwithin{1\quad2\quad1}       \\
    &\centerwithin{1\quad3\quad3\quad1} & &\centerwithin{1\quad3\quad3\quad1} \\
\end{align*}
\end{document}

Original Answer:

Not a very nice solution. More a proof of concept, that it is possible to use the align environment as it is.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
           &1                  &            &1                 \\
    1      &\enskip 1          &          1 &\enskip 1         \\
  1\enskip &2\enskip 1         &   1\enskip &2\enskip 1        \\
1\enskip 3 &\enskip 3\enskip 1 & 1\enskip 3 &\enskip 3\enskip 1\\
\end{align*}
\end{document}

Output:

align

Benjamin
  • 4,781
  • 1
    Note there's a problem as soon as the binomial coefficients have more than one digit: the sides of the triangle are curved. – Bernard Feb 04 '16 at 10:26
  • 1
    Sure you are right. But as I understood the question it is not really about the pascal triangles, but about centering two parts of an equation on the left and right. – Benjamin Feb 04 '16 at 12:56
  • 1
    There is already a question with very good answers here on SE on how to create Pascal's triangles with tikz. If someone wants to create Pascal's triangles using tikz is imho the way to go. And \phantom is by the way not the solution to the curved sides. Every entry has to be put into a box. E. g. with this command \newcommand{\mybox}[1]{\makebox[1.5em]{\ensuremath{#1}}}. – Benjamin Feb 04 '16 at 20:03