1

I am using the \DeclarePairedDelimiterXPP command from the mathtools package to declare some new delimiters, for which scaling can be turned on and off easily. Specifically, I want to declare the command \evalat, which indicates the evaluation of an expression at a given point: e.g. $\left.\frac{x}{2}\right|_{x=1}$.

As I said before, I want it to have the scaling options as provided by the \DeclarePairedDelimiter-type commands. This means that \evalat{\frac{x}{2}}{x=1} gives a non-scaled vertical line on the right, \evalat*{\frac{x}{2}}{x=1} gives a scaled vertical line on the right and \evalat[\size]{\frac{x}{2}}{x=1} gives a vertical bar with size \size.

I tried the following definitions:

\DeclarePairedDelimiterXPP{\evalat}[2]{}{.}{|}{_{#2}}{#1}

and

\DeclarePairedDelimiterXPP{\evalat}[2]{}{\left.}{\right|}{_{#2}}{#1}

The first one works correctly in the starred (automatic scaling) version. Its non-starred version however results in $.\frac{x}{2}|_{x=1}$, with the dot still shown on the left side. The second version always scales the delimiters, both in the starred and the non-starred version.

I understand why the commands behave as they do, but I do not know how to get the behaviour that I want?

PS. This answer to another question could be a fall-back solution, but I would rather have the _{x=1} as an argument to the command.

1
  • As is the declarepaired cannot handle "empty" fences. I tend to make the Eval at macro completely manual as I find the \EvalAt{expression}{point} cumbersome and unnatural to read. I tend to just have expression \EvalAt[scaler]{point}`
    – daleif
    Jul 1, 2019 at 16:32

1 Answer 1

6

It's simpler to define the command directly:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}

\NewDocumentCommand{\evalat}{sO{}mm}{%
  \IfBooleanTF{#1}
    {\kern-\nulldelimiterspace\left.#3\right|_{#4}}
    {#3#2|_{#4}}%
}

\begin{document}

\[
\evalat{x^2}{x=1}=1
\qquad
\evalat*{\frac{x^2}{3}}{x=6}=12
\qquad
\evalat[\Big]{\frac{x^2}{3}}{x=6}=12
\]

\end{document}

enter image description here

You must log in to answer this question.

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