JP-Ellis / tikz-feynman

Feynman Diagrams with TikZ
http://www.jpellis.me/projects/tikz-feynman
Other
148 stars 20 forks source link

Manual placement: Labelled vertex spacing #6

Closed kahn-jms closed 8 years ago

kahn-jms commented 8 years ago

The default above/below spacing between labelled vertexes (~0.5cm for 12pt font size) is appended to the distance specified by users. This leads to imprecise distances between vertexes and results in unpredictable vertex placement when font sizes are varied.

Example (note the non-horizontal fermion lines of the neutrinos) :

\begin{feynman}
    \vertex (a1) {\(b\)};
    \vertex[right=1.5cm of a1] (a2);
    \vertex[right=1.5cm of a2] (a3);
    \vertex[right=1.5cm of a3] (a4) {\(s\)};

    \vertex[below=1.5cm of a2] (b1);
    \vertex[below=1.5cm of a3] (b2);
    \vertex[below=1.0cm of a4] (b3) {\(\nu\)};

    \vertex[below=0.75cm of b1] (c1);
    \vertex[below=0.25cm of b3] (c2) {\(\bar{\nu}\)};

    \diagram* {
        {[edges=fermion]
            (a1) -- (a2) -- [edge label=\(t\)] (a3) -- (a4),
        },
        (a2) -- [boson, edge label'=\(W\)] (b1),
        (a3) -- [boson, edge label=\(W\)] (b2),
        (b1) -- [fermion, edge label=\(l^{-}\)] (b2) -- [fermion] (b3),
        (b1) -- [half right, looseness=2.0] (c1) -- [anti fermion] (c2)
    };
\end{feynman}

box_bad-alignment

Workaround

Specifying labelled vertexes relative to unlabelled vertexes. In the example above changing the lines

\vertex[below=1.0cm of a4] (b3) {\(\nu\)};
\vertex[below=0.25cm of b3] (c2) {\(\bar{\nu}\)};

to contain

\vertex[right=1.5cm of b2] (b3) {\(\nu\)};
\vertex[right=3.0cm of c1] (c2) {\(\bar{\nu}\)};

creates precisely horizontal lines.

Proposed Solution

Changing the spacing to be the user specified distance from the centre of the relative vertex when a nonzero distance is set, such that the lines

\vertex[below=1.5cm of a4] (b3) {\(\nu\)};
\vertex[below=0.75cm of b3] (c2) {\(\bar{\nu}\)};

would produce horizontal lines in the aforementioned example. Leaving the current default spacing between labelled vertexes when no distance or 0cm is specified would make sense as a relative distance of 0cm is trivially the same vertex.