# multiple alignment inside cases environment

How can i use multiple alignment inside cases environment? i tired to use alignat, align* ... but it seems that they dont work inside equation environment.

\label{eq:13} \begin{aligned} W_{ij} = \begin{cases} tf_{ij} \times \log \left( \frac{N}{n_i} \right) &if\quad &AW_i = 0\\ AW_i \times tf_{ij} \times \log \left( N/ n_i \right) &if\quad 0<&AW_i<1\\ \left(1 + \log \left( AW_i \right) \right) \times tf_{ij} \times \log \left(\frac{N}{n_i} \right) &if\quad &AW_i \geq 1 \end{cases} \end{aligned}


when i insert second & for each case it returns error !

Basically, use only & symbol per row. If this were might document, I'd stick with the default layout for the right-hand column of the cases environment, which is left alignment of the material. For sure, you can't used an aligned environment to achieve your formatting objective.

Two additional comments: (i) Use \left and \right only sparingly. (ii) Try to keep your notation consistent. At times, you use \frac{N}{n_i}, while at others you write N/n_i. In the present context, I'd use the latter, i.e., inline-fraction notation.

Note also that I changed all instances of tf_{ij} in your code to \mathit{tf}_{\!ij}, both to tighten up the appearance of tf and to "snug up" the subscript term to its base. If you have a lot of instances of tf{ij}, you may want to create a shorthand macro, say, \newcommand\tfij{\mathit{tf}_{\!ij}}, and then replace all instances of tf_{ij} in your document with \tfij.

\documentclass{article}
\usepackage{amsmath} % for 'cases' env. and '\text' macro
\begin{document}
$$\label{eq:13} W_{ij} = \begin{cases} \mathit{tf}_{\!ij} \times \log(N/n_i) & \text{if AW_i = 0}\\ AW_i \times \mathit{tf}_{\!ij} \times \log(N/n_i) & \text{if 0<AW_i<1}\\ (1 + \log AW_i) \times \mathit{tf}_{\!ij} \times \log(N/n_i) & \text{if AW_i \geq 1} \end{cases}$$
\end{document}


Addendum: For the case at hand (pun intended), what you may want to think about, in terms of changing the layout, is to right-align the material in the first column of the cases environment.

\documentclass{article}
\usepackage{amsmath} % for 'cases' env. and '\text' macro
\newcommand\tfij{\mathit{tf}_{\!ij}}
\begin{document}

$$\label{eq:13a} W_{ij} = \begin{cases} \hfill \tfij \times \log(N/n_i) & \text{if AW_i = 0}\\ \hfill AW_i \times \tfij \times \log(N/n_i) & \text{if 0<AW_i<1}\\ (1 + \log AW_i) \times \tfij \times \log(N/n_i) & \text{if AW_i \geq 1} \end{cases}$$
\end{document}


Second addendum, to address the OP's follow-up comment: To achieve the desired special alignment of the material in the second column of the cases environment, I suggest you use \phantom statements in rows 1 and 3.

\documentclass{article}
\usepackage{amsmath} % for 'cases' env. and '\text' macro
\newcommand\tfij{\mathit{tf}_{\!ij}}
\begin{document}

$$\label{eq:13aa} W_{ij} = \begin{cases} \hfill \tfij \times \log(N/n_i) & \text{if \phantom{0<{}}AW_i = 0}\\ \hfill AW_i \times \tfij \times \log(N/n_i) & \text{if 0<AW_i<1}\\ (1 + \log AW_i) \times \tfij \times \log(N/n_i) & \text{if \phantom{0<{}}AW_i \geq 1} \end{cases}$$
\end{document}

• Thanks alot for your comments. But i would like to have two alignments symbol for each case. One before "if" and another one before "AW". – DAkbariSE Apr 28 '18 at 7:15
• @danitiger33 - I've posted an addendum to show how your specific alignment needs might be met. Incidentally, IMNSHO, $0=AW_i$ would look better than $\phantom{0<{}}AW_i = 0$. – Mico Apr 28 '18 at 7:24