1

I'm trying to typeset an equation in which there are a lot of Feynman diagrams, which I draw with tikz-feynman, as in the example I pasted below. When I compile, it halts at the first tikzpicture, with the following error:

Runaway argument?
 &= \begin {tikzpicture}[scale=0.64,baseline=(o)] \begin {feynman}[in\ETC.
! Paragraph ended before \align* was complete.
<to be read again> 
\par 
l.17 

I tried with pdflatex and lualatex, with no differences between the two. If instead of the align* environment I use an equation* and aligned combination, it works without any problem. However I'd like to use align* since the equation is very long (I shortened it as much as possible in the MWE below) and this way I'm able to break the equation in different pages with \allowdisplaybreaks.

I also tried using simple tikzpictures such as just some circles, without anything from tikz-feynman, and it doesn't throw any error.

Where does the problem lie? Can I draw Feynman diagrams inside an align environment, and how?

\documentclass[10pt,b5paper]{article}

\usepackage{mathtools}
\usepackage{tikz-feynman}

\begin{document}
\begin{align*}
    &=
    \begin{tikzpicture}[scale=0.64,baseline=(o)]
        \begin{feynman}[inline=(o)]
            \path (-1,0) -- (3,2);
            \vertex [empty dot, minimum size=0mm] (o) at (1,1) {};
            \vertex [dot, label=180:$x$]   (x)  at (0,0) {};
            \vertex [dot, label=0:$x'$]    (y)  at (2,0) {};
            \vertex [dot, label=180:$x_1$] (x1) at (0,2) {};
            \vertex [dot, label=0:$x_2$]   (x2) at (2,2) {};

            \diagram*{
                (x1) -- [fermion, half left, out=25, in=155] (x2)
                -- [fermion, half left, out=25, in=155] (x1),
                (x1) -- [photon] (x2),
            };
            \draw (x) arc [start angle=180, end angle=-180, radius=3.5mm];
            \draw (y) arc [start angle=0, end angle=360, radius=3.5mm];
        \end{feynman}
    \end{tikzpicture}
    -
    \begin{tikzpicture}[scale=0.64,baseline=(o)]
        \begin{feynman}[inline=(o)]
            \path (-1,0) -- (3,2);
            \vertex [empty dot, minimum size=0mm] (o) at (1,1) {};
            \vertex [dot]   (x)  at (0,0) {};
            \vertex [dot]    (y)  at (2,0) {};
            \vertex [dot] (x1) at (0,2) {};
            \vertex [dot]   (x2) at (2,2) {};

            \diagram*{
                (x1) -- [fermion, half left, out=25, in=155] (x2)
                -- (o)
                -- [fermion] (x)
                -- [fermion] (y)
                -- (o)
                -- [fermion] (x1),
                (x1) -- [photon] (x2),
            };
            \draw [-, line width=2mm, white] (o)++(-2mm,-2mm) -- ++(4mm,4mm);
            \draw [-, black] (o)++(-2mm,-2mm) -- ++(4mm,4mm);

        \end{feynman}
    \end{tikzpicture}
    +\\[2mm] &
    -
    \begin{tikzpicture}[scale=0.64,baseline=(o)]
        \begin{feynman}[inline=(o)]
            \path (-1,0) -- (3,2);
            \vertex [empty dot, minimum size=0mm] (o) at (1,1) {};
            \vertex [dot]   (x)  at (0,0) {};
            \vertex [dot]    (y)  at (2,0) {};
            \vertex [dot] (x1) at (0,2) {};
            \vertex [dot]   (x2) at (2,2) {};

            \diagram*{
                (x1) -- [fermion, half left, out=25, in=155] (x2)
                -- [fermion] (y)
                -- [fermion] (x)
                -- [fermion] (x1),
                (x1) -- [photon] (x2),
            };
        \end{feynman}
    \end{tikzpicture}
    -
    \begin{tikzpicture}[scale=0.64,baseline=(o)]
        \begin{feynman}[inline=(o)]
            \path (-1,0) -- (3,2);
            \vertex [empty dot, minimum size=0mm] (o) at (1,1) {};
            \vertex [dot]   (x)  at (0,0) {};
            \vertex [dot]    (y)  at (2,0) {};
            \vertex [dot] (x1) at (0,2) {};
            \vertex [dot]   (x2) at (2,2) {};

            \diagram*{
                (x) -- [fermion, half left, out=25, in=155] (y)
                -- [fermion, half left, out=25, in=155] (x),
                (x1) -- [photon] (x2),
            };
            \draw (x1) arc [start angle=0, end angle=360, radius=3.5mm];
            \draw (x2) arc [start angle=180, end angle=-180, radius=3.5mm];
        \end{feynman}
    \end{tikzpicture}
\end{align*}
\end{document}
  • Don't you have a blank line somewhere? – Bernard Jan 6 '18 at 21:19
  • I do. I never thought they were a problem. I'll try removing them. – yellowquark Jan 6 '18 at 21:26
  • I don't think it's a problem if it's inside a tikzpicture environment, but there may be one if it's in mathematical part of your code. – Bernard Jan 6 '18 at 21:31
  • @Bernard Seems it is a problem also inside a tikzpicture, after removing them the code works fine. – Torbjørn T. Jan 6 '18 at 21:32
  • @Bernard That's what I was thinking either, and I was careful not to leave any... but it appears that blank lines inside tikzpictures are bad, too! I removed them and now it works. Thanks a lot! – yellowquark Jan 6 '18 at 21:33
2

After the O.P. and @Torbjørn T. experimented, it appears the tikzpicture environment is not blank lines-friendly when it is nested in equations.

Equations, whether multiline or not, don't like blank lines, don't like blank lines, and they don't like them even if they're nested in a tikzpicture.

However, if you use blank lines an aligned environment nested in equation(*), it will compile smoothly.

  • I don't think it's a problem with tikzpicture itself, since I always used blank lines in this environment and I never had a problem (switching from align to equation + aligned "solves" the problem, in fact), but with the align environment. Apparently there cannot be a blank line anywhere inside it, not even in nested environments. – yellowquark Jan 6 '18 at 21:47
  • OK, I'll modify my answer, as it may be useful to others. – Bernard Jan 6 '18 at 21:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.