
次のMWE
\documentclass{article}
\usepackage{tikz}
\begin{document}
\noindent{}\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture}
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture}\\
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture}
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture}
\end{document}
生産する
次のような方法で空白を削除できることはわかっています:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\noindent{}\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture}\hspace*{-0.3em}
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture}\\[-1pt]
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture}\hspace*{-0.3em}
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture}
\end{document}
しかし、この方法では手動で間隔を微調整する必要があり、エラーが発生しやすいようです。図の間の空白 (水平と垂直の両方) を自動的に削除する方法はありますか?
答え1
パラメータを適切に設定すれば、を使用できますtabular
。
\documentclass{article}
\usepackage{tikz}
\newenvironment{pics}
{\par\raggedright % maybe \centering
\setlength\tabcolsep{0pt}\renewcommand{\arraystretch}{0}%
\begin{tabular}{*{10}c}}
{\end{tabular}\par}
\begin{document}
\begin{pics}
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture} &
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture} \\
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture} &
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture}
\end{pics}
\bigskip
\begin{pics}
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture} &
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture} &
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture} &
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture} \\
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture} &
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture} &
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture} &
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture} &
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture}
\end{pics}
\end{document}
答え2
水平方向のギャップはアンドリューのコメント: 環境間の行末スペース。
画像はベースラインスキップよりも大きいため、TeX はレジスタを使用して\lineskip
垂直方向にボックスを分離します。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\noindent
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture}%
\begin{tikzpicture}\fill [red] (0,0) rectangle(1,1);\end{tikzpicture}%
\\[-\lineskip]
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture}%
\begin{tikzpicture}\fill [red] (0,0) rectangle (1,1);\end{tikzpicture}%
\end{document}