4

I have a project, I must use align*, but I have problem with it superficiality.

    \begin{align*}
        \span {n \choose n_{1}} &&\times&& {n-n_{1} \choose n_{2}} &&\times&& \cdots &&\times&& {n_{k} \choose n_{k}}\\
        &= \frac{n!}{n_{1}!(n-n_{1})!} &&\times&& \frac{(n-n_{1})!}{n_{2}!((n-n_{1})!-n_{2})!} &&\times&& \cdots &&\times&& \frac{n_{k}!}{n_{k}!1!}\\
        &= \frac{n!}{n_{1}!n_{2}! ... n_{k}!} \span\span\span\span\span\span
    \end{align*}

for above code I get this output:

enter image description here

but I want some thing like:

enter image description here

I tried \centering but it doesn't work and I tried \mkern+/-xmu but it doesn't have functionality,if text size or font is changed, then the superficiality result would change too.

Mico
  • 506,678
ryhn
  • 41

5 Answers5

5

You can set content is similarly-sized boxes; this is automated using \eqmathbox[<tag>][<align>]{<stuff>} where the default <align>ment is centred.

enter image description here

\documentclass{article}

\usepackage{amsmath,eqparbox}

% https://tex.stackexchange.com/a/34412/5764 \makeatletter \NewDocumentCommand{\eqmathbox}{o O{c} m}{% \IfValueTF{#1} {\def\eqmathbox@##1##2{\eqmakebox[#1][#2]{$##1##2$}}} {\def\eqmathbox@##1##2{\eqmakebox{$##1##2$}}} \mathpalette\eqmathbox@{#3} } \makeatother

\begin{document}

\begin{alignat}{4} \eqmathbox[box1]{\binom{n}{n_1}} & {}\times{} & \eqmathbox[box2]{\binom{n - n_1}{n_2}} & {}\times{} & \cdots & {}\times{} & \eqmathbox[box3]{\binom{n_k}{n_k}} \ = \eqmathbox[box1]{\frac{n!}{n_1! (n - n_1)!}} & {}\times{} & \eqmathbox[box2]{\frac{(n - n_1)!}{n_2!((n - n_1)! - n_2)!}} & {}\times{} & \cdots & {}\times{} & \eqmathbox[box3]{\frac{n_k!}{n_k!1!}} \ = \eqmathbox[box1]{\frac{n!}{n_1! n_2! \dots n_k!}} \end{alignat}

\end{document}

Werner
  • 603,163
4

With array:

enter image description here

\documentclass{article}

\begin{document} [\setlength\arraycolsep{2pt} \begin{array}{*{8}{c}} & {n \choose n_{1}} & \times & {n-n_{1} \choose n_{2}} & \times & \cdots &\times & {n_{k} \choose n_{k}} \[2ex] = & \frac{n!}{n_{1}!(n-n_{1})!} & \times & \frac{(n-n_{1})!}{n_{2}!((n-n_{1})!-n_{2})!} & \times & \cdots & \times & \frac{n_{k}!}{n_{k}!1!} \[2ex] = & \frac{n!}{n_{1}!n_{2}! ... n_{k}!}& & & & & \end{array} ] \end{document}

Edit: Considering @Mico suggestion to use \displaymath equation size:

enter image description here

\documentclass{article}
\usepackage{amsmath}

\begin{document} [\setlength\arraycolsep{1pt} \begin{array}{*{8}{>{\displaystyle}c}} & \binom{n}{n_{1}} & \times & \binom{n-n_{1}}{n_{2}} & \times & \cdots &\times & \binom{n_{k}}{n_{k}} \[3ex] = & \frac{n!}{n_{1}!(n-n_{1})!} & \times & \frac{(n-n_{1})!}{n_{2}!((n-n_{1})!-n_{2})!} & \times & \cdots & \times & \frac{n_{k}!}{n_{k}!1!} \[3ex] = & \frac{n!}{n_{1}!n_{2}! ... n_{k}!}& & & & & \end{array} ] \end{document}

Zarko
  • 296,517
  • You may want to use display math mode rather than inline math mode for the binomials and the \frac expressions. – Mico Sep 08 '21 at 06:50
  • @Mico, I left math terms as were written by OP. I will add suggested form ASAP. – Zarko Sep 08 '21 at 06:58
4

