Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\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}
share|improve this question
    
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 at 14:01

1 Answer 1

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.

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.