使用 tikz 在对齐环境中将箭头指向常量

使用 tikz 在对齐环境中将箭头指向常量

这个问题是建立优雅的解决方案发布的这里, 由...提供伯纳德

我想使用 来获得替代解决方案tikz

下面是我尝试实现的代码(注释掉),失败了tikz

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

\begin{document}

\begin{align*}
  D(\lambda,x) = & ~ f(x) + \lambda'g(x) \quad \lambda\geqslant 0\\
\intertext{the dual is given as:}
\lambda^{*} = & ~ \arg\{ \max_{\lambda}D(\lambda,x^{*}) \}\\
            = & ~ \arg\{ \max_{\lambda}D(\lambda) \}
\end{align*}

\vspace{2cm}

%Tikz attempt

%\begin{align*}
%\tikz{\node$\{D(\lambda,x) = & ~ f(x) + \lambda'g(x) \quad \lambda\geqslant 0\\
%\intertext{the dual is given as:}
%\lambda^{*} = & ~ \arg\{ \max_{\lambda}D(\lambda,\subnode{d1}{$x^{*}$}) \}$};}\\
%                = & ~ \arg\{ \max_{\lambda}D(\lambda) \}
%\end{align*}

%\begin{tikzpicture}[remember picture,overlay]
%\draw[blue,thick,->] (d1) to [in=90,out=245] + (198:2.5cm) node[anchor=north,text = black] {const.};
%\end{tikzpicture}

\end{document}

enter image description here

答案1

只保留tikz真正需要的部分tikz。不要管方程式,只需将一个明智的点粘贴tikzmark到您想要指向的位置,然后将箭头和文本放在单独的图片中(如您所见)。

\documentclass{book}
%\url{http://tex.stackexchange.com/q/297831/86}
\usepackage{amsmath,amsfonts,amssymb,amsthm}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc,,arrows,shapes,decorations.pathreplacing}
\tikzset{every picture/.style={remember picture}}

\begin{document}

\begin{align*}
  D(\lambda,x) = & ~ f(x) + \lambda'g(x) \quad \lambda\geqslant 0\\
\intertext{the dual is given as:}
\lambda^{*} = & ~ \arg\{ \max_{\lambda}D(\lambda,x^{*}\tikzmark{a}) \}\\
            = & ~ \arg\{ \max_{\lambda}D(\lambda) \}
\end{align*}

\begin{tikzpicture}[remember picture,overlay]
\draw[blue,thick,<-] (pic cs:a) to [in=90,out=-45] + (-18:2.5cm) node[anchor=north,text = black] {const.};
\end{tikzpicture}
\end{document}

我把\tikzmark 因为x^{*}将标签放在等式的右边似乎更好。

pointing to a term in an equation

相关内容