Beamer에서 이동 중에도 방정식, 화살표 및 설명 확인 가능

Beamer에서 이동 중에도 방정식, 화살표 및 설명 확인 가능

나는 비머와 결합된 tikZ가 다음과 같이 방정식을 강조 표시할 수 있는 방식을 좋아합니다(비머 기사 및 기사 모드에서도 잘 작동함).TeX예제 저는 이 기능을 자주 사용하지만 "이동 중에" 코드를 조작하기는 어렵다고 생각합니다. 내 코드에서 쉽게 호출할 수 있는 newcommand(?) \EqNComments(수식 및 설명) 을 만들고 싶습니다 .

    \EqNComments
    {$\Delta$}{=}{Le point Delta}
    {$\mathcal{N}(d_1)$}{+}{Hedge ratio}
    {$K.e^{-rt}.\mathcal{N}(d_2)$}{}{Strike actualised}

여기에 이미지 설명을 입력하세요

다음은 3x3 요소와 매우 잘 작동하는 MWE입니다.

  1. newcommand매개변수 제한이 9개로 제한되어 있습니다.
  2. \foreach코드를 최적화하기 위해 a를 입력하는 데 문제가 있습니다.
  3. 이 문제를 처리하는 더 지능적인 방법이 있어야 합니다...

    \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}
    

답변1

이것은 그런 종류의 작업을 수행합니다. tikzmark이는 무엇보다도 간격을 파괴하지 않고 현재 모드를 감지하기 때문에 더 나은 도구인 라이브러리를 사용합니다 . 어떤 수량에도 다음과 같이 주석을 달 수 있습니다.

\tmn{<quantity>}{<annotation>}

이를 환경에 배치하는 한 현재 AnnotatedEquation수행 중인 작업과 유사하게 목록에 주석이 추가됩니다. 노드는 정의된 범위 내에서 스타일 등을 Col1사용 합니다 . Col2선택적 인수를 사용하여 일부 키를 추가할 수 있습니다.

\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}

여기에 이미지 설명을 입력하세요

에서 작동하는 버전은 다음과 같습니다 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}

부록: 여기에 화살표를 조정할 수 있는 더 복잡하지만 더 일반적인 버전이 있습니다. 이는 키를 사용하여 수행할 수 있습니다 special arrow. 예를 들어,

\tmn[special arrow={out=90,annotations/out anchor=north}]{\Delta}{Le point Delta}= \tmn{\mathcal{N}(d_1)}{Hedge ratio}

화살표가 주석 문자의 북쪽에서 나와 90도 각도로 나가도록 지시합니다. 기본값은 동쪽 앵커와 0도입니다. 이는 분수의 분자를 다룰 때 특히 유용합니다.

\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}

여기에 이미지 설명을 입력하세요

추가 개선이 가능하지만 이를 실제로 사용하는 사용자의 의견이 필요합니다.

관련 정보