# How to remove the upper space above \frac{…}{…} in \left[…\right]?

If you render the code below, you'll see a large space over the top of the fraction. How to remove that space?

$$\left[\frac{x}{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x}}}}}}}}}}}}}}}}}}}\right]$$


I want to achieve this desired effect:

Note how the space above is removed, while the alignment of the equation is still as before (the horizontal line of the fraction is in its place).

I'm not sure you really want to do it, because the fraction will be misaligned with respect to everything else in the equation.

\documentclass{article}
\usepackage{amsmath}
\usepackage{delarray}

\begin{document}

$$\begin{array}\lbrack{@{}c@{}}\rbrack \dfrac{x}{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x}}}}}}}}}}}}}}}}}}} \end{array}$$

\end{document}


In order to properly realign the fraction line, some moving around is needed:

\documentclass{article}
\usepackage{amsmath}
\usepackage{delarray}

\begin{document}

$$\sbox{0}{\dfrac{x}{y}} y=\raisebox{\dimexpr\ht0-\height}{% \begin{array}\lbrack{@{}c@{}}\rbrack \dfrac{x}{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x}}}}}}}}}}}}}}}}}}} \end{array}}$$

\end{document}


• Is your answer a reply to John Kormylos answer, to use a \raisebox. At least, thats, what I read from your "you don't want to do it" ... If I am right, please add that in your text. – Jan Jan 10 '17 at 18:54
• @Jan No, it's a reply to the OP – egreg Jan 10 '17 at 20:34
• @Jan I really can't understand what your comment is about. I answered the OP, adding that it's better to not doing something like this. What's wrong with it? – egreg Jan 10 '17 at 21:00
• I added a figure depicting what I want to achieve. It turns out that none of the solutions that are provided here actually do what I want. – caveman Jan 12 '17 at 8:11
• @caveman Exactly what I predicted. ;-) I added the trick, but I find the result awful. – egreg Jan 12 '17 at 9:08

The \left \right syntax will vertically center the baseline (actually, a point about 2.5pt above the baseline) in the reserved space. To move the baseline up or down, use \raisebox.

\documentclass{article}
\usepackage{mathtools}
\begin{document}
$$\left[\raisebox{\dimexpr 2.5pt+0.5\depth-0.5\height}% {\displaystyle \frac{x}{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x}}}}}}}}}}}}}}}}}}}}% \right]$$
\end{document}


\newcommand{\CenterObject}[1]{\ensuremath{\vcenter{\hbox{#1}}}}
$$\left[\CenterObject{\displaystyle\frac{x}{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x_{x}}}}}}}}}}}}}}}}}}}}\right]$$