195

How do I insert the line "|" after the equation in LaTeX (see image below)? I'm using LyX so if you can point me to the symbol of that line is also OK.

enter image description here

I don't know if this line has a proper name so the title of this question may be very vague. If you could provide me a name, I'll edit this question's title.

7 Answers 7

74

You could just type the symbol (|) directly. This won't scale, to get it larger you could use the same technique as Niel de Beaudrap. In the LyX GUI this is done via the Insert Delimiter button on the math toolbar: button for "insert delimiter" in LyX

Set the left delimiter to None, and the right to |. Uncheck Keep matched, and let the Size be set to Variable:

delimiter options in LyX

In LyX this looks like as below (left). The dotted vertical line indicates an invisible delimiter (as \left. in Niels example). Result in PDF on the right.

LyX view of fraction with delimiters PDF output of the previous image

Edit in response to Marcs answer:

To use \rvert I think you have to use ERTs. If you don't have any other math constructs that use amsmath, you may have to make LyX use this package manually: Document --> Settings --> Math options. Uncheck Use AMS math package automatically, and check Use AMS math package.

enabling amsmath in LyX

In your equation, add an ERT (Ctrl + L) and type \biggr\rvert. That is, the first backslash may appear automatically, in which case don't type it.

\biggr\rvert in LyX

\biggr is one of several commands for manually scaling a delimiter, rather than the automatic provided by \left \right. Other sizes are \bigr, \Bigr and \Biggr, with the latter being the largest. For left delimiters, replace r with l. (See section 4.14.1 Delimiter sizes in amsmaths manual.)

Should you want to use \left\right, you need to add an ERT with \left. before the fraction (or whatever it is) and have \right\rvert in the one after.

0
165

I don't know how you would get this in LyX. However, if you're comfortable with writing things in mathmode by hand, I would write this as

T(s) = \frac{1}{H(\hat S)} \bigg\rvert_{\hat S = \epsilon^{1/n} \frac{s}{\omega_P}}

The relevant bit is the \bigg\rvert, which you can substitute with \Big\rvert or \Bigg\rvert to get a smaller or larger vertical stroke. If you would like to resize the vertical stroke automatically depending on what occurs to the left of it, I would recommend

T(s) = \left. \frac{1}{H(\hat S)} \right\rvert_{\hat S = \epsilon^{1/n} \frac{s}{\omega_P}}

where \left. puts an invisible left-bracket-like symbol on the left, whose right-side partner is the vertical stroke given by \right|. These pairs work equally for other braces/brackets.

2
  • It seems like all I can find is how to type | instead of ]. what's the corresponding command for ]?
    – steven
    Sep 17, 2019 at 18:06
  • @steven ] will work just fine. You can also use \rbrace.
    – Teepeemm
    Mar 12, 2021 at 16:08
45

Do not use | directly. Instead I suggest you use \rvert, which is provided by the amsmath package to address the overloading of the | symbol. See section 4.14.2 of the amsmath documentation.

24

Try the following:

\begin{equation}
  \left.\frac{\frac{1}{x}}{\frac{5}{1+\frac{x}{7}}}\right\vert_{-5}^{17}
\end{equation}
4
  • 8
    This isn't much different from what is suggested in the other answers...
    – Werner
    Sep 7, 2013 at 6:21
  • 2
    This answer is actually much better than the others because the vertical bar automatically scales to the height of the rest of the expression. The other answers require fiddling by the user to get the right height.
    – Tyler R.
    Jul 23, 2020 at 21:28
  • 1
    @TylerR. The other answers do mention using \left. \right\rvert. There are also some who object to using \left/\right because it doesn't get the spacing correct. See tex.stackexchange.com/q/173717/107497
    – Teepeemm
    Mar 12, 2021 at 16:13
  • this is a better solution.
    – yanpengl
    Dec 15, 2021 at 11:38
4

You could also try using \Bigg|_{f(x)=y} this would get you the vertical line at any scale you like!

2

When using Lyx, I found it very useful (and fast) to create a shortcut for the command math-delim . |. It creates a variable sized container with nothing on the left side and the \vert on the right side, so this works perfectly for me.

So: Tools > Preferences > Editing > Shortcuts... New... Function: math-delim . | (with the blank space bethween the dot and the vertical line) and choose your preferred keys for the shortcut.

2

How to stretch a vertical bar to be tall:

To stretch a vertical bar to be tall, such as to plug in values into a definite integral's antiderivative, add an invisible vertical bar on the left with \left., and a visible vertical bar on the right with \right|. Ex: \left.{\left[\cfrac{x}{\cfrac{a+b}{c}}\right]}\right|_{\;0}^{\;4} is

enter image description here

Note that the \; here is a wider space to space the numbers to the right of the vertical bar.

I just added this info. to this community wiki question here as well: Mathematics Stack Exchange: MathJax basic tutorial and quick reference

You must log in to answer this question.

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