JP-Ellis / tikz-feynman

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

baseline issues #13

Closed npapapietro closed 8 years ago

npapapietro commented 8 years ago

I'm likely doing this incorrectly as I am still becoming ever more versed in latex so bear with me if this is a silly question.

I'm trying to make a simple loop graph equal to some equation. My code is

\begin{equation}
  \feynmandiagram [baseline=(c), horizontal=b to c] {
    a [particle=\(\phi\)] -- [scalar] b 
      -- [fermion, half left, looseness=1.5, edge label=\(\bar{\psi}\)]  c
      -- [fermion, half left, looseness=1.5, edge label=\(\psi\)]  b,
    c -- [scalar] d [particle=\(\phi\)],
  };
  = \Delta m^2
\end{equation}

I can use layered layout but the = is not inline with the scalar horizontal. If I use the above I get an out put inline but the scalar lines are angled off the horizontal (looks like /O/).

JP-Ellis commented 8 years ago

Hi, and thanks for taking an interest in TikZ-Feynman!

The default algorithm tries its best to figure out how to place everything, but as you can see it doesn't always work perfectly. The initial output generated is:

As you correctly found out, you can fix this by using the layered layout key which now produces the following output:

\begin{equation*}
  \feynmandiagram [baseline=(c), layered layout, horizontal=b to c] {
  ...
\end{equation*}

This is a definite improvement, but the \phi doesn't line up correctly with the equal sign. This can be resolved by moving the baseline of the diagram. At the stage, the diagram uses vertex (c) and you can see that the vertex lines up with the bottom of the m. If we use the baseline of the \phi with (d.base) then we get everything looking much better:

\begin{equation*}
  \feynmandiagram [baseline=(d.base), layered layout, horizontal=b to c] {
  ...
\end{equation*}

Finally, you might want to have the diagram be a bit smaller so that it doesn't take up so much space within the equations. This can be achieved by specifying the small key, or equivalently, using the inline key instead of baseline (you should notice that text remains the same size):

\begin{equation*}
  \feynmandiagram [inline=(d.base), layered layout, horizontal=b to c] {
  ...
\end{equation*}