Take a look at the following code:
$$\begin{array}{rr|r|c|l}
vd_2:&\raisebox{0pt}[0pt]{\makebox[0pt][l]{$\overbrace{\phantom{b_1\dots b_{n-l_{k-1}-2k}\hspace{2\arraycolsep}b_{n-l_{k-1}-2k+1}\dots b_{n-k-1}b_{n-k}\hspace{2\arraycolsep}c^k}}^v$}}b_1\dots b_{n-l_{k-1}-2k}&b_{n-l_{k-1}-2k+1}\dots b_{n-k-1}b_{n-k}&c^k&d_2\\
\mathrm{PW}(w):&\dots w_r c^{r+1-k}&c^k\raisebox{0pt}[0pt][0pt]{\makebox[0pt][l]{$\underbrace{\phantom{w_{k-1}\hspace{4.17em}\hspace{2\arraycolsep}c^k\hspace{2\arraycolsep}\widetilde{w_{k-1}}\dots}}_{w_r}$}}w_{k-1}\hspace{4.17em}&c^k&\widetilde{w_{k-1}}\dots\dots
\end{array}$$
I would like to draw the \underbrace
in a more elegant way. The main problem is how to make sure that $c^kw_{k-1}$
is in the dead center of the column. In the proposed code, it has been done artifically: the empty space of length 4.17em
is added to the right of $c^kw_{k-1}$
, where the value 4.17em
is obtained by trial-and-error. This works nicely in 12pt
, but if the font size is changed, it slides off the center. Even if there were not a problem with changing the font size, it would seem logical that there is a nicer way to accomplish this effect, instead of guessing the value 4.17em
(or whichever works for the particular font size) until a good enough pixel-precision is reached.
Best Answer
This is fairly straight forward to do using the
savepos
module from thezref
package. It allows you to place markers (or labels) in the text and retrieve their coordinates (x and y) in small point (orsp
) units. The code is also much cleaner without the box adjustments you used.Taking your code, I've defined the labels
L
to denote the left-most entry in yourarray
(as a frame of reference),TL
andTR
to be the left and right\overbrace
coordinate in the top row, andBL
andBR
to be the left and right\underbrace
coordinate in the bottom row.Then I construct an invisible table before typesetting the actual table. The invisible is overlapped by the actual table using
\mathrlap
(to produce a right overlap in math mode) from themathtools
package. Finally, spacing is obtained by\hspace
s as needed. Vertical alignment is rectified using\strut
, since there is otherwise no content to adjust the height/depth above/below the\overbrace
/\underbrace
. Using\mathstrut
instead results in slightly weaker vertical alignment:Above is new
zref
version, while your original construction is given below. Since this useszref
and positioning labels, you have to compile (at least) twice for the referencing to be correct.