# Five iterated integrals

Apparently, there are the commands \iint, \iiint, and \iiiint to type iterated integral symbols. To compute an integral in R^4 x [0,T] (i.e. over a 4-dimensional space and time), I would type \iiiiint_{\mathbb R^4 \times [0,T]}, except that the command \iiiiint is not pre-defined. Is there a way to type a symbol containing five iterated integrals?

• $\iiiint\!\!\int$
– Cfun
Jul 8, 2016 at 22:33
• amsmath provides \idotsint. Jul 8, 2016 at 22:33
• @SAM: in display math, you need \iiiint\!\!\!\int. (Cf. The TeXbook, bottom of p. 169.)
– GuM
Jul 8, 2016 at 22:43
• I am using TexMaKer i.stack.imgur.com/LJGfj.png
– Cfun
Jul 8, 2016 at 22:51
• After seeing your edit, I’d say that \idotsint_{\mathbb R^4 \times [0,T]} is sufficiently clear for the reader, and definitely looks better. Now, really, good night to everybody!
– GuM
Jul 8, 2016 at 23:15

The amsmath package already provides the infrastructure:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\ams@newcommand{\iiiiint}{\DOTSI\protect\MultiIntegral{5}}
\renewcommand{\MultiIntegral}[1]{%
\edef\ints@c{\noexpand\intop
\ifnum#1=\z@\noexpand\intdots@\else\noexpand\intkern@\fi
\ifnum#1>\tw@\noexpand\intop\noexpand\intkern@\fi
\ifnum#1>\thr@@\noexpand\intop\noexpand\intkern@\fi
\noexpand\intop
\noexpand\ilimits@
}%
\futurelet\@let@token\ints@a
}
\makeatother

\begin{document}
\begin{gather}
\iiiiint
\\
\iiiiint_{\Gamma}
\\
\iiiiint\limits_{\Gamma}
\end{gather}
\end{document}


A variant allowing any number of integral signs; \multiint should only be used with an argument at least 2.

\documentclass{article}
\usepackage{amsmath}
\usepackage{expl3}

\makeatletter
%\ams@newcommand{\iiiiint}{\DOTSI\protect\MultiIntegral{5}}
\ams@newcommand{\multiint}[1]{\DOTSI\protect\MultiIntegral{#1}}
\renewcommand{\MultiIntegral}[1]{%
\edef\ints@c{\noexpand\intop
\ifnum#1=\z@\noexpand\intdots@\else\noexpand\intkern@\fi
\replicate{#1-2}{\noexpand\intop\noexpand\intkern@}%
\noexpand\intop
\noexpand\ilimits@
}%
\futurelet\@let@token\ints@a
}
\makeatother
\ExplSyntaxOn
\cs_new:Npn \replicate #1 #2 { \prg_replicate:nn { #1 } { #2 } }
\ExplSyntaxOff

\begin{document}
\begin{gather}
\multiint{6}
\\
\multiint{6}_{\Gamma}
\\
\multiint{6}\limits_{\Gamma}
\end{gather}
\end{document}


• Simply programmation side, why it doesn't work after 5 ? #1>4
– Cfun
Jul 8, 2016 at 22:44
• Just add more lines with #1>5, #1>6, etc. You could definitely add a command there to do the work rather than add one line at a time, for instance \replicate{#1-2}{\noexpand\intop\noexpand\intkern@}. Each line adds an integral sign more, so if you have 5 lines, at most you have 5 integrals. But I think it could be done more efficiently. Jul 8, 2016 at 22:47
• but #1>4 is verified for 5 !
– Cfun
Jul 8, 2016 at 22:48
• @SAM: Yes indeed, but the code that is executed if #1>4 simply adds one integral sign!
– GuM
Jul 8, 2016 at 22:51
• @SAM I added a version allowing any number Jul 8, 2016 at 23:11