How can I fit my linear program to my sheet but still have numbers aligned on the right?


% page layout

% fancy math


&\textbf{Minimize} \\
&z =\sum\limits_{i \in I}\sum\limits_{t \in W_i^{work}} c^{period} * x_{i,t}^{work} + \sum\limits_{i \in I} c^{over} * o_i + \sum\limits_{i \in I} c^{staff} * v_i^{staff} + \sum\limits_{d \in D} c^{device} * v_d^{device} \\
&\textbf{subject to}  \\
&\sum\limits_{i \in I_{q':q'=q}} (( \sum\limits{r=t}^{t+W_z^{demand}} x_{i,r}^{work} - y_{i,t}^{break} ) * v_i^{staff}) \geq b_{q,t,z}^{staff} && \forall q \in Q,t \in T, z \in Z \\
&H^{break} * \sum\limits{t \in W_i^{shift}} y_{i,t}^{shift} = \sum\limits{t \in W_i^{break}} y_{i,t}^{break} && \forall i \in I \\
&D_i^{min} \leq \sum\limits{t \in T} y_{i,t}^{shift} \leq D_i^{max} && \forall i \in I


That's what I have so far:

lp solution

Maybe splitting some formulas is a solution? How tiny can I make the font till it is no longer readable?

I followed this question using alignat, sadly there is no numbering and it is much smaller.

Edit #1:
\quad helped a lot, but one line is missing.

enter image description here

  • 1
    You need to replace the three instances of && with \quad. – Mico Nov 2 '14 at 17:49
  • Besides all, you need vector notation. Summations are simply confusing and hard to read. – percusse Nov 2 '14 at 17:54
  • Thanks I updated my question, sadly still one is misfits (see edit 1) – lony Nov 2 '14 at 17:54

I would do the following

  • Replace the three instances of && before \forall with \quad. Optionally, since there's now only one alignment point left, replace {alignat}{2} with align.

  • Add \notag instructions to the two lines that contain just text ("minimize", "subject to")

  • Force all words in superscript position to be typeset in text-upright instead of math-italic mode. I would do this even if it didn't help make the first equation fit within the text block (which it does, happily). If you strongly prefer text-italics over text-upright mode for the words in the superscript positions, replace \textnormal in the definition of the \tn macro with \textit.

  • Enlarge the parentheses in the first condition line using \Bigl and \Bigr. To snug up the first and second summation symbols in that line, insert \!\!\! -- three negative thinspaces.

  • To force the limits of summation of the two summation expressions in the first math row to be set at the same depth, replace {i \in I} with {i \in I^{\mathstrut}}. A \mathstrut is an invisible object with the height and depth of a parenthesis (().

  • Finally, I would delete all \limits directives, as they are redundant and just provide clutter. The material in align and alignat environments is typeset in \displaystyle by default, meaning that all summation signs will be set in "large" form and all limits of summation will be set below (and, if present, above) the summation symbols rather than side-set on the right.

enter image description here

\newcommand\tn[1]{\textnormal{#1}} % shortcut macro

&\textbf{Minimize} \notag \\
&z =\sum_{i \in I^{\mathstrut}}\sum_{t \in W_i^{\tn{work}}} c^{\tn{period}} * x_{i,t}^{\tn{work}} + \sum_{i \in I} c^{\tn{over}} * o_i + \sum_{i \in I} c^{\tn{staff}} * v_i^{\tn{staff}} + \sum_{d \in D} c^{\tn{device}} * v_d^{\tn{device}} \\
&\textbf{subject to} \notag \\
&\sum_{i \in I_{q':q'=q}} \!\!\! \Bigl(\Bigl( \sum{r=t}^{t+W_z^{\tn{demand}}} x_{i,r}^{\tn{work}} - y_{i,t}^{\tn{break}} \Bigr) * v_i^{\tn{staff}}\Bigr) \geq b_{q,t,z}^{\tn{staff}} \quad \forall q \in Q,t \in T, z \in Z \\
&H^{\tn{break}} * \sum{t \in W_i^{\tn{shift}}} y_{i,t}^{\tn{shift}} = \sum{t \in W_i^{\tn{break}}} y_{i,t}^{\tn{break}} \quad \forall i \in I \\
&D_i^{\tn{min}} \leq \sum{t \in T} y_{i,t}^{\tn{shift}} \leq D_i^{\tn{max}} \quad \forall i \in I

  • Nice, thank you. One further question. Can I also change the setting to textit to textnormal all over my document? – lony Nov 2 '14 at 19:37
  • @lony - Sure. In fact, I'd make an effort to use the \tn macro for all word-like terms that occur in a math context. In the example you've given the terms only occur in superscript positions, but I could well imagine that they can appear elsewhere too. Is that correct? – Mico Nov 2 '14 at 19:48
  • yes, they could. Is it possible to avoid the macro and just "set" the font right? – lony Nov 2 '14 at 20:04
  • @lony - Not sure what you mean by "setting the font right". Are you expecting TeX to somehow "know" if a superscript term is supposed to be set in upright roman letters? If the only words that can arise in a math context are period, over, staff, work, break, demand, device, and shift, you could define macros such as \def\period{{\tn{period}} and then use \period whenever the term occurs in math mode. (The macros \min and \max are already pre-defined, so don't re-define them.) – Mico Nov 2 '14 at 20:16
  • I mean if I can set a "setting in TeX" to always use your macros font and avoid adding it to all the text formulas inside my hole document? – lony Nov 3 '14 at 7:56

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.