5

I have the following equation:

\begin{equation}
    C_k = \frac{1}{N}\sum\limits_{n=1}^N k_n           for k \in {1,\dots,K}
\end{equation}

How can I get the for, and everything after it, to stand 'separate' from the equation?

9

You can use \quad to add a space (or \qquad if you want it bigger) and \text{} to insert some text in your equation in a way that it is not typeset in displaymath style. Remember also to insert a space right after the text with\ or to add it inside the text like \text{for }.

\begin{equation}
    C_k = \frac{1}{N}\sum\limits_{n=1}^N k_n \quad \text{for}\  k \in \{1,\dots,K\}
\end{equation}

enter image description here

  • 3
    I'd go “all the way”: \text{for $k\in\{1,\dots,K\}$} so you don't risk forgetting spaces. I'd also add a comma after the main part of the formula (but this is only personal preference). I'd also suppress “for”, probably. – egreg Sep 24 '13 at 11:06
  • @egreg never thought of using this solution.. nice! – Red Sep 24 '13 at 11:08
  • In this case it's not so important, as there is only one space to take care of. In other cases it can be much handier. – egreg Sep 24 '13 at 11:09
  • I would use \qquad to get a more visual separation. See my answer below. – daleif Sep 24 '13 at 11:38
3

I tend to do this

\newcommand\qqtext{\qquad\text}
\begin{equation}
    C_k = \frac{1}{N}\sum\limits_{n=1}^N k_n   \qqtext{for $k \in {1,\dots,K}$}
\end{equation}

Note that I include the entire for... part inside the \qqtext{...}, because semantically this is where it belongs.

This way I ensure I always have the same distance for the conditions. I also tend to use the following macros

\newcommand\qtextq[1]{\quad\text{#1}\quad} % for 'and' between eqs
\newcommand\qtext{\quad\text}  % when there is not enough space for \qqtext

Plus possibly e versions using \enspace instead of \quad.

I tend to hide these spacings inside macros in order to make the general text easier to read (less typographic noise).

enter image description here

1

I usually use the align environment for this, this is especially useful if there's more than one line and you want all of them to be aligned the same way. The & specifies where to align.

\begin{align}
    C_k &= \frac{1}{N}\sum\limits_{n=1}^N k_n & &\text{for}\ k \in {1,\dots,K}
\end{align}

enter image description here

  • 1
    Using an align structure for the purpose at hand is borderline overkill. Using align for a single-line equation can also create inferior vertical spacing compared with an environment such as equation. – Mico Sep 24 '13 at 11:43

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.