22

enter image description here

I have a big question that I cannot solve by myself.

I would like to add text on my equations, but I like to have some graphics on those. For instance, I would like to explain why I am doing something, e.g. by saying which theorem/result i am using to get to a precise point on my equation. However, I don't want to use only text, but emphasizing with graphics and text box linked with some arrows is preferred.

The image you find is similar to what I am thinking.

I thank you for the help

Best

19

Here, I do it as a compound stacking operation. The macro \calloutsym is the red circle and underarrow; \callouttext{} places \scriptsize text under \calloutsym, where the text can be multi-line with the use of \\ in the argument; and \callout{}{} places the \callouttext of the second argument under the first argument. EDITED so that \callout can take an optional argument denoting a different vertical shift than the default 1.5pt on the red circle (if your circled text is, for example, taller).

\documentclass{article}
\usepackage{graphicx}
\usepackage[usestackEOL]{stackengine}
\usepackage{xcolor}
\def\calloutsym{%
  \ensurestackMath{%
  \scalebox{1.7}{\color{red}\stackunder[0pt]{\bigcirc}{\downarrow}}}%
}
\newcommand\callouttext[1]{%
  \def\stacktype{S}\renewcommand\useanchorwidth{T}\stackText%
  \stackunder{\calloutsym}{\scriptsize\Longstack{#1}}\stackMath%
}
\newcommand\callout[3][1.5pt]{%
  \def\stacktype{L}\stackMath\stackunder[#1]{#2}{\callouttext{#3}}%
}
\begin{document}
\[ K \callout{\subseteq}{by compactness} \bigcup_{J=1}^{n} V_{nJ} \]
\[ \lim_{n\rightarrow \infty} \int\limits_{x} f_{n} \mathrm{d}\mu 
\callout[1.8pt]{=}{By Monotone\\Convergence Theorem} \int\limits_{x} f \mathrm{d}\mu
\]
\end{document}

enter image description here

I should point out that, by default, the red circle will not be overlapped by surrounding math text. However, if the circled item is within text that should not be cleaved apart, the use of \renewcommand\useanchorwidth{T} will present the original math without making allowances for the red circle.

\[
 \renewcommand\useanchorwidth{T}
 \callout[.5pt]{D}{Total\\Derivative}\vec{V}/Dt =  \ldots\quad
 \renewcommand\useanchorwidth{F}
 \callout[.5pt]{D}{Total\\Derivative}\vec{V}/Dt =  \ldots
\]

enter image description here

| improve this answer | |
  • Nice! This is rather useful with writing lecture notes. (Btw. shouldn't the ring be pushed down a tiny bit?) – Svend Tveskæg Oct 25 '13 at 7:13
  • Also, I think the proper way of typesetting the differential operator is \newcommand*\dif{\mathop{}\!\mathrm{d}} and the using \dif. (Originally, not my idea.) – Svend Tveskæg Oct 25 '13 at 8:30
  • 1
    @SvendTveskæg I updated the result to make the default shift a little larger, and make the shift available as an optional argument to \callout – Steven B. Segletes Oct 25 '13 at 10:53
  • @SvendTveskæg Thanks for the tip on the \dif. I'll leave it out of this solution not to distract things, but I'll add it to my "in-house" style. – Steven B. Segletes Oct 25 '13 at 10:56
15

With tikz:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes}

\tikzset{every picture/.style={remember picture}}

\begin{document}

\begin{equation}
K \tikz[baseline]{ \node[draw=red,fill=red!20,anchor=base,circle,inner sep = 0pt]
  (d1) {$\subseteq$}; } \bigcup_{J=1}^{n} V_{nJ}
\qquad \qquad
\lim_{n\rightarrow \infty} \int\limits_{x} f_{n} \mathrm{d}\mu \tikz[baseline]{ 
    \node[draw=blue,fill=blue!20,anchor=base,circle,inner sep = 0pt] (d2) {$=$}; } \int\limits_{x} f \mathrm{d}\mu
\end{equation}%
%
\begin{tikzpicture}[overlay,remember picture]
\draw[red,->] (d1) -- +(270:1cm) node[anchor=north,text = black,] {by compactness};
\draw[blue,->] (d2) -- +(270:1cm) node[anchor=north,text = black, align = left] {by monotone \\ convergence theorem};
\end{tikzpicture}
%
\end{document}

enter image description here

You can bend arrows by to [in=145,out=235] instead of -- in

\draw[red,->] (d1) to [in=90,out=235] +(270:1cm) node[anchor=north,text = black,] {by compactness};

enter image description here

| improve this answer | |
9

With hf-tikz:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[customcolors,markings]{hf-tikz}

\tikzset{offset def/.style={
    above left offset={0.015,0.3},
    below right offset={-0.015,-0.12},
  },
  use color/.style={
    offset def,
    set fill color=white,
    set border color=#1,
  },
}

\newcommand{\annotate}[2][]{
\tikz[remember picture,overlay]\draw[#1,use marker id] (0,0) -- +(270:1cm)
 node[anchor=north,text=black,align=center] {#2};
}

\begin{document}

\begin{equation}
K 
\tikzmarkin[use color=red,mark at =0.785]{a}\subseteq\tikzmarkend{a}
\annotate[red,-stealth,font=\footnotesize]{by compactness}
\bigcup_{J=1}^{n} V_{nJ}
\qquad \qquad
\lim_{n\rightarrow \infty} \int\limits_{x} f_{n} \mathrm{d}\mu 
\tikzmarkin[use color=blue,mark at =0.785]{b}=\tikzmarkend{b}ù
\annotate[blue,-stealth,font=\footnotesize]{by monotone \\ convergence theorem}
\int\limits_{x} f \mathrm{d}\mu
\end{equation}
\end{document}

The result:

enter image description here

| improve this answer | |
2

You could start looking at pstricks solutions. Here is an example of equation and a graph together: (Note: I had to switch my compiler to XeLaTeX to get this to work)

\documentclass[10pt]{article}
\usepackage[top=.5in, bottom=.5in,left=0.5in,right=0.5in]{geometry}
\usepackage{amsmath}
\usepackage{pstricks-add}
\begin{document}
The region is rotated around the x-axis, find the volume bounded by: $\displaystyle \quad y=(\,x+1\,)^{2}, \quad y{\,=\,}0, \quad x=1, \quad x=2 $\\\\\\    
\begin{center}
\newrgbcolor{zzttqq}{0.6 0.2 0}
\psset{xunit=1.0cm,yunit=1.0cm,algebraic=true,dotstyle=o,dotsize=3pt 0,linewidth=0.8pt,arrowsize=3pt 2,arrowinset=0.25}
\begin{pspicture*}(-0.5,-0.5)(2.5,9.3)
\psaxes[labelFontSize=\scriptstyle,xAxis=true,yAxis=true,Dx=1,Dy=1,ticksize=-2pt 0,subticks=2]{->}(0,0)(-0.5,-0.5)(2.5,9.3)[x,140] [y,-40]
\pscustom[linecolor=zzttqq,fillcolor=zzttqq,fillstyle=solid,opacity=0.1]{\psplot{1}{2}{(x+1)^2}\lineto(2,0)\lineto(1,0)\closepath}
\psplot[plotpoints=200]{-0.5}{2.5}{(x+1)^2}
\psline(1,-0.5)(1,4)
\rput[tl](0.1,8.1){$y=(x+1)^{2}$}
\psline(2,-0.5)(2,10)
\end{pspicture*}
\newline
\end{center}

\begin{align*}
\text{Area} &= \int_a^{b} \Bigg[\, \pi\,(\text{\,radius\,})^{2}\; \Bigg] \,dx \\\\
~ &= \int_0^{1} \Bigg[\, \pi\,(\,x^{2}\,)^{2}\; \Bigg] \,dx \\\\
~ &= \int_0^{1} \Bigg[\, \pi\,x^{4}\; \Bigg] \,dx \\\\
~ &= \Bigg[\, \pi\,\frac{\,x^{5}}{5} \;  \Bigg]_0^{1} \\\\
~ &= \Bigg[\, \pi\,\frac{\,1^{5}}{5} \; - \pi\,\frac{0^{5}}{4} \,  \Bigg] \\\\
~ &= \,\frac{\pi}{5} \, - \, 0 \\\\
~ &= \frac{\pi}{5}
\end{align*}
\end{document}

Code is from here http://www.latex-community.org/forum/viewtopic.php?f=46&t=10757

| improve this answer | |

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.