Graphics, Figures & Tablestikz-feynman underbrace

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
topsquark
Posts: 71
Joined: Wed Oct 05, 2022 10:30 pm

tikz-feynman underbrace

Post by topsquark »

Does anyone know the tikz-feynman package? I am having a problem doing an underbrace. (See the attachment below.) I want to label the "udd" as an "n," but the brace is pointing upward. I need it to point down and I can't find anything in the tikz-feynman manual that tells me how to do that. I'm including the code so you all can see it but it won't run on the Forum.

Thanks!

-Dan

\usepackage {tikz-feynman}
\begin{tikzpicture}
\begin{feynman}
% Nodes
\vertex (a);
\vertex [right=0.5cm of a] (b);
\vertex [right=0.5cm of b] (c);
\vertex [below left=of a] (uin) {\(u\)};
\vertex [below left=of b] (d1in) {\(d\)};
\vertex [below left=of c] (d2in) {\(d\)};
\draw [decoration={brace},decorate] (uin.south west) -- (d2in.south east) node[pos=0.5,below] {\(n\)};
\vertex [above left=of a] (u1out) {\(u\)};
\vertex [above left=of b] (dout) {\(d\)};
\vertex [above left=of c] (u2out) {\(u\)};
\draw [decoration={brace},decorate] (u1out.north west) -- (u2out.north east) node[pos=0.5,above] {\(p\)};
\vertex at ($(c)+(1.5,0.5cm)$) (d);
\vertex at ($(d)+(1.5,-0.5cm)$) (eout) {\(e^{-}\)};
\vertex [above right=of d] (antineutrinoin) {\(\overline{\nu _e}\)};
% Diagram
\diagram* {
(uin) -- [fermion] (a) -- [fermion] (u1out),
(d1in) -- [fermion] (b) -- [fermion] (dout),
(d2in) -- [fermion] (c) [dot] -- [fermion] (u2out),
(c) -- [boson, edge label'=\(W^{-}\)] (d),
(d) -- [fermion] (eout),
(antineutrinoin) -- [fermion] (d),
};
\end{feynman}
\end{tikzpicture}
Beta Decay.jpg
Beta Decay.jpg (53.04 KiB) Viewed 3965 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

tikz-feynman underbrace

Post by rais »

Hi Dan,
I don't know the package, but a short test revealed you just need to swap the 2 coordinates to get what you want:

Code: Select all

\draw [decoration={brace},decorate] (d2in.south east) -- (uin.south west) node[midway,below=2pt] {\(n\)};
"midway" is just a symbolic name for "pos=0.5", the "2pt" let the n be positioned a bit further away from the brace's tip in this case.
In full:

Code: Select all

\documentclass{article}
\usepackage {tikz-feynman}
\begin{document}
\begin{tikzpicture}
\begin{feynman}
% Nodes
\vertex (a);
\vertex [right=0.5cm of a] (b);
\vertex [right=0.5cm of b] (c);
\vertex [below left=of a] (uin) {\(u\)};
\vertex [below left=of b] (d1in) {\(d\)};
\vertex [below left=of c] (d2in) {\(d\)};
\draw [decoration={brace},decorate] (d2in.south east) -- (uin.south west) node[midway,below=2pt] {\(n\)};
\vertex [above left=of a] (u1out) {\(u\)};
\vertex [above left=of b] (dout) {\(d\)};
\vertex [above left=of c] (u2out) {\(u\)};
\draw [decoration={brace},decorate] (u1out.north west) -- (u2out.north east) node[pos=0.5,above] {\(p\)};
\vertex at ($(c)+(1.5,0.5cm)$) (d);
\vertex at ($(d)+(1.5,-0.5cm)$) (eout) {\(e^{-}\)};
\vertex [above right=of d] (antineutrinoin) {\(\overline{\nu _e}\)};
% Diagram
\diagram* {
(uin) -- [fermion] (a) -- [fermion] (u1out),
(d1in) -- [fermion] (b) -- [fermion] (dout),
(d2in) -- [fermion] (c) [dot] -- [fermion] (u2out),
(c) -- [boson, edge label'=\(W^{-}\)] (d),
(d) -- [fermion] (eout),
(antineutrinoin) -- [fermion] (d),
};
\end{feynman}
\end{tikzpicture}
\end{document}
KR
Rainer
Bartman
Posts: 369
Joined: Fri Jan 03, 2020 2:39 pm

tikz-feynman underbrace

Post by Bartman »

A different approach:

Code: Select all

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

\begin{document}
\begin{tikzpicture}
\begin{feynman}
% Nodes
\vertex (a);
\vertex [right=0.5cm of a] (b);
\vertex [right=0.5cm of b] (c);

% changes the height of the text and straighten the brace
\vertex [below left=of a, text height=height("d")] (uin) {\(u\)};
\vertex [below left=of b] (d1in) {\(d\)};
\vertex [below left=of c] (d2in) {\(d\)};

\draw [decoration={brace,mirror},decorate]% adds the mirror option
  % moves the node between the coordinates
  (uin.south west) -- node[below] {\(n\)} (d2in.south east)
;

\vertex [above left=of a] (u1out) {\(u\)};
\vertex [above left=of b] (dout) {\(d\)};
\vertex [above left=of c] (u2out) {\(u\)};

\draw [decoration={brace},decorate] 
  (u1out.north west) -- node[above] {\(p\)} (u2out.north east)
;

% I removed the unit of measurement to achieve a uniform representation. 
% It just shows another way of doing the same thing and is not intended 
% as a correction to your source code.
\vertex at ($(c)+(1.5,0.5)$) (d);
\vertex at ($(d)+(1.5,-0.5)$) (eout) {\(e^{-}\)};
\vertex [above right=of d] (antineutrinoin) {\(\overline{\nu_e}\)};
% Diagram
\diagram* {
  (uin) -- [fermion] (a) -- [fermion] (u1out),
  (d1in) -- [fermion] (b) -- [fermion] (dout),
  (d2in) -- [fermion] (c) [dot] -- [fermion] (u2out),
  (c) -- [boson, edge label'=\(W^{-}\)] (d),
  (d) -- [fermion] (eout),
  (antineutrinoin) -- [fermion] (d),
};
\end{feynman}
\end{tikzpicture}
\end{document}
topsquark
Posts: 71
Joined: Wed Oct 05, 2022 10:30 pm

tikz-feynman underbrace

Post by topsquark »

I'll have to remember that coordinate trick.

And the text height thing. I was thinking I was simply stuck with that but I was going to experiment later on. I never would have found that solution.

Is there a more comprehensive manual for tikz-feynman than https://mirror.mwt.me/ctan/graphics/pgf ... eynman.pdf?

Thanks to both of you!

-Dan
User avatar
Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

tikz-feynman underbrace

Post by Stefan Kottwitz »

Hi Dan,

that's the latest manual (texdoc: tikz-feynman) of the package developer, so I think there's no better documentation. Btw. there's a related package, called tikz-feynhand.

Stefan
LaTeX.org admin
Post Reply