# How to tidy the equation in overleaf

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

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

Here is the code:

$$\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}$$

$$\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}$$



Then, here is the 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.

• Welcome to the TEX.SE. community. What is the minimal complete example to reproduce your screenshot? Please can you glue in your question? Jan 24 at 10:37
• It is probably better to rephrase especially since you are working in two columns and thus have much more limited space. Jan 24 at 10:48
• Hi @Sebastiano, I added the expected equation on this page. Is that what you meant? Hi Daleif, what is meant by "to rephrase"? Any example, perhaps? Thank you. Jan 24 at 11:06
• What document class are you using? Jan 24 at 11:53
• Hi @egreg, it is \documentclass[journal]{IEEEtran}. Jan 25 at 6:40

# wrap and small fontsize

\documentclass{IEEEtran}
\usepackage{tabularray}
\usepackage{amsmath}
\usepackage{showframe}
\usepackage{lipsum}
\begin{document}
\lipsum[1-6]
$$\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}$$

$$\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}$$
\par\lipsum[1]
\end{document}


# double column equation

\documentclass{IEEEtran}
\usepackage{cuted}
\usepackage{amsmath}
\usepackage{showframe}
\usepackage{lipsum}
\begin{document}
\lipsum[1-2]
\begin{strip}
$$\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}$$
$$\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{strip}
\lipsum[4-7]
\end{document}


Typesetting such big formulas in two-column format often requires some comprimise.

Here the compromise is to split the longish parts and give up with cases, so pushing the conditions under the longer top part.

Using newtxmath not only ensures consistency between text and math fonts, but also makes the math narrower.

Note. showframe and lipsum are used only for debugging. The former adds the frames as seen in the picture.

\documentclass[journal]{IEEEtran}
\usepackage{amsmath,mathtools}
\usepackage{newtxtext,newtxmath}

\usepackage{showframe,lipsum}

\begin{document}

\lipsum*[1][1-3]
\begin{align}
\label{eq:R3}
\hspace{-0.5em}
R_3(i) &=
\left\lbrace
\begin{aligned}
&\mathmakebox[0.5\columnwidth][l]{(q_i.c_i + (1-q_i)p_i + (n+1)w + nv)} \\[0.5ex]
&\cdot\left(\frac{q_i}{m_i-z_i} +\frac{1-q_i}{m_i-z_i}\right)
&& \text{if } i \geq n-1
\\[2ex]
&\mathmakebox[0.5\columnwidth][l]{(q_n.p_n + (1-q_n)c_n + (n+1)w + nv)} \\[0.5ex]
&\cdot\left(\frac{q_n}{m_n-z_n} +\frac{1-q_n}{m_n-z_n}\right)
&& \text{if } i = n
\end{aligned}
\right.
\\
\label{eq:R4}
\hspace{-0.5em}
R_4(i) &=
\left\lbrace
\begin{aligned}
&\mathmakebox[0.5\columnwidth][l]{(q_i.p_i + (1-q_i)c_i + (n+3)w + (n+2)v)} \\[0.5ex]
&\cdot\left(\frac{q_i}{z_i+1} +\frac{1-q_i}{z_i+1}\right)
&& \text{if } i \geq n-1
\\[2ex]
&\mathmakebox[0.5\columnwidth][l]{(q_n.c_n + (1-q_n)p_n + (n+3)w + (n+2)v)} \\[0.5ex]
&\cdot\left(\frac{q_n}{z_n+1} +\frac{1-q_n}{z_n+1}\right)
&& \text{if } i = n
\end{aligned}
\right.
\end{align}
\lipsum

\end{document}


• Hi @egred, both notations are well written, however there is additional text: Lorem ipsum... same as in your screenshot. What should I do to delete the unnecessarily text? Thank you. Jan 25 at 8:33
• There are missing "are" between two equations in the systeme. Can you see the image in the question? Jan 25 at 9:07
• @NicholasTI Just remove the \lipsum commands. I removed the “and” between the cases, because it's not customary to have it: the brace already tells the reader about it. Jan 25 at 9:10
• Thank you @egred Jan 25 at 9:14
• Hi @clara, do you mind taking a look at this question: tex.stackexchange.com/q/678591/288908 , please? Thank you. Mar 8 at 3:38

I'd like to suggest that you load the mathtools package -- a superset of the amsmath package -- and employ \mathrlap wrappers and dcases environments, both provided by the mathtools package.

\documentclass[journal]{IEEEtran}
\usepackage{mathtools}   % for '\mathrlap' macro and 'dcases' env.
\usepackage{newtxtext,newtxmath} % Times Roman text and math font clones
\usepackage{lipsum}      % filler text
\begin{document}
\lipsum[1] % a paragraph of filler text
\begin{align}
R_3(i) &=
\begin{dcases}
\mathrlap{\bigl(q_i c_i + (1-q_i)p_i + (n+1)w + nv\bigr)} \\
& \text{if $1\le i<n$} \\[1ex]
\mathrlap{\bigl(q_n p_n + (1-q_n)c_n + (n+1)w + nv)} \\
& \text{if $i=n$}
\end{dcases} \label{eq:R3} \\[1.5ex]
R_4(i) &=
\begin{dcases}
\mathrlap{\bigl(q_i p_i + (1-q_i)c_i + (n+3)w + (n+2)v\bigr)} \\
& \text{if $1\le i<n$} \\[1ex]
\mathrlap{\bigl(q_n c_n + (1-q_n)p_n + (n+3)w + (n+2)v\bigr)}\\
& \text{if $i=n$}

• @NicholasTI - Just omit the directives \lipsum[1] and \lipsum.