6

I want to create subequations and allign them such that nice 'inquality constraints' arise. My current code:

\begin{subequations}
\begin{align}
a & \le b & \le c \label{eq:constr1}\\
d & \le effff & \le f \label{eq:constr1}\\
\end{align}
\label{eq:constr}%
\end{subequations}

The result in PDF is a much too large distance between "b and c" and "efffff and f". I would like to have \le exactly below eachother. Have b and effff centered between those. Finally a and d should be right aligned to the \le and c and f should be left aligned to the \le.

6
  • 1
    Leave the second & out. The columns in align (and family) are rlrlrl… aligned. Or use aligned and a & \le b && \le c. Commented Dec 2, 2012 at 21:50
  • 1
    Also, don't use the same \label ("eq:constr1") more than once.
    – Mico
    Commented Dec 2, 2012 at 21:52
  • … or (“centering for b and e”) use simply a \le b & \le c (i.e. leave the first & out). Related: alignat examples, more complex case of alignments Commented Dec 2, 2012 at 21:58
  • In reality b and e are strings of unequal length, sorry for not mentioning that.
    – Martijn
    Commented Dec 2, 2012 at 22:14
  • 2
    @Martijn Well, a minimal working example (MWE) could help out and maybe an image of what you actually want to achieve. Commented Dec 2, 2012 at 22:19

1 Answer 1

8

If you want the middle column to be centered than you need to either resort to using a \makebox to reserve enough width for that column, which requires knowing what the widest element is beforehand, or to use an array:

enter image description here

Notes

  • The alignat provides pairs of rl aligned equations. Since we want the third column to be left aligned, we need to use a && to skip past the prior column that would have been right aligned.
  • For the array solution we need to use {} to make the inequality symbols be treated as relational operators, similar to the difference in spacing of $-x$ and ${}-x$.
  • The calc package was used for the \widthof{} macro, so is only required for the alignat solution.
  • As Qrrbrbirlbel commented, you could make use of the array package and incorporate the required {} into the column specification, as shown in the last example in the code below.

Code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{calc}
\usepackage{array}

\newcommand*{\Widest}{effff}%
\newcommand*{\WideAs}[1]{\makebox[\widthof{$\Widest$}][c]{$#1$}}%
\begin{document}\noindent
You can use \verb|alignat|:
%
\begin{alignat*}{3}
    a & \le \WideAs{b}     && \le c \\
    d & \le \WideAs{effff} && \le f 
\end{alignat*}
%
Or use \verb|array|:
%
\[\begin{array}{r@{}c@{}l}
    a \le {}& b     &{} \le c \\
    d \le {}& effff &{} \le f 
\end{array}\]
%
Alternatively using the \verb|array| package:
\[\begin{array}{r<{{}}@{}c@{}>{{}}l}
    a \le & b     & \le c \\
    d \le & effff & \le f 
\end{array}\]
\end{document}
7
  • You could use {r<{{}}@{}c@{}>{{}}l} (array package) to mimic the behavior of *align* and wouldn’t have to manually insert {}. And you might point out that alignat does provide equation numbers quite easier than array. Commented Dec 3, 2012 at 3:05
  • @Qrrbrbirlbel: Thanks, incorporated that as well. Commented Dec 3, 2012 at 3:11
  • Thank you so much! The equations however are compressed in height as would normally don for using $some-equation$. What would be a solution to keep the proper full size?
    – Martijn
    Commented Dec 3, 2012 at 9:26
  • @Martijn: I do not know why you think the equations are compressed. The solutions here produce the correct display mode math spacing. If you are using inline math (as is the case $some-equation$, then the equations are compressed in order to not alter the interline spacing of a paragraph. Commented Dec 3, 2012 at 9:33
  • If you still think they are compressed I would recommend you post a follow up question and be sure to include a minimum working example including \documentclass and the appropriate packages that illustrates this compression. It should start with \documentclass{} and end with \end{document}. Commented Dec 3, 2012 at 9:34

You must log in to answer this question.

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