I wonder how to typeset the restriction of a function to some subdomain, a la $f|_A$ or $f\restriction_A$ , but with the vertical bar being as big as possible.
7 Answers
If you want the vertical bar to be at least \big, the following doesn't have the spacing issues of Ulrich's solution:
\newcommand\restr[2]{{% we make the whole thing an ordinary symbol
\left.\kern-\nulldelimiterspace % automatically resize the bar with \right
#1 % the function
\vphantom{\big|} % pretend it's a little taller at normal size
\right|_{#2} % this is the delimiter
}}
If you don't need the extra height for normal size symbols, comment the \vphantom line.
Use it as \restr{f}{A}.
The above code works best in display style. In other styles (particularly text style) it's likely better to remove the phantom.
\documentclass{article}
\usepackage{amsmath}
\newcommand\restr[2]{{% we make the whole thing an ordinary symbol
\left.\kern-\nulldelimiterspace % automatically resize the bar with \right
#1 % the function
\littletaller % pretend it's a little taller at normal size
\right|_{#2} % this is the delimiter
}}
\newcommand{\littletaller}{\mathchoice{\vphantom{\big|}}{}{}{}}
\begin{document}
[
\restr{f}{U}=\frac{\restr{g}{U}}{\restr{h}{U}}
]
\end{document}
- 1,121,712
-
I thought you had a principle to always suppress end-line spaces with
%, even in math mode, for the sake of “uniformity”. But perhaps that principle is less than a decade old?;-)– Gaussler Sep 26 '22 at 07:37 -
@Gaussler I leave as an exercise to the reader to explain why spaces here are not relevant.
;-)– egreg Sep 27 '22 at 09:30 -
I know they’re not making any difference for commands intended for math mode, but look at your own comments right here.
;-)– Gaussler Sep 27 '22 at 09:33
Does $\left.f\right|_A$ provide what you are looking for?
- 906
-
Hello @Lustique, is there a way to add another condition below? For example A and below B? – Gennaro Arguzzi Oct 18 '22 at 14:01
How about \newcommand\restr[2]{\ensuremath{\left.#1\right|_{#2}}}, which can be used like this: $\restr{f}{A}$?
(Warning, haven't tested...)
- 1,121,712
- 9,830
I use the following:
\def\restrict#1{\raise-.5ex\hbox{\ensuremath|}_{#1}}
because normally the vertical bar must be lowered (and not centered on the math axis as other symbols). And it doesn't need to be very big, it is the fact that it goes lower than the rest that shows that it is a restriction and not an absolute value or a divides symbol.
- 2,013
- 19
- 18
-
12Since it's LaTeX, it should be
\newcommand\restrict[1]{\raisebox{-.5ex}{$|$}_{#1}}– egreg Nov 17 '15 at 10:08
I had that problem recently and I looked it up here, but since then I usually type $f_{\big|A}$
- 213
Another option is \eval{f}_A provided by the physics package:
\documentclass{standalone}
\usepackage{amssymb}
\usepackage{physics}
\begin{document}
\begin{tabular}{cccc}
\verb=f\restriction_A= & \verb={f|}_A= & \verb={f\bigr|}_A= & \verb=\eval{f}_A= \
$f\restriction_A$ & ${f|}_A$ & ${f\bigr|}_A$ & $\eval{f}_A$ \ \noalign{\vskip 1mm}
$f^{(n)}\restriction_A$ & ${f^{(n)}|}_A$ & ${f^{(n)}\bigr|}_A$ & $\eval{f^{(n)}}_A$ \
\end{tabular}
\end{document}
- 621


\restriction,\usepackage{amssymb}. – Evgeni Sergeev Nov 22 '13 at 06:18