# Lower and upper Riemann integrals?

How can I make an integral symbol with a bar above it or a bar below it?

• Mathematical FYI: Technically they are lower and upper Darboux integrals. The Riemann integral is defined using tagged partitions instead. Of course the two definitions are equivalent as per the sketch of a proof given in the first Wikipedia article. Commented Feb 12, 2012 at 6:08

From what I've seen online, it suffices to use \overline and \underline.

Here is a minimal example that defines

\upRiemannint{<lo>}{<hi>}


which draws the "upper Riemann integral" over the range [<lo>,<hi>]. Analogously,

\loRiemannint{<lo>}{<hi>}


defines the "lower Riemann integral" over the range [<lo>,<hi>].

\documentclass{article}
\newcommand{\upRiemannint}[2]{
\overline{\int_{#1}^{#2}}
}
\newcommand{\loRiemannint}[2]{
\underline{\int_{#1}^{#2}}
}
\begin{document}
$\loRiemannint{a}{b} f(x)\,\mathrm{d}x \qquad \textrm{or} \qquad \upRiemannint{a}{b} f(x)\,\mathrm{d}x$
\end{document}


These integrals also translate to use in text mode, but vertical alignment is slightly off due to the integral sign by default.

• Sorry for this negative comment but the output of your code just doesn't look right to my mathematical eye. Leo Liu got the right output. I wonder if the his code could be simplified? Commented Feb 13, 2012 at 1:54
• @PredragPunosevac: I agree. I found this source and went from there...
– Werner
Commented Feb 13, 2012 at 15:22
• @PredragPunosevac yes, it may look bad, but that's how it is expressed in lots of books. Commented Mar 7, 2013 at 16:31

Personally I use shorter bars. It makes the macro much more complex:

\documentclass{article}
\usepackage{amsmath}
\def\upint{\mathchoice%
{\mkern13mu\overline{\vphantom{\intop}\mkern7mu}\mkern-20mu}%
{\mkern7mu\overline{\vphantom{\intop}\mkern7mu}\mkern-14mu}%
{\mkern7mu\overline{\vphantom{\intop}\mkern7mu}\mkern-14mu}%
{\mkern7mu\overline{\vphantom{\intop}\mkern7mu}\mkern-14mu}%
\int}
\def\lowint{\mkern3mu\underline{\vphantom{\intop}\mkern7mu}\mkern-10mu\int}
\begin{document}
\begin{gather*}
\upint_a^b f(x)\,\mathrm{d}x \\
\lowint_a^b f(x)\,\mathrm{d}x
\end{gather*}
\end{document}


I'm not sure which is better. Some new Unicode math fonts (XITS Math and Asana Math) have \lowint and \upint, and you can use unicode-math package to load the fonts. They also use wide bars.

(from unimath-symbols doc)

• Do we need \mathchoice for \lowint too? Commented Apr 8, 2018 at 17:42

If you want complete control over the placement of the bars, you can try the following code for the lower integral:

\lefteqn{\int_a^b f(x)}\lefteqn{\hspace{0.0ex}\rule[-2.25ex]{1.1ex}{.05ex}}
\phantom{\int_a^b f(x)}\mathrm{d}x


And for the upper integral:

\lefteqn{\int_a^b f(x)}\lefteqn{\hspace{1.2ex}\rule[ 3.35ex]{1.1ex}{.05ex}}
\phantom{\int_a^b f(x)}\mathrm{d}x


The hspace argument controls left/right positioning. The three rule arguments respectively control height, length and thickness of the bar.

• What package (or otherwise) provides \lefteqn?
– Werner
Commented Feb 20, 2017 at 17:11
• @Werner It's in the kernel. Commented Feb 20, 2017 at 17:13

Late to the party, but here's how we can do it with Computer Modern fonts.

Other fonts would need slightly different tweaks, but the macros are quite flexible and should be easily adaptable.

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\NewDocumentCommand{\lowerint}{}{\mathop{}\mathpalette\lowerint@\relax\!\int}
\NewDocumentCommand{\upperint}{}{\mathop{}\mathpalette\upperint@\relax\!\int}
\newcommand{\lowerint@}[2]{%
\begingroup
\sbox\z@{$\m@th#1\int$}%
\lowup@{l}{\underline}{#1}%
\endgroup
}
\newcommand{\upperint@}[2]{%
\begingroup
\sbox\z@{$\m@th#1\int$}%
\lowup@{r}{\overline}{#1}%
\endgroup
}
\newcommand{\lowup@}[3]{%
% #1 = l (lower) or r (upper)
% #2 = \underline (lower) or \overline (upper)
% #3 = math style
\rlap{%
\hspace{0.05\wd\z@}%
\makebox[0.9\wd\z@][#1]{%
$\m@th#2{% \hspace{0.4\wd\z@}% \ifx#3\displaystyle\else\hspace{0.1\wd\z@}\fi \vphantom{\copy\z@}% }$%
}%
\hspace{0.05\wd\z@}%
}%
}
\makeatother

\begin{document}

$\lowerint_a^b f(x)\,dx\quad \upperint_a^b f(x)\,dx$
\begin{center}
$\lowerint_a^b f(x)\,dx\quad \upperint_a^b f(x)\,dx$ \\
$\scriptstyle\lowerint_a^b f(x)\,dx\quad \upperint_a^b f(x)\,dx$ \\
\end{center}

\end{document}


Just to make an example with NewTX, the following change to \lowup@ seems to produce a satisfying result: load \usepackage{newtx} and make no other change to the code above except in the definition of \lowup@:

\newcommand{\lowup@}[3]{%
% #1 = l (lower) or r (upper)
% #2 = \underline (lower) or \overline (upper)
% #3 = math style
\rlap{%
\makebox[0.9\wd\z@][#1]{%
$\m@th#2{% \hspace{0.4\wd\z@}% \ifx#3\displaystyle\else\hspace{0.1\wd\z@}\fi \vphantom{\copy\z@}% }$%
}%
}%
}


Another non UTF option is to use \upint and \lowint commands available in stix-package. Read section 2.2 of the documentation that comes with it, particularly compatibility with AMS packages.

• Why a $-1$ for this? Is there anything wrong with the answer? Commented Aug 28, 2017 at 10:57
Stix package have a specific explicit slant: \upintsl and \lowintsl.
\documentclass[a4paper,12pt]{article}
$\upintsl_a^b f_{(-)}dx, \ \lowintsl_c^d f_{(+)}dx$