# Typesetting a function restriction with a bar shorter than \big

The question about function restrictions didn't solve my problem, nor did the related questions about bigger parenthesis larger than Bigg.

I'd like to typeset a function restriction, with the vertical bar a bit lowered. f_{\big|W} results in something close to what I want:

To perfect it, the bar would be cut off where it reaches the baseline of the subscript symbol (in this case W). So that it doesn't reach below it.

How can I accomplish that?

• Whatever you end up using, you should define a macro that you use like \restr{f}{W} or \restr{W}{f} and let the macro output the style you want. That way you have clearer code, and much easier to tweak in the whole document. – Manuel Jan 29 '17 at 14:33

\vrule inside an horizontal box has the property to match the height and depth of this box. Also all dimensions (height, depth, width) can be explicitly specified.

Example:

\documentclass{article}
\begin{document}
$f_{\mkern 1mu \vrule height 2ex\mkern2mu W}$
\end{document}


• The spacing around the vertical bar is achieved by \mkern to use the math unit mu that adopts to the current math style automatically.

• The "W" looks a tiny bit lower than the rule. The reason is that "W" draws this tiny bit outside its character bounding box. The depth can be explicitly specified for fine-tuning.