I wrote some functions that allow to lower/raise the text under/above xrightarrow
arrows. It seams that the text typeset using these macros is a little wider but it doesn't look too bad ;)
The code required is:
\usepackage{ifthen}
\usepackage{xargs}
\newcommandx{\yaHelper}[2][1=\empty]{%
\ifthenelse{\equal{#1}{\empty}}%
{ \ensuremath{ \scriptstyle{ #2 } } } % no offset
{ \raisebox{ #1 }[0pt][0pt]{ \ensuremath{ \scriptstyle{ #2 } } } } % with offset
}
\newcommandx{\yrightarrow}[4][1=\empty, 2=\empty, 4=\empty, usedefault=@]{%
\ifthenelse{\equal{#2}{\empty}}
{ \xrightarrow{ \protect{ \yaHelper[ #4 ]{ #3 } } } } % there's no text below
{ \xrightarrow[ \protect{ \yaHelper[ #2 ]{ #1 } } ]{ \protect{ \yaHelper[ #4 ]{ #3 } } } } % there's text below
}
\newcommandx{\yleftarrow}[4][1=\empty, 2=\empty, 4=\empty, usedefault=@]{%
\ifthenelse{\equal{#2}{\empty}}
{ \xleftarrow{ \protect{ \yaHelper[ #4 ]{ #3 } } } } % there's no text below
{ \xleftarrow[ \protect{ \yaHelper[ #2 ]{ #1 } } ]{ \protect{ \yaHelper[ #4 ]{ #3 } } } } % there's text below
}
\newcommandx{\yRightarrow}[4][1=\empty, 2=\empty, 4=\empty, usedefault=@]{%
\ifthenelse{\equal{#2}{\empty}}
{ \xRightarrow{ \protect{ \yaHelper[ #4 ]{ #3 } } } } % there's no text below
{ \xRightarrow[ \protect{ \yaHelper[ #2 ]{ #1 } } ]{ \protect{ \yaHelper[ #4 ]{ #3 } } } } % there's text below
}
\newcommandx{\yLeftarrow}[4][1=\empty, 2=\empty, 4=\empty, usedefault=@]{%
\ifthenelse{\equal{#2}{\empty}}
{ \xLeftarrow{ \protect{ \yaHelper[ #4 ]{ #3 } } } } % there's no text below
{ \xLeftarrow[ \protect{ \yaHelper[ #2 ]{ #1 } } ]{ \protect{ \yaHelper[ #4 ]{ #3 } } } } % there's text below
}
Usage is: yrightarrow[<TEXT-BELOW>][<OFFSET-BELOW>]{<TEXT-ABOVE>}[<OFFSET-ABOVE>}
and similarly for the others.
A working minimal example looks like this:
\documentclass{minimal}
\usepackage{amsmath}
\usepackage{ifthen}
\usepackage{xargs}
\newcommandx{\yaHelper}[2][1=\empty]{%
\ifthenelse{\equal{#1}{\empty}}%
{ \ensuremath{ \scriptstyle{ #2 } } } % no offset
{ \raisebox{ #1 }[0pt][0pt]{ \ensuremath{ \scriptstyle{ #2 } } } } % with offset
}
\newcommandx{\yrightarrow}[4][1=\empty, 2=\empty, 4=\empty, usedefault=@]{%
\ifthenelse{\equal{#2}{\empty}}
{ \xrightarrow{ \protect{ \yaHelper[ #4 ]{ #3 } } } } % there's no text below
{ \xrightarrow[ \protect{ \yaHelper[ #2 ]{ #1 } } ]{ \protect{ \yaHelper[ #4 ]{ #3 } } } } % there's text below
}
\begin{document}
\begin{align*}
A \yrightarrow{\pi \, \text{s.d.r.}}[-2pt] B \, , \: C \yrightarrow[\pi \, \text{s.d.r.}][4pt]{\pi \, \text{s.d.r.}}[-2pt] D
\end{align*}
\end{document}
However, this seems to be a brute force approach and I don't know whether there may be any side-effects (also I'm not doing any math-size checks, the stuff above and below the arrow will be always set in scriptstyle
). And of course it is a "dumb" solution because one has to determine the offset manually. And finally there's no support for the feature suggested by the fifth image.
I'd advise you to accept this answer not (yet) because I hope that somebody can provide a better solution (hopefully including the feature suggested by the fifth image, which possibly could be achieved by printing first the content with a slightly larger font and white colour and then overprint the actual content in black).
Adapting my answer at LaTeX package to help diagram translation of one language to another, I provide a first cut.
The syntax is
\notate[B<race>]{<referenced math>}{<dropline length in \baselineskips>}{<math notation>}
The <math notation>
can be given as a \parbox
, if longer text is needed (shown in first example below).
The MWE:
\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\usepackage{scalerel}
\usepackage{graphicx,amsmath}
\parskip \baselineskip
\def\myupbracefill#1{\rotatebox{90}{\stretchto{\{}{#1}}}
\def\rlwd{.5pt}
\newcommand\notate[4][B]{%
\if B#1\else\def\myupbracefill##1{}\fi%
\def\useanchorwidth{T}%
\setbox0=\hbox{$\displaystyle#2$}%
\def\stackalignment{c}\stackunder[-6pt]{%
\def\stackalignment{c}\stackunder[-1.5pt]{%
\stackunder[2pt]{\strut $\displaystyle#2$}{\myupbracefill{\wd0}}}{%
\rule{\rlwd}{#3\baselineskip}}}{%
\strut\kern9pt$\rightarrow$\smash{\rlap{$~\displaystyle#4$}}}%
}
\begin{document}
\begin{equation*}
\implies \frac{d}{dt} \displaystyle\int_{-\infty}^{+\infty} |\psi (x, t)|^2 \, dx
= \frac{i\hbar}{2m} \left[ \psi^* \frac{\partial}{\partial x} \psi - \left( \frac{\partial}{\partial x} \psi^* \right) \psi \right] \bigg|_{-\infty}^{+\infty}
\notate[X]{{}={}}{2}{\parbox[t]{1in}{Here, $\psi$ and $\psi^*$ are the
blah-blah variables.}} 0
\hspace{5ex}
\end{equation*}
\bigskip
\[
y = \psi^*
\notate{\frac{d\psi}{dt}}{4}{
\frac{d\psi}{dt} = \frac{ih}{2m}\frac{\partial^2}{\partial t^2}\psi
- \frac{i}{h} V\psi
}
+ \notate{\frac{d\psi^*}{dt}}{1}{
\frac{d\psi*}{dt} = -\frac{ih}{2m}\frac{\partial^2}{\partial t^2}\psi^*
+ \frac{i}{h} V\psi
}
\psi
\hspace{14ex}
\]
\end{document}
Note that this solution avoids the overlapping lines shown by the OP for a multi-part comment.
Since the math notation is \rlap
ped, the overall effect can be shifted left as needed by adding an \hspace{<length>}
to the end of the equation.
Because the math notation is \smash
ed, some extra skip may be needed for multi-line notations.
Best Answer
Use the command
This is a variation of the answer to "\xRightarrow (text)".
The following output is obtained by the code below it.