[Tex/LaTex] Typesetting a function restriction with a bar shorter than \big

math-mode

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:

enter image description here

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?

Best Answer

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

Result

  • 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.