3

I will like to reduce the space between the statement and the condition (the blue arrow length) in the latex case equation shown in the attached figure. My aim is to make the condition move a bit to the left to accommodate the equation number which was obscured by the length of the equation. I will want to also maintain the vertical alignment between the "if"s after space reduction(note, I am working on two-column IEEEtrans template)

\begin{numcases}{G(t,i) =}
    0, & $\text{if } t = 1$; \\
    \pi_2 (O(t)), & $\text{if }G(t-1,i) \leq0$;\\
    G(t-1,i) + \pi_{2} (O(t)), & $\text{otherwise}$.
\end{numcases}

enter image description here

  • Welcome to TeX SX! You can't really, as the three conditions are vertically aligned. If you don't want them to be aligned, you can use the empheq package to do it. – Bernard Jun 9 '17 at 10:09
  • @Bernard shouldn't there be a way to move the three conditions at the same time while keeping their alignment. Like moving them all a little bit to the right. If this is still not possible, it there a way to force this equation to fit into one column. – obiigbe91 Jun 9 '17 at 10:14
4

You can, but you won't save much space. Here is an example with \mathrlap from mathtools (needless to load amsmath). I also simplified your code, and added another solution, which looks better, in my opinion:

\documentclass[12pt,a4paper]{article}
\usepackage{mathtools, cases}

\begin{document}

\begin{numcases}{G(t,i) =}
  0, & if $ t = 1$; \\
  \pi₂ (O(t)), & if $ G(t-1,i) \leq0$;\\
  G(t-1,i) + \pi_{2} (O\mathrlap{(t))}, & otherwise.
\end{numcases}

\begin{numcases}{G(t,i) =}
  0, & $\text{if } t = 1$; \\
  \pi₂ (O(t)), & $\text{if }G(t-1,i) \leq0$;\\
  G(t-1,i) + \mathrlap{\pi_{2} (O(t)),\quad \text{otherwise}}.
\end{numcases}

\end{document} 

enter image description here

  • Thanks, @Bernard, I followed the second option you suggested. – obiigbe91 Jun 9 '17 at 18:25
4

You can save much space if you write the third case over two lines. You can use an array-like environment for this.

\documentclass[12pt,a4paper]{article}
\usepackage{mathtools, cases}

\begin{document}

\begin{numcases}{G(t,i) =}
    0, & $\text{if } t = 1$; \\
    \pi_2 (O(t)), & $\text{if }G(t-1,i) \leq0$;\\
    G(t-1,i) + \pi_{2} (O(t)), & $\text{otherwise}$.
\end{numcases}

\begin{numcases}{G(t,i) =}
  0,                         & $\text{if } t = 1$; \\
  \pi(O(t)),                 & $\text{if }G(t-1,i) \leq0$;\\
  \begin{array}[b]{@{}l@{}}G(t-1,i)\\      
  {}+\pi_2(O(t)),\end{array} & \text{otherwise}. 
\end{numcases}

\end{document} 

enter image description here

2

I guess you are in a two column setup.

\documentclass[twocolumn]{article}

\usepackage{amsmath,empheq}
\usepackage{eqparbox} % for the second example

\usepackage{lipsum} % for context

\newcommand{\meq}[2]{%
  \eqmakebox[#1][s]{$\displaystyle#2$}%
}


\begin{document}

\lipsum*[2]
\begin{empheq}[left={G(t,i)=\empheqlbrace}]{align}
 & 0,\quad\text{if $t = 1$}; \\
 & \pi_2 (O(t)),\quad\text{if $G(t-1,i) \leq0$};\\
 & G(t-1,i) + \pi_{2} (O(t)),\quad\text{otherwise}.
\end{empheq}
\lipsum*[3]
\begin{empheq}[left={G(t,i)=\empheqlbrace}]{align}
 & \meq{A}{0,\hfill\text{if $t = 1$};} \\
 & \meq{A}{\pi_2 (O(t)),\hfill\text{if $G(t-1,i) \leq0$};}\\
 & \meq{A}{G(t-1,i) + \pi_{2} (O(t)),\quad\text{otherwise}.}
\end{empheq}
\lipsum[4-10]

\end{document}

The \meq approach requires an arbitrary tag as the first argument, which must be different for each case; so, if you have another similar equation, use B or whatever.

As you see, the longest line has to be selected “manually” for setting the separation.

enter image description here

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.