带有文本的圆形箭头有效,但带有公式的圆形箭头失败!

带有文本的圆形箭头有效,但带有公式的圆形箭头失败!

我使用了代码http://www.texample.net/tikz/examples/circular-arrows-text/并对其进行了一点修改。下面的文本是HI,它工作正常。当我更改HI为时$\pi$,排版没有完成。有什么建议吗?

平均能量损失

\documentclass[tikz,border=10pt]{standalone}
\usepackage{amssymb} 
\usetikzlibrary{decorations.text} 
\newcommand*{\mytextstyle}{\Large\bfseries\color{black!85}} 
\newcommand{\arcarrow}[8]{% 
% inner radius, middle radius, outer radius, start angle, 
% end angle, tip protusion angle, options, text   
\pgfmathsetmacro{\rin}{#1}
\pgfmathsetmacro{\rmid}{#2}   
\pgfmathsetmacro{\rout}{#3}
\pgfmathsetmacro{\astart}{#4}   
\pgfmathsetmacro{\aend}{#5}
\pgfmathsetmacro{\atip}{#6}   
\fill[#7] (\astart:\rin) arc (\astart:\aend:\rin)
       -- (\aend+\atip:\rmid) 
       -- (\aend:\rout) arc (\aend:\astart:\rout)
       -- (\astart+\atip:\rmid) -- cycle;
\path[decoration = {text along path, text = {|\mytextstyle|#8},
    text align = {align = center}, raise = -0.5ex}, decorate]
    (\astart+\atip:\rmid) arc (\astart+\atip:\aend+\atip:\rmid); 
}

\begin{document}

\begin{tikzpicture}   \fill[even odd rule,red!30] circle (3.8) circle (3.2);
    \arcarrow{3}{3.5}{4}{-30}{30}{5}{red,   draw = red!50!black, very thick}{HI} 
\end{tikzpicture} 
\end{document}

答案1

只需将文本括在另外一组括号 ( {}) 中即可:

\documentclass[tikz,border=10pt]{standalone}
\usepackage{amssymb} 
\usetikzlibrary{decorations.text} 
\newcommand*{\mytextstyle}{\Large\bfseries\color{black!85}} 
\newcommand{\arcarrow}[8]{% 
% inner radius, middle radius, outer radius, start angle, 
% end angle, tip protusion angle, options, text   
\pgfmathsetmacro{\rin}{#1}
\pgfmathsetmacro{\rmid}{#2}   
\pgfmathsetmacro{\rout}{#3}
\pgfmathsetmacro{\astart}{#4}   
\pgfmathsetmacro{\aend}{#5}
\pgfmathsetmacro{\atip}{#6}   
\fill[#7] (\astart:\rin) arc (\astart:\aend:\rin)
       -- (\aend+\atip:\rmid) 
       -- (\aend:\rout) arc (\aend:\astart:\rout)
       -- (\astart+\atip:\rmid) -- cycle;
\path[decoration = {text along path, text = {|\mytextstyle|#8},
    text align = {align = center}, raise = -0.5ex}, decorate]
    (\astart+\atip:\rmid) arc (\astart+\atip:\aend+\atip:\rmid); 
}

\begin{document}

\begin{tikzpicture}   \fill[even odd rule,red!30] circle (3.8) circle (3.2);
    \arcarrow{3}{3.5}{4}{-30}{30}{5}{red,   draw = red!50!black, very thick}{{$\pi$}}
%                                    another set of braces                   ^     ^
\end{tikzpicture} 
\end{document}

在此处输入图片描述

相关内容