在 tikz-feynman 中正确对齐不同长度的顶点标签(用括号装饰)

在 tikz-feynman 中正确对齐不同长度的顶点标签(用括号装饰)

在以下(不完整的)费曼图中,

\documentclass{minimal}

\usepackage{tikz-feynman}

\begin{document}

  \begin{tikzpicture}
    \begin{feynman}
      \vertex (i1) {$b$};
      \vertex [right=of i1] (m1) ;
      \vertex [right=of m1] (o1) {$c$};
      \vertex [below=2em of i1] (i2) {$\bar u, \bar d$};
      \vertex [right=of i2] (m2) ;
      \vertex [right=of m2] (o2) {$\bar u, \bar d$};

      \diagram* {
        (i1) -- [fermion] (m1),
        (m1) -- [fermion] (o1),
        (o2) -- [fermion] (m2),
        (m2) -- [fermion] (i2)
      };
      
      % annotations
      \draw [decoration={brace}, decorate] (i2.south west) -- (i1.north west)
        node [pos=0.5, left] {$B^-, \bar B^{0}$};
    \end{feynman}
  \end{tikzpicture}

\end{document}

支架呈一定角度绘制

在此处输入图片描述

因为标签的长度不同。有没有简单的方法可以解决这个问题?

答案1

利用(i2.west |- i1.north)支架顶边的正交坐标:

\documentclass[border=3.141592]{standalone}
\usepackage{tikz-feynman}

\begin{document}
    \begin{tikzpicture}
\begin{feynman}
  \vertex (i1) {$b$};
  \vertex [right=of i1] (m1) ;
  \vertex [right=of m1] (o1) {$c$};
  \vertex [below=2em of i1] (i2) {$\bar{u}, \bar d$};
  \vertex [right=of i2] (m2) ;
  \vertex [right=of m2] (o2) {$\bar{u}, \bar{d}$};

  \diagram* {
    (i1) -- [fermion] (m1),
    (m1) -- [fermion] (o1),
    (o2) -- [fermion] (m2),
    (m2) -- [fermion] (i2)
            };
% annotations
  \draw [decoration={brace}, decorate] 
    (i2.south west) -- node [left] {$B^-, \bar{B}^{0}$} (i2.west |- i1.north);
\end{feynman}
  \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

只需将幻影放在\hphantom{,\bar d}上面,\vertex (i1)问题就解决了。费米子的长度也相同。

\documentclass[12pt]{article}
\usepackage{tikz-feynman}
\begin{document}
  \begin{tikzpicture}
    \begin{feynman}
      \vertex (i1) {$b\hphantom{,\bar d}$};
      \vertex [right=of i1] (m1) ;
      \vertex [right=of m1] (o1) {$c$};
      \vertex [below=2em of i1] (i2) {$\bar u, \bar d$};
      \vertex [right=of i2] (m2) ;
      \vertex [right=of m2] (o2) {$\bar u, \bar d$};

      \diagram* {
        (i1) -- [fermion] (m1),
        (m1) -- [fermion] (o1),
        (o2) -- [fermion] (m2),
        (m2) -- [fermion] (i2)
      };
      % annotations
      \draw [decoration={brace}, decorate] (i2.south west) -- (i1.north west)
        node [pos=0.5, left] {$B^{-}, \bar B^{0}$};
    \end{feynman}
  \end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容