6

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

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.

  • 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
2

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:

enter image description here

\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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.