GithubHelp home page GithubHelp logo

transientlunatic / tikz-feyn Goto Github PK

View Code? Open in Web Editor NEW
17.0 5.0 0.0 50 KB

A LaTeX package to draw Feynman diagrams using TikZ

License: BSD 3-Clause "New" or "Revised" License

TeX 100.00%
feynman-diagrams tikz latex latex-package

tikz-feyn's Introduction

Tikz-feyn

Tikz-feyn is a LaTeX package which generates Feynman diagrams using the PGF/TikZ package.

Feature requests, bugs, feedback, and comments are always welcome!

The documentation for this package is very very lacking at the moment, and it's something I'll improve. I promise. When I find the time.

I originally created this package to make typing notes for a quantum field theory class easier (read I was procrastinating), but now it's there for the whole world to use,

Requirements

You'll need the tikz, xparse, and ifthen packages for LaTeX, all of which are available in texlive.

Usage

Tikz-feyn can be loaded by

\usepackage{tikz-feyn}

A Feynman diagram can be constructed in one of two environments:

  • tfeyn produces display-style-like diagrams, which are suitable for being used in part of a diagram, for example example1
  • tfeynin produces inline Feynman diagrams which can be inserted into text, or into an equation, for example example2

In the current implementation of Tikz-feyn each Feynman diagram is composed of a number of columns. For example, example1

contains four columns. We construct a column using the \tfcol macro:

\tfcol(0,0){a, b, ..., z}[<vertical space>]

This creates a column of vertices, each equally-spaced, with the names, a, b, through to z. The bottom of the column will be aligned to the coordinates in the first, optional, argument.

To join vertices with edges use the \tf macro, for example

\tf[f]{a1,a2}

joins vertices a1 annd a2 with a fermion. The full set of arguments fot \tf is

\tf[<particle>]{<vertices>}[<inner direction>]

If you include a new vertex inside the list of vertices it will be created between the first and last vertices in the list, and its positioning can be dictated by the third argument as either u (up), d (down), l (left), or r (right). So a more complex example,

\tf[f]{a1,c1,a2}[r]

joins a1 to a2 with a fermion, but it creates a vertex called c1 in a column to the right of them, and vertically half-way between them.

To see all of this in action, let's have a full example of a diagram:

\begin{tfeyn}
	\tfcol{a1, a2}
	\tfcol{b1, b2}
	\tf[f]{a1,c1,a2}[r]
	\tf[f]{b1,c3,b2}[l]
	\tf[p]{c1, c3}
\end{tfeyn}

So we set up two sets of vertices, a1 and a2, and b1, and b2. Next we connect a1 to a2 with a fermion, and we make a node, c1 half way along that edge, to the right of the a column, and we do something similar on the b column, but to the left. We can now connect c1 and c2 with a photon (p), and we have the completed diagram:

example2

It's possible to do all sorts of other fancy stuff, thanks to the underlying TikZ package.

Arcs and loops can be created within diagrams by adding the l style to a \tf macro:

\tf[p,l]{v4,v6}

and if necessary, it can be customised by adding a looseness key:

\tf[p,l, looseness=1]{i,o}

which adjusts the circularity of the arc. For an extreme example, take a diagram composed only loops and arcs:

\begin{tfeyn}
  \tfcol{i}[1cm]
  \tfcol{o}
  \tf[p,l, looseness=1]{i,o}
  \tf[p,l, looseness=1]{o,i}
  \tf[f,l]{i,o}
  \tf[f,l]{o,i}
\end{tfeyn}

which produces the output

example2

Any TikZ style can be applied to any vertex, so to make a red photon just write

\tf[p,red] {i,o}

for example.

Lit of Supplied Edges

Each particle in a Feynman diagram is represented as an edge, and in Tikz-feyn, each particle is created by styling an edge. The following styles are available:

Particle Style name(s) Example Image
Photon p, photon \tf[p]{i,o}
W Boson w, wboson \tf[w]{i,o}
Z Boson z, zboson \tf[z]{i,o}
Higgs Boson h, higgs \tf[h]{i,o}
Gluon g, gluon \tf[g]{i,o}
Graviton G, graviton \tf[G]{i,o}
Fermion f, fermion \tf[f]{i,o}

It should be fairly easy to implement your own style if you want to add some esoteric particle I don't know about!

tikz-feyn's People

Contributors

transientlunatic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.