# Cases with long text at the end.

So I need an outlup like this:

And this is the code i use:

\documentclass[10pt,a4paper,5p,twocolumn,preprint,review,authoryear]{elsarticle}
\usepackage[english]{babel}
\usepackage[fleqn]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\usepackage{geometry}
\usepackage{fleqn}
\usepackage{txfonts}
\begin{document}
$$\label{eq:piece_pipe_case} \hspace{-0.045\textwidth}h_{J3} - h_{J4} = \begin{cases} m_{P2,1} q_{P2} + c_{P2,1}, & \hspace{-0.045\textwidth}\text{if } q_{lim \, 1} \leq q_{P2} \leq q_{lim \,2} \\ m_{P2,2} q_{P2} + c_{P2,2}, & \hspace{-0.045\textwidth}\text{if } q_{lim \, 2} \leq q_{P2} \leq q_{lim \,3} \hdots \\ m_{P2,N_{piece}} q_{P2} + c_{P2,N_{piece}}, & \end{cases} %M(\lambda_{1,i,j} -1) &\leq& h_{k1,j} - h_{k2,j} - m_{1,i} q - c_{1,i} &\leq M(1-\lambda_{1,i,j})& \\ %M(\lambda_{2,i,j} -1) &\leq& h_{k1,j} - h_{k2,j} - m_{2,i} q - c_{2,i} &\leq M(1-\lambda_{2,i,j})&\ldots$$
\hspace{0.2\textwidth}
$\text{if } q_{lim N_{piece}-1} \leq q_{P2} \leq q_{lim \, N_{piece}}$

\end{document}


and all is well, but now I have a page / column break between the equation and the last line so it all goes tits up. I've tried vpace etc. Now the issue is I'd rather not use other packages as this format is journal approved and I want to avoid doing the same thing again when this thing gets published.

Any Ideas on how to fix this?

I don't like making the cases bigger as the bracket then looks ridiculous, also the alignment of the ifs that I've carefully fudged would break again.

I'm aware of solutions with parbox etc, and I thought I had this cracked but there is now a line break there and I'm stuffed.

Related Q: Multiline text in multiline equation and others.

Done using by stacking under the 3rd row (column 2) of the case. The key adjustments open to the user are the 20pt stacking baseline skip, which appears as an argument to \stackengine; and \hspace{1in}, which was used in the 3rd line of the case to set the right alignment of the underset stack.

METHOD 1:

EDITED to use a \rule rather than a \vspace to correct for the \smashed stack, so that the page-bottom margin is not adversely affected. Here, I set the \rule depth to 3\baselineskip, which works for this case, but would require adjustment if the case depth were altered.

\documentclass[10pt,a4paper,5p,twocolumn,preprint,review,authoryear]{elsarticle}
\usepackage[english]{babel}
\usepackage[fleqn]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{geometry}
\usepackage{fleqn}
\usepackage{txfonts}
\usepackage{stackengine}
\stackMath
\begin{document}
$$\label{eq:piece_pipe_case} \hspace{-0.045\textwidth}h_{J3} - h_{J4} = \begin{cases} m_{P2,1} q_{P2} + c_{P2,1}, & \hspace{-0.045\textwidth}\text{if } q_{lim \, 1} \leq q_{P2} \leq q_{lim \,2} \\ m_{P2,2} q_{P2} + c_{P2,2}, & \hspace{-0.045\textwidth}\text{if } q_{lim \, 2} \leq q_{P2} \leq q_{lim \,3} \hdots \\ m_{P2,N_{piece}} q_{P2} + c_{P2,N_{piece}}, & %M(\lambda_{1,i,j} -1) &\leq& h_{k1,j} - h_{k2,j} - m_{1,i} q - c_{1,i} &\leq M(1-\lambda_{1,i,j})& \\ %M(\lambda_{2,i,j} -1) &\leq& h_{k1,j} - h_{k2,j} - m_{2,i} q - c_{2,i} &\leq M(1-\lambda_{2,i,j})&\ldots \smash{\stackengine{20pt}{\hspace{1in}}{% \text{if } q_{lim N_{piece}-1} \leq q_{P2} \leq q_{lim \, N_{piece}} }{U}{r}{F}{T}{L}} \end{cases}\rule[-3\baselineskip]{0pt}{1pt}$$
\end{document}


METHOD 2

Alternately, if one wanted the case to enclose the final qualifier, simply remove the \smash and the \rule from the Method 1 approach (i.e., Method 2 is easier):

\documentclass[10pt,a4paper,5p,twocolumn,preprint,review,authoryear]{elsarticle}
\usepackage[english]{babel}
\usepackage[fleqn]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{geometry}
\usepackage{fleqn}
\usepackage{txfonts}
\usepackage{stackengine}
\stackMath
\begin{document}
$$\label{eq:piece_pipe_case} \hspace{-0.045\textwidth}h_{J3} - h_{J4} = \begin{cases} m_{P2,1} q_{P2} + c_{P2,1}, & \hspace{-0.045\textwidth}\text{if } q_{lim \, 1} \leq q_{P2} \leq q_{lim \,2} \\ m_{P2,2} q_{P2} + c_{P2,2}, & \hspace{-0.045\textwidth}\text{if } q_{lim \, 2} \leq q_{P2} \leq q_{lim \,3} \hdots \\ m_{P2,N_{piece}} q_{P2} + c_{P2,N_{piece}}, & %M(\lambda_{1,i,j} -1) &\leq& h_{k1,j} - h_{k2,j} - m_{1,i} q - c_{1,i} &\leq M(1-\lambda_{1,i,j})& \\ %M(\lambda_{2,i,j} -1) &\leq& h_{k1,j} - h_{k2,j} - m_{2,i} q - c_{2,i} &\leq M(1-\lambda_{2,i,j})&\ldots \stackengine{20pt}{\hspace{1in}}{% \text{if } q_{lim N_{piece}-1} \leq q_{P2} \leq q_{lim \, N_{piece}} }{U}{r}{F}{T}{L} \end{cases}$$
\end{document}


