为什么我无法在 tikz-feynman 中输入等号数学符号“=”?

为什么我无法在 tikz-feynman 中输入等号数学符号“=”?

我输入 $p+p'=q+q'$ 作为动量的标签,然后 TeX 返回以下错误

Missing $ inserted.
<inserted text> 
$

Missing } inserted.
<inserted text> 
}

Extra }, or forgotten $.
\pgfdecoratedinputsegmentlinetocode ...tyle ] {$q}

Package tikz: Giving up on this path. Did you forget a semicolon?.

错误

我猜测可能是tikz-feynman程序包扫描了=“动量”之类的单词后面的符号,并且=在数学模式下错误识别了该符号,但我不知道如何修复它。

\documentclass{standalone}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
\feynmandiagram [large, vertical=b to d]
{
    a [particle=$\mu^+$] -- [fermion, reversed momentum=$k'$] b -- [anti fermion, momentum=$k$] c [particle=$\mu^-$],
    b -- [photon, reversed momentum=$q=p+p'=k+k'$] d,
    e [particle=$e^+$] -- [anti fermion, momentum'=$p'$] d -- [anti fermion, reversed momentum'=$p$] f [particle=$e^-$];
};
\end{document}

答案1

为了避免混淆 TikZ 的键值处理,您可以将整个标签包装在{...}

% !TeX TS-program = lualatex
\documentclass{standalone}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
\feynmandiagram [large, vertical=b to d]
{
    a [particle=$\mu^+$] -- [fermion, reversed momentum=$k'$] b -- [anti fermion, momentum=$k$] c [particle=$\mu^-$],
    b -- [photon, reversed momentum={$q=p+p'=k+k'$}] d,
    e [particle=$e^+$] -- [anti fermion, momentum'=$p'$] d -- [anti fermion, reversed momentum'=$p$] f [particle=$e^-$];
};
\end{document}

在此处输入图片描述

相关内容