# Remove space around tikzpictures

I need to create a document in which pages are horizontal and each of them contains eight rectangles that take exactly and all the paper size. After some tries I came up with a code like this MWE:

\documentclass[a4paper]{article}
\usepackage[landscape,margin=0mm]{geometry}
\usepackage{parskip}

\usepackage{tikz}

\begin{document}
\pgfmathsetmacro{\myWidth}{74}
\pgfmathsetmacro{\myHeight}{105}

\begin{tikzpicture} % #1
\draw (0,0) rectangle (\myWidth mm,\myHeight mm);
\end{tikzpicture}
\begin{tikzpicture} % #2
\draw (0,0) rectangle (\myWidth mm,\myHeight mm);
\end{tikzpicture}
\begin{tikzpicture} % #3
\draw (0,0) rectangle (\myWidth mm,\myHeight mm);
\end{tikzpicture}
\begin{tikzpicture} % #4
\draw (0,0) rectangle (\myWidth mm,\myHeight mm);
\end{tikzpicture}
\begin{tikzpicture} % #5
\draw (0,0) rectangle (\myWidth mm,\myHeight mm);
\end{tikzpicture}
\begin{tikzpicture} % #6
\draw (0,0) rectangle (\myWidth mm,\myHeight mm);
\end{tikzpicture}
\begin{tikzpicture} % #7
\draw (0,0) rectangle (\myWidth mm,\myHeight mm);
\end{tikzpicture}
\begin{tikzpicture} % #8
\draw (0,0) rectangle (\myWidth mm,\myHeight mm);
\end{tikzpicture}
\end{document}


It nearly does what I need, but it leaves some space between the rectangles:

It's only 0,8 mm large, but I need to remove it and make the rectangles touch each other. I also suppose that there is some space below the rectangles because tikzpictures 5 to 8 are put on a second page instead of below the 1 to 4 set.

How can I remove the space around the tikzpicture environments?

Note 1: I can't draw all the rectangles in the same tikzpicture because in my real document the rectangles are automatically filled with datas from a CSV file (thanks @Schrödinger's cat; I forgot to specify that!). Well, I could draw the document with a "per page" code, but I would prefer to keep it simpler and use a "per rectangle" approach.

• try: \end{tikzpicture}% then newline and then \begin{tikzpicture} .... % has to be placed just after \end{tikzpicture} to remove this unwanted space Apr 2 '20 at 16:16
• @koleygr I found something similar in answers to other questions but it works only a half: the space between rectangles 1 to 4 is removed, but rectangles 5 to 8 disappear. I suppose they overlap, as if I add an empty line between below tikzpicture #4 the other ones appear in another page. Apr 3 '20 at 7:56

Just draw it in one tikzpicture.

\documentclass[a4paper]{article}
\usepackage[landscape,margin=0mm]{geometry}
\usepackage{tikz}
\begin{document}
\noindent
\begin{tikzpicture}
\pgfmathsetmacro{\myHeight}{105}
\draw foreach \X in {1,...,8}
{({\paperwidth*(\X-1)/8+\pgflinewidth/2},\pgflinewidth/2) rectangle
({\paperwidth*\X/8-\pgflinewidth/2},\myHeight*1pt-\pgflinewidth/2)};
\end{tikzpicture}
\end{document}

• I forgot to specify that each rectangle will be automatically filled with datas from a CSV file, so I would prefer a "per rectangle" approach. Thank you anyway - to be honest I hadn't even considered that I could draw all the rectangles in the same tikzpicuture environment =). If I won't find any other solution I'll try to adapt your code. Apr 3 '20 at 7:45