2

Building on How do I put text over symbols? I created a new command :

\newcommand{\myequ}[1]{\stackrel{\mathclap{\normalfont\mbox{#1}}}{=}}

which gives overwriting :

enter image description here

when #1 is too long. Is there a way to tweak the new command so that it could take the length of #1 into account automatically ?

Olórin
  • 358

1 Answers1

3

Remove the \mathclap, whose very purpose is to hide the width of its argument.

\documentclass{article}
\usepackage{mathtools}
\newcommand{\myequ}[1]{\stackrel{\normalfont\mbox{#1}}{=}}
\begin{document}
\[
y \myequ{eq.(3.3.44)} \int_\Omega x\,dx
\]
\end{document}

enter image description here

You may also wish to consider using \small or \scriptsize in preference to \normalfont.

Thanks to Bernard for reminding me of \eqmakebox, which can help for cases where align is involved:

\documentclass{article}
\usepackage{mathtools,eqparbox}
\newcommand{\myequ}[1]{\stackrel{\scriptsize\mbox{#1}}{=}}
\begin{document}
\begin{align}
y \eqmakebox[][c]{$\myequ{eq.(3.3.44)}$}& \int_\Omega x\,dx\\
z_1 \eqmakebox[][c]{$\myequ{eq.(576)}$}& \int_\Omega x^{(2+ 3x)}\,dx
\end{align}
\end{document}

enter image description here