# Two diagrams side by side

I am trying to put two feynman diagrams side by side, but they get displayed below eachother. I am using feynmf and subfloat. This normally works for pictures.

\begin{figure}[ht!]
\centering
\subfloat{

\begin{fmfgraph*}(40, 25)
\fmfstraight
\fmfbottom{wm,i2,z2}
\fmftop{wp,i1,z1}
\fmf{dashes}{wp,i1,z1}
\fmf{dashes}{z2,i2,wm}
\fmf{dashes,caption=$W^{+}$}{i1,i2}
%  \fmf{dashes,caption=$Z^0$}{i2,z1}
% \fmf{dashes,caption=$Z^0$}{i2,z2}
\fmfv{lab=$Z^0$}{z1}
\fmfv{lab=$Z^0$}{z2}
\fmfv{lab=$W^+$}{wp}
\fmfv{lab=$W^-$}{wm}
\end{fmfgraph*}
}

\subfloat{

\begin{fmfgraph*}(40, 25)
\fmfstraight
\fmfbottom{wm,i2,z2}
\fmftop{wp,i1,z1}
\fmf{dashes}{wp,i1,z1}
\fmf{dashes}{z2,i2,wm}
\fmf{dashes,caption=$W^{+}$}{i1,i2}
%  \fmf{dashes,caption=$Z^0$}{i2,z1}
% \fmf{dashes,caption=$Z^0$}{i2,z2}
\fmfv{lab=$Z^0$}{z1}
\fmfv{lab=$Z^0$}{z2}
\fmfv{lab=$W^+$}{wp}
\fmfv{lab=$W^-$}{wm}
\end{fmfgraph*}
}

\caption{Exchange of W boson}
\end{figure}

-
Don't leave blank lines between the \subfloats –  egreg Jan 25 '12 at 17:34
I'd also recommend you provide a minimal example. A lot is not clear for people who never use fmfgraph*. For example, which packages should they include.... –  Marc van Dongen Jan 25 '12 at 17:50
I didn't know that problem was unrelated to fmfgraph. I'll try and make better examples next time. –  Ben Ruijl Jan 26 '12 at 10:43

As @egreg said in the comments, the reason why the second figure is below is due to the blank line.

There is a very good reason for this. Recall that in text mode a blank line signals the beginning of a new paragraph and subsequent text is placed below. So, the following will place the words next to each other:

One
Two


but the following will place the words below each other:

One

Two


Same goes for pictures, there are just boxes as far as TeX is concerned, not much different from letters, words, paragraphs, etc....

The MWE below produces the image on the left, but if you insert a blank line you get the image on the right:

## Note:

• My rule of thumb is not to use blank lines unless I am trying to indicate a new paragraph. For readability you can insert a comment line as long as the first non-blank character is a %. Note that it does not need to be at the beginning of the line as in the MWE below.

## Code:

Since this problem is not related to feynmf, I simply used pgfplots to generate the figures:

\documentclass{article}
\usepackage{pgfplots}
\usepackage{subfig}

\begin{document}
\begin{figure}[ht!]
\centering
\subfloat{
\begin{tikzpicture}
\begin{axis}[height=3cm]
\end{axis}
\end{tikzpicture}
}
% A blank line here like a new paragraph so next picture is placed below
\subfloat{
\begin{tikzpicture}
\begin{axis}[height=3cm]
\end{axis}
\end{tikzpicture}
}

\caption{Exchange two subfloats}
\end{figure}
\end{document}

-