Stretch accent over fraction

The following code

\documentclass[12pt]{memoir}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{accents}

\begin{document}

\begin{align*}
1- \frac{x}{x^2-1} - \frac{x-2}{x-x^2} &= 1 - \frac{x}{\left ( x-1 \right ) \left ( x+1 \right )} + \frac{x-2}{x \left ( x-1 \right )} \\
&=\accentset{x(x-1)(x+1)}{\accentset{\smile}{1}} - \accentset{x}{\accentset{\smile}{\frac{x}{(x-1)(x+1)}}} + \accentset{(x+1)}{\accentset{\smile}{\frac{x-2}{x(x-1)}}} \\
&= \frac{x(x-1)(x+1)}{x(x-1)(x+1)} - \frac{x^2}{x(x-1)(x+1)} + \frac{(x-2)(x+1)}{x(x-1)(x+1)} \\
&= \frac{x\left ( x^2-1 \right ) -x^2 + x^2 +x-2x-2}{x(x-1)(x+1)}\\
&= \frac{x^3 - 2x - 2}{x \left ( x-1 \right )\left ( x+1 \right )}
\end{align*}

\end{document}


produces

As you can see the accent over the fraction is quite ugly. Is there a workaround to stretch it? The accents package may be found here.

• My opinion: the floating factors above the second line actually make the equations harder to read and understand, not easier.
– Stef
Commented May 22, 2023 at 6:53

I would like to suggest that you use \overbrace instructions instead of \accentset directives. In the code below, I also use a couple of \vphantom instructions, which insert typographical struts, to assure that the three overbrace symbols are set at the same height.

I would also eliminate several pointless \left/\right auto-sizing directives (since they don't do anything useful, and actually do some harm to the spacing) and shift the & alignment point in row 1 to the left, in order to assure that the five-row align* expression actually fits within the text block.

\documentclass[12pt]{memoir}
%\usepackage{amsmath}  % is loaded automatically by 'mathtools'
\usepackage{mathtools} % for \mathclap macro
%\usepackage{amsfonts} % is loaded automatically by 'amssymb'
\usepackage{amssymb}

%%\usepackage{newpxtext,newpxmath} % optional (Palatino fonts)

\begin{document}

\begin{align*}
1- \frac{x}{x^2-1}
&- \frac{x-2}{x-x^2} = 1 - \frac{x}{(x-1)(x+1)} + \frac{x-2}{x(x-1)} \\[1.5\jot]
&={\overbrace{1\vphantom{\frac{2}{()}}}%
^{\mathclap{\smash[b]{x(x-1)(x+1)}}}
}
- \frac{\overbrace{x\vphantom{2}}^{x}}{(x-1)(x+1)}
+ \frac{\overbrace{x-2}^{x+1}}{x(x-1)} \\[\jot]
&= \frac{x(x-1)(x+1)}{x(x-1)(x+1)}
- \frac{x^2}{x(x-1)(x+1)}
+ \frac{(x-2)(x+1)}{x(x-1)(x+1)} \\[\jot]
&= \frac{x(x^2-1)-x^2+x^2+x-2x-2}{x(x-1)(x+1)} \\[\jot]
&= \frac{x^3-2x-2}{x(x-1)(x+1)}
\end{align*}

\end{document}

• (+1). However, the notation you used is not in the spirit of Greek mathematics. The standard notation is the one I used. Nevertheless, great solution. If nothing else arises, I'll probably use yours. Commented May 21, 2023 at 9:27
• overbrace notation is standard in international mathematics papers. at least ones written in English
– qwr
Commented May 21, 2023 at 20:53