Overleaf Equations – How to Tidy Up Equations in Overleaf?

equationsoverleaf

I would like to write two equations (R3 and R4) in overleaf.

expected equations
Since I use a template which are in two column format, the equations become untidy as in the screenshot.

Here is the code:

\begin{equation} \label{eq:R3}
R_3(i) = 
 \begin{cases} 
  (q_i.c_i + (1-q_i)p_i + (n+1)w + nv)(\frac{q_i}{m_i-z_i} +\frac{(1-q_i)}{m_i-z_i})  & \text{if } i \geq (n-1) \\
  (q_n.p_n + (1-q_n)c_n + (n+1)w + nv)(\frac{q_n}{m_n-z_n} +\frac{(1-q_n)}{m_n-z_n})       & \text{if } i = n
 \end{cases}\end{equation}

\begin{equation} \label{eq:R4}
R_4(i) = 
 \begin{cases} 
  (q_i.p_i + (1-q_i)c_i + (n+3)w + (n+2)v)(\frac{q_i}{z_i+1} +\frac{(1-q_i)}{z_i+1})  & \text{if } i \geq (n-1) \\
  (q_n.c_n + (1-q_n)p_n + (n+3)w + (n+2)v)(\frac{q_n}{z_n+1} +\frac{(1-q_n)}{z_n+1})       & \text{if } i = n
 \end{cases}\end{equation}

Then, here is the preview.
preview

Do you have any idea how to make these equations tidier ?
I am thinking to make the font smaller however I am not sure what to do.

Thank you.

Best Answer

wrap and small fontsize

\documentclass{IEEEtran}
\usepackage{tabularray}
\usepackage{amsmath}
\usepackage{showframe}
\usepackage{lipsum}
\begin{document}
\lipsum[1-6]
\begin{equation}\label{eq:R3}
\small
R_3(i) =
\begin{cases}
\begin{tblr}{colspec={l},colsep={0pt}}(q_i.c_i + (1-q_i)p_i + (n+1)w + nv) \\ \times(\frac{q_i}{m_i-z_i} +\frac{(1-q_i)}{m_i-z_i})\end{tblr} & \text{if } i \geq (n-1) \\
\begin{tblr}{colspec={l},colsep={0pt}}(q_n.p_n + (1-q_n)c_n + (n+1)w + nv) \\ \times(\frac{q_n}{m_n-z_n} +\frac{(1-q_n)}{m_n-z_n})\end{tblr} & \text{if } i = n
\end{cases}
\end{equation}

\begin{equation}\label{eq:R4}
\footnotesize
R_4(i) =
\begin{cases}
\begin{tblr}{colspec={l},colsep={0pt}}(q_i.p_i + (1-q_i)c_i + (n+3)w + (n+2)v) \\ \times(\frac{q_i}{z_i+1} +\frac{(1-q_i)}{z_i+1})\end{tblr} & \text{if } i \geq (n-1) \\
\begin{tblr}{colspec={l},colsep={0pt}}(q_n.c_n + (1-q_n)p_n + (n+3)w + (n+2)v) \\ \times(\frac{q_n}{z_n+1} +\frac{(1-q_n)}{z_n+1})\end{tblr} & \text{if } i = n
\end{cases}
\end{equation}
\par\lipsum[1]
\end{document}

enter image description here

double column equation

\documentclass{IEEEtran}
\usepackage{cuted}
\usepackage{amsmath}
\usepackage{showframe}
\usepackage{lipsum}
\begin{document}
\lipsum[1-2]
\begin{strip}
\begin{equation}\label{eq:R3}
R_3(i) =
\begin{cases}
(q_i.c_i + (1-q_i)p_i + (n+1)w + nv)(\frac{q_i}{m_i-z_i} +\frac{(1-q_i)}{m_i-z_i}) & \text{if } i \geq (n-1) \\
(q_n.p_n + (1-q_n)c_n + (n+1)w + nv)(\frac{q_n}{m_n-z_n} +\frac{(1-q_n)}{m_n-z_n}) & \text{if } i = n
\end{cases}
\end{equation}
\begin{equation}\label{eq:R4}
R_4(i) =
\begin{cases}
(q_i.p_i + (1-q_i)c_i + (n+3)w + (n+2)v)(\frac{q_i}{z_i+1} +\frac{(1-q_i)}{z_i+1}) & \text{if } i \geq (n-1) \\
(q_n.c_n + (1-q_n)p_n + (n+3)w + (n+2)v)(\frac{q_n}{z_n+1} +\frac{(1-q_n)}{z_n+1}) & \text{if } i = n
\end{cases}
\end{equation}
\end{strip}
\lipsum[4-7]
\end{document}

enter image description here