While trying to adapt Bernard’s answer to a similar question (Vertical bar for “evaluated at”), I noticed that it is defective in that it smashes the height of the “evaluated” subformula, as it can clearly be seen in this modified example,
\documentclass{article}
\usepackage{amsmath}
\newcommand\eval[1]{\begin{array}[t]{@{}c@{\,}|@{\,}}%
\raisebox{0pt}[0.33\height][1.33\depth]{$ \displaystyle#1 $}\end{array}}
\begin{document}
\begin{align*}
& 5 + \eval{\dfrac{df}{dt}}_{t = 0} \\[2ex]
& 5 + \eval{\frac{d\Bigl(\dfrac{f}{g}\Bigr)}{dt}}_{t = 0}
\end{align*}
\end{document}
which produces the following output:
However, I liked the idea of using a vertical rule instead of a \vert
delimiter, so I worked out another solution based on this same principle. The height and the depth of the rule are computed keeping in mind the rules detailed in Appendix G of The TeXbook for the placement of subscripts (Rules 18a and 18b). Of course, I’ve open to suggestions for what concerns the value of the various parameters.
Here is my current proposal:
% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.
\usepackage[T1]{fontenc} % Not always necessary, but recommended.
% End of standard header. What follows pertains to the problem at hand.
\usepackage{amsmath} % I always load it when dealing with math!
\makeatletter
\newcommand*\evaluateat[2]{%
#1% first, typeset the base symbol(s)
\mkern .5\thinmuskip % too little? too much?
\mathpalette{\EA@evaluate@at{#2}}{#1}% then, add the vertical bar
}
\newcommand*\EA@evaluate@at[3]{%
% #1 <- subscripted annotation
% #2 <- style selector, e.g., "\textstyle"
% #3 <- base symbol(s)
\setbox\z@ \hbox{$\m@th\color@begingroup #2#3\color@endgroup$}%
\dimen@ \dimexpr \ht\z@ *\tw@/\thr@@ \relax
\dimen@ii \dp\z@
\ifx #2\scriptscriptstyle
\EA@calc@style@dependent@values \scriptscriptfont \scriptscriptfont
\else \ifx #2\scriptstyle
\EA@calc@style@dependent@values \scriptfont \scriptscriptfont
\else
\EA@calc@style@dependent@values \textfont \scriptfont
\fi \fi
\vrule \@height\dimen@ \@depth\dimen@ii \@width\dimen4
\mathord{% or "\mathclose{}\mathopen{}\mathinner{"?
\vrule \@depth\dp\z@ \@height\z@ \@width\z@
}% } brace match
_{\,#1}%
}
\newcommand*\EA@calc@style@dependent@values[2]{%
% #1 <- main font selector, e.g., "\textfont"
% #2 <- relative script font selector, e.g., "\scriptfont"
\advance \dimen@ii \fontdimen19#2\tw@
\dimen4 \fontdimen16#1\tw@
\ifdim \dimen@ii<\dimen4
\dimen@ii \dimen4
\fi
\advance \dimen@ii \dimen4 % extra depth
% \dimen4 \dimexpr \fontdimen5#1\tw@ *6/5\relax
\dimen4 \fontdimen5#1\tw@ % the ex-height
\ifdim \dimen4 <\z@
\dimen4 -\dimen4
\fi
\ifdim \dimen@<\dimen4
\dimen@ \dimen4
\fi
% Now re-use "\dimen4" to hold the default rule thickness:
\dimen4 \fontdimen8#1\thr@@
}
\makeatother
\begin{document}
In-line: \( \evaluateat{\mathord.}{x=0} + \evaluateat{f}{x=0} +
\evaluateat{f(x)}{x=0} + \evaluateat{\frac{df}{dx}}{x=0} \). And displayed:
\[
\evaluateat{f}{x=0}+\evaluateat{\frac{df}{dx}}{x=0}
- \evaluateat{\,\frac{\frac{df}{dx}\,}{\,\frac{df}{dy}\,}}{x=0,y=0}
\]
Example in \verb|\scriptstyle|:
\( \frac{\evaluateat{f(x)}{x=0}}{g\left(\evaluateat{f(x)}{x=0}\right)} \).
Another example:
\[ \evaluateat{df}{x} \colon T_{x}M\longrightarrow T_{y}N \]
\end{document}
This is the output it yields:
\EvalAt[\Big]{t=0}
and then leave it to each case as to how much to scale. Left right constructions end up looking bad on most cases anyway\DeclarePairedDelimiter
.