3

Consider the following code:

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-feynman}

\begin{document}
$$\begin{tikzpicture}[scale=0.5, baseline=(current  bounding  box.center)]
     \begin{feynman}
    \vertex (x);
    \vertex[right=of x] (y);
    \vertex[above left=of x] (a);
    \vertex[below left=of x] (b);
    \vertex[above right=of y] (c);
    \vertex[below right=of y] (d);
    \diagram*{
        (x) --[fermion, half left] (y),
        (x) --[anti fermion, half right] (y),
        (a) --[charged scalar] (x),
        (x) --[charged scalar] (b),
        (y) --[anti fermion] (c),
        (y) --[fermion] (d),
    };
    \end{feynman}
    \end{tikzpicture}$$
\end{document}

Although I put scale=0.5 option in the tikzpicture environment, it seems that the scaling does not work. How can I fix this problem?

3

The key scale will act only on coordinates, not the size of nodes. If you use scale=0.5, transform shape also the nodes will be scaled. If you want to apply it to every picture, you can use

\tikzset{every picture/.style={
    scale=0.5, transform shape,
    }}

Notice however that the arrows and linewidths are not scaled with the picture (they go with the linewidth); the solution to this is not simple.

If you want a seamless scaling, the best option is perhaps to use \scalebox.

\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-feynman}

\newcommand{\diagram}{%
\begin{tikzpicture}[baseline=(current  bounding  box.center)]
     \begin{feynman}
    \vertex (x);
    \vertex[right=of x] (y);
    \vertex[above left=of x] (a);
    \vertex[below left=of x] (b);
    \vertex[above right=of y] (c);
    \vertex[below right=of y] (d);
    \diagram*{
        (x) --[fermion, half left] (y),
        (x) --[anti fermion, half right] (y),
        (a) --[charged scalar] (x),
        (x) --[charged scalar] (b),
        (y) --[anti fermion] (c),
        (y) --[fermion] (d),
    };
    \end{feynman}
    \end{tikzpicture}%
}

\begin{document}

Normal:

\[ \diagram \]

\begingroup %this will make the changes to every picture local
    \tikzset{every picture/.style={
        ,scale=0.5, transform shape
    }}
    Scale and transform shape:
    \[\diagram\]
\endgroup

Using \texttt{scalebox}:
\[\scalebox{0.5}{\diagram}\]

\end{document}

enter image description here

Please notice however the following warning:

Package tikz-feynman Warning: Consider loading TikZ-Feynman with \usepackage[co
mpat=1.1.0]{tikz-feynman} so that you can be warned if TikZ-Feynman changes. on
 input line 26.
| improve this answer | |

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.