4

Code

\documentclass[a4paper,twoside,12pt]{book}
\usepackage{amstext}
\usepackage[utf8]{inputenc}
\usepackage{cases}
\usepackage{amsmath}

\begin{document}
\begin{subnumcases}{}\label{eq:regola_scelta_reject}
    \begin{aligned}
    objective   &: \qquad \min \quad \sum_{j=1}^{H}x_jw_j\\
    subject to  &: \qquad \displaystyle\sum_{j=1}^{H}x_jw_j \geq W_L\\
    \end{aligned} \label{eq:regola_scelta_reject_1}\\
    \begin{aligned}
    objective   &: \qquad \min \quad \sum_{j=1}^{H}x_jw_j \vee H_{e} \geq 2 \\  
    subject to  &: \qquad \displaystyle\sum_{j=1}^{H}x_jw_j < W_L\\
    \end{aligned} \label{eq:regola_scelta_reject_2}\\
\end{subnumcases}
\end{document}

What I'm doing wrong? This is what I'm trying to acheive:

Example

  • 3
    Please always post complete documents. Without effort it is hard to see what you have done wrong as we can't see the output or error message without reconstructing a document that you presumably have already. – David Carlisle Mar 13 '14 at 13:52
  • @DavidCarlisle Fixed. The fact is that casesrequest 2 condition on the same line. Is there any alternative to casesthat doesn't include the 2-nd condition? – gmeroni Mar 13 '14 at 13:59
  • surrounding the cases environment in dollar signs will remove the particular errors you are experiencing, but there are other issues, such as material you intend as text being placed into math style. – Steven B. Segletes Mar 13 '14 at 14:01
  • 1
    Also, when David suggests that "complete documents" should be posted, he means something that begins with \documentclass and ends with \end{document}. – Steven B. Segletes Mar 13 '14 at 14:02
  • @gmeroni as Steven says that isn't a usable document. – David Carlisle Mar 13 '14 at 14:12
5

enter image description here

\documentclass[a4paper,twoside,12pt]{book}
\usepackage{amstext}
\usepackage[utf8]{inputenc}


\usepackage{amsmath}
\usepackage{cases}

\begin{document}
\begin{subnumcases}{}\label{eq:regola_scelta_reject}
    \mbox{objective:}&$\displaystyle \qquad \min\sum_{j=1}^{H}x_jw_j$\\
    \mbox{subject to:}  &$\displaystyle \qquad \sum_{j=1}^{H}x_jw_j \geq W_L$\\[12pt]
     \xdef\theparentequation{\the\numexpr\theparentequation+1}%
     \setcounter{equation}{1}%
      \mbox{objective:}&$\displaystyle \qquad \min \sum_{j=1}^{H}x_jw_j \vee H_{e} \geq 2$ \\  
    \mbox{subject to:}  &$\displaystyle \qquad \sum_{j=1}^{H}x_jw_j < W_L$ \label{eq:regola_scelta_reject_2}
\end{subnumcases}
\end{document}
  • Is there a way to split in two part? I'd have (1a),(1b) and (2a),(2b) since I need to reference the two knapsack problem separately. – gmeroni Mar 13 '14 at 15:42
  • @gmeroni see update – David Carlisle Mar 13 '14 at 16:49
  • @DavidCarlisle: What comment are you replying to :) – Aditya Mar 13 '14 at 23:26
  • @DavidCarlisle Thanks but the outcome is this. I set the x.xx numbering. – gmeroni Mar 14 '14 at 8:33
  • @gmeroni The output of the code I posted above is as shown in the image I posted. If you have different input that isn't doing the right thing it is best to ask a new question with a complete document that demonstrates the problem. Not much I can do just looking at an image without knowing what made it. – David Carlisle Mar 14 '14 at 9:12
1

Maybe this code suits your needs – if I've well understood. You need the empheq package (which loads amsmath), with th overloadoption, to have a simpler code:

        \documentclass[a4paper]{article}
        \usepackage[utf8]{inputenc}
        \usepackage{mathtools}
        \usepackage[overload]{empheq}

        \begin{document}

        \begin{align}[left = (R)\enspace\empheqlbrace]%\label{eq:regola_scelta_reject}\smash[t]\smash[b]
         &  \begin{alignedat}{2}\label{eq:regola_scelta_reject_1}
          &  \text{objective: } & &  \min \sum_{j=1}^{H} x_j w_j\\
           & \text{subject to: } &\qquad   & \sum_{j=1}^{\smash H} x_j w_j \geq W_L\\
         \end{alignedat}\\]
            &   \begin{alignedat}{2} \label{eq:regola_scelta_reject_2}
          &  \text{objective: } & &  \min  \sum_{j=1}^{H}x_jw_j \vee H_{e} \geq 2 \\
           & \text{subject to: } & \qquad  & \sum_{j=1}^{\smash H} x_jw_j < W_L
         \end{alignedat}\
        \end{align}

        \end{document}

Results in: enter image description here

Note that you can't have a label for the align outer environment and for the inner alignedat environnments. I simulated a tag ((R)) for the outer align.

  • Thank you @bernard. Is there any way to label Objective and constraint separately like (1a) and (1b)? – gmeroni Mar 13 '14 at 15:21
  • 1
    In a simple way (I mean with pre-existing tools one just has to pick), I'm afraid not. The subequationsenvironment does that, but it does not work with nested environments like aligned and such. If I find something, I'll update my answer – Bernard Mar 13 '14 at 15:42
  • mathtools also loads amsmath. don't know whether this affects the [overload] option to empheq. – barbara beeton Mar 13 '14 at 15:46
  • @barbarabeeton: actually, empheq loads mathtools, hence amsmath. It's just that I used a minimal template that loads mathtools, and I forgot to cleanup my code on adding empheq. – Bernard Mar 13 '14 at 16:01

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.