2

Consider the following MWE:

 % !TeX program = lualatex
    \documentclass{beamer}
    \usepackage{tikz-feynman}
    \usetheme{metropolis}           
    \title{A minimal example}
    \date{\today}
    \author{Matthias Vogelgesang}
    \institute{Centre for Modern Beamer Themes}
    \begin{document}
      \maketitle
      \section{First Section}
      \begin{frame}{First Frame}
       \begin{figure}[H]
    \begin{tabular}{cc}
        \multicolumn{2}{c}{\tikzfeynmanset{
                every plain={blue},
            }
            \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1,remember picture] {
                a  -- [plain] t1 
                -- [scalar,red] t2 
                --[plain]t3 
                -- [plain]t1,
                t2 -- [plain] p1 ,
                t3 -- [plain] p2,
            };
            \tikz[overlay,remember picture]{\path (t1) --(t2) coordinate[midway] (m1);
                \draw[thick,red] (m1) --(t1);
            }
        }\\
        \multicolumn{2}{c}{(a) $C_{PRR}$}\\[6pt]
        \tikzfeynmanset{
            every plain={blue},
        }
        \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1,remember picture] {
            a  -- [plain] t1 
            -- [scalar,red] t2 
            --[scalar,red]t3 
            -- [plain]t1,
            t2 -- [plain] p1 ,
            t3 -- [plain] p2,
        };
        \tikz[overlay,remember picture]{\path (t1) --(t2) coordinate[midway] (m1);
            \draw[thick,red] (m1) --(t1);
        }
        \tikz[overlay,remember picture]{\path (t2) --(t3) coordinate[midway] (m2);
            \draw[thick,red] (m2) --(t3);
        } &   \tikzfeynmanset{
            every plain={blue},
        }
        \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1,remember picture] {
            a  -- [plain] t1 
            -- [scalar,red] t2 
            --[scalar,red]t3 
            -- [plain]t1,
            t2 -- [plain] p1 ,
            t3 -- [plain] p2,
        };
        \tikz[overlay,remember picture]{\path (t1) --(t2) coordinate[midway] (m1);
            \draw[thick,red] (m1) --(t1);
        }
        \tikz[overlay,remember picture]{\path (t2) --(t3) coordinate[midway] (m2);
            \draw[thick,red] (m2) --(t2);
        } 
        \\
        (b) $ C_{PMR} $ & (c) $ C_{PPR} $ \\[6pt]
        \tikzfeynmanset{
            every plain={blue},
        }
        \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1,remember picture] {
            a  -- [plain] t1 
            -- [scalar,red] t2 
            --[scalar,red]t3 
            -- [scalar,red]t1,
            t2 -- [plain] p1 ,
            t3 -- [plain] p2,
        };
        \tikz[overlay,remember picture]{\path (t1) --(t2) coordinate[midway] (m1);
            \draw[thick,red] (m1) --(t1);
        }
        \tikz[overlay,remember picture]{\path (t2) --(t3) coordinate[midway] (m2);
            \draw[thick,red] (m2) --(t2);
        }
        \tikz[overlay,remember picture]{\path (t3) --(t1) coordinate[midway] (m3);
            \draw[thick,red] (m3) --(t3);
        }
        &       \tikzfeynmanset{
            every plain={blue},
        }
        \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1,remember picture] {
            a  -- [plain] t1 
            -- [scalar,red] t2 
            --[scalar,red]t3 
            -- [scalar,red]t1,
            t2 -- [plain] p1 ,
            t3 -- [plain] p2,
        };
        \tikz[overlay,remember picture]{\path (t1) --(t2) coordinate[midway] (m1);
            \draw[thick,red] (m1) --(t1);
        }
        \tikz[overlay,remember picture]{\path (t2) --(t3) coordinate[midway] (m2);
            \draw[thick,red] (m2) --(t3);
        }
        \tikz[overlay,remember picture]{\path (t3) --(t1) coordinate[midway] (m3);
            \draw[thick,red] (m3) --(t3);
        } \\
        (d) $C_{PPP}$ & (e) $ C_{PMP} $ 
    \end{tabular}
    %   \caption{caption}
\end{figure}
\end{frame}
\end{document}

The above produces the following diagram:

