How to justify an element in matrix

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.$

-
Another way would be to replace +\infty with +\infty\hfill. This will move the +\infty to the left as desired. – Peter Grill Sep 17 '12 at 5:56
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – Jubobs Jan 12 '14 at 13:41

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}


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

-
The formula works correctly in Latex. However, I'm not sure if I can export it to other environments such as MathType or not. By the way, thank you for your help. – remo Sep 17 '12 at 5:19

You can use an array instead, and then indicate the column specification. For example, using @{}lc produces a similar layout to your matrix yet left-aligned:

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
${{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.$

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

\end{document}


The excessive use of \left and \right is not required. It introduces unwanted spacing and doesn't add any value. Consider using less-invasive constructions like \bigl and \bigr.

-
But When I paste your code in MathType, it does not change the display. – remo Sep 17 '12 at 5:08