
Gosto da maneira como o tikZ combinado com o beamer pode destacar equações (funciona bem com o modo beamerarticle e artigo também), como emTeXexemplo
Costumo usar esse recurso, mas acho que o código é difícil de manipular "em trânsito". Gostaria de criar uma newcommand
(?) \EqNComments
(Equação e Comentários) que eu pudesse chamar facilmente em meu código.
\EqNComments
{$\Delta$}{=}{Le point Delta}
{$\mathcal{N}(d_1)$}{+}{Hedge ratio}
{$K.e^{-rt}.\mathcal{N}(d_2)$}{}{Strike actualised}
Aqui está o MWE que funciona muito bem com elementos 3x3.
- Estou preso à limitação de 9 nos
newcommand
parâmetros - Tenho problemas para inserir um
\foreach
para otimizar meu código Deve haver uma maneira mais inteligente de processar este assunto...
\documentclass{beamer} %\documentclass[11pt,twoside]{article} %\usepackage[envcountsect]{beamerarticle} \usetheme{Warsaw} \usepackage{amsmath} \usepackage{amssymb} \usepackage{tikz} \usetikzlibrary{arrows,shapes} \tikzset{ Col1/.style= {fill=blue!20,anchor=base,rounded corners=2pt}, Col2/.style= {Col1, fill=red!20}, Col3/.style= {Col1, fill=green!20}, } \newcommand{\EqNComments}[9] { \tikzstyle{every picture}+=[remember picture] \tikzstyle{na} = [baseline=-.5ex] \begin{frame} \begin{equation} \tikz[baseline] {\node[Col1] (d1) {#1};} #2 \tikz[baseline] {\node[Col2] (d2) {#4};} #5 \tikz[baseline] {\node[Col3] (d3) {#7};} #8 % \tikz[baseline] {\node[Col3] (d4) {#10};} #11 \end{equation} \begin{itemize} \item #3 \tikz[na] \node[coordinate] (s1) {}; \item #6 \tikz[na] \node[coordinate] (s2) {}; \item #9 \tikz[na] \node[coordinate] (s3) {}; % \item #12 % \tikz[na] \node[coordinate] (s4) {}; \end{itemize} \begin{tikzpicture}[overlay] \path[->] (s1) edge [bend left] (d1); \path[->] (s2) edge [bend right] (d2); \path[->] (s3) edge [out=0, in=-90] (d3); % \path[->] (s4) edge [out=0, in=-90] (d4); \end{tikzpicture} \end{frame} } \begin{document} \EqNComments {$\Delta$}{=}{Le point Delta} {$\mathcal{N}(d_1)$}{+}{Hedge ratio} {$K.e^{-rt}.\mathcal{N}(d_2)$}{-}{Strike actualised} %{dividendes}{.}{Not working here if I try to extend the command to 12 arguments} \end{document}
Responder1
Isso faz algo desse tipo. Utiliza a tikzmark
biblioteca, que é uma ferramenta melhor porque, entre outras coisas, não destrói o espaçamento e detecta o modo em que estamos. Qualquer quantidade pode ser anotada com
\tmn{<quantity>}{<annotation>}
Contanto que você os coloque em um AnnotatedEquation
ambiente, eles serão anotados na lista de forma semelhante ao que você está fazendo. Os nós usarão os estilos Col1
, Col2
etc. na medida em que forem definidos. Você pode usar o argumento opcional para adicionar algumas chaves.
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\newcounter{mytn}
\makeatletter
\newcommand{\tmn}[3][]{\stepcounter{mytn}%
\tikzmarknode[Col\the\numexpr\value{mytn}-\mytn@start\relax/.try,inner xsep=2pt,%
minimum height=1.6em,#1]{mytn-\number\value{mytn}}{#2}%
\expandafter\gdef\csname tmn@annot@\number\value{mytn}\endcsname{#3}}
\newenvironment{AnnotatedEquation}{\edef\mytn@start{\number\value{mytn}}%
\begin{equation}}{\end{equation}%
\edef\mytn@end{\number\value{mytn}}%
\ifnum\mytn@end>\mytn@start
\begin{itemize}
\foreach \X in {\the\numexpr\mytn@start+1,...,\mytn@end}
{\item \tikzmarknode{mytn-annot-\X}{\csname tmn@annot@\X\endcsname}%
\begin{tikzpicture}[overlay,remember picture]
\draw[-stealth] (mytn-annot-\X.east) to[out=0,in=-90] (mytn-\X.south);
\end{tikzpicture}}
\end{itemize}
\fi}
\makeatother
\tikzset{ Col1/.style= {fill=blue!20,anchor=base,rounded corners=2pt},
Col2/.style= {Col1, fill=red!20},
Col3/.style= {Col1, fill=green!20}, }
\begin{document}
\begin{frame}[t]
\frametitle{Some annotated equation}
\begin{AnnotatedEquation}
\tmn{\Delta}{Le point Delta}= \tmn{\mathcal{N}(d_1)}{Hedge ratio}-
\tmn{K\cdot \mathrm{e}^{-r\,t}\cdot\mathcal{N}(d_2)}{Strike actualised}
\end{AnnotatedEquation}
\end{frame}
\begin{frame}[t]
\frametitle{Another annotated equation}
\begin{AnnotatedEquation}
\tmn{\Delta}{Le point Delta}= \tmn{\mathcal{N}(d_1)}{Hedge ratio}-
\tmn{K\cdot \mathrm{e}^{-r\,t}\cdot\mathcal{N}(d_2)}{Strike actualised}
+\tmn{\xi}{a Weyl spinor}
+\tmn{\eta}{another Weyl spinor}
\end{AnnotatedEquation}
\end{frame}
\end{document}
Aqui está uma versão que funciona com external
.
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{tikzmark,external}
\newcounter{mytn}
\makeatletter
\newcommand{\tmn}[3][]{\stepcounter{mytn}%
\tikzmarknode[Col\the\numexpr\value{mytn}-\mytn@start\relax/.try,inner xsep=2pt,%
minimum height=1.6em,#1]{mytn-\number\value{mytn}}{#2}%
\expandafter\gdef\csname tmn@annot@\number\value{mytn}\endcsname{#3}}
\newenvironment{AnnotatedEquation}{\edef\mytn@start{\number\value{mytn}}%
\tikzexternaldisable
\begin{equation}}{\end{equation}%
\edef\mytn@end{\number\value{mytn}}%
\ifnum\mytn@end>\mytn@start
\begin{itemize}
\foreach \X in {\the\numexpr\mytn@start+1,...,\mytn@end}
{\item \tikzmarknode{mytn-annot-\X}{\csname tmn@annot@\X\endcsname}%
\begin{tikzpicture}[overlay,remember picture]
\draw[-stealth] (mytn-annot-\X.east) to[out=0,in=-90] (mytn-\X.south);
\end{tikzpicture}}
\end{itemize}
\fi\tikzexternalenable}
\makeatother
\tikzset{ Col1/.style= {fill=blue!20,anchor=base,rounded corners=2pt},
Col2/.style= {Col1, fill=red!20},
Col3/.style= {Col1, fill=green!20}, }
\begin{document}
\begin{frame}[t]
\frametitle{Some annotated equation}
\begin{AnnotatedEquation}
\tmn{\Delta}{Le point Delta}= \tmn{\mathcal{N}(d_1)}{Hedge ratio}-
\tmn{K\cdot \mathrm{e}^{-r\,t}\cdot\mathcal{N}(d_2)}{Strike actualised}
\end{AnnotatedEquation}
\end{frame}
\begin{frame}[t]
\frametitle{Another annotated equation}
\begin{AnnotatedEquation}
\tmn{\Delta}{Le point Delta}= \tmn{\mathcal{N}(d_1)}{Hedge ratio}-
\tmn{K\cdot \mathrm{e}^{-r\,t}\cdot\mathcal{N}(d_2)}{Strike actualised}
+\tmn{\xi}{a Weyl spinor}
+\tmn{\eta}{another Weyl spinor}
\end{AnnotatedEquation}
\end{frame}
\end{document}
TERMO ADITIVO: Aqui está uma versão mais complicada, mas também mais geral, que permite ajustar as setas. Isso pode ser feito usando a special arrow
chave. Por exemplo,
\tmn[special arrow={out=90,annotations/out anchor=north}]{\Delta}{Le point Delta}= \tmn{\mathcal{N}(d_1)}{Hedge ratio}
instrui a seta a sair do norte do texto da anotação e sair em um ângulo de 90 graus. Os padrões são a âncora leste e 0 graus. Isto é particularmente útil ao lidar com numeradores de frações.
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{tikzmark,external}
\newcounter{mytn}
\makeatletter
\newcommand{\tmn}[3][]{\stepcounter{mytn}%
\tikzmarknode[annotations/Col\the\numexpr\value{mytn}-\mytn@start\relax/.try,inner xsep=2pt,%
minimum height=1.6em,#1]{mytn-\number\value{mytn}}{#2}%
\expandafter\gdef\csname tmn@annot@\number\value{mytn}\endcsname{#3}}
\tikzset{special arrow/.code={%
\expandafter\xdef\csname tmn@arrow@style@\number\value{mytn}\endcsname{#1}}}
\newenvironment{AnnotatedEquation}{\edef\mytn@start{\number\value{mytn}}%
\tikzexternaldisable
\begin{equation}}{\end{equation}%
\edef\mytn@end{\number\value{mytn}}%
\ifnum\mytn@end>\mytn@start
\begin{itemize}
\foreach \X in {\the\numexpr\mytn@start+1,...,\mytn@end}
{\item \tikzmarknode{mytn-annot-\X}{\csname tmn@annot@\X\endcsname}%
\begin{tikzpicture}[overlay,remember picture]
\ifcsname tmn@arrow@style@\X\noexpand\endcsname
\draw[-stealth,out=0,in=-90,
style/.expanded=\csname tmn@arrow@style@\X\noexpand\endcsname]
(mytn-annot-\X.\pgfkeysvalueof{/tikz/annotations/out anchor})
to (mytn-\X.\pgfkeysvalueof{/tikz/annotations/in anchor});
\else
\draw[-stealth,out=0,in=-90] (mytn-annot-\X.\pgfkeysvalueof{/tikz/annotations/out anchor})
to (mytn-\X.\pgfkeysvalueof{/tikz/annotations/in anchor});
\fi
\end{tikzpicture}}
\end{itemize}
\fi\tikzexternalenable}
\makeatother
\tikzset{annotations/.cd,
Col1/.style= {fill=blue!20,anchor=base,rounded corners=2pt},
Col2/.style= {annotations/Col1, fill=red!20},
Col3/.style= {annotations/Col1, fill=green!20},
in anchor/.initial=south,out anchor/.initial=east}
\begin{document}
\begin{frame}[t]
\frametitle{Some annotated equation}
\begin{AnnotatedEquation}
\tmn{\Delta}{Le point Delta}= \tmn{\mathcal{N}(d_1)}{Hedge ratio}-
\tmn{K\cdot \mathrm{e}^{-r\,t}\cdot\mathcal{N}(d_2)}{Strike actualised}
\end{AnnotatedEquation}
\end{frame}
\begin{frame}[t]
\frametitle{Another annotated equation}
\begin{AnnotatedEquation}
\tmn[special arrow={out=90,annotations/out anchor=north}]{\Delta}{Le point Delta}= \tmn{\mathcal{N}(d_1)}{Hedge ratio}-
\tmn{K\cdot \mathrm{e}^{-r\,t}\cdot\mathcal{N}(d_2)}{Strike actualised}
+\frac{\tmn[special arrow={in=-160,annotations/in anchor=west}]{\xi}{a Weyl spinor}}{\tmn{\eta}{another Weyl spinor}}
\end{AnnotatedEquation}
\end{frame}
\end{document}
Outras melhorias são possíveis, mas requerem a contribuição dos usuários que realmente utilizam isso.