[Tex/LaTex] how to align texts in equation cases

aligncasesequations

I need to make an equation case with text following it. That text should be displayed in the middle of the two cases. This is my code:

 \begin{eqnarray}\label{eq13}
  a_k =
  \begin{cases}
  1 & \text{if $f_i$ has a value $v_k$}, \\
  0 & \text{otherwise}
  \end{cases}
  \text{$f_i$ is a non-binary feature, \\$k=1,...,n$}
 \end{eqnarray}

It wouldn't work, I want to begin a new line with $k=1,...,n$, since it sticks out of the page. I am using ACM format. How can I solve the problem?

Best Answer

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{align}\label{eq13}
  a_k =
  \begin{cases}
  1 & \text{if $f_i$ has a value $v_k$}, \\
  0 & \text{otherwise}
  \end{cases}
  \text{\quad\parbox{0.4\linewidth}{$f_i$ is a non-binary feature,\\ $k=1,...,n$}}
 \end{align}

\end{document}

enter image description here