You say you "must use align". However, I can see no reason for not using an array environment, with automatic display math mode and two custom column types. Oh, and do please use \binom{...}{...} rather than { ... \choose ...}.

enter image description here

\documentclass{article}
\usepackage{array}   % for '\newcolumntype' macro
\newcolumntype{C}{>{\displaystyle}c}  % automatic display-math mode
\newcolumntype{O}{>{{}}c<{{}}} % column type for math operators
\usepackage{amsmath} % for '\binom' macro

\begin{document} [ \setlength\arraycolsep{0pt} \begin{array}{ *{4}{OC} } & \binom{n}{n_{1}} &\times& \binom{n-n_{1}}{n_{2}} &\times& \cdots &\times& \binom{n_{k}}{n_{k}} \[15pt] = & \frac{n!}{n_{1}!,(n-n_{1})!} &\times& \frac{(n-n_{1})!}{n_{2}!,((n-n_{1})!-n_{2})!} &\times& \cdots &\times& \frac{n_{k}!}{n_{k}!,1!} \[12pt] = & \frac{n!}{n_{1}!,n_{2}! \dots n_{k}!} \end{array} ] \end{document}

Mico
  • 506,678
2

With a single alignment point and also eqparbox:

\documentclass{article}
\usepackage{amsmath}
\usepackage{eqparbox} 
\newcommand{\eqmathbox}[2][M]{\eqmakebox[#1]{$\displaystyle#2$}}

\begin{document}

\begin{align} \eqmathbox[M1]{\binom {n}{n_1}}& \times \eqmathbox[M2]{\binom {n-n_1}{n_2}} \times \cdots \times \eqmathbox[M3]{\binom{n_k}{ n_k}}\[0.5ex] = \eqmathbox[M1]{\frac{n!}{n_1!(n-n_1)!}} & \times \eqmathbox[M2]{\frac{(n-n_1)!}{n_2!((n-n_1)!-n_2)!}} \times \cdots \times \eqmathbox[M3]{\frac{n_k!}{n_k!,1!}}\ = \eqmathbox[M1]{\frac{n!}{n_1!,n_2! ... n_k!} } \end{align}

\end{document}

enter image description here

Bernard
  • 271,350
1

Here are my solutions, the latter being similar to, but distinct from, Mico’s.

\documentclass{article}
\usepackage{amsmath}
\usepackage{array,booktabs}

\begin{document}

I usually start from the assumption that readers can read, pairing up the terms by themselves, so large white space around operation symbols can be avoided. \begin{multline} \binom{n}{n_{1}} \times \binom{n-n_{1}}{n_{2}} \times \dots \times \binom{n_{k}}{n_{k}} \ \begin{aligned} &= \frac{n!}{n_{1}!,(n-n_{1})!} \times \frac{(n-n_{1})!}{n_{2}!,((n-n_{1})-n_{2})!} \times \cdots \times \frac{n_{k}!}{n_{k}!,1!}\ &= \frac{n!}{n_{1}!,n_{2}! \dots n_{k}!} \end{aligned} \end{multline} However, you can center the corresponding terms, if you so prefer; an accurate comparison will tell you which display to use. \begin{equation} \setlength{\arraycolsep}{0pt} % let TeX do the spacing job \begin{array}{ @{} >{{}}c<{{}} % operator or relation >{\displaystyle}c % term >{{}}c<{{}} % operator or relation >{\displaystyle}c % term >{{}}c<{{}} % operator or relation >{\displaystyle}c % term >{{}}c<{{}} % operator or relation >{\displaystyle}c % term @{} } & \binom{n}{n_{1}} &\times& \binom{n-n_{1}}{n_{2}} &\times& \dotsb &\times& \binom{n_{k}}{n_{k}} \ \addlinespace =& \frac{n!}{n_{1}!,(n-n_{1})!} &\times& \frac{(n-n_{1})!}{n_{2}!,((n-n_{1})-n_{2})!} &\times& \dotsb &\times& \frac{n_{k}!}{n_{k}!,1!} \ \addlinespace =& \multicolumn{7}{>{\displaystyle}l}{\frac{n!}{n_{1}!,n_{2}! \dots n_{k}!}} \end{array} \end{equation} Some filler text at the end, with the repeated recommendation to use the first display and not the second one. Oh, I fixed a wrong factorial removing it.

\end{document}

Please, read the commentary.

enter image description here

egreg
  • 1,121,712