2

I have aligned display equations similar to the following example. I'm using words as placeholders here, but they are actually mathematical expressions:

\begin{gather}
\begin{alignedat}{3}
 (& \text{dolor}       && +\text{adipiscing} && +\text{amet} \\
  & \text{consectetur} && -\text{sit}        && -\text{elit} && )
\end{alignedat}
\end{gather}

aligned display equation

I want to add an underbrace to each alignment column. In other words, there are three groups of terms, each consisting of one term in the first and one in the second row:

\begin{gather}
\begin{alignedat}{3}
 (& \text{dolor} && +\text{adipiscing} && +\text{amet} \\
  &  \underbrace{\text{consectetur}}_{\text{first}}
  && \underbrace{-\text{sit}}_{\text{second}}
  && \underbrace{-\text{elit}}_{\text{third}} && )
\end{alignedat}
\end{gather}

aligned display equation with naive underbraces

Each underbrace only spans the width of its term in the second row. Instead, I would like to place an underbrace that spans the widest term in its align column, indicating that it applies to all terms in this column. Here is a photoshop example:

aligned display equation with underbrace labels

Is this possible in a generic way, i.e. without having to manually create phantom elements of the longest term of each column for every such equation block?

4

You can use the eqparbox package for that. I would not extend the underbrace over the signs, but keep them outside.

\documentclass{article}
\usepackage{amsmath}
\usepackage{eqparbox}
\begin{document}
\begin{gather}
\begin{alignedat}{3}
 (& \eqmakebox[A][l]{dolor} && +\eqmakebox[B][l]{adipiscing} &&
 +\eqmakebox[C][l]{amet} \\
  &  \underbrace{\eqmakebox[A][l]{consectetur}}_{\text{first}}
  && -\underbrace{\eqmakebox[B][l]{sit}}_{\text{second}}
  && -\underbrace{\eqmakebox[C][l]{elit}}_{\text{third}} && )
\end{alignedat}
\end{gather}
\end{document}

enter image description here

Or following suggestions by barbara beeton.

\documentclass{article}
\usepackage{amsmath}
\usepackage{eqparbox}
\begin{document}
\begin{gather}
\begin{alignedat}{3}
 (&\, \eqmakebox[A][l]{dolor} && \eqmakebox[B][l]{$\,{}+\text{adipiscing}$} &&
 \eqmakebox[C][l]{$\,{}+\text{amet}$} \\
  &  \underbrace{\eqmakebox[A][l]{consectetur}}_{\text{first}}
  && \underbrace{\eqmakebox[B][l]{${}-\text{sit}$}}_{\text{second}}
  && \underbrace{\eqmakebox[C][l]{${}-\text{elit}$}}_{\text{third}} && )
\end{alignedat}
\end{gather}
\end{document}

enter image description here

Or

\documentclass{article}
\usepackage{amsmath}
\usepackage{eqparbox}
\begin{document}
\begin{gather}
\begin{alignedat}{3}
 (\!&\, \eqmakebox[A][l]{dolor} && \,\eqmakebox[B][l]{${}+\text{adipiscing}$} &&
 \,\eqmakebox[C][l]{${}+\text{amet}$} \\
  &  \underbrace{\eqmakebox[A][l]{consectetur}}_{\text{first}}
  && \underbrace{\eqmakebox[B][l]{${}-\text{sit}$}}_{\text{second}}
  && \underbrace{\eqmakebox[C][l]{${}-\text{elit}$}}_{\text{third}} && )
\end{alignedat}
\end{gather}
\end{document}

enter image description here

|improve this answer|||||
  • 1
    I'm not sure why, but the alignment is a little bit off. A manual adjustment adding a thinspace at the beginning of each segment in the first line would probably line things up, but obviously it's not the best approach. – barbara beeton Feb 22 at 20:50
  • @barbarabeeton Thanks for the heads up! I agree. I actually would not include the signs in the underbraces. – Schrödinger's cat Feb 22 at 20:56
  • But neither element in the first column has a sign. What about adding a zero-height hphantom of the braces to the first line? (Might have to adjust the vertical spacing.) – barbara beeton Feb 22 at 20:59
  • @barbarabeeton Thanks! Two more proposals.... ;-) – Schrödinger's cat Feb 22 at 21:10
  • 1
    Yay! Much better! – barbara beeton Feb 22 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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