2

How I can make sometimes the arrow direction up and sometimes down in a one unique tex file (I want to have both of them in a Latex-tex)? Following program make arrow down.

\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}
user3271929
  • 153
  • 5

1 Answers1

4

In addition to using \uparrow as suggested in a comment, two instances of \stackunder had to be changed to \stackon.

Of course, this question/answer are based on Graphics equations: put text on equations

\documentclass{article}
\usepackage{graphicx}
\usepackage[usestackEOL]{stackengine}
\usepackage{xcolor}
\def\calloutsym{%
  \ensurestackMath{%
  \scalebox{1.7}{\color{red}\stackon[0pt]{\bigcirc}{\uparrow}}}%
}
\newcommand\callouttext[1]{%
  \def\stacktype{S}\renewcommand\useanchorwidth{T}\stackText%
  \stackon{\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

ADDENDUM:

To handle both up and down callouts, just create tailored versions for each, invoked here with \upcallout[callout-vshift]{math item to callout}{callout text} and the corresponding \downcallout. REVISED to condense the code.

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

enter image description here