"Evaluated at" bar for derivatives: \Bigr, \biggr, or \left...\right?
Since \big
is the minimum requested size anyway, it's better to use a simpler approach:
\documentclass{article}
\usepackage{amsmath,mleftright}
\usepackage{xparse}
\NewDocumentCommand{\evalat}{sO{\big}mm}{%
\IfBooleanTF{#1}
{\mleft. #3 \mright|_{#4}}
{#3#2|_{#4}}%
}
\begin{document}
\begin{align}
& \evalat{f(x)}{x=0} \\
& \evalat[\big]{f(x)}{x=0} \\
& \evalat[\Big]{\frac{\partial f}{\partial x}}{x=0} \\
& \evalat[\bigg]{\frac{\partial f}{\partial x}}{x=0} \\
& \evalat*{\frac{\partial f}{\partial x}}{x=0} \\
& \evalat[\bigg]{\frac{\partial^2 f}{\partial x^2}}{x=0} \\
& \evalat*{\frac{\partial^2 f}{\partial x^2}}{x=0} \\
& \evalat[\bigg]{\left(1+\frac{1}{x}\right)^{\!x^2}}{x=1} \\
& \evalat*{\left(1+\frac{1}{x}\right)^{\!x^2}}{x=1}
\end{align}
\end{document}
Note that the last one has a definitely too big bar.
Elaborating on daleif’s suggestion:
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\DeclarePairedDelimiter\evaluat{.}{\rvert}
\reDeclarePairedDelimiterInnerWrapper\evaluat{nostar}{\mathopen{}#2\mathclose{#3}}
\begin{document}
Some examples:
\begin{itemize}
\item with \verb|\evaluat[\big]|
\[\evaluat[\big]{\frac{\partial f}{\partial x}}_{x=0}\]
\item with \verb|\evaluat[\Bigg]|
\[\evaluat[\Bigg]{\frac{\partial f}{\partial x}}_{x=0}\]
\item with \verb|\evaluat*|
\[\evaluat*{\frac{\partial f}{\partial x}}_{x=0}\]
(in this case, a \verb|\left|\ \ldots\verb|\right| construction is
used);
\item and with \verb|\evaluat| (thanks again, egreg~;-)
\[\evaluat{\frac{\partial f}{\partial x}}_{x=0}\]
\end{itemize}
\end{document}
And here is the output:
Afterthought
Since the OP put an emphasis on questions of style and best usage, I must
correct an evident imperfection of the above code: although the \evaluat
command produces, in all variants, a math list that begins with an
Open atom and ends with a Close atom, nevertheless \evaluat*
inserts
\nulldelimiterspace
on the left of the mandatory argument, while the
other forms do not. This is easily corrected:
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{mathtools}
\DeclarePairedDelimiter\evaluat{.}{\rvert}
\reDeclarePairedDelimiterInnerWrapper\evaluat{nostar}{%
\mathopen{}#2\mathclose{#3}%
}
\reDeclarePairedDelimiterInnerWrapper\evaluat{star}{%
\mathopen{}\mathclose\bgroup #1\hskip -\nulldelimiterspace \relax
#2\aftergroup\egroup #3%
}
\begin{document}
Some examples:
\begin{itemize}
\item with \verb|\evaluat[\big]|
\[\evaluat[\big]{\frac{\partial f}{\partial x}}_{x=0}\]
\item with \verb|\evaluat[\Bigg]|
\[\evaluat[\Bigg]{\frac{\partial f}{\partial x}}_{x=0}\]
\item with \verb|\evaluat*|
\[\evaluat*{\frac{\partial f}{\partial x}}_{x=0}\]
(in this case, a \verb|\left|\ \ldots\verb|\right| construction is
used);
\item and with \verb|\evaluat| (thanks again, egreg~;-)
\[\evaluat{\frac{\partial f}{\partial x}}_{x=0}\]
\end{itemize}
Difference between non-\verb|\big| and \verb|\big|:
$\evaluat{x}$, $\evaluat[\big]{x}$.
Test for \verb|\nulldelimiterspace|:
\begin{align*}
& 1+\evaluat{f(x)}_{x=0} \\
& 1+\evaluat*{f(x)}_{x=0}
\end{align*}
\end{document}
The output is:
Let us also magnify the portion pertaining to the \nulldelimiterspace
test:
Of course, the rationale behind the choice of using
\DeclarePairedDelimiter
was that a simple definition would suffice, with
the mathtools package taking care of all the details; if one needs to
have recourse so heavily to callback routines, I agree with egreg that this
approach loses its sense, and that it is better to directly define an
appropriate command, as he does (however, I would recommend the same
correction in his code too, and also to arrange for the generated math list
to always begin with an Open atom—albeit unlikely, an Op could precede).
I've recently adopted the physics
package as part of my usual tool kit, with the advantage that it provides a tool explicitly for this \evaluated{}
(or \eval{}
).
It seems to apply a minimum size bar, and to scale it up as needed.
Here is an minimal example extracted from a document I wrote for class recently
\documentclass{minimal}
\usepackage{physics}
\begin{document}
here we recognize the terminal velocity in the denominator of the
RHS
\begin{align*}
\Delta x
&= \mp\frac{m}{k} \int_{v_1}^{v_2}
\frac{v\dd{v}}{v^2 \pm v_t^2} \\
\\
&= \mp\frac{m}{k} \frac{1}{2} \eval{\ln\qty({v^2 \pm
v_t^2})}_{v_1}^{v_2} \\
\\
&= \mp\frac{m}{2k}
\qty[\ln\qty(v_2^2 \pm v_t^2) - \ln\qty(v_1^2 \pm v_t^2)] \,.
\end{align*}
\end{document}
which generates this output:
The use of \eval
is on the second line of the align
environment.