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

  • 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 '19 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 '19 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 '19 at 20:53
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.

| improve this answer | |
  • Thanks for this quick and clear answer ! Good point for the theorems... – projetmbc Sep 2 '19 at 20:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.