2

I have spent some time already trying to fix the way this formula looks, but to no avail. Does anyone have an idea on how to make this look better? Mainly the equation number should fit to the right of the equation.

\begin{flalign} \label{eqRWnaRO}
PGW_i =
&\begin{cases}
   PGW_{max},& \text{if } PGW_{i-1} - Q_{PGW,Use}+ MBR_{rec} \ldots \\ &\quad *Q_{GW} + RO_{rec}*Q_{RW,PGW} \geq PGW_{max}\\
   0,& \text{if } PGW_{i-1} -  Q_{PGW,Use}+ MBR_{rec} \ldots \\ &\quad *Q_{GW} + RO_{rec}*Q_{RW,PGW} \leq 0 \\
   PGW_{i-1} -  Q_{PGW,Use} + MBR_{rec} \ldots \\ \quad *Q_{GW} + RO_{rec}*Q_{RW,PGW},& \text{otherwise}
\end{cases}&& 
\end{flalign}

The resulting equation

  • Welcome to TeX SX! Do you want the equation number be centred w.r.t. the group? – Bernard Apr 14 at 9:30
  • 1
    please post a complete small document not just a fragment, in particular for this question it is important to know the text width. But as a general comment never use math italic for multi-letter words use \mathrm{rec} or \mathit{rec} not rec 9and same for Use, max etc – David Carlisle Apr 14 at 9:36
  • Hi, I used all the replies with great results! For future reference, how do I see text width? I'm new to the TEX scene. – Arjen Apr 14 at 19:49
1

Here is a way, using the \mathrlap command from mathtools at the end of the line which a little too long. I added a variant with a slightly simpler code, using the fleqn environment from nccmath, since you don't seem to have any alignment:

\documentclass{article}
\usepackage{geometry}
\usepackage{mathtools, nccmath}

\begin{document}

\begin{flalign} \label{eqRWnaRO}
PGW_i =
&\begin{cases}
   PGW_{\max},& \text{if } PGW_{i-1} - Q_{PGW,Use}+ MBR_\mathrm{rec} \ldots \\
    &\quad *Q_{GW} + RO_\mathrm{rec}*Q_{RW,PGW} \geq \mathrlap{PGW_{\max}}\\
   0,& \text{if } PGW_{i-1} - Q_{PGW,Use}+ MBR_\mathrm{rec} \ldots \\
    &\quad *Q_{GW} + RO_\mathrm{rec}*Q_{RW,PGW} \leq 0 \\
   PGW_{i-1} - Q_{PGW,Use} + MBR_\mathrm{rec} \ldots \\ \quad *Q_{GW} + RO_\mathrm{rec}*Q_{RW,PGW},& \text{otherwise}
\end{cases}&&
\end{flalign}\bigskip

\begin{fleqn}
\begin{equation}
  \label{eqRWnaRO}
PGW_i =
\begin{cases}
   PGW_{\max},& \text{if } PGW_{i-1} - Q_{PGW,Use}+ MBR_\mathrm{rec} \ldots \\
    &\quad *Q_{GW} + RO_\mathrm{rec}*Q_{RW,PGW} \geq \mathrlap{PGW_{\max}}\\
   0,& \text{if } PGW_{i-1} - Q_{PGW,Use}+ MBR_\mathrm{rec} \ldots \\
    &\quad *Q_{GW} + RO_\mathrm{rec}*Q_{RW,PGW} \leq 0 \\
   PGW_{i-1} - Q_{PGW,Use} + MBR_\mathrm{rec} \ldots \\ \quad *Q_{GW} + RO_\mathrm{rec}*Q_{RW,PGW},& \text{otherwise}
\end{cases}
\end{equation}
\end{fleqn}

\end{document} 

enter image description here

1

I had to guess the line width based on your image, but changes:

avoid math italic for multi-letter names, avoid multi-line constructs like fleqn for single line displays, add a \jot extra space between the lines of the cases, and I also dropped the commas.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\addtolength\textwidth{72pt}% more or less as shown in question
\begin{document}

