
ミニページに 4 つの tikz 図をインラインで挿入しようとしていますが、図とタイトルの間に予期しないスペースがあります。これは、配置した図の数や図の大きさに関係なく発生するようです。なぜこのようなことが起こるのでしょうか?
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[x11names]{xcolor}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pst-plot}
\pgfplotsset{compat=newest}
\setlength{\textfloatsep}{12pt plus 2pt minus 2pt}
\title{}
\author{}
\date{February 2016}
\begin{document}
\maketitle
\section{Title}
\begin{figure}
\centering
\begin{minipage}{.2\textwidth}
\begin{tikzpicture}[transform canvas={scale=0.5}]
\begin{axis}[
axis lines=middle,
grid = major,
xmin=-2, xmax=2,
ymin=-2, ymax=2,
xlabel=$x_1$,
ylabel=$x_2$,
xtick={-2,-1,0,...,2},
ytick={-2,-1,0,...,2}]
\addplot [thin, samples=100] {x};
\addplot [only marks, mark = +, color = red] table {
-1 0
0 1
};
\draw [-latex, red, thick] (0,0) -- (-1,1);
\end{axis}
\end{tikzpicture}
\end{minipage}\hfill
\begin{minipage}{.2\textwidth}
\begin{tikzpicture}[transform canvas={scale=0.5}]
\begin{axis}[
axis lines=middle,
grid = major,
xmin=-2, xmax=2,
ymin=-2, ymax=2,
xlabel=$x_1$,
ylabel=$x_2$,
xtick={-2,-1,0,...,2},
ytick={-2,-1,0,...,2}]
\addplot [thin, samples=100] {x};
\addplot [only marks, mark = +, color = red] table {
-1 0
0 1
};
\draw [-latex, red, thick] (0,0) -- (-1,1);
\end{axis}
\end{tikzpicture}
\end{minipage}\hfill
\begin{minipage}{.2\textwidth}
\begin{tikzpicture}[transform canvas={scale=0.5}]
\begin{axis}[
axis lines=middle,
grid = major,
xmin=-2, xmax=2,
ymin=-2, ymax=2,
xlabel=$x_1$,
ylabel=$x_2$,
xtick={-2,-1,0,...,2},
ytick={-2,-1,0,...,2}]
\addplot [thin, samples=100] {x};
\addplot [only marks, mark = +, color = red] table {
-1 0
0 1
};
\draw [-latex, red, thick] (0,0) -- (-1,1);
\end{axis}
\end{tikzpicture}
\end{minipage}\hfill
\begin{minipage}{.2\textwidth}
\begin{tikzpicture}[transform canvas={scale=0.5}]
\begin{axis}[
axis lines=middle,
grid = major,
xmin=-2, xmax=2,
ymin=-2, ymax=2,
xlabel=$x_1$,
ylabel=$x_2$,
xtick={-2,-1,0,...,2},
ytick={-2,-1,0,...,2}]
\addplot [thin, samples=100] {x};
\addplot [only marks, mark = +, color = red] table {
-1 0
0 1
};
\draw [-latex, red, thick] (0,0) -- (-1,1);
\end{axis}
\end{tikzpicture}
\end{minipage}
\caption{Caption}
\label{fig:my_label}
\end{figure}
答え1
に基づくミニページに包まれた4つの図の下に2つのキャプション次のような結果が得られます。
前述の回答に関して、私は問題の MWE からの前文の一部のみを取り上げました。完全を期すために、完全なコードを繰り返します。
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[x11names]{xcolor}
%\usepackage{tikz}
\usepackage{pgfplots}
%\usepackage{pst-plot}
\pgfplotsset{compat=newest}
\setlength{\textfloatsep}{12pt plus 2pt minus 2pt}
\title{my article}
\author{me}
\date{February 2016}
\begin{document}
\maketitle
\section{Title}
\begin{figure}[h]
\begin{minipage}{.48\textwidth}
\begin{tabular}{cc}
\begin{tikzpicture}[scale=0.45]
\begin{axis}[
axis lines=middle,
grid = major,
xmin=-2, xmax=2,
ymin=-2, ymax=2,
xlabel=$x_1$,
ylabel=$x_2$,
xtick={-2,-1,0,...,2},
ytick={-2,-1,0,...,2}]
\addplot [thin, samples=100] {0};
\addplot [only marks, mark = +, color = red] table {
-1 0
0 1
};
\draw [-latex, red, thick] (0,0) -- (-1,0);
\end{axis}
\end{tikzpicture}
& \begin{tikzpicture}[scale=0.45]
\begin{axis}[
axis lines=middle,
grid = major,
xmin=-2, xmax=2,
ymin=-2, ymax=2,
xlabel=$x_1$,
ylabel=$x_2$,
xtick={-2,-1,0,...,2},
ytick={-2,-1,0,...,2}]
\addplot [thin, samples=100] {x};
\addplot [only marks, mark = +, color = red] table {
-1 0
0 1
};
\draw [-latex, red, thick] (0,0) -- (-1,1);
\end{axis}
\end{tikzpicture}
\end{tabular}
\caption{Caption A}
\label{fig:my_label-A}
\end{minipage}
\hfill
\begin{minipage}{.48\textwidth}\centering
\begin{tabular}{cc}
\begin{tikzpicture}[scale=0.45]
\begin{axis}[
axis lines=middle,
grid = major,
xmin=-2, xmax=2,
ymin=-2, ymax=2,
xlabel=$x_1$,
ylabel=$x_2$,
xtick={-2,-1,0,...,2},
ytick={-2,-1,0,...,2}]
\addplot [thin, samples=100] {0};
\addplot [only marks, mark = +, color = red] table {
-1 0
};
\addplot [only marks, mark = -, color = blue] table {
0 1
};
\draw [-latex, red, thick] (0,0) -- (-1,0);
\end{axis}
\end{tikzpicture}
&
\begin{tikzpicture}[scale=0.45]
\begin{axis}[
axis lines=middle,
grid = major,
xmin=-2, xmax=2,
ymin=-2, ymax=2,
xlabel=$x_1$,
ylabel=$x_2$,
xtick={-2,-1,0,...,2},
ytick={-2,-1,0,...,2}]
\addplot [thin, samples=100] {-x};
\addplot [only marks, mark = +, color = red] table {
-1 0
};
\addplot [only marks, mark = -, color = blue] table {
0 1
};
\draw [-latex, red, thick] (0,0) -- (-1,-1);
\end{axis}
\end{tikzpicture}
\end{tabular}
\caption{Caption B}
\label{fig:my_label}
\end{minipage}
\end{figure}
\end{document}