带解释框的方程

带解释框的方程

我尝试这样的事情

在此处输入图片描述

我想采用以下解决方案:投影机中的解释气泡

并使用下面 Ethan 的回答我成功做到了这一点(见下图):

\documentclass[11pt, a4paper, parskip=half]{scrartcl}
\usepackage{tikz} 
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\usepackage{amsmath, amsfonts, amssymb}
\usetikzlibrary{calc,shapes.callouts}
\usetikzlibrary{arrows,shapes,trees,positioning}  

\begin{document}

\newcommand{\marker}[1]{\tikz[baseline,remember picture] \coordinate (#1) {};}
\tikzset{mycalloutstyle/.style={
       rectangle callout, rounded corners,align=center,text
       width=1.5cm, callout absolute pointer = {#1}}}

\[ \left( {\color{blue}\marker{a}\sqrt{x-12}}+{\color{red}\marker{b}\sqrt{x}} \right)^{2} = \]% };
\begin{tikzpicture}[remember picture,overlay]
\draw (b) ++ (-1,-1) node[mycalloutstyle={(b)++(0.4,-.1)},fill=cyan!20]{$\phantom{({\color{blue}A}+{\color{red}B})^2}$};
\draw (a) ++ (0.7,-1) node[mycalloutstyle={(a)++(.5,-.1)},fill=cyan!20,text width=2cm]{$\hspace{0.0cm}({\color{blue}A}+{\color{red}B})^2$};
\end{tikzpicture}

\end{document}

在此处输入图片描述

如果有更优雅的解决方案,我愿意接受改进。

答案1

我认为要自动显示两个指针,必须定义一种新的标注(并为该标注定义两个输入坐标)。通过一些手动对齐,并移除标注周围的边框,可以将两个标注重叠,使其看起来像一个:

\documentclass{article}
\usepackage{tikz} 
\usetikzlibrary{shapes.callouts}

\tikzset{mycalloutstyle/.style={
       rectangle callout, rounded corners,align=center,text
       width=1cm,fill=cyan!20, callout absolute pointer = {#1}
    }
}


\begin{document}
\begin{tikzpicture}
\draw (0,0)  node (myequation) {$\color{blue}(\sqrt{x-12}+1)^2$};
\draw (myequation.north) ++ (-0.5,1)node[mycalloutstyle={(myequation.north)++(-10pt,0)}]{A};
\draw (myequation.north) ++ (0.5,1)node[mycalloutstyle={(myequation.north)++(20pt,0)}]{B};
\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

align*使用环境和\psDefBoxNodes: 命令获取解释框的方法如下pst-node

\documentclass[svgnames]{article}
\usepackage{amsmath}
\usepackage{pst-node}

\begin{document}

\psset{fillstyle=solid, fillcolor=PowderBlue, linecolor=PowderBlue, framearc = 0.4,linejoin=1,linewidth=0.4pt}
\begin{align*}
\psframebox{(\psDefBoxNodes{A}{A}+ \psDefBoxNodes{B}{B})^2} & =\psframebox{\vphantom{(} \psDefBoxNodes{Asq}{A ^2}} + \\[1ex]
\bigl(\psDefBoxNodes{lroot}{\sqrt{x + 4}}+ \psDefBoxNodes{one}{1\strut}\bigr)^2 & =\bigl(\psDefBoxNodes{rroot}{\sqrt{x + 4}\strut}\bigr)^2
\psline(A:bl)(lroot:tC)(A:br)\psline(B:bl)(one:tC)(B:br)
\psline(Asq:bl)(rroot:tC)(Asq:br)
\end{align*}

\end{document} 

在此处输入图片描述

相关内容