• Method 1 is what I wanted. Thank you. I'll accept an answer once I know whether I can implement it as is. – ic_fl2 May 13 '15 at 14:33
• @ic_fl2 If you have difficulties or questions, don't hesitate to ask. – Steven B. Segletes May 13 '15 at 14:36

As it does not fit the column too well, I would reformat the whole thing:

% arara: pdflatex

\documentclass[10pt,a4paper,5p,twocolumn,preprint,review,authoryear]{elsarticle}
\usepackage[english]{babel}
%\usepackage{microtype} % for the secreenshot... can't test your font setup.
\usepackage{mathtools}
\usepackage{blindtext}
\newcommand*{\limit}{\text{lim}}
%\usepackage{txfonts} % does not work for me

\begin{document}
\blindtext[3]
\label{eq:piece_pipe_case} h_{J3} - h_{J4} = \begin{cases} \begin{aligned}q_{P2}&m_{P2,1} + c_{P2,1},\\[-2\jot]&\text{if } q_{\limit 1} \leq q_{P2} \leq q_{\limit 2}\end{aligned} \\ \begin{aligned}q_{P2}&m_{P2,2} + c_{P2,2},\\[-2\jot]&\text{if } q_{\limit 2} \leq q_{P2} \leq q_{\limit 3}\end{aligned}\\ \begin{aligned}q_{P2}&m_{P2,N_\text{piece}} + c_{P2,N_\text{piece}},\\[-2\jot]&\text{if } q_{\limit N_\text{piece}-1} \leq q_{P2} \leq q_{\limit N_\text{piece}}\end{aligned} \end{cases}
\end{document}


You could, of course, write 6 cases here, but this will occupy more vertical space above an below the outer lines. I think, here it is worth to do that much typing.

I left away the (doubled loaded) fleqn option as I had the feeling that it does not harmony too good with elsarticle. You may put it back, if you really need it.

• Not what I originally wanted but I like it. – ic_fl2 May 13 '15 at 14:34
• @ic_fl2 glad to hear that. – LaRiFaRi May 13 '15 at 14:45

The space is tight, so a custom array seems the best approach:

\documentclass[10pt,a4paper,5p,twocolumn,preprint,review,authoryear]{elsarticle}
\usepackage[english]{babel}
\usepackage[fleqn]{amsmath}

\usepackage{newtxtext,newtxmath}

\usepackage{amssymb}
\usepackage{array}

\newcommand{\ts}[1]{\mathrm{#1}}

\begin{document}

$$\label{eq:piece_pipe_case} h_{J3} - h_{J4} = \left\{ \begin{array}{@{}l >{}l<{} @{}} m_{P2,1} q_{P2} + c_{P2,1}, & if q_{\ts{lim}\,1} \leq q_{P2} \leq q_{\ts{lim}\,2} \\[1ex] m_{P2,2} q_{P2} + c_{P2,2}, & if q_{\ts{lim}\,2} \leq q_{P2} \leq q_{\ts{lim}\,3} \\ \qquad\dots\\ \multicolumn{2}{@{}l@{}}{m_{P2,N_{\ts{piece}}} q_{P2} + c_{P2,N_{\ts{piece}}},} \\ \multicolumn{2}{@{}>{}r<{}@{}}{% if q_{\ts{lim}\,N_{\ts{piece}}-1} \leq q_{P2} \leq q_{\ts{lim}\,N_{\ts{piece}}}% } \end{array} \right.\kern-\nulldelimiterspace$$

\end{document}


Note that I used newtxtext and newtxmath that give better results than txfonts, though being based on the same fonts. Note also that the word fragments in subscript should be typeset upright.

A possible alternative, with all conditions in the following line,

\documentclass[10pt,a4paper,5p,twocolumn,preprint,review,authoryear]{elsarticle}
\usepackage[english]{babel}
\usepackage[fleqn]{amsmath}

\usepackage{newtxtext,newtxmath}

\usepackage{amssymb}
\usepackage{array}

\newcommand{\ts}[1]{\mathrm{#1}}

\begin{document}

$$\label{eq:piece_pipe_case} h_{J3} - h_{J4} = \left\{ \begin{array}{@{}l@{}} m_{P2,1} q_{P2} + c_{P2,1}, \\ \qquad\text{if q_{\ts{lim}\,1} \leq q_{P2} \leq q_{\ts{lim}\,2}} \\[1ex] m_{P2,2} q_{P2} + c_{P2,2}, \\ \qquad\text{if q_{\ts{lim}\,2} \leq q_{P2} \leq q_{\ts{lim}\,3}} \\ \quad\dots \\ m_{P2,N_{\ts{piece}}} q_{P2} + c_{P2,N_{\ts{piece}}}, \\ \qquad\text{% if q_{\ts{lim}\,N_{\ts{piece}}-1} \leq q_{P2} \leq q_{\ts{lim}\,N_{\ts{piece}}}% } \end{array} \right.\kern-\nulldelimiterspace$$

\end{document}