方程中的箭头导致方程看起来不整洁

方程中的箭头导致方程看起来不整洁

在下面的代码中,当我将箭头放在方程式中时,箭头指向的方程式元素的对齐方式会变得混乱。是否可以保持方程式的对齐方式(如第二个方程式所示),同时仍让箭头指向它们?谢谢您的帮助。

这是我的代码:

\documentclass{book}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{mathptmx}
\usepackage{calc}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc,,arrows,shapes,decorations.pathreplacing}
\tikzset{every picture/.style={remember picture}}

\begin{document}
We denote
\begin{equation}
\hat{x}^{-}_{k} \equiv \hat{x}(\tikz[baseline]{\node(d1){$k$}}\mid \tikz[baseline]{\node(d2){$k-1$}})
\end{equation}
\begin{tikzpicture}[remember picture,overlay]{
   \draw[blue,thick,<-,rounded corners] (d1) |- ++ (0.6cm,-1.5cm) node[anchor=west,text = black,] (label1) {\emph{what is the $kth~x$}};
   \draw[blue,thick,<-,rounded corners] (d2) |- ($(label1.west)-(-0.8cm,-0.6cm)$) node[anchor=west,text = black] {$given~\hat{x}_{k-1},~z_{k-1}$};}
\end{tikzpicture}
\vspace{1cm}

We denote
\begin{equation}
\hat{x}^{-}_{k} \equiv \hat{x}(k\mid k-1)
\end{equation}

\end{document} 

答案1

tikzmark无论如何,当您加载库时,请使用它的\subnode,并将整个方程放在一个节点中:

在此处输入图片描述

\documentclass{book}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{mathptmx}
\usepackage{calc}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc,arrows,shapes,decorations.pathreplacing}
%\tikzset{every picture/.style={remember picture}}

\begin{document}
We denote
\begin{equation}
\tikz{\node{$\hat{x}^{-}_{k} \equiv \hat{x}(\subnode{d1}{$k$}\mid \subnode{d2}{$k-1$})$};}
\end{equation}
\begin{tikzpicture}[remember picture,overlay]{
   \draw[blue,thick,<-,rounded corners] (d1) |- ++ (0.6cm,-1.5cm) node[anchor=west,text = black,] (label1) {\emph{what is the $k$th $x$}};
   \draw[blue,thick,<-,rounded corners] (d2) |- ($(label1.west)-(-0.8cm,-0.6cm)$) node[anchor=west,text = black] {given $\hat{x}_{k-1},~z_{k-1}$};}
\end{tikzpicture}
\vspace{1cm}

We denote
\begin{equation}
\hat{x}^{-}_{k} \equiv \hat{x}(k\mid k-1)
\end{equation}

\end{document} 

相关内容