
O seguinte 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}
produz
Eu sei que posso eliminar o espaço em branco com algo como:
\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}
mas isso exige que eu ajuste manualmente o espaçamento e parece sujeito a erros. Existe uma maneira automática de eliminar o espaço em branco (horizontal e vertical) entre as figuras?
Responder1
Você pode usar um tabular
, com parâmetros definidos corretamente:
\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}
Responder2
As lacunas horizontais são explicadas pelo método de AndrewComente: Espaços por fim de linha entre os ambientes.
Como as imagens são maiores que o salto da linha de base, o TeX usa o registro \lineskip
para separar as caixas na direção vertical:
\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}