[Tex/LaTex] Horizontal alignment argument for ‘subscript’ of \underbrace

horizontal alignmentmath-mode

The picture below shows what I'm able to produce, but what I'd really like is to have the "coefficient" text aligned to the right (meaning that the tip of the \underbrace points to the 't') and the "variable" text aligned to the left (meaning that the tip of the second underbrace points tot the 'v'). Surely this is possible! [But I haven't figured out how … I naively tried a [l] or [r] argument with \underbrace, but had no success.]

Here is a MWE (minimum working example) of my source that I have used with pdflatex:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

$$\overbrace{\underbrace{-\pi\vphantom{(y)}}_\text{coefficient}\underbrace{y^2\vphantom{(y)}}_\text{variable}}^\text{term}$$

\end{document} 

Horizontal alignment argument for 'subscript' of \underbrace

Best Answer

mathtools provides \mathrlap and \mathllap for overlapping content to the right/left. The following does that with some negative space to position the letters under the \underbrace tip:

enter image description here

\documentclass{article}
\usepackage{mathtools}% http://ctan.org/pkg/mathtools
\begin{document}
\[
  \overbrace{
    \underbrace{-\pi\vphantom{(y)}}_\text{coefficient}
    \underbrace{y^2\vphantom{(y)}}_\text{variable}}^\text{term}
\]


\[
  \overbrace{
    \underbrace{-\pi\vphantom{(y)}}_{\mathllap{\text{coefficient}\!}}
    \underbrace{y^2\vphantom{(y)}}_{\mathrlap{\!\text{variable}}}}^\text{term}
\]
\end{document}