Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
1  
Leave the second & out. The columns in align (and family) are rlrlrl… aligned. Or use aligned and a & \le b && \le c. –  Qrrbrbirlbel Dec 2 '12 at 21:50
1  
Also, don't use the same \label ("eq:constr1") more than once. –  Mico Dec 2 '12 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 –  Qrrbrbirlbel Dec 2 '12 at 21:58
    
In reality b and e are strings of unequal length, sorry for not mentioning that. –  Martijn Dec 2 '12 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. –  Qrrbrbirlbel Dec 2 '12 at 22:19
show 1 more comment

1 Answer

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}
share|improve this answer
    
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. –  Qrrbrbirlbel Dec 3 '12 at 3:05
    
@Qrrbrbirlbel: Thanks, incorporated that as well. –  Peter Grill Dec 3 '12 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 Dec 3 '12 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. –  Peter Grill Dec 3 '12 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}. –  Peter Grill Dec 3 '12 at 9:34
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.