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.

David Carlisle
  • 757,742
Martijn
  • 101

1 Answers1

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}

Peter Grill
  • 223,288
  • 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 03 '12 at 03:05
  • @Qrrbrbirlbel: Thanks, incorporated that as well. – Peter Grill Dec 03 '12 at 03: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 03 '12 at 09: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 03 '12 at 09: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 03 '12 at 09:34
  • Hi Peter, my department at the university provides a documentclass with a lot of build in options to keep publications uniform. Unfortunatly I can therefor not provide a MWE with a documentclass.

    I can also not upload a picture to show you the difference between the example in my original post and the result I get now. Hopefully I can do so in the future with more credits.

    – Martijn Dec 03 '12 at 09:49
  • Well then I believe that the problem lies in your custom document class. You can upload an image picture icon if you edit your question. Then just remove the leading ! and someone with more rep will put the ! back in and the image will be displayed. – Peter Grill Dec 03 '12 at 09:52