[Tex/LaTex] Underbrace messing with horizontal spacing

underbrace

Consider the following MWE:

\documentclass{article}
\usepackage{amsmath,stackengine}
\stackMath
\begin{document}
\renewcommand\useanchorwidth{T}
\begin{equation*}
\left( 0, \ldots, \underbrace{e_j}_\text{$i$-th postion}, \ldots, 0 \right)
\end{equation*}
\end{document}

This produces the following output:

enter image description here

The problem is that I followed Steven B. Segletes' solution in Underbrace changing spacing of operators in order to prevent the underbrace text from messing with the horizontal spacing of the surrounding ldots. Does anyone know what I've done wrong?

And I'd also like the parentheses to ignore the underbrace text with regards to automatic vertical sizing; I'm not sure if I should put that in a separate question because I'm new to the site!

Best Answer

I propose one of these solutions, more elegant from my point of view, than an oversized \underbrace. They're based respectively on the \underbracket command from mathtools, or on the \bclap command from stackengine.

\documentclass{article}
\usepackage{mathtools}
\usepackage[usestackEOL]{stackengine}

\begin{document}

\begin{equation*}
\bigl( 0, \ldots,  \underbracket[0.4pt]{e_j}_{\clap{\scriptsize$i$-th position}}, \ldots, 0 \bigr)\vspace*{3ex}
\end{equation*}

Some text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. 
\begin{equation*}
\bigl( 0, \ldots, e_{\stackMath\bclap{\substack{\boldsymbol{\vert}\\\text{\scriptsize $ i $-th position}}}j}, \ldots, 0 \bigr)
\end{equation*}
Some text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. 

\end{document} 

enter image description here

Related Question