3

The following picture shows the equation output format of my MWE: equation

I want to keep the output format, and number each of the four equations. I use array under the equation environment, but it just numbers the whole equation. How could I number each equation while keeping the output format?

The following is my MWE:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

This is the output format of the four equations:

\begin{equation}
\begin{array}{cl}
 Y_l^{\mathrm{hx}} \veebar Y_l^{\mathrm{cx}} & \quad \forall l \in \mathrm{MS} \\
%
Y_l^{\mathrm{hx}} \Longleftrightarrow Y_{l,k}^{\mathrm{hx_1}} \veebar Y_{l,k}^{\mathrm{hx_2}} \veebar
Y_{l,k}^{\mathrm{hx_3}} & \quad \forall l, \; \forall k \in \mathrm{HM}  \\
%
Y_l^{\mathrm{cx}} \Longleftrightarrow Y_{l,k}^{\mathrm{cx_1}} \veebar Y_{l,k}^{\mathrm{cx_2}} \veebar
Y_{l,k}^{\mathrm{cx_3}} & \quad \forall l, \; \forall k \in \mathrm{CM} \\
%
Y_{m,k}^{\mathrm{ws_1}} \veebar Y_{m,k}^{\mathrm{ws_2}} \veebar
Y_{m,k}^{\mathrm{ws_3}} & \quad \forall l, \; \forall k \in \mathrm{WM} 
\end{array}
\end{equation}

\end{document}
1
  • Please make your example compilable.
    – LaRiFaRi
    Aug 10, 2015 at 9:39

3 Answers 3

3

You can adapt the code in https://tex.stackexchange.com/a/209732/4427

\documentclass{article}
\usepackage{amsmath,amssymb}

\makeatletter
\newcommand{\Cen}[2]{%
  \ifmeasuring@
    #2%
  \else
    \makebox[\ifcase\expandafter #1\maxcolumn@widths\fi]{$\displaystyle#2$}%
  \fi
}
\makeatother


\begin{document}

This is the output format of the four equations:

\begin{align}
\Cen{1}{Y_l^{\mathrm{hx}} \veebar Y_l^{\mathrm{cx}}}
& \quad \forall l \in \mathrm{MS} \\
%
\Cen{1}{
  Y_l^{\mathrm{hx}} \Longleftrightarrow 
  Y_{l,k}^{\mathrm{hx_1}} \veebar Y_{l,k}^{\mathrm{hx_2}} \veebar
  Y_{l,k}^{\mathrm{hx_3}}
}
& \quad \forall l, \; \forall k \in \mathrm{HM}  \\
%
\Cen{1}{
  Y_l^{\mathrm{cx}} \Longleftrightarrow
  Y_{l,k}^{\mathrm{cx_1}} \veebar Y_{l,k}^{\mathrm{cx_2}} \veebar
  Y_{l,k}^{\mathrm{cx_3}}
}
& \quad \forall l, \; \forall k \in \mathrm{CM} \\
%
\Cen{1}{
  Y_{m,k}^{\mathrm{ws_1}} \veebar Y_{m,k}^{\mathrm{ws_2}} \veebar
  Y_{m,k}^{\mathrm{ws_3}}
}
& \quad \forall l, \; \forall k \in \mathrm{WM} 
\end{align}

\end{document}

enter image description here

2

With the alignat environment from amsmath, this is easy:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}

\begin{alignat}{2}
                & \mathrel{\hphantom{\Longleftrightarrow}} Y_l^{\mathrm{hx}} \veebar Y_l^{\mathrm{cx}} & \quad & \forall l \in \mathrm{MS} \\ %
  Y_l^{\mathrm{hx}} & \Longleftrightarrow Y_{l,k}^{\mathrm{hx_1}} \veebar Y_{l,k}^{\mathrm{hx_2}} \veebar Y_{l,k}^{\mathrm{hx_3}} & & \forall l, \; \forall k \in \mathrm{HM} \\ %
  Y_l^{\mathrm{cx}} & \Longleftrightarrow Y_{l,k}^{\mathrm{cx_1}} \veebar Y_{l,k}^{\mathrm{cx_2}} \veebar Y_{l,k}^{\mathrm{cx_3}} & & \forall l, \; \forall k \in \mathrm{CM} \\%
                    &\begin{gathered} Y_{m,k}^{\mathrm{ws_1}} \veebar Y_{m,k}^{\mathrm{ws_2}} \veebar Y_{m,k}^{\mathrm{ws_3}}\end{gathered} & & \forall l, \; \forall k \in \mathrm{WM}
\end{alignat}

\end{document} 

enter image description here

2
  • 1
    Easy, but not centered. ;-)
    – egreg
    Aug 10, 2015 at 9:54
  • I thought it looked better this way. I modified it since I first posted: now I align the first three equations.
    – Bernard
    Aug 10, 2015 at 10:00
1

The centred left hand side is really hard to read. Please try to find some good alignment points and use one of the two following approaches:

% arara: pdflatex

\documentclass{article}
\usepackage{amssymb} % needed for \vbar
\usepackage{mathtools}

\begin{document}    
    This is the output format of the four equations:\setcounter{equation}{16}   
    \begin{align}
        Y_l^{\mathrm{hx}} \veebar Y_l^{\mathrm{cx}} & \quad \forall l \in \mathrm{MS} \\
        %
        Y_l^{\mathrm{hx}} \Longleftrightarrow Y_{l,k}^{\mathrm{hx_1}} \veebar Y_{l,k}^{\mathrm{hx_2}} \veebar
        Y_{l,k}^{\mathrm{hx_3}} & \quad \forall l, \; \forall k \in \mathrm{HM} \\
        %
        Y_l^{\mathrm{cx}} \Longleftrightarrow Y_{l,k}^{\mathrm{cx_1}} \veebar Y_{l,k}^{\mathrm{cx_2}} \veebar
        Y_{l,k}^{\mathrm{cx_3}} & \quad \forall l, \; \forall k \in \mathrm{CM} \\
        %
        Y_{m,k}^{\mathrm{ws_1}} \veebar Y_{m,k}^{\mathrm{ws_2}} \veebar
        Y_{m,k}^{\mathrm{ws_3}} & \quad \forall l, \; \forall k \in \mathrm{WM} 
    \end{align}
    \begin{alignat}{2}
        & Y_l^{\mathrm{hx}} \veebar Y_l^{\mathrm{cx}} && \quad \forall l \in \mathrm{MS} \\
        %
        Y_l^{\mathrm{hx}} \Longleftrightarrow & Y_{l,k}^{\mathrm{hx_1}} \veebar Y_{l,k}^{\mathrm{hx_2}} \veebar
        Y_{l,k}^{\mathrm{hx_3}} && \quad \forall l, \; \forall k \in \mathrm{HM} \\
        %
        Y_l^{\mathrm{cx}} \Longleftrightarrow &Y_{l,k}^{\mathrm{cx_1}} \veebar Y_{l,k}^{\mathrm{cx_2}} \veebar
        Y_{l,k}^{\mathrm{cx_3}} && \quad \forall l, \; \forall k \in \mathrm{CM} \\
        %
        &Y_{m,k}^{\mathrm{ws_1}} \veebar Y_{m,k}^{\mathrm{ws_2}} \veebar
        Y_{m,k}^{\mathrm{ws_3}} && \quad \forall l, \; \forall k \in \mathrm{WM} 
    \end{alignat}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .