5

In the following align environment I use two columns of formulas, one left and one right-aligned. In the first line the left part is very long, and in the third line the right part is really long and is then forced to overflow the line and push the eq. numbering to the next line.

Is it possible to make the right part in the third line disregard the alignment, and just be right-aligned before the eq. numbering?

\documentclass[a4paper]{article}
\usepackage{amsmath}

\begin{document}
\begin{align}
 &b_k + H_k \leq E_g \cdot d^s_{g,k,j} + (1 - d^s_{g,k,j})\cdot (J+1), && \forall j \in T, \, k \in V, \, g \in G \\
 &b_k \geq S_g \cdot d^s_{g,k,j}, && \forall j \in T, \, k \in V, \, g \in G \\
 &d^s_{g,k,j} + d^s_{g',\ell,j} \leq 2 - u_{k,\ell},  && \forall j \in T, \, k, \ell \in V,\,g, g' \in G, \, g' < g
\end{align}
\end{document}

Screenshot

2
  • 1
    Dirty manual hack: \hskip-1.9cm\forall Commented yesterday
  • Remember that you can also write the two different for all parts on the line after the equations referring to the eq-numbers they are for.
    – daleif
    Commented yesterday

3 Answers 3

6

Here is what I'd probably do

\documentclass[a4paper]{article}
\usepackage{amsmath}

\begin{document}
\begin{gather}
  b_k + H_k \leq E_g \cdot d^s_{g,k,j} + (1 - d^s_{g,k,j})\cdot (J+1), \label{A} \\
 b_k \geq S_g \cdot d^s_{g,k,j}, \label{B} \\
 d^s_{g,k,j} + d^s_{g',\ell,j} \leq 2 - u_{k,\ell},  \label{C}
\end{gather}
where equations \eqref{A} and \eqref{B} are for all $j \in T, \, k \in V, \, g \in G$ and equation \eqref{C} 
is for all $j \in T, \, k, \ell \in V$, and all $g, g' \in G$, with $g' < g$.
\end{document}

enter image description here

6

I suggest you give \mathllap a try.

enter image description here

\documentclass[a4paper]{article}
\usepackage{mathtools} % for '\mathllap' macro

\begin{document}

\counterwithin{equation}{section} % just for this example
\appendix
\stepcounter{section}
\setcounter{equation}{23}

\begin{align}
 &b_k + H_k \leq E_g \cdot d^s_{g,k,j} 
   + (1 - d^s_{g,k,j})(J+1), 
 & \forall j\in T,\, k\in V,\, g\in G& \\
 &b_k \geq S_g \cdot d^s_{g,k,j}, 
 & \forall j\in T,\, k\in V,\, g\in G& \\
 &d^s_{g,k,j} + d^s_{g',\ell,j} \leq 2 - u_{k,\ell},  
 & \mathllap{\forall j\in T;\, k,\ell\in V;\, g, g'\in G;\, g'<g}&
\end{align}
\end{document}
2
  • 2
    +1 for replicating the same numbering :) Imho, using \mathllap seems like a dirtier hack than using \hspace*{-22mm} which allows to right-align it more precisely (for example in your screenshot the g is standing over). Is there no way to do this in a "clean" way?
    – johk95
    Commented yesterday
  • @johk95 - I've modified the answer to eliminate what you call a standover.
    – Mico
    Commented yesterday
3

You can give IEEEtrantools a try.

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{IEEEtrantools}

\begin{document}

% borrowed from Mico's answer
\counterwithin{equation}{section} % just for this example
\appendix
\stepcounter{section}
\setcounter{equation}{23}
%%%

\begin{IEEEeqnarray}{c}
b_k + H_k \leq E_g \cdot d^s_{g,k,j} + (1 - d^s_{g,k,j})(J+1), 
\ \hfill
\forall j\in T,\, k\in V,\, g\in G
\\
b_k \geq S_g \cdot d^s_{g,k,j}, 
\ \hfill
\forall j\in T,\, k\in V,\, g\in G
\\
d^s_{g,k,j} + d^s_{g',\ell,j} \leq 2 - u_{k,\ell},
\ \hfill
\forall j\in T;\, k,\ell\in V;\, g, g'\in G;\, g'<g
\end{IEEEeqnarray}

\end{document}

output

You must log in to answer this question.

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