latex3 icon indicating copy to clipboard operation
latex3 copied to clipboard

xfrac: make \sfrac (optionally) produce a \mathinner atom

Open schtandard opened this issue 5 years ago • 2 comments

I often find that \sfrac fractions need to be separated from adjacent terms by additional space in math expressions. image Many times, treating the fraction as a \mathinner atom produces pleasing results. image I would like \sfrac to create a \mathinner atom by default when used in math mode.

Currently the only option is to write a wrapper macro that inserts the \mathinner command when in math mode, but that seems a bit clumsy and redundant, since \sfrac checks for math mode anyways. (One could also modify \sfrac, of course, but that should not be encouraged.) A package option that facilitates this would be really nice.


MWE used to produce the examples above:

\documentclass{article}

\usepackage{xfrac}

\begin{document}

\(\sfrac{2}{3} b\)

\(\sfrac{a}{2} (b + c)\)

\vskip 2ex

\(\mathinner{\sfrac{2}{3}} b\)

\(\mathinner{\sfrac{a}{2}} (b + c)\)

\end{document}

schtandard avatar Nov 15 '20 13:11 schtandard

The main use cases were always text mode, hence this wasn't thought about much back then. I agree, making it an Inner atom would probably often lead to a more visually pleasing output and would also squarely put in the same category as if using \frac.

Hoegholm avatar Nov 18 '20 11:11 Hoegholm

and would also squarely put in the same category as if using \frac.

Surprisingly, \frac does not create inner atoms (cf. [1], [2]). This shouldn't discourage this change, though, I think.

schtandard avatar Nov 18 '20 11:11 schtandard