由于某种原因,我找不到哪里出错了。我在 algorithm2e 环境中放置了一个 tikz 节点,现在文件无法编译。我收到错误,Missing } inserted.
我看不到我缺少“}”的地方请帮助我编译文件。谢谢。
以下是代码:
\documentclass{article}
\usepackage{amsmath, amsfonts, amssymb, amsthm, bm}
\usepackage{commath}
\usepackage{xcolor}
\usepackage[most]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usetikzlibrary{tikzmark,calc,,arrows,shapes,decorations.pathreplacing}
\tikzset{every picture/.style={remember picture}}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\newcommand\mycommfont[1]{\footnotesize\ttfamily\textcolor{blue}{#1}}
\SetCommentSty{mycommfont}
\definecolor{mybluei}{RGB}{0,173,239}
\begin{document}
\colorbox{mybluei!05}{\color{black}
\begin{minipage}{\textwidth}
\SetAlgoLined
\SetNlSty{textbf}{}{:}
\begin{algorithm}[H]
\begin{align*}
Q_{s} &= \left[ q_{1}, q_{2},...,q_{M-1}\right]
\intertext{Then}
\tikz{\node{$E_{s} &= \subnode(d4){$X$}\subnode(d5){$Q_{s}$} \hspace{1.5cm} \Rightarrow\rho\times(M-1)$};}
\end{align*}
\begin{tikzpicture}[remember picture,overlay]{
\draw[blue,thick,->] (d4) to [in=90,out=245] + (225:2.7cm) node[anchor=north,text = black] {current estimate};
\draw[blue,thick,->] (d5) to [in=90,out=265] +(235:1.8cm) node[anchor=north,text = black] {previous estimate};}
\end{tikzpicture}
\end{algorithm}
\end{minipage}}
\end{document}
答案1
几点:align
无法看到&
TikZ 内部的node
。放在图片E_s &=
外面\tikz
。\subnode
应该用作\subnode{d4}{$X$}
,而不是\subnode(d4){$X$}
(注意括号)。并且您需要将 的基线设置tikzpicture
为有用的内容。
\documentclass{article}
\usepackage{amsmath, amsfonts, amssymb, amsthm, bm}
\usepackage{commath}
\usepackage[most]{tcolorbox}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usetikzlibrary{tikzmark,calc,,arrows,shapes,decorations.pathreplacing}
\tikzset{every picture/.style={remember picture}}
\usepackage[linesnumbered,ruled,vlined]{algorithm2e}
\newcommand\mycommfont[1]{\footnotesize\ttfamily\textcolor{blue}{#1}}
\SetCommentSty{mycommfont}
\definecolor{mybluei}{RGB}{0,173,239}
\begin{document}
\begin{minipage}{\textwidth}
\SetAlgoLined
\SetNlSty{textbf}{}{:}
\begin{algorithm}[H]
\begin{align*}
Q_{s} &= \left[ q_{1}, q_{2},...,q_{M-1}\right]
\intertext{Then}
E_{s} &= \tikz[baseline=(a.base)]\node(a){\subnode{d4}{$X$}\subnode{d5}{$Q_{s}$} \hspace{1.5cm} $\Rightarrow\rho\times(M-1)$};
\end{align*}
\begin{tikzpicture}[remember picture,overlay]{
\draw[blue,thick,->] (d4) to [in=90,out=245] + (225:2.7cm) node[anchor=north,text = black] {current estimate};
\draw[blue,thick,->] (d5) to [in=90,out=265] +(235:1.8cm) node[anchor=north,text = black] {previous estimate};}
\end{tikzpicture}
\end{algorithm}
\end{minipage}
\end{document}