0

I want to make the integral symbol in displayed equations smaller by using the nccmath's \medint command, which looks quite suitable.

Is there a way to always have \medint prepend \int only in displayed math, but without typing a new command, i.e. \int in displaystyle math? Perhaps with \mathchoice?

  • \let\int\medint? But, to my opinion this is not good idea. Beer use original name for integral – Zarko Apr 10 '22 at 20:37
  • @Zarko: This is not what I meant. With this, you would get the \medint size in every context, displaystyle, textstyle, scriptstyle, etc. I only want to change it in displaystyle, if possible. And also, I would have to type \let\int{\medint\int}. – Gargantuar Apr 10 '22 at 20:41
  • Than you need to clarify your question. – Zarko Apr 10 '22 at 21:24
  • Aren't you on the right track with \mathchoice? Like in this answer? – codecepts Apr 15 '22 at 15:39
  • I might be, but I just don't know the internals of \int and \intop and the like. – Gargantuar Apr 15 '22 at 15:46
  • You could have a try with \mathchoice whose 4 arguments define the code used or the 4 math styles. But the problem comes from the fact that \medint is not supposed to be prepended, as it is a command taking the following integral as an argument. Why not simply use \textstyle . Anyway you need it as \medint in displaystyle does'nt change the size of the symbol !! Perhaps prefer scalerel, as suggested in answer suggested by @codecepts comment. – Jhor Apr 15 '22 at 15:52

1 Answers1

1

You can do it, although I don't think it's a good idea.

\documentclass{article}
\usepackage{amsmath}
\usepackage{nccmath}

\RenewDocumentCommand\int{t\limits t\nolimits e{^_}}{% \mathpalette\usemedint{{#1}{#2}{#3}{#4}}% } \ExplSyntaxOn \NewDocumentCommand{\usemedint}{mm} { \gargantuar_medint:Nnnnn #1 #2 } \cs_new_protected:Nn \gargantuar_medint:Nnnnn { \use:e { \token_if_eq_meaning:NNT #1 \displaystyle { \exp_not:N \medint } \intop \bool_if:nT { #2 } { \limits } \bool_if:nT { #3 } { \nolimits } \tl_if_novalue:nF { #4 } { \sp { \exp_not:n { #4 } } } \tl_if_novalue:nF { #5 } { \sb { \exp_not:n { #5 } } } } } \cs_generate_variant:Nn \gargantuar_medint:Nnnn { Neee } \ExplSyntaxOff

\begin{document}

\begin{center} $\int_a^b f(x),dx$ \end{center}

[ \int_a^b f(x),dx + \int\limits_\Gamma g(z),dz ]

[ \int\limits_{\text{test}} \qquad \int\nolimits_\Gamma ]

[ \int_{\text{test}} \qquad \int\nolimits_\Gamma ]

\end{document}

enter image description here

The trick is to gather all possible tokens following \int, namely a possible \limits or \nolimits, then the superscript and the subscript. The whole lot is preceded, if in \displaystyle, by \medint.

For comparison, here's the standard output

enter image description here

Here's the output if amsmath is called with the intlimits option.

enter image description here

egreg
  • 1,121,712
  • Why don't you think that it isn't a good idea? I'm trying to typeset a lecture script in German, and in German tradition, we have the intlimits option with smaller integrals, as e.g. the integrals in unicode. If you have a better idea (e.g. I've seen the scalerel package), I'm very open about it (since your solution doesn't look like it is meant to be done). See e.g. Königsberger: Analysis 1 for a good standard. – Gargantuar Apr 15 '22 at 21:55