3

I'm looking for a big vertical bar that puts the lower and upper elements at the same height as on the default integral sign. Currently, using \Big| (or \Bigr|), and \bigg| (or \biggr|) gives an ugly output. Here's a MWE to show my issue:

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{tensor}

\begin{document}

\begin{gather*}
    \int_{-\, a}^{+\, a} f(x) \frac{d}{dx} \: \Theta(x - \tensor{x}{_0}) \, dx \\[2ex]
\begin{aligned}
    &= f(x) \, \Theta(x - \tensor{x}{_0}) \biggr|_{-\, a}^{+\, a} - \int_{\tensor{x}{_0}}^a \frac{d}{dx} \: f(x) \, dx \\[2ex]
    &= f(x) \, \Theta(x - \tensor{x}{_0}) \Bigr|_{-\, a}^{+\, a} - \int_{\tensor{x}{_0}}^a \frac{d}{dx} \: f(x) \, dx \\[2ex]
    &= f(a) - f(x) \biggr|_{\tensor{x}{_0}}^a = f(a) - f(x) \Big|_{\tensor{x}{_0}}^a.
\end{aligned}
\end{gather*}

\end{document}

Preview of what this code is doing:

enter image description here

So what am I doing wrong with this code? How could I draw a vertical bar that puts its two elements exactly at the same position as an integral sign?

(note that I'm using the tensor package for another reason, not relevant here)


EDIT:. I could define a custom vertical bar of the same size as the integral sign using the scalerel package:

\usepackage{scalerel}
\newcommand*{\eval}{\stretchrel*{|}{\int}}

but then the lower and upper elements aren't placed at the proper position. So no luck here.

2
  • 1
    Why not use a \left....\right| pair?
    – Werner
    Feb 23, 2021 at 19:58
  • @Werner, it doesn't work. The size isn't right. And it's more complicated to type because of the left part.
    – Cham
    Feb 23, 2021 at 20:02

2 Answers 2

8

Define \def\myvert{\biggr|{\vphantom{\int}}} and use \myvert_{..}^{..} instead \biggr|_{..}^{..}.

Edit: If you want to have equal size of the bar and the \int then you can define it as \vrule:

\def\myvert{{\mkern2mu\vrule\,\vphantom{\int}}}
6
  • I could combine your solution with my stretched bar defined in my edit above.
    – Cham
    Feb 23, 2021 at 20:13
  • 2
    @Cham OK, you are asking for simpler way. So I added another solution using \vrule primitive, you don't need load any next LaTeX package.
    – wipet
    Feb 24, 2021 at 6:35
  • \def\myvert{\mathclose{...}}? Feb 24, 2021 at 7:06
  • Yes, it should be better because Inner (a \left...\right construction) should preceded. And Inner-Close is without space, Inner-Ord with small space. The right side of \myvert are unchanged, because Ord-* is equal to Close-*. The other differences Bin-Close, Rel-Close, Op-Close are unlikely in this situation.
    – wipet
    Feb 24, 2021 at 7:20
  • Well, the scalerel package was already loaded just for another macro I'm using, so no problem here. But your new definition is a nice one too.
    – Cham
    Feb 24, 2021 at 14:20
4

Combining wipet's answer and a scaled up version of |, I get good results:

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{tensor}
\usepackage{scalerel}
\newcommand*{\eval}{\stretchrel*{|}{\int}{\vphantom{\int}}}

\begin{document}

\begin{gather*}
    \int_{-\, a}^{+\, a} f(x) \frac{d}{dx} \: \Theta(x - \tensor{x}{_0}) \, dx \\[2ex]
\begin{aligned}
    &= f(x) \, \Theta(x - \tensor{x}{_0}) \biggr|_{-\, a}^{+\, a} - \int_{\tensor{x}{_0}}^a \frac{d}{dx} \: f(x) \, dx \\[2ex]
    &= f(x) \, \Theta(x - \tensor{x}{_0}) \eval_{-\, a}^{+\, a} - \int_{\tensor{x}{_0}}^a \frac{d}{dx} \: f(x) \, dx \\[2ex]
    &= f(a) - f(x) \eval_{\tensor{x}{_0}}^a = f(a) - f(x) \Big|_{\tensor{x}{_0}}^a.
\end{aligned}
\end{gather*}

\end{document}

Preview:

enter image description here

I'm wondering if there's a simpler or better way of getting the same result.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .