在对齐环境中使用时,Tikz 箭头编译到错误的位置

在对齐环境中使用时,Tikz 箭头编译到错误的位置

您能帮我防止箭头显示在错误的页面上吗?我在环境中有一个 tikz 箭头align,出于某种原因,箭头显示在下一页上,而不是其预期位置。

这是我的代码:

\documentclass[11pt]{book}
\usepackage[top=3cm,bottom=3cm,left=3.2cm,right=3.2cm,headsep=10pt,a4paper]{geometry}
\usepackage{lipsum}
\usepackage{tikz} 
\usepackage[english]{babel} 
\usepackage{xcolor}
\definecolor{mybluei}{RGB}{0,173,239}
\definecolor{myblueii}{RGB}{63,200,244}
\usepackage{mathtools}
\usepackage{amsmath,amsfonts,amssymb,amsthm, bm}
\usetikzlibrary{tikzmark,calc,arrows,shapes,decorations.pathreplacing,pgfplots.groupplots, matrix}
\tikzset{every picture/.style={remember picture}}

\begin{document}
\section{Test 1}

\subsection{Test 2}
\lipsum[2-3]

\subsection{Solution}
\begin{align}
x_{k+1} & = \Phi_{k}x_{k} + w_{k}   && w_{k}\sim N(0,Q_{k})\\
z_{k+1} & = H_{k+1}x_{k+1} + v_{k+1}   && v_{k}\sim N(0,R_{k})\\
\bar{x}_{0}, & ~P_{0}\nonumber\\
\intertext{Parameter Values and Initial conditions:}
\Phi_{k} & = e^{-1}, \quad Q_{k} = q = 2, \quad P_{0}=2, \quad \bar{x_{0}} = 0 \nonumber\\
R_{k} & = r = 4,  \quad H_{k}=h=1\nonumber\\
\hat{x}^{-}_{k+1} & = \tikz[baseline]{\node[draw=myblueii,fill=mybluei!20,anchor=base,
                                            ellipse,inner xsep=-1pt,inner ysep=0pt]
  (d13) {$e^{-1}\hat{x}_{k}$}}\nonumber\\[1ex]
\hat{x}_{k+1} & = \hat{x}^{-}_{k+1} + K_{k+1}(z_{k+1}-e^{-1}\hat{x}_{k})\nonumber\\
\Aboxed{\hat{x}_{k+1} & = e^{-1}\hat{x}_{k} + K_{k+1}(z_{k+1}-e^{-1}\hat{x}_{k})}\nonumber\\
\intertext{where}
\Aboxed{K_{k+1} & = P_{k+1}H'_{k+1}R^{-1}_{k+1} = P_{k+1}\cdot\frac14}\nonumber\\
\intertext{where}
P_{k+1} & = \left[ P_{k+1}^{-^{-1}}+H'_{k+1}R^{-1}_{k+1}H_{k+1}\right]^{-1}\nonumber\\
P_{k+1} & = \left[\left( \Phi_{k}P_{k}\Phi'_{k}\right)+\frac14 \right]^{-1}\nonumber\\
\Aboxed{P_{k+1} & = \left[ \left(e^{-1}P_{k}e^{-1}\right)^{-1} + \frac14 \right]^{-1}}\nonumber\\
K_{k+1} & = \frac14\left[ \frac{e^{-2}}{P_{k}} + \frac14\right]^{-1}\nonumber
\end{align}
\begin{tikzpicture}[overlay,remember picture]
\draw[myblueii,thick,->] (d13) to [in=90,out=235] +(240:.55cm) node[anchor=north,text = black,] {};
\end{tikzpicture}

\begin{flalign*}
\textbf{(a)}    &&  P(1)        & = 3.1479              &&  \\
                &&  K(1)        & = 0.786986            &&  \\
                &&  \hat{x}(1)  & = 0 + 0.786986(1.5-0) &&  \\
                &&              & = 1.1805              &&  \\[1ex]
\end{flalign*}
\qed

\end{document} 

答案1

TeX 发出一页后就永远结束了。它不会返回并更改它。因此,如果节点在第 1 页上,而箭头直到第 2 页才添加,则箭头无法进入第 1 页。无论如何都不可能。

如果您尝试按原样放置tikzpicturealign则会出错。但如果您使用tikzmark(而不是仅仅加载它),它就会起作用。您可能会在第一次运行时遇到错误,但第二次运行时它会起作用。(有关解决此问题的方法,请参阅文档。)

箭头指向

\documentclass[11pt]{book}
\usepackage[top=3cm,bottom=3cm,left=3.2cm,right=3.2cm,headsep=10pt,a4paper]{geometry}
\usepackage{tikz}
\usepackage{lipsum}
\definecolor{mybluei}{RGB}{0,173,239}
\definecolor{myblueii}{RGB}{63,200,244}
\usepackage{mathtools}
\usepackage{amsfonts,amssymb,amsthm, bm}
\usetikzlibrary{tikzmark,shapes.geometric}
\tikzset{every picture/.style={remember picture}}

\begin{document}
\section{Test 1}

\subsection{Test 2}
\lipsum[2-3]

\subsection{Solution}
\begin{tikzpicture}[overlay,remember picture]
\draw[myblueii,thick,->] (pic cs:markme) to [in=90,out=235] +(240:.55cm) node[anchor=north,text = black,] {};
\end{tikzpicture}
\begin{align}
x_{k+1} & = \Phi_{k}x_{k} + w_{k}   && w_{k}\sim N(0,Q_{k})\\
z_{k+1} & = H_{k+1}x_{k+1} + v_{k+1}   && v_{k}\sim N(0,R_{k})\\
\bar{x}_{0}, & ~P_{0}\nonumber\\
\intertext{Parameter Values and Initial conditions:}
\Phi_{k} & = e^{-1}, \quad Q_{k} = q = 2, \quad P_{0}=2, \quad \bar{x_{0}} = 0 \nonumber\\
R_{k} & = r = 4,  \quad H_{k}=h=1\nonumber\\
\hat{x}^{-}_{k+1} & = \tikzmark{markme}\tikz[baseline]{\node[draw=myblueii,fill=mybluei!20,anchor=base,
                                            ellipse,inner xsep=-1pt,inner ysep=0pt]
  (d13) {$e^{-1}\hat{x}_{k}$}}\nonumber\\[1ex]
\hat{x}_{k+1} & = \hat{x}^{-}_{k+1} + K_{k+1}(z_{k+1}-e^{-1}\hat{x}_{k})\nonumber\\
\Aboxed{\hat{x}_{k+1} & = e^{-1}\hat{x}_{k} + K_{k+1}(z_{k+1}-e^{-1}\hat{x}_{k})}\nonumber\\
\intertext{where}
\Aboxed{K_{k+1} & = P_{k+1}H'_{k+1}R^{-1}_{k+1} = P_{k+1}\cdot\frac14}\nonumber\\
\intertext{where}
P_{k+1} & = \left[ P_{k+1}^{-^{-1}}+H'_{k+1}R^{-1}_{k+1}H_{k+1}\right]^{-1}\nonumber\\
P_{k+1} & = \left[\left( \Phi_{k}P_{k}\Phi'_{k}\right)+\frac14 \right]^{-1}\nonumber\\
\Aboxed{P_{k+1} & = \left[ \left(e^{-1}P_{k}e^{-1}\right)^{-1} + \frac14 \right]^{-1}}\nonumber\\
K_{k+1} & = \frac14\left[ \frac{e^{-2}}{P_{k}} + \frac14\right]^{-1}\nonumber
\end{align}

\begin{flalign*}
\textbf{(a)}    &&  P(1)        & = 3.1479              &&  \\
                &&  K(1)        & = 0.786986            &&  \\
                &&  \hat{x}(1)  & = 0 + 0.786986(1.5-0) &&  \\
                &&              & = 1.1805              &&  \\[1ex]
\end{flalign*}
\qed

\end{document}

相关内容