vertex arithmetic with tikz-feynman

In this MWE (minimal working example)

\RequirePackage{luatex85}
\documentclass{article}
\thispagestyle{empty}
\usepackage{tikz}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
\begin{tikzpicture}
\begin{feynman}
\vertex (it) at (0, 0);
\vertex (ib) at ($(it) + (1.1, 1.1)$);
\diagram*
{
(it) -- [photon] (ib),
(1, 2) -- [fermion] (ib),
};
\draw[->] (1, 2) -- (ib);
\end{feynman}
\end{tikzpicture}
\end{document}


At lines

\vertex (ib) at ($(it) + (1.1, 1.1)$);
\draw[->] (1, 2) -- (ib);


one can see the flexibility of tikz in defining coordinates. However, the on-the-fly coordinate (1,2) at line

(1, 2) -- [fermion] (ib),


is not accepted.

Nevertheless, it is highly desirable to define coordinates and perform coordinate arithmetic inside the scope of \diagram.

Any suggestions?

The \diagram (and \diagram*) commands from TikZ-Feynman (CTAN) use the graphdrawing library from TikZ which use algorithms in order determine the placement of nodes. These algorithm cannot handle pure coordinates so unfortunately, it will never be possible to have

\diagram* {
(1, 2) -- (i1),
};


Nailing Vertices

It is possible to give a hint to the algorithm as to the final placement of the vertex with desired at=<coordinate>; however, some algorithms do not support this and will disregard the hint entirely.

To be more forceful, it is possible to use the nail at=<coordinate> which not only gives the hint to the algorithm, but then disregards the coordinate calculated by the underlying algorithm and overrides it with the specified coordinate. As this is quite a brute-force method, it may lead to some surprising results.

Here's an example of the keys in action which specify everything completely in order to create a slight slant for the boson line:

\RequirePackage{luatex85}
\documentclass[tikz, border=10pt]{standalone}

\usepackage[compat=1.1.0]{tikz-feynman}

\begin{document}
\begin{tikzpicture}
\begin{feynman}
\diagram {
i1 [nail at={(-2, 1)}]
-- [fermion] a
-- [fermion] i2 [nail at={(-2, -1)}],
a [nail at={(-1, 0.2)}] -- [boson] b [nail at={(1, -0.2)}],
f1 [nail at={(2, 1)}]
-- [fermion] b
-- [fermion] f2 [nail at={(2, -1)}],
};
\end{feynman}
\end{tikzpicture}
\end{document}


Note that since coordinates have a comma ,, it is necessary to surround the coordinate in braces {} otherwise TikZ will understand that comma as denoting the start of the next option.

As you can see, this can quickly become quite messy with all the extra coordinate, and I don't think this provides much of an improvement over using the \vertex command beforehand.

Nudging Vertices

If what you are really interested in is providing little tweaks to certain vertices, then these can be specified with the nudge family of commands (see §27.6 of the PGF/TikZ Manual). This still uses the coordinate automatically calculated by the algorithm, but then nudges the coordinate slightly before drawing everything.

An example of the nudge in action to create a similar diagram as above:

\RequirePackage{luatex85}
\documentclass[tikz, border=10pt]{standalone}

\usepackage[compat=1.1.0]{tikz-feynman}

\begin{document}
\feynmandiagram [horizontal=a to b] {
i1 -- [fermion] a -- [fermion] i2,
a [nudge up=0.2cm] -- [boson] b [nudge down=0.2cm],
f1 -- [fermion] b -- [fermion] f2,
};
\end{document}