72

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.

Vivi
  • 26,953
  • 31
  • 77
  • 79
Michael
  • 821

7 Answers7

65

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}

enter image description here

egreg
  • 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
33

Does $\left.f\right|_A$ provide what you are looking for?

Lustique
  • 906
5

How about \newcommand\restr[2]{\ensuremath{\left.#1\right|_{#2}}}, which can be used like this: $\restr{f}{A}$?

(Warning, haven't tested...)

egreg
  • 1,121,712
5

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.

yannis
  • 2,013
  • 19
  • 18
3

I had that problem recently and I looked it up here, but since then I usually type $f_{\big|A}$

Javi
  • 213
1

I would prefer $f\arrowvert_A$ to the above-mentioned suggested commands.

Mensch
  • 65,388
0

Another option is \eval{f}_A provided by the physics package:

enter image description here

\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}