0

I have the following in LaTeX:

v_{i}=\frac{ 1}{ n}\sum_{j=1}^{n}\left(\mu_{ij} \right)^{m}x_{j}\hspace where\hspace n_{i}=\sum_{j=1}^{n}\left(\mu_{ij}\right)^{m}

How can I make a space before and after where?

I tried \hspace, but seems didn't work.

azetina
  • 28,884
Simplicity
  • 1,305
  • Try \quad or \qquad – azetina Dec 03 '13 at 20:30
  • The \hspace macro takes an argument: \hspace{<length>}. For example: \hspace{.5em} or \hspace{2cm}. Also, you shouldn't use text in math-mode. After loading the amsmath/amstext package, you can use \text{ where }. – Qrrbrbirlbel Dec 03 '13 at 20:35

2 Answers2

6

Rules of thumb:

  • Never type text in math mode.
  • Never type math in text mode.

Your code can be written in two ways:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ v_{i}=\frac{ 1}{ n}\sum_{j=1}^{n}\left(\mu_{ij} \right)^{m}x_{j} \text{ where } n_{i}=\sum_{j=1}^{n}\left(\mu_{ij}\right)^{m} \]
\end{document}

or

\documentclass{article}
\begin{document}
Inline math looks like $v_{i}=\frac{ 1}{ n}\sum_{j=1}^{n}\left(\mu_{ij} \right)^{m}x_{j}$ where $n_{i}=\sum_{j=1}^{n}\left(\mu_{ij}\right)^{m}$.
\end{document}
marczellm
  • 11,809
5

Some standard spacing in math mode include \quad or \qquad but using \hspace{<length>} is possible:

enter image description here

\documentclass[letterpaper]{article}
\usepackage{mleftright}
\usepackage{amsmath}
\begin{document}
\[
v_{i}=\frac{1}{n}\sum_{j=1}^{n}\mleft(\mu_{ij} \mright)^{m}x_{j}\quad \text{where}\hspace{2em} n_{i}=\sum_{j=1}^{n}\mleft(\mu_{ij}\mright)^{m}
\]
\[
v_{i}=\frac{1}{n}\sum_{j=1}^{n}\left(\mu_{ij} \right)^{m}x_{j}\quad \text{where}\hspace{2em} n_{i}=\sum_{j=1}^{n}\left(\mu_{ij}\right)^{m}
\]
\end{document}

The MWE above illustrates the effects of the use of \left and \right. For that, you can consider using the mleftright package by Heiko Oberdiek:

The pack­age de­fines vari­ants \mleft and \mright of \left and \right, that make the de­lim­iters act as \math­open and \math­close. Th­ese com­mands ad­dress spac­ing dif­fi­cul­ties in sub­for­mu­las.

Read Spacing around \left and \right for an interesting discussion about this.

azetina
  • 28,884