
Mir gefällt die Art und Weise, wie tikZ in Kombination mit beamer Gleichungen hervorheben kann (es funktioniert auch gut mit beamerarticle und dem Artikelmodus), wie inTeX-Beispiel
Ich verwende diese Funktion häufig, aber ich denke, dass der Code „unterwegs“ schwer zu bearbeiten ist. Ich möchte eine newcommand
(?) \EqNComments
(Gleichung und Kommentare) erstellen, die ich in meinem Code einfach aufrufen kann.
\EqNComments
{$\Delta$}{=}{Le point Delta}
{$\mathcal{N}(d_1)$}{+}{Hedge ratio}
{$K.e^{-rt}.\mathcal{N}(d_2)$}{}{Strike actualised}
Hier ist MWE, das sehr gut mit 3x3-Elementen funktioniert.
- Ich stecke mit der Beschränkung auf 9
newcommand
Parameter fest - Ich habe Probleme, einen
\foreach
Code einzugeben, um ihn zu optimieren Es muss einen intelligenteren Weg geben, diese Angelegenheit zu bearbeiten …
\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}
Antwort1
Dies macht etwas in dieser Art. Es verwendet die tikzmark
Bibliothek, die ein besseres Werkzeug ist, weil sie unter anderem die Abstände nicht zerstört und den Modus erkennt, in dem wir uns befinden. Jede Menge kann mit
\tmn{<quantity>}{<annotation>}
Solange Sie diese in eine AnnotatedEquation
Umgebung einfügen, werden sie von der Liste ähnlich kommentiert, wie Sie es tun. Die Knoten verwenden die Stile Col1
usw. Col2
in dem Umfang, in dem sie definiert sind. Sie können das optionale Argument verwenden, um einige Schlüssel hinzuzufügen.
\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}
Hier ist eine Version, die mit funktioniert 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}
NACHTRAG: Hier ist eine kompliziertere, aber auch allgemeinere Version, die es ermöglicht, die Pfeile zu verstellen. Dies kann mit der special arrow
Taste erfolgen. Zum Beispiel:
\tmn[special arrow={out=90,annotations/out anchor=north}]{\Delta}{Le point Delta}= \tmn{\mathcal{N}(d_1)}{Hedge ratio}
weist den Pfeil an, aus dem Norden des Anmerkungstextes herauszukommen und in einem Winkel von 90 Grad nach außen zu zeigen. Die Standardeinstellungen sind der östliche Anker und 0 Grad. Dies ist insbesondere beim Umgang mit Zählern von Brüchen hilfreich.
\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}
Weitere Verbesserungen sind möglich, erfordern jedoch die Eingabe von Benutzern, die diese tatsächlich verwenden.