8

I'm looking to add an arrow underneath an equals sign to explain the step that has been taken. See below:

example

To achieve the arrow style that I like to use, I used \drsh from mathabx.

I tried using \underset to set this under the equals sign, but could not achieve the result I was looking for.

\documentclass{article} 
\usepackage{enumitem}
  \newlength\widest 
\usepackage{amsmath}
\usepackage{mathabx}

\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} 
{\underset{\qquad\text{\makebox[0pt]{{\huge$\drsh$} Testing}}}{=}} 0
\end{equation*}
\end{document}

attempt

If at all possible, I would also like to be able to draw something like the following:

another_example

I have read things about TikZ being very good for this sort of thing, but I have never used it before. If you think this is the right way to go, could you please offer me a push in the right direction?

I believe it's also worth mentioning that I have been using these \drsh arrows in text as well, for example something like the following:

enter image description here

\documentclass{article} 
\usepackage{enumitem}
  \newlength\widest 
\usepackage{mathabx}

\begin{document}

\noindent
Some text
\settowidth\widest{{\huge$\drsh$}}
\begin{description}[leftmargin=\dimexpr\widest+\labelsep\relax,labelindent=0pt,
labelwidth=\widest]
\item[{\huge$\drsh$}] Some more text
\end{description}
\end{document} 

Is there a smarter way to do this?

0

2 Answers 2

9

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).

EDITED to allow multiple uses of \notate in a single equation, with and without underbrace as specified.

The MWE:

\documentclass{article}
\usepackage[usestackEOL]{stackengine}
\usepackage{scalerel}
\usepackage{graphicx,amsmath}
\parskip \baselineskip
\def\svmybf#1{\rotatebox{90}{\stretchto{\{}{#1}}}
\def\svnobf#1{}
\def\rlwd{.5pt}
\newcommand\notate[4][B]{%
  \if B#1\let\myupbracefill\svmybf\else\let\myupbracefill\svnobf\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}
\]

\[ S = \int \notate[X]{L}{2.5}{\text{1st: No brace, as expected}} 
  \notate{dV}{1}{\text{2nd: Should have the brace!}} 
\]
\end{document}

enter image description here

Note that this solution avoids the overlapping lines shown by the OP for a multi-part comment.

Since the math notation is \rlapped, 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 \smashed, some extra skip may be needed for multi-line notations.

8
  • Thanks! I simply used \parbox for multi-line comments
    – flopflips
    Commented Aug 28, 2015 at 16:50
  • I fail to use the command \notate for the equation that contains & in the align environment.
    – raf
    Commented Apr 1, 2023 at 18:33
  • 1
    @raf Aha. There is no way that \notate can work across a & boundary of align. Commented Apr 21, 2023 at 17:02
  • 1
    @raf Please see my edit for the fix. Commented May 25, 2023 at 18:43
  • 1
    Thank you so much. Nowadays, it is one of my most frequently used commands. That's why it made me ask a follow-up question to customize it with some more features. :)
    – raf
    Commented May 25, 2023 at 19:45
6

Here's another option using the tikzmark library; the basic idea is to place some marks that will be later used to draw the braces with the arrows and place the explanatory texts:

\documentclass{article} 
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark,decorations.pathreplacing}

\begin{document}

\begin{equation*}
\implies  
\frac{d}{dt} \int_{-\infty}^{+\infty} \lvert\psi (x, t)\rvert^2 \, dx 
= \frac{i\hbar}{2m} \Bigl[ \psi^* \frac{\partial}{\partial x} \psi 
  - \Bigl( \frac{\partial}{\partial x} \psi^* \Bigr) \psi \Bigr] 
  \biggm|_{-\infty}^{+\infty}
\tikzmark{zero}= 0
\end{equation*}

\begin{tikzpicture}[remember picture,overlay]
\draw[->,>=latex]
  ([shift={(8pt,-2pt)}]pic cs:zero) |- 
  ++(10pt,-20pt) 
  node[right,text width=3cm] 
    {And here we add the explanation for this equality
    };
\end{tikzpicture}

\bigskip
\[
y = \psi^* \frac{d\psi}{\tikzmark{starta}dt\tikzmark{enda}} + \frac{d\psi^*}{\tikzmark{startb}dt\tikzmark{endb}}\psi
\]

\begin{tikzpicture}[remember picture,overlay]
\draw[decorate,decoration={brace,mirror}]
  ([xshift=-3pt]pic cs:starta) -- node (aux) {} ([xshift=3pt]pic cs:enda);
\draw[->,>=latex]
  (aux) |-
  ++(10pt,-50pt) 
  node[right] 
    {$\displaystyle\frac{d\psi}{dt} = \frac{ih}{2m}\frac{\partial^2}{\partial t^2}\psi 
      - \frac{i}{h} V\psi$%
    };  
\draw[decorate,decoration={brace,mirror}]
  ([xshift=-3pt]pic cs:startb) -- node (auxi) {} ([xshift=3pt]pic cs:endb);
\draw[->,>=latex]
  (auxi) |-
  ++(10pt,-20pt) 
  node[right] 
    {$\displaystyle\frac{d\psi*}{dt} = -\frac{ih}{2m}\frac{\partial^2}{\partial t^2}\psi^* 
      + \frac{i}{h} V\psi$%
    };  
\end{tikzpicture}

\end{document}

The result:

enter image description here

You must log in to answer this question.

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