[Tex/LaTex] How to justify an element in matrix

horizontal alignmentmatrices

I have a formula in LaTeX attached below. But I could not justify the position of $+\infty$ symbol. I want it appear just after the $\{$ and aligns to the left of the second term.

The LaTeX Code:

${{R}_{1}}\left( {{x}_{pi}},{{G}_{q}},{{x}_{qj}} \right)=\,\left\{ \begin{matrix}
   +\infty  & p=q  \\
   \underset{l=1}{\overset{d}{\mathop \sum }}\,({{x}_{pi}}\left[ l \right]-{{x}_{qj}}\left[ l \right])\left( 2\left( {{x}_{qj}}\left[ l \right]-{{{\bar{x}}}_{q}}\left[ l \right] \right)+({{x}_{pi}}\left[ l \right]-{{x}_{qj}}\left[ l \right])(\left| {{G}_{q}} \right|-1)/|{{G}_{q}}| \right) & p\ne q  \\
\end{matrix} \right.$

Best Answer

I would use a cases environment (from the amsmath package):

\documentclass[10pt]{article}
\usepackage{amsmath}

\begin{document}

\[
{{R}_{1}}( {{x}_{pi}},{{G}_{q}},{{x}_{qj}} ) = 
\begin{cases}
   +\infty  & p=q  \\
   \sum\limits_{l=1}^{d}\,({{x}_{pi}}[ l ]-{{x}_{qj}} [ l ])\bigl( 2( {{x}_{qj}} [ l ]-{{{\bar{x}}}_{q}} [ l] \bigr)+({{x}_{pi}}[ l ]-{{x}_{qj}} [ l])(\lvert {{G}_{q}} \rvert|-1)/\lvert{{G}_{q}}\rvert ) & p\ne q  \\
\end{cases}
\]

\end{document}

enter image description here

I removed some superfluous \left, \right constructs and replaced one of them with \bigl, \bigr.