0

I'm using function restriction notation like here, but after switching to XeLaTeX with unicode-math I noticed that it looks slightly odd. Here's a minimal working example

\documentclass{minimal}
\usepackage{unicode-math}
\begin{document}
\[  
\left. \frac{dy}{dx} \right\vert_{x=5} \quad 
\left. y \right\vert_{x=5}
\]
\end{document}

Here's the output with unicode-math:

enter image description here

and here it is without unicode-math:

enter image description here

Apparently with unicode-math delimiters are shorter and the baseline of subscripts is lower.

Ideally I would like the bottom of the vertical bar to extend to the baseline of the subscript, and at the same time keep the automatic scaling of the delimiter wrt. the expression on the left of it.

How could I achieve this?

In case it's relevant: I'll be using texgyrepagella-math font.

4
  • Some of this is font-related, and some of it can be adjusted by looking at font dimensions... unfortunately I don't have a good interface to them, yet! Commented Feb 5, 2018 at 14:11
  • Side note: Don't use the minimal documentclass :) Commented Feb 5, 2018 at 14:43
  • @PhelypeOleinik thanks, I didn't know. But I checked and it doesn't seem to make much of a difference in the output in this case.
    – Michael
    Commented Feb 5, 2018 at 15:32
  • 1
    @Michael No, it doesn't make a difference in this case. Just a question of good practice :) Commented Feb 5, 2018 at 15:38

1 Answer 1

2

In case anyone is interested, this is the hack I came up with myself, combining things from this and this answer:

\documentclass{article}

\newcommand{\restr}[2]{%
\mathchoice{%
\restriction{#1}{#2}{\displaystyle}%
}{%
\restriction{#1}{#2}{\textstyle}%
}{%
\restriction{#1}{#2}{\scriptstyle}%
}{%
\restriction{#1}{#2}{\scriptscriptstyle}%
}%
}

\newlength{\totbarheight}
\newlength{\bardepth}

\newcommand{\restriction}[3]{%
\settodepth{\bardepth}{\(#3 #1\)} %
\settoheight{\totbarheight}{\(#3 #1\)}%
\addtolength{\totbarheight}{\bardepth}%
\addtolength{\totbarheight}{1ex}% make it somewhat higher
\addtolength{\bardepth}{0.7ex}% make it extend somewhat further down
{#1 %
\rule[-\bardepth]{0ex}{\totbarheight} %invisible rule to force the next \vrule to be bigger
\mkern 2mu \vrule width 0.14ex \mkern 2.5mu}
{\addtolength{\bardepth}{-0.2ex}%make shorter to lift the baseline of the subscript
\addtolength{\totbarheight}{-0.2ex}
\rule[-\bardepth]{0ex}{\totbarheight}}_{#2}
}


\begin{document}

\(\restr{\frac{dy}{dx}}{x=2}  5\restr{y}{x=a}\)

\[\restr{\frac{dy}{dx}}{x=2} 5\restr{y}{x=a}\]

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .