3

I would like the output of the standard code

$x \left.\right|_{x\gets 5}$

namely

Standard

but with the ability to lower the subscript and extend the vertical bar downwards. There are several relevant pages on Stack Exchange but none I found that quite does it. For instance

$x \left.\rule[-4mm]{0mm}{4mm}\right|_{x\gets 5}$

does it but at the cost of the vertical bar also extending upwards:

Better

and I want to avoid that. Specifically, I would like the top of the vertical bar to be at the same height as given by the standard code.

1 Answer 1

3
\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\evalat}[2]{\mathpalette\eval@at{{#1}{#2}}}
\newcommand{\eval@at}[2]{\eval@@at#1#2}
\newcommand{\eval@@at}[3]{%
  #2\,
  {%
   \sbox0{$#1\left|#2\right|$}%
   \vrule height \ht0 depth \dimexpr\dp0+1ex\relax
  }_{\,#3}
}
\makeatother

\begin{document}

\[
\evalat{x}{x\gets5}
\qquad
\evalat{\frac{x+1}{x-1}}{x\gets2}
\]

\end{document}

enter image description here

1
  • I like it so much I started to replace the very, very many, many occurrences of the hack I had before. I found only one instance where the vertical bar still sticks up. I couldn't care less but if you do, let me know how to get you the guilty code.
    – schremmer
    Nov 6, 2018 at 3:17

You must log in to answer this question.

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