3

In the following excerpt, I was wondering how to center the expression J'_{+}(x^*)(y-x^*), located in the second column of the first line, between the \leq and = signs. I tried to insert \hfill with no effect.

Thanks.

enter image description here

\documentclass{extbook}
\usepackage{amsmath}

\begin{document}
\begin{alignat}{2} 0 & \leq J'_{+}(x^)(y-x^) && = \lim_{t \downarrow 0} \frac{J \big[ x^ + t(y-x^) \big] - J(x^)}{t} \ h & \leq \lim_{t \downarrow 0} \frac{t J(y) + (1-t) J(x^) - J(x^)}{t} && = J(y)-J(x^). \end{alignat} \end{document}

AEW
  • 819

2 Answers2

5

Like this?

enter image description here

\documentclass{article}
\usepackage{amsmath}
\usepackage{IEEEtrantools}
\begin{document}

\begin{IEEEeqnarray}{cCcCl} 0 & \leq & J'{+}(x^)(y-x^) & = & \lim{t \downarrow 0} \frac{J \big[ x^* + t(y-x^) \big] - J(x^)}{t} \ h & \leq & \lim_{t \downarrow 0} \frac{t J(y) + (1-t) J(x^) - J(x^)}{t} & = & J(y)-J(x^*). \end{IEEEeqnarray}

\end{document}

Stephen
  • 3,826
  • Yes, @Stephen, thank you. Is there a solution with the standard math environments? – AEW Jul 12 '23 at 21:18
4

You'd have to measure the width of the larger expression, which would allow you to place thinner objects within a larger box and adjust the alignment, if needed. This can be automated using eqparbox:

enter image description here

\documentclass{extbook}

\usepackage{amsmath,eqparbox}

% https://tex.stackexchange.com/a/34412/5764 \makeatletter \NewDocumentCommand{\eqmathbox}{o O{c} m}{% \IfValueTF{#1} {\def\eqmathbox@##1##2{\eqmakebox[#1][#2]{$##1##2$}}} {\def\eqmathbox@##1##2{\eqmakebox{$##1##2$}}} \mathpalette\eqmathbox@{#3} } \makeatother

\begin{document}

\begin{alignat}{2} 0 & \leq \eqmathbox[JJ]{ J'_{+} (x^) (y - x^) } && = \lim_{t \downarrow 0} \frac{J \big[ x^ + t (y - x^) \big] - J(x^)}{t} \ h & \leq \eqmathbox[JJ]{\lim_{t \downarrow 0} \frac{t J(y) + (1 - t) J(x^) - J(x^)}{t}} && = J(y) - J(x^). \end{alignat}

\end{document}

\eqmathbox[<tag>][<align>]{<stuff>} figures out the maximum width needed for <stuff> across the same <tag>. Individual <align>ment can be changed for <stuff> that isn't the widest across the same <tag> (default is centred).

If you don't enjoy this automation, then use this:

\newsavebox{\bigmath}
\savebox{\bigmath}{$\displaystyle \lim_{t \downarrow 0} \frac{t J(y) + (1 - t) J(x^*) - J(x^*)}{t}$}% Capture large math object

\begin{alignat}{2} 0 & \leq \makebox[\wd\bigmath]{$J'_{+} (x^) (y - x^)$} && = \lim_{t \downarrow 0} \frac{J \big[ x^ + t (y - x^) \big] - J(x^)}{t} \ h & \leq \lim_{t \downarrow 0} \frac{t J(y) + (1 - t) J(x^) - J(x^)}{t} && = J(y) - J(x^*).

Werner
  • 603,163
  • Thank you, @Werner, for the detailed answer. – AEW Jul 12 '23 at 21:47
  • I’m not sure that the label should be an optional argument, because each such measurement needs a specific label. – egreg Jul 13 '23 at 11:27