1

enter image description hereAs you can see in the immage I attached, the code produces the diagram correctly, yet not where I'd like it to be, i.e. below the first line of text (the second line was just a test)

\documentclass[lualatex]{beamer}

\usepackage{graphicx}
\usepackage{tikz-feynman}

\begin{frame}

  \frametitle{Involved Feynman diagrams}

  At LO in $\alpha$ there is only one diagram: 
  
  \begin{figure}[!h]
    \begin{tikzpicture}
      \feynmandiagram[horizontal=a to b]{
        i1 [particle=\(e^{-}\)] -- [fermion] a -- [fermion] i2  [particle=\(e^{+}\)],
        a -- [photon] b,
        f1 [particle=\(\mu^{-}\)] -- [fermion] b -- [fermion] f2  [particle=\(\mu^{+}\)],      
      };
    \end{tikzpicture}
  \end{figure}

  prova
    
\end{frame}

Any help would be much appreciated. Thank you.

Edit: possibly useful information, compiling with lualatex

3
  • Welcome to TeX.SX! Remove \begin{figure} and \end{figure}
    – gernot
    Jan 27, 2021 at 14:18
  • Thank you for the answer! Originally, I didn't enclose it in a figure environment, and I had the exact same problem. That's why I tried with figure.
    – skip2skp
    Jan 27, 2021 at 14:23
  • 1
    Also remove \begin{tikzpicture}...\end{tikzpicture}. \feynmandiagram is already a tikzpicture
    – gernot
    Jan 27, 2021 at 14:29

1 Answer 1

1

Remove the tikzpicture environment. The command feynmandiagram already includes tikzpicture. From the docs:

Feynman diagrams can be declared with the \feynmandiagram command. It is analogous to the \tikz command from TikZ and requires a final semi-colon (;) to finish the environment.

enter image description here

\documentclass{beamer}
\usepackage{tikz-feynman}
\begin{document}

\begin{frame}

  \frametitle{Involved Feynman diagrams}

  At LO in $\alpha$ there is only one diagram: 
  \begin{center}
      \feynmandiagram[horizontal=a to b]{
        i1 [particle=\(e^{-}\)] -- [fermion] a -- [fermion] i2  [particle=\(e^{+}\)],
        a -- [photon] b,
        f1 [particle=\(\mu^{-}\)] -- [fermion] b -- [fermion] f2  [particle=\(\mu^{+}\)],      
      };
  \end{center}
  prova
    
\end{frame}
\end{document}
5
  • Yup, this solved it. Thank you very much.
    – skip2skp
    Jan 27, 2021 at 14:34
  • figure environment doesn't harm and is not cause of OP problem, it only has similar effect as center environment -- center the Feynman diagram ( +1 )
    – Zarko
    Jan 27, 2021 at 14:36
  • @Zarko Sure, but why introduce a float and tie it to the spot? In presentations, captions also don't make much sense, since everyone can see that it's a figure, and numbering figures and referencing them later doesn't make much sense in a presentation (the audience neither remembers the figure nor can skip back).
    – gernot
    Jan 27, 2021 at 14:38
  • figure in beamer not float. It is always where is inserted, so use of its positioning option, for example [!h] as OP do, is nosens. It for sure not cause OP problems but nesting of tikzpictures, as you clearly stated.
    – Zarko
    Jan 27, 2021 at 14:45
  • @Zarko Thanks for the explanation, never used figure in beamer, but it makes sense ...
    – gernot
    Jan 27, 2021 at 15:19

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.