aaa
\begin{flalign} \label{eqRWnaRO}
PGW_i =
&\begin{cases}
   PGW_{max},& \text{if } PGW_{i-1} - Q_{PGW,Use}+ MBR_{rec} \ldots \\ &\quad *Q_{GW} + RO_{rec}*Q_{RW,PGW} \geq PGW_{max}\\
   0,& \text{if } PGW_{i-1} -  Q_{PGW,Use}+ MBR_{rec} \ldots \\ &\quad *Q_{GW} + RO_{rec}*Q_{RW,PGW} \leq 0 \\
   PGW_{i-1} -  Q_{PGW,Use} + MBR_{rec} \ldots \\ \quad *Q_{GW} + RO_{rec}*Q_{RW,PGW},& \text{otherwise}
\end{cases}&& 
\end{flalign}

bbb
\begin{equation} \label{eqRWnaROb}
\mathrm{PGW}_i =
\begin{cases}
   \mathrm{PGW}_{\max}& \text{if } \mathrm{PGW}_{i-1} - Q_{\mathrm{PGW},\mathrm{Use}}+ \mathrm{MBR}_{\mathrm{rec}} \ldots \\ &\quad *Q_{GW} + RO_{\mathrm{rec}}*Q_{RW,\mathrm{PGW}} \geq \mathrm{PGW}_{\max}\\[\jot]
   0& \text{if } \mathrm{PGW}_{i-1} -  Q_{\mathrm{PGW},\mathrm{Use}}+ \mathrm{MBR}_{\mathrm{rec}} \ldots \\ &\quad *Q_{GW} + RO_{\mathrm{rec}}*Q_{RW,\mathrm{PGW}} \leq 0 \\[\jot]
   \mathrm{PGW}_{i-1} -  Q_{\mathrm{PGW},\mathrm{Use}} + {}\\
   \quad  \mathrm{MBR}_{\mathrm{rec}} \ldots  & \text{otherwise} \\
   \quad *Q_{GW} + RO_{\mathrm{rec}}*Q_{RW,\mathrm{PGW}}
\end{cases}
\end{equation}


\end{document}
1

Rather than feature the repeated expression PGW_{i-1} - Q_{PGW,Use} + MBR_{rec} \cdot Q_{GW} + RO_{rec}\cdot Q_{RW,PGW} fully three [3!] times inside a single cases environment, I'd give it a name (say, \theta(PGW_{i-1})), state it up front, and then simplify the contents of the cases environment considerably. (You are obviously free to come up with another function name that \theta!) Your readers might appreciate that you made an effort to keep the visual presentation of your material as clutter-free as possible.

In the following code, note the use of the \vn macro (short for "variable name", I suppose) to typeset variable names more compactly than if they written out in ordinary math mode.

enter image description here

\documentclass{article}
\usepackage{amsmath}  % for 'cases' environment
\newcommand\vn[1]{\mathit{#1}} % typeset variable names

\begin{document}
Put $\theta(\vn{PGW}_{\!i-1})=\vn{PGW}_{\!i-1} - Q_{\vn{PGW},\vn{Use}} 
+ \vn{MBR}_{\vn{rec}} \cdot Q_{\vn{GW}} + \vn{RO}_{\vn{rec}}\cdot Q_{RW,\vn{PGW}}$; 
then,
\begin{equation} \label{eqRWnaRO}
\vn{PGW}_{\!i} =
\begin{cases}
\vn{PGW}_{\!\max} 
  & \text{if }\theta(\vn{PGW}_{\!i-1})\geq\vn{PGW}_{\!\max}\\ 
0 & \text{if }\theta(\vn{PGW}_{\!i-1})\leq 0, \\ 
\theta(\vn{PGW}_{\!i-1})
  & \text{otherwise.}
\end{cases}
\end{equation}

\end{document}

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.