overlay problem

As you can see the overlay are all stacked in the bottom left corner of the slide instead of being applied to each diagram individually. Note that this problem doesn't happen in an article or a book document class.

How to get the overlay to be applied correctly?

  • do you compile two times? – Zarko Jul 1 '18 at 14:20
  • @Zarko Yeah, didn't help. – Subho Jul 1 '18 at 14:21
  • well, i belive that i after second compiling receive correct result. i use xelatex. from short overview of your code i wonder, why you use overlay, remember picture mechanism. – Zarko Jul 1 '18 at 14:23
  • @Zarko To make semi-dotted lines in the feynman diagrams – Subho Jul 1 '18 at 14:24
  • @Zarko I have to use lualatex only as feynman-tikz works correctly using lualatex – Subho Jul 1 '18 at 14:28
2

Your code can be repaired by simply adding

\tikzset{every picture/.append style={remember picture}}

at the beginning of your document. All the remember pictures thus become redundant,

    \documentclass{beamer}
    \usepackage{tikz-feynman}
    \usetheme{metropolis}           
    \title{A minimal example}
    \date{\today}
    \author{Matthias Vogelgesang}
    \institute{Centre for Modern Beamer Themes}
    \tikzset{every picture/.append style={remember picture}}
    \begin{document}
      \maketitle
      \section{First Section}
      \begin{frame}{First Frame}
       \begin{figure}[H]
    \begin{tabular}{cc}
        \multicolumn{2}{c}{\tikzfeynmanset{
                every plain={blue},
            }
            \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1] {
                a  -- [plain] t1 
                -- [scalar,red] t2 
                --[plain]t3 
                -- [plain]t1,
                t2 -- [plain] p1 ,
                t3 -- [plain] p2,
            };
            \tikz[overlay]{\path (t1) --(t2) coordinate[midway] (m1);
                \draw[thick,red] (m1) --(t1);
            }
        }\\
        \multicolumn{2}{c}{(a) $C_{PRR}$}\\[6pt]
        \tikzfeynmanset{
            every plain={blue},
        }
        \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1] {
            a  -- [plain] t1 
            -- [scalar,red] t2 
            --[scalar,red]t3 
            -- [plain]t1,
            t2 -- [plain] p1 ,
            t3 -- [plain] p2,
        };
        \tikz[overlay]{\path (t1) --(t2) coordinate[midway] (m1);
            \draw[thick,red] (m1) --(t1);
        }
        \tikz[overlay]{\path (t2) --(t3) coordinate[midway] (m2);
            \draw[thick,red] (m2) --(t3);
        } &   \tikzfeynmanset{
            every plain={blue},
        }
        \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1] {
            a  -- [plain] t1 
            -- [scalar,red] t2 
            --[scalar,red]t3 
            -- [plain]t1,
            t2 -- [plain] p1 ,
            t3 -- [plain] p2,
        };
        \tikz[overlay]{\path (t1) --(t2) coordinate[midway] (m1);
            \draw[thick,red] (m1) --(t1);
        }
        \tikz[overlay]{\path (t2) --(t3) coordinate[midway] (m2);
            \draw[thick,red] (m2) --(t2);
        } 
        \\
        (b) $ C_{PMR} $ & (c) $ C_{PPR} $ \\[6pt]
        \tikzfeynmanset{
            every plain={blue},
        }
        \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1] {
            a  -- [plain] t1 
            -- [scalar,red] t2 
            --[scalar,red]t3 
            -- [scalar,red]t1,
            t2 -- [plain] p1 ,
            t3 -- [plain] p2,
        };
        \tikz[overlay]{\path (t1) --(t2) coordinate[midway] (m1);
            \draw[thick,red] (m1) --(t1);
        }
        \tikz[overlay]{\path (t2) --(t3) coordinate[midway] (m2);
            \draw[thick,red] (m2) --(t2);
        }
        \tikz[overlay]{\path (t3) --(t1) coordinate[midway] (m3);
            \draw[thick,red] (m3) --(t3);
        }
        &       \tikzfeynmanset{
            every plain={blue},
        }
        \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1] {
            a  -- [plain] t1 
            -- [scalar,red] t2 
            --[scalar,red]t3 
            -- [scalar,red]t1,
            t2 -- [plain] p1 ,
            t3 -- [plain] p2,
        };
        \tikz[overlay]{\path (t1) --(t2) coordinate[midway] (m1);
            \draw[thick,red] (m1) --(t1);
        }
        \tikz[overlay]{\path (t2) --(t3) coordinate[midway] (m2);
            \draw[thick,red] (m2) --(t3);
        }
        \tikz[overlay]{\path (t3) --(t1) coordinate[midway] (m3);
            \draw[thick,red] (m3) --(t3);
        } \\
        (d) $C_{PPP}$ & (e) $ C_{PMP} $ 
    \end{tabular}
    %   \caption{caption}
