3

How can I align this part of my paper:

\subsection{Decision variables}

\noindent$y_{pij}^{mk}=\left\{\begin{array}{ll} 1, & \;\;\; \hbox{ If the robot
loads or uloades a part to/from machine $m$ in position $p$ and gripper one
holds a part that should be loaded on machine $i\in \mathcal{M}$ and gripper
two holds a part that should be loaded on machine $j\in \mathcal{M}$}, \\
    0, &\;\;\; \hbox{Otherwise} \end{array} \right.
    $

It is published like the following picture.

enter image description here

As you see, the end of the description of this binary variable is out of the page.

Thanks.

  • What about a \parbox instead of \hbox? Also, you can use the cases environment to typeset this kind of thing. Plus, instead of \noindent, you should use a display-style math environment. – Zoxume Apr 26 '16 at 17:54
  • Something else you can do is transform the mathematical expression by pure text. For example: “y_pij^mk=1 if the robots loads […] and y_pij^mk=0 otherwise. – Zoxume Apr 26 '16 at 18:11
  • Thank you so much Zoxume. Your answer was perfect. Especially the last part about making the first line of the \parbox at the same height. It is completely correct now. – VHD Apr 26 '16 at 18:29
  • Then don’t forget to upvote it and to click on the tick mark. – Zoxume Apr 26 '16 at 18:29
  • ok but I am completely new here. I signed up few hours ago. How should I do that? :-) – VHD Apr 26 '16 at 19:31
5

There are several things that you should do:

  1. Use a display-style math environment, like \[ ... \].
  2. Use the cases environment to typeset mathematical cases.
  3. Use a \parbox to allow your text to be typeset on several lines.

This said, you can do this:

\[y_{pij}^{mk} = \begin{cases}
1, & \parbox{5cm}{If the robot loads or uloades a part to/from machine $m$ in position $p$ and gripper one holds a part that should be loaded on machine $i\in \mathcal{M}$ and gripper two holds a part that should be loaded on machine $j\in \mathcal{M}$} \\
0, & \text{Otherwise}
\end{cases}\]

The result is:

You can adjust the width of the \parbox to better suit your needs.

To make the first line of the \parbox at the same height as the “1”, you can give the \parbox command some options:

\parbox[t][][t]{length}{Your text}

(Found here: Tabular, parbox, vertical alignment.)

Result:

  • You may also use array construction for this. – cacamailg Apr 26 '16 at 18:13
1

For example:

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{equation*}
    \left\{%
        \begin{array}{ll}
            1 & \text{\parbox[t][][t]{0.8\textwidth}{If the robot loads or uploads a part to/from machine $m$ in position $p$ and gripper one holds a part that should be loaded on machine $i\in \mathcal{M}$ and gripper two holds a part that should be loaded on machine $j\in \mathcal{M}$}}, \\
            0 & \text{Otherwise}
        \end{array}%
    \right.
\end{equation*}

\end{document}
  • 2
    There is less code with the cases construction which does the same, plus no need to wrap paroxysmal in the text command – daleif Apr 26 '16 at 19:21
1

A simple code with flalign* and the dcases* environment from mathtools:

\documentclass{article}

\usepackage{mathtools}
\usepackage[showframe]{geometry}

\begin{document}

\begin{flalign*}
  & y_{pij}^{mk}=\begin{dcases*} 1, & \parbox[t]{0.863\linewidth}{ If the robot loads or uloades a part to/from machine $m$ in position $p$ and gripper one holds a part that should be loaded on machine $i ∈ \mathcal{M}$ and gripper two holds a part that should be loaded on machine $j ∈ \mathcal{M}$}, \\ 0, &Otherwise
  \end{dcases*}
\end{flalign*}

\end{document} 

enter image description here

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.