2

I have been trying to break up this long equation (see below) to fit into the page. It is quite long and I am wondering how I can break it up into different parts. There is something wrong with the \multiline function in my version, so I want to avoid using that.

\begin{equation}
        \begin{aligned}
        V^{j} \left ( q_{c},q_{e} \right ) \equiv  \max_{\sigma^{j}, c_{c}^{j}, c_{e}^{j}, y_{c}^{j}, y_{e}^{j}} \left \{ \delta^{j} u(c^{j}) - g(y^{j}) + W\left ( \frac{\phi}{\gamma_{c}}[q_{c}-c_{c}^{j}+y_{c}^{j}], \frac{\psi}{\gamma_{e}}[\sigma^{j} (R q_{e}-\kappa^{j}-c_{e}^{j}+y_{e}^{j}) + (1-\sigma^{j}) (q_{e}-c_{e}^{j}+y_{e}^{j}) ] \right ) + \lambda_{c}^{j} (q_{c}-c_{c}^{j}) + \lambda_{e}^{j} (Rq_{e}-\kappa^{j}-c_{e}^{j})
        \right \},\label{eqn:17}
    \end{aligned}
\end{equation}\\

The output I am getting:

enter image description here

I am looking for an output that is like

enter image description here

but under the maximization problem with the main brackets.

Here are the relevant packages:

\documentclass[a4paper,12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{mathtools}
\usepackage{graphicx,amsmath,stackengine,scalerel}
\newcommand\qunderline[1]{\ThisStyle{%
        \ensurestackMath{\stackengine{-1pt}{\SavedStyle#1}
            {\SavedStyle\underline{\hphantom{#1}}}{U}{c}{F}{F}{S}}}%
}
\usepackage{xfrac}
\usepackage{nicefrac}
\usepackage{accents}
4
  • Please merge your code fragments to one small, compilable document. In equation code you have errors. In showed preamble the most of of packages are irrelevant to your problem, many of them are loaded twice ...
    – Zarko
    Jan 27 at 6:05
  • @Zarko I made some edits
    – OGC
    Jan 27 at 6:41
  • to late for my answer ... but you still not merge both fragments in one small document, which reproduce your problem. As now see, you also change the equation ...
    – Zarko
    Jan 27 at 6:48
  • 2
    The correct name of the environment (not macro) is multline, not multiline.
    – Mico
    Jan 27 at 7:07

2 Answers 2

5

If you use multline rather than multiline as the name of the environment, you should be fine with just two line breaks in the long formula.

Because of the line breaks, you can't use \left and \right all that well. Instead, do use explicit sizing directives such as \bigl, \Bigl, and \biggl (and their corresponding closing counterparts).

The horizontal line in the following screenshot is there just to illustrate the width of the textblock.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for 'multline' env. and '\substack' macro

\begin{document}
\hrule % just to illustrate width of text block
\begin{multline} \label{eqn:17}
V^{j}(q_{c},q_{e}) \equiv  
\max_{\substack{\sigma^{j}, c_{c}^{j}, c_{e}^{j},\\ y_{c}^{j}, y_{e}^{j}}}
\biggl \{ \delta^{j} u(c^{j}) - g(y^{j}) 
+ W\Bigl( \tfrac{\phi}{\gamma_{c}} \bigl[q_{c}-c_{c}^{j}+y_{c}^{j}\bigl]\,,\\ 
\tfrac{\psi}{\gamma_{e}}
\bigl[ \sigma^{j} (R q_{e}-\kappa^{j}-c_{e}^{j}+y_{e}^{j}) 
+ (1-\sigma^{j}) (q_{e}-c_{e}^{j}+y_{e}^{j}) \bigr] \Bigr ) \\
+ \lambda_{c}^{j} (q_{c}-c_{c}^{j}) + \lambda_{e}^{j} (Rq_{e}-\kappa^{j}-c_{e}^{j})
\biggr \}\,.
\end{multline}
\end{document}
5
  • In aligned environment math terms are not break in multi lines. Consequently your equation spill out of page
  • Even you break equation on three parts, it is still to long, it protrude right text border and consequently the equation number is pushed below of equation.
  • A possible solution is to use smaller font size in equation, for example by employ \medmath command defined in the nccmath package
\documentclass[a4paper,12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{nccmath}

\usepackage{lipsum} % for dummy text filler

\begin{document}
\lipsum[66]
\begin{equation}\label{eqn:17}
    \medmath{
    \begin{aligned}
V^{j}( q_{c},q_{e}) 
    & \equiv  \max_{\substack{\sigma^{j}, c_{c}^{j}, c_{e}^{j},\\ 
                             y_{c}^{j}, y_{e}^{j}}}
    \biggl\{ \delta^{j} u(c^{j}) - g(y^{j})     \\
    &\quad {} +  \beta W \left( 
        \frac{\phi}{\gamma_{c}}\bigl[q_{c} - c_{c}^{j} + y_{c}^{j}\bigr], \frac{\psi}{\gamma_{e}}\bigl[\sigma^{j} (R q_{e} -\kappa^{j} - c_{e}^{j} +y_{e}^{j}) + (1-\sigma^{j}) (q_{e}-c_{e}^{j}+y_{e}^{j}) \bigr]
                        \right) \\
    &\quad {} +  \lambda_{c}^{j} (q_{c}-c_{c}^{j}) + \lambda_{e}^{j} (Rq_{e}-\kappa^{j}-c_{e}^{j})
    \biggr\},
    \end{aligned}
            }
\end{equation}
some more text, see \eqref{eqn:17}
\end{document}

enter image description here

Off-topic In your preamble amsmath is still load twice (actually three times because mathtools load it too). More correct is (considering new nccmath):

\documentclass[a4paper,12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{nccmath,amssymb,amsfonts}
\usepackage{mathtools}
\usepackage{graphicx,stackengine,scalerel}
\newcommand\qunderline[1]{\ThisStyle{%
        \ensurestackMath{\stackengine{-1pt}{\SavedStyle#1}
            {\SavedStyle\underline{\hphantom{#1}}}{U}{c}{F}{F}{S}}}%
}
\usepackage{xfrac}
\usepackage{nicefrac}
\usepackage{accents}
5
  • Thanks for the solution! The code runs but I get this error: Undefined control sequence. \medmath
    – OGC
    Jan 27 at 6:46
  • 1
    than you not load package nccmath. it had to be loaded before mathtools.
    – Zarko
    Jan 27 at 6:50
  • 1
    +1 for the use of \substack. :-)
    – Mico
    Jan 27 at 7:09
  • 1
    @Mico, thank you very much. the same for your answer! BTW, I understood multiline as multi line, i.e. that OP like to break equation into many lines ...
    – Zarko
    Jan 27 at 7:14
  • to continue above comment: *without of use ˙multlined` *environment (as is required in question title). Question is to me a bit misleading.
    – Zarko
    Jan 27 at 7:22

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.