使用 tikz 在分数部分周围绘制突出显示的不规则形状

使用 tikz 在分数部分周围绘制突出显示的不规则形状

我希望获得一些帮助以使此输出仅围绕分数的一部分:

在此处输入图片描述

这是我目前所拥有的:

\documentclass{article}
\usepackage{mathtools}% superior to amsmath
\usepackage{tikz}
\usetikzlibrary{tikzmark,shapes.geometric}
\tikzset{every picture/.style={remember picture}}

\begin{document}

\begin{tikzpicture}[overlay,remember picture]
\draw[blue,thick,<-latex] (pic cs:markme) to [in=180,out=45] +(45:1cm) node[anchor=west,text = black,] {Dipole};
\end{tikzpicture}

\begin{equation*}
M(z)=\frac{-0.7768(z-1.3)\tikzmark{markme}\tikz[baseline]{\node[draw=blue,fill=blue!20,anchor=base,
                                            ellipse,inner xsep=-1pt,inner ysep=0pt]
  (d13) {(z-0.9141)}}}{z(z-0.8)(z-0.9)}
\end{equation*}

\end{document}

答案1

像这样吗?

![![在此处输入图片描述

我已将两个节点声明为remembered,然后在其上绘制一条复杂且透明的路径。可以使用 将其绘制在表达式后面background layer

\documentclass{article}
\usepackage{mathtools}% superior to amsmath
\usepackage{tikz}
\usetikzlibrary{tikzmark,shapes.geometric}
\tikzset{every picture/.style={remember picture}}

\begin{document}

\begin{equation*}
M(z)=\frac{-0.7768(z-1.3)\tikz[baseline, remember picture]{\node[anchor=base, inner xsep=-1pt,inner ysep=0pt]
  (d13) {$(z-0.9141)$};}}{z(z-0.8)\tikz[baseline, remember picture]{\node[anchor=base, inner xsep=-1pt, inner ysep=0pt] (d14){$(z-0.9)$};}}
\end{equation*}

\begin{tikzpicture}[overlay]
\draw[opacity=.5, rounded corners, fill=red!40] ([shift={(-1pt,1pt)}]d13.north west)-|([shift={(1pt,-1pt)}]d13.south east)--([shift={(1pt,1pt)}]d14.north east)|-([shift={(-1pt,-1pt)}]d14.south west)|-([shift={(-1pt,-1pt)}]d13.south west)--cycle;
\draw[blue,thick,-latex, shorten <=1pt] (d13.east) to [in=180,out=0] +(45:1cm) node[anchor=west,text = black,] {Dipole};
\end{tikzpicture}
\end{document}

答案2

可以将tikzpicture环境放在环境之前equation,就像 OP 的问题一样,您只需运行pdflatex两次;s 创建的标签将\tikzmark在第二次运行时被识别。

% arara: pdflatex
% arara: pdflatex
\documentclass{article}
\usepackage{mathtools}% superior to amsmath
\usepackage{tikz}
\usetikzlibrary{tikzmark,calc}

\begin{document}
    \begin{tikzpicture}[overlay,remember picture]
        \draw[thick,blue,fill=blue!20,rounded corners] 
            ($(pic cs:mark1)+(0,-3pt)$) -- ($(pic cs:mark1)+(0,10pt)$) -- 
            ($(pic cs:mark2)+(2pt,10pt)$) -- ($(pic cs:mark2)+(2pt,-7pt)$) -- 
            ($(pic cs:mark4)+(2pt,6pt)$) -- ($(pic cs:mark4)+(2pt,-4pt)$) -- 
            ($(pic cs:mark3)+(0,-4pt)$) -- ($(pic cs:mark3)+(0,8pt)$) -- cycle; 
        \draw[blue,thick,-latex] ($(pic cs:mark2)+(2pt,4pt)$) to [in=180,out=15] +(30:1cm) 
            node[anchor=west,text=black] {Dipole};
    \end{tikzpicture}
    \begin{equation*}
        M(z)=\frac{-0.7768(z-1.3)\tikzmark{mark1}(z-0.9141)\tikzmark{mark2}}{z(z-0.8)\tikzmark{mark3}(z-0.9)\tikzmark{mark4}}
    \end{equation*}
\end{document}

在此处输入图片描述

相关内容