# I'm trying to put 3 figures side-by-side, but using subfigures put them in a column instead. Am I doing something wrong? Here's my code:

\documentclass[12pt]{article}

\usepackage{tikz}
\usepackage{amsmath}
\usepackage{bm}
\usepackage{amssymb}
\usepackage{subcaption}
\usetikzlibrary{decorations.markings}

\usepackage[a4paper,textwidth=17cm,textheight=23cm]{geometry}

\begin{document}

\begin{figure}
\begin{subfigure}[b]{0.30\textwidth}
\centering
\begin{tikzpicture}[decoration={markings,
mark=between positions 0 and 1 step 25pt
with { \draw [fill] (0,0) circle [radius=2pt];}}]
\path[postaction={decorate}] (0,4) to (4,4);
\path[postaction={decorate}] (0,3) to (4,3);
\path[postaction={decorate}] (0,2) to (4,2);
\path[postaction={decorate}] (0,1) to (4,1);
\path[postaction={decorate}] (0,0) to (4,0);
\draw [<->] (2.3,2) -- (1.75,2) -- (1.75,2.65);
\draw [dashed] (0, 1.5) -- (4,1.5);
\draw [dashed] (0, 2.5) -- (4,2.5);
\end{tikzpicture}
\label{lattice1}
\end{subfigure}

\begin{subfigure}[b]{0.30\textwidth}
\centering
\begin{tikzpicture}[decoration={markings,
mark=between positions 0 and 1 step 25pt
with { \draw [fill] (0,0) circle [radius=2pt];}}]
\path[postaction={decorate}] (0,4) to (4,4);
\path[postaction={decorate}] (0,3) to (4,3);
\path[postaction={decorate}] (0,2) to (4,2);
\path[postaction={decorate}] (0,1) to (4,1);
\path[postaction={decorate}] (0,0) to (4,0);
\draw [<->] (2.3,2) -- (1.75,2) -- (1.75,2.65);
\draw [dashed] (1.25,0) -- (1.25,4);
\draw [dashed] (2.25,0) -- (2.25,4);
\end{tikzpicture}
\label{lattice2}
\end{subfigure}

\begin{subfigure}[b]{0.30\textwidth}
\centering
\begin{tikzpicture}[decoration={markings,
mark=between positions 0 and 1 step 25pt
with { \draw [fill] (0,0) circle [radius=2pt];}}]
\path[postaction={decorate}] (0,4) to (4,4);
\path[postaction={decorate}] (0,3) to (4,3);
\path[postaction={decorate}] (0,2) to (4,2);
\path[postaction={decorate}] (0,1) to (4,1);
\path[postaction={decorate}] (0,0) to (4,0);
\draw [<->] (2.3,2) -- (1.75,2) -- (1.75,2.65);
\draw [dashed] (1.25,0) -- (1.25,4);
\draw [dashed] (2.25,0) -- (2.25,4);
\draw [dashed] (0, 1.5) -- (4,1.5);
\draw [dashed] (0, 2.5) -- (4,2.5);
\end{tikzpicture}
\label{lattice3}
\end{subfigure}
\end{figure}

\end{document}

-
Welcome to TeX.SX! Your problem is the same as in tex.stackexchange.com/questions/171275/… Basically, an empty line signifies a paragraph break, also inside a figure, and a new paragraph always starts in a new line. – Torbjørn T. May 4 '14 at 14:01

Your problem was the extra line / whitespace after the \end{subfigure} instances, try the following:

\documentclass[12pt]{article}
\usepackage{tikz} \usepackage{amsmath} \usepackage{bm} \usepackage{amssymb} \usepackage{subcaption} \usetikzlibrary{decorations.markings}
\usepackage[a4paper,textwidth=17cm,textheight=23cm]{geometry}
\begin{document}
\begin{figure} %
\begin{subfigure}[b]{0.30\textwidth} \centering \begin{tikzpicture}[decoration={markings, mark=between positions 0 and 1 step 25pt with { \draw [fill] (0,0) circle [radius=2pt];}}] \path[postaction={decorate}] (0,4) to (4,4); \path[postaction={decorate}] (0,3) to (4,3); \path[postaction={decorate}] (0,2) to (4,2); \path[postaction={decorate}] (0,1) to (4,1); \path[postaction={decorate}] (0,0) to (4,0); \draw [<->] (2.3,2) -- (1.75,2) -- (1.75,2.65); \draw [dashed] (0, 1.5) -- (4,1.5); \draw [dashed] (0, 2.5) -- (4,2.5); \end{tikzpicture} \label{lattice1}
\end{subfigure} %
\begin{subfigure}[b]{0.30\textwidth} \centering \begin{tikzpicture}[decoration={markings, mark=between positions 0 and 1 step 25pt with { \draw [fill] (0,0) circle [radius=2pt];}}] \path[postaction={decorate}] (0,4) to (4,4); \path[postaction={decorate}] (0,3) to (4,3); \path[postaction={decorate}] (0,2) to (4,2); \path[postaction={decorate}] (0,1) to (4,1); \path[postaction={decorate}] (0,0) to (4,0); \draw [<->] (2.3,2) -- (1.75,2) -- (1.75,2.65); \draw [dashed] (1.25,0) -- (1.25,4); \draw [dashed] (2.25,0) -- (2.25,4); \end{tikzpicture} \label{lattice2}
\end{subfigure} %
\begin{subfigure}[b]{0.30\textwidth} \centering \begin{tikzpicture}[decoration={markings, mark=between positions 0 and 1 step 25pt with { \draw [fill] (0,0) circle [radius=2pt];}}] \path[postaction={decorate}] (0,4) to (4,4); \path[postaction={decorate}] (0,3) to (4,3); \path[postaction={decorate}] (0,2) to (4,2); \path[postaction={decorate}] (0,1) to (4,1); \path[postaction={decorate}] (0,0) to (4,0); \draw [<->] (2.3,2) -- (1.75,2) -- (1.75,2.65); \draw [dashed] (1.25,0) -- (1.25,4); \draw [dashed] (2.25,0) -- (2.25,4); \draw [dashed] (0, 1.5) -- (4,1.5); \draw [dashed] (0, 2.5) -- (4,2.5); \end{tikzpicture} \label{lattice3}
\end{subfigure} %
\end{figure}
\end{document}


By ending critical lines (this is also needed with minipages for example) with a % symbol, any subsequent whitespace is ignored until the next line begins.

-