![为什么我无法在 tikz-feynman 中输入等号数学符号“=”?](https://linux22.com/image/474154/%E4%B8%BA%E4%BB%80%E4%B9%88%E6%88%91%E6%97%A0%E6%B3%95%E5%9C%A8%20tikz-feynman%20%E4%B8%AD%E8%BE%93%E5%85%A5%E7%AD%89%E5%8F%B7%E6%95%B0%E5%AD%A6%E7%AC%A6%E5%8F%B7%E2%80%9C%3D%E2%80%9D%EF%BC%9F.png)
我输入 $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}