我正在关注这个问题在我的方程式中给出注释。我的计划是跟踪某些方程式段的颜色,这样就可以轻松理解。
如果您看到两个方程式,它们的颜色不匹配。有什么最好的方法可以跟踪碎片方程式的颜色,以便轻松识别它们?
\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}
\begin{AnnotatedEquation}
\tmn{K\cdot \mathrm{e}^{-r\,t}\cdot\mathcal{N}(d_2)}{Strike actualised} =
\tmn{S\cdot \mathrm{e}^{-r\,t}\cdot\mathcal{N}(d_2)}{Strike actualised}
+ \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}
\end{document}
更新:
答案1
一个非常简单的解决方案是在两个方程之间重新定义颜色。
\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}
\tikzset{ Col2/.style= {fill=blue!20,anchor=base,rounded corners=2pt},
Col3/.style= {Col2, fill=red!20},
Col1/.style= {Col2, fill=green!20}, }
\begin{AnnotatedEquation}
\tmn{K\cdot \mathrm{e}^{-r\,t}\cdot\mathcal{N}(d_2)}{Strike actualised} =
\tmn{S\cdot \mathrm{e}^{-r\,t}\cdot\mathcal{N}(d_2)}{Strike actualised}
+ \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}
\end{document}