3

In the following MnWE, the macro \lhypbad produces a good vertical alignment but doesn't respect the space around the math operator <. See the picture below. What is the best way to fix that ?

\documentclass[12pt,a4paper]{article}

\usepackage{amsmath}

\newcommand\leqhyp{%
    \stackrel{\text{hyp}}{\leq}%
}

\newcommand\lhyp{%
    \stackrel{\text{hyp}}{<}%
}

\newcommand\lhypbad{%
    \stackrel{\text{hyp}}{<\vphantom{\leq}}%
}

\begin{document}


$x \leqhyp 1 \lhyp y$

$x \leqhyp 1 \lhypbad y$

\end{document}

Screenshot

3
  • Unrelated, \text is the wrong macro to use here. Consider \mathrm. Why see what happens if you add \itshape to the start of your mwe.
    – daleif
    Sep 2, 2019 at 20:45
  • You could use mathtools and its \mathclap I'd also use \scriptscriptstyle to make is smaller. Additionally, I'd probably not even write stuff above the equal sign as it is generally bad typesetting style.
    – daleif
    Sep 2, 2019 at 20:47
  • The purpose of this command is purely pedagogical : this will be used in lessons stressing the different semantic uses of symbols like = , \leq ... and so on.
    – projetmbc
    Sep 2, 2019 at 20:53

1 Answer 1

4

The symbols for \leq and < have different height. You can force the latter to be the same height as the former by using \vphantom, but \mathrel has to surround the construction. Also {<}\vphantom{\leq} should be used in order to avoid spurious spacing.

\documentclass[12pt,a4paper]{article}

\usepackage{amsmath}

\newcommand\leqhyp{%
  \overset{\mathrm{hyp}}{\leq}%
}

\newcommand\lhyp{%
  \mathrel{\overset{\mathrm{hyp}}{{<}\vphantom{\leq}}}%
}

\begin{document}

$x \leqhyp 1 \lhyp y$

\end{document}

enter image description here

Generally speaking, \overset is better than \mathrel. In this particular case, however, \stackrel{\mathrm{hyp}}{{<}\vphantom{\leq}} could do, because \stackrel always makes a relation symbol.

Also \mathrm should be preferred to \text here, or the word “hyp” could be in italics in theorems.

1
  • Thanks for this quick and clear answer ! Good point for the theorems...
    – projetmbc
    Sep 2, 2019 at 20:49

You must log in to answer this question.

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