latex3 / mathtools

Mathematical tools to use with amsmath
LaTeX Project Public License v1.3c
57 stars 7 forks source link

Awkward spacing with some operators and paired delimiter #53

Closed Enivex closed 9 months ago

Enivex commented 1 year ago

If I define \DeclarePairedDelimiter{\brak}{\lbrack}{\rbrack} then spacing will often be way to cramped (in my opinion) between operators and large versions of the delimiter.

\lim_{n\to \infty}\brak*{\int_0^\infty}\quad \sum_{n\to \infty}\brak*{\int_0^\infty}

displays as

image

The reason for this is obviously the \mathopen in the definition. Which is great for operators like \sin, but not so great in these cases (in my opinion). I much prefer to do something like

\lim_{n\to \infty}{}\brak*{\int_0^\infty}\quad \sum_{n\to \infty}{}\brak*{\int_0^\infty}

which displays as

image

The $n \to \infty$ and $n=0$ are no longer uncomfortably close to the delimiter.

My question is: Is there a better way to handle this than having to manually add {} to add space in these cases?

(This also happens with other delimiters, but I chose brackets to illustrate the issue)

davidcarlisle commented 1 year ago

I'd say this is by design, although rather than add {} each time you could adjust the definition

\DeclarePairedDelimiter{\brakinner}{\lbrack}{\rbrack}
\newcommand\brak{{}\brakinner}
Enivex commented 1 year ago

I could do that, but it doesn't change the fact that I would have to manually use different versions depending on context.

After thinking about it, I think I'd want the space for any operator with limits set above and below in display math (i.e. sum, lim, anything defined with \DeclareMathOperator*}. Would it be possible to achieve something like that automatically?

Edit: Alternatively I'll have to learn to like the default spacing.

juhaszp95 commented 1 year ago

Hello,

Somewhat related to this (although not exactly) is that I get awkward spacing when using Libertinus with mathtools. Consider the following MWE (in LuaTeX):

\documentclass[12pt]{article}
\usepackage{libertinus-otf}

\usepackage{mathtools}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}

\begin{document}
    $c\lvert c \rvert \ c\abs{c} \ c\abs*{c}$
\end{document}

I get the following output: image

Notice how the spacing is off in the last case, and c comes very close to colliding with |. I'm not sure if this is a font issue or a mathtools issue, but given the spacing is different between the starred and non-starred version of the command, I thought it might be the latter.

daleif commented 1 year ago

First of, please don't hijack questions (make your own issue). Secondly the problem is also present without mathtools: $c\lvert c \rvert\quad \left\lvert c \right\rvert$ so I don't think this has anything to do with mathtools.

daleif commented 9 months ago

As David mentioned the \mathopen is by design. Will not be changed,