\end{figure}
\end{frame}
\end{document}

enter image description here

The reason why your code didn't work was that the vertices inside the Feynman diagrams didn't get remembered correctly.

EDIT: Just for completeness: there is an arguably much more straightforward way of producing the same output: just define an "new" style

\tikzset{semidashed straight line/.style={dashed,postaction={decorate,decoration={markings,
         mark=at position 0 with {\coordinate (X0); },
         mark=at position 0.5 with {\draw[thick,solid] (X0) -- (0,0); }}}}}

This way you do not need any overlays. (In your example, you could further simplify that by setting all scalars to this style, like you do repeatedly for the solid lines, but I personally would not do that because you may need a real scalar somewhere.)

    \documentclass{beamer}
    \usepackage{tikz-feynman}
    \usetikzlibrary{decorations.markings}
    \usetheme{metropolis}           
    \title{A minimal example}
    \date{\today}
    \author{Matthias Vogelgesang}
    \institute{Centre for Modern Beamer Themes}
    \tikzset{semidashed straight line/.style={dashed,postaction={decorate,decoration={markings,
     mark=at position 0 with {\coordinate (X0); },
     mark=at position 0.5 with {\draw[thick,solid] (X0) -- (0,0); }}}}}
    \begin{document}
      \maketitle
      \section{First Section}
      \begin{frame}{First Frame}
       \begin{figure}[H]
    \begin{tabular}{cc}
        \multicolumn{2}{c}{\tikzfeynmanset{
                every plain={blue},
            }
            \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1] {
                a  -- [plain] t1 
                -- [semidashed straight line,red] t2 
                --[plain]t3 
                -- [plain]t1,
                t2 -- [plain] p1 ,
                t3 -- [plain] p2,
            };
        }\\
        \multicolumn{2}{c}{(a) $C_{PRR}$}\\[6pt]
        \tikzfeynmanset{
            every plain={blue},
        }
        \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1] {
            a  -- [plain] t1 
            -- [semidashed straight line,red] t2 
            --[semidashed straight line,red]t3 
            -- [plain]t1,
            t2 -- [plain] p1 ,
            t3 -- [plain] p2,
        };
        &   \tikzfeynmanset{
            every plain={blue},
        }
        \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1] {
            a  -- [plain] t1 
            -- [semidashed straight line,red] t2 
            --[semidashed straight line,red]t3 
            -- [plain]t1,
            t2 -- [plain] p1 ,
            t3 -- [plain] p2,
        };
        \\
        (b) $ C_{PMR} $ & (c) $ C_{PPR} $ \\[6pt]
        \tikzfeynmanset{
            every plain={blue},
        }
        \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1] {
            a  -- [plain] t1 
            -- [semidashed straight line,,red] t2 
            -- [semidashed straight line,red]t3 
            -- [semidashed straight line,red]t1,
            t2 -- [plain] p1 ,
            t3 -- [plain] p2,
        };
        &       \tikzfeynmanset{
            every plain={blue},
        }
        \feynmandiagram[scale=.5,transform shape] [small, horizontal=a to t1] {
            a  -- [plain] t1 
            -- [semidashed straight line,red] t2 
            --[semidashed straight line,red]t3 
            -- [semidashed straight line,red]t1,
            t2 -- [plain] p1 ,
            t3 -- [plain] p2,
        };\\
        (d) $C_{PPP}$ & (e) $ C_{PMP} $ 
    \end{tabular}
    %   \caption{caption}
\end{figure}
\end{frame}
\end{document}

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.