0

I would like to ask you on how to give some space (yellow highlighted) inside an equation as below screenshot.

expected

This is the code in overleaf with TeX Live version 2022.

\documentclass[journal]{IEEEtran}
\usepackage{mathtools}
\begin{document}

\begin{equation} \label{eq:R2} R_2(i) = (\frac{1}{m_i})(p_i+c_i+2w) \forall i =1,\ldots,n \end{equation} \end{document}

The current result is as follows. pdf

  • Note that it is often nicer to read if one writes out a symbol like \forall when it is after an equation, aka ... \qquad\text{for all $i=1,\dots,n}, one can even easily make a \For macro that essentially is \qquad\text{....} and thus hide the spacing in it such that is does not clog up your code. – daleif Mar 06 '23 at 12:10

2 Answers2

5

Just add \quad, \qquad etc between the two parts of the equation.

\begin{equation} \label{eq:R2}
R_2(i) = (\frac{1}{m_i})(p_i+c_i+2w) \qquad  \forall i =1,\ldots,n
\end{equation}
Stephen
  • 3,826
1

There are 3 possibilities for you to do this:

  1. Using \quad or \qquad:

Input (Using \quad):

\begin{equation} \label{eq:R2}
    R_2(i) = \left(\frac{1}{m_i}\right)(p_i+c_i+2w) \quad  \forall i =1,\ldots,n
\end{equation}

Output (Using \quad):

enter image description here


Input (Using \qquad):

\begin{equation} \label{eq:R2}
    R_2(i) = \left(\frac{1}{m_i}\right)(p_i+c_i+2w) \qquad  \forall i =1,\ldots,n
\end{equation}

Output (Using \qquad):

enter image description here



  1. Using \hspace{#key}, where #key is some unit of measurement, such as pt, mm, cm, etc:

Input (Using \hspace{1cm}):

\begin{equation} \label{eq:R2}
    R_2(i) = \left(\frac{1}{m_i}\right)(p_i+c_i+2w) \hspace{1cm}  \forall i =1,\ldots,n
\end{equation}

Output (Using \hspace{1cm}):

enter image description here



  1. Using a sigle slash \ sometimes:

Input (Using \ four times):

\begin{equation} \label{eq:R2}
    R_2(i) = \left(\frac{1}{m_i}\right)(p_i+c_i+2w) \ \ \ \  \forall i =1,\ldots,n
\end{equation}

Output (Using \ four times):

enter image description here

Jimeens
  • 617
  • 3
    Note that the two last ones are not recommended. It is never a good idea to have random \hspace's scattered around the code. With \ (backslash space) it is easy to miss one, such that you have inconsistent spacing. Thus it is better to always encourage users to use \quad and \qquad – daleif Mar 06 '23 at 12:08
  • 1
    Personally I prefer to use \hspace{}, because it is simple and convenient, and the spacing control is much simpler to manipulate. If you want equal spacing every time, just define a command, for example \def\hsp{\hspace{1cm}}, and with this you are not bound to the measurements of \quad or \qquad – Jimeens Mar 06 '23 at 12:12
  • 1
    Here is a real life example of why users should not know about \hspace: \chapter{Introduction\hspace{0.2pt}: \hspace{0.4pt}number\hspace{0.4pt}, \hspace{0.6pt}algebra \hspace{0.4pt}and \hspace{0.4pt}complex numbers} \vspace{-18pt} (I have it listed as an example of what not to do in an old talk of mine). Imaging having to be the editor on such a manuscript. – daleif Mar 06 '23 at 12:28
  • 1
    What did you mean to exemplify in this comment? It didn't make any sense to me this usage – Jimeens Mar 06 '23 at 12:49
  • That is what I mean, when users start adding \hspace all over, this is something we end up seeing. So it is better the average user never knows about \hspace. Similarly that the average user should never know that \\ can be used in the text. \hspace should never be used in math. – daleif Mar 06 '23 at 12:53
  • 1
    I understand the confusion for beginners using commands like \hspace{}. But they're valuable for learning; the more they're used, the more users understand their usefulness and use them judiciously. Neglecting them for novices may seem reasonable, but isn't optimal for teaching. – Jimeens Mar 06 '23 at 13:23