2

I have an equation, as shown in the following picture:

enter image description here

I want to center the second part of the objective function ( + \alpha \sum_{j} \left(Qp_j + Qn_j\right) ) between the two red lines. How can I achieve that. The following is my MWE:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
The objective is to minimize the total operational cost:
\begin{equation}
\begin{gathered}
\min z = \mathrm{fa} \left(N_{\mathrm{h}} \mathrm{CFW} \sum_{j} Fw_j + 
             \mathrm{CHU} \sum_{k} Q_k^{\mathrm{HU}} + \mathrm{CCU} \sum_{k} Q_k^{\mathrm{CU}}\right) \\ 
           + \alpha \sum_{j} \left(Qp_j + Qn_j\right) 
\end{gathered}
\end{equation}
\end{document}
  • Is fa a factor of the second part/line? – Bernard Aug 10 '15 at 10:06
9

Unless the material on the second row falls in the scope of "fa" (which, judging by the screenshot you've posted, isn't the case), I would not center the material on the second row with respect to the parentheses on the first row. Instead, I would use a split environment, as is shown in the screenshot below. Why not center the material on row 2? Because doing so risks "losing it" in the clutter, visually/typographically speaking.

enter image description here

\documentclass{article}
\usepackage{amsmath}
\begin{document}
    \begin{equation}\begin{split}
    \min z &= \mathrm{fa} \biggl(N_{\mathrm{h}} \mathrm{CFW} \sum_{j} Fw_j 
             + \mathrm{CHU} \sum_{k} Q_k^{\mathrm{HU}} 
             + \mathrm{CCU} \sum_{k} Q_k^{\mathrm{CU}}\biggr) \\ 
    &\quad+ \alpha \sum_{j} \bigl(Qp_j + Qn_j\bigr) 
    \end{split}\end{equation}
\end{document}

If you must center the second row relative to the RHS of the first row, you could so via an array environment embedded in the equation environment.

enter image description here

\documentclass{article}
\usepackage{amsmath,array}
\begin{document}
The objective is to minimize the total operational cost:
\begin{equation}
\min z = 
\begin{array}[t]{@{}>{\displaystyle}c@{}}
\mathrm{fa} \biggl(N_{\mathrm{h}} \mathrm{CFW} \sum_{j} Fw_j 
             + \mathrm{CHU} \sum_{k} Q_k^{\mathrm{HU}} 
             + \mathrm{CCU} \sum_{k} Q_k^{\mathrm{CU}}\biggr) \\ 
{}+ \alpha \sum_{j} \bigl(Qp_j + Qn_j\bigr) \\
\end{array}
\end{equation}
\end{document}
  • You're missing a space between + and alpha in the second example. With {}+\alpha you'd get it (spoiling the centering by a tiny bit); or +\:\alpha using explicitly \medmuskip.. – egreg Aug 10 '15 at 8:15
  • @egreg - thanks for noticing that the + sign in the second row is treated as a unary rather than as a binary operator. I'll fix up the code right away (by adding a {} (empty math atom) in front of the + symbol in question). I trust no-one is going to notice the every-so-slight asymmetry. :-) – Mico Aug 10 '15 at 8:19
2

Mico's answer is great. I just wanted to point out that if you want the centering, an easier (but perhaps more hacky) way to do it is to simply push the second line to the right:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
The objective is to minimize the total operational cost:
\begin{equation}
\begin{gathered}
\min z = \mathrm{fa} \left(N_{\mathrm{h}} \mathrm{CFW} \sum_{j} Fw_j + 
             \mathrm{CHU} \sum_{k} Q_k^{\mathrm{HU}} + \mathrm{CCU} \sum_{k} Q_k^{\mathrm{CU}}\right) \\ 
             \hphantom{\min z = {}} % Pushes content to the right by the right amount
           + \alpha \sum_{j} \left(Qp_j + Qn_j\right) 
\end{gathered}
\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.