74

I was having some thought about what would be the syntax to make the end point evaluation of derivatives or integrals. Such as making the | with the two end points of evaluation on the top an bottom of the line. Any suggestions would be wonderful.

lockstep
  • 250,273
night owl
  • 7,593
  • 11
    I was really hoping this was going to be a question about doing symbolic integration and differentiation in TeX. Alas, it was actually about typesetting. =) – TH. Apr 15 '11 at 17:07
  • 2
    I came here interested in typesetting, and found it useful. – Ross Millikan Jun 15 '11 at 05:07

6 Answers6

95

The \big| or \Big| symbols work quite well

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ \int_a^b x^2\;\mathrm{d}x= \tfrac{1}{3} x^3 \Big|_a^b \]
\end{document}

enter image description here

Danie Els
  • 19,694
  • 1
    Thank You Danie, that worked excellent. Just what I was looking for. One question while on the topic. I noticed you using \tfrac, is there any significance to that over using \dfrac. How different are they and what do they actually mean if you know? Meaning the 't' and 'd'. – night owl Apr 15 '11 at 15:13
  • 4
    @night owl: \tfrac is the inline "text" mode fraction and \dfrac the display math frac. \tfrac is smaller and I prefer it for single line equations. – Danie Els Apr 15 '11 at 15:35
  • Thank You. That was very useful to know for later references. – night owl Apr 15 '11 at 15:56
  • 2
    @night: \tfrac is nice for numerical fractions but I would avoid it when variables are in the numerator or denominator. – Matthew Leingang Apr 15 '11 at 18:48
  • How do you get that integral sign like that. Mines looks loose and sloppy at the ends. Using: $ \displaystyle\int f(x)\ dx. $
              OR
    
    

    $$ \displaystyle\int f(x)\ dx. $$

    – night owl Apr 19 '11 at 11:54
  • for some reason MS Word equations tool doesn't understand \Big modifier. Any idea how to make | bigger in this case? – dKab Jan 18 '19 at 22:38
  • Oftentimes (this would be font-dependent) the integral symbol \int looks thicker than the evaluation symbol | (see also Gonzalo's answer). No-one seems bothered. I would be tempted to have a thinner integral squiggle or a thicker evaluation bar... am I "wrong"? – PatrickT Oct 08 '22 at 20:55
  • Thank you for this!! – Charith Jan 01 '24 at 02:26
40

The \left - \right construct gives you an expandable evaluation symbol:

\documentclass[12pt]{article}
\usepackage{amsmath}

\DeclareMathOperator{\di}{d\!}
\newcommand*\Eval[3]{\left.#1\right\rvert_{#2}^{#3}}

\begin{document}

\[
  \int_{a}^{b}x\di x = \Eval{\dfrac{1}{2}x^{2}}{a}{b}
\]

\[
  \int_{a}^{b}\di x = \Eval{x}{a}{b}
\]

\end{document}

EDIT: I modified the code following the comment by Ryan Reich.

doncherry
  • 54,637
Gonzalo Medina
  • 505,128
  • Thanks for the response. Your looks clean, just a tad bit more work. hehe.. +1 – night owl Apr 15 '11 at 15:57
  • 8
    You could just write \left.\frac{1}{2} x^2\right|_a^b, too. – Ryan Reich Apr 15 '11 at 18:13
  • 5
    +1 I prefer this over using the \big| or \Big| symbols because of the expandability - you may have a very complex expression of which you don't know the vertical extent, and hence which size modifier for the |. It's a "tad bit more work" up front as @night owl pointed out, but you don't need to tweak and recompile to get it looking just right :). – cm2 Sep 27 '11 at 15:32
  • @RyanReich Why the dot is needed after \left? – Anton May 08 '22 at 12:20
  • 1
    @anton it's a placeholder because there has to be an argument there, but we don't actually want anything printed. It is a special case specifically designed for this purpose; no period is actually shown. – Ryan Reich May 08 '22 at 19:28
12

If you want the evaluation symbol to be of the same height as the integration symbol, you can enclose a phantom integration symbol between \left and \right, like this:

\documentclass{article}
\usepackage{amsmath}

\DeclareMathOperator*{\di}{\mathrm{d}\!}
\def\at{
  \left.
  \vphantom{\int}
  \right|
}

\begin{document}
  \begin{eqnarray}
    \int_a^b x^2 \di x &=& \frac{x^3}{3}\at_a^b \\
    \int\limits_a^b x^2 \di x &=& \frac{x^3}{3}\at_a^b
  \end{eqnarray}
\end{document}

denshion
  • 121
8

The commath package has the \eval command for this purpose.

Emre
  • 6,337
8

This hasn't got anything to do with your question, but I'll post it anyway (it's on topic I guess).

I don't know if this is correct (since few people do it), but I like it when the integration limits are above and below the integral sign:

\DeclareMathOperator{\di}{d\!}

\[
    \int\limits_a^b\! x\di x = \tfrac{1}{2}x^2\Big|_a^b
\]

As you can see, adding the macro \limits to your code makes the integral look good. You can do this for any math operator.

Also notice that the \! command brings the integrandum closer to the integral sign. I like this kind of snugged integrals.

Integral of x dx between a and b

fgb
  • 103
romeovs
  • 9,102
  • .. unusual, is there a maths book or article using it? I would be interested in having a look. – yannisl Apr 16 '11 at 17:22
  • @Yiannis: As I said, don't know if it's the correct way of typesetting integral bounds, I just like it myself. I geuss I've seen it around somewhere, just can't remember where. – romeovs Apr 16 '11 at 18:15
  • 3
    This is the standard way of typesetting integration limits in Russian literature. – ScumCoder Aug 16 '16 at 21:26
  • This is probably not done because the integral symbol's already pretty tall, so stacking over- and underscripts on it fills even more vertical space. – Chappers May 27 '17 at 21:48
  • @chappers, would it make sense to align the integration bounds of the integral (lhs) with those of the evaluation (rhs)? since the vertical space is already used up... maybe that's the Russian logic... I just noticed that denshion's answer below addresses this possibility. – PatrickT Oct 08 '22 at 20:59
1

None of the stuff here gave me the desired outcome in the editor I was using (MATLAB live script), but I found this and it's really nice:

\bigg/_{\!\!\! a}^{\,b}

Example:

\frac{\sqrt{\pi}}{2}\bigg/_{\!\!\! a}^{\,b}x^2

enter image description here

0x464e
  • 121
  • 6