I get an annoying white space in my rendered graphics with lines that begin or end at the page's borders. I am using the "standalone" document class for actually not having those margins.
Let us assume the following code for my TikZ graphic.
\documentclass[tikz]{standalone}
\usepackage{tikz}
\usepackage{color}
\begin{document}
\begin{tikzpicture}
% simple gray box
\fill[darkgray] (0, 0) rectangle (2, 2);
% green line beginning from the left
\draw[green, line width=0.5cm] (0, 1) -- (1, 1);
\end{tikzpicture}
\end{document}
What I get with the above TeX code is this image (zoomed in for better seeing what I mean):
By dragging that image around with your mouse you sure will mention that there is some white space between the image's left border and the gray box (where the image should actually begin).
And yes, I know that this white space would totally make sense if I had drawn the line like this:
\draw[green, line width=0.5cm] (0, 1.5) -- (0, 1) -- (1, 1);
…But I didn't.
In my case I only need to draw horizontal lines from left to right and not along the border. I also use dark boxes in the background like the gray one in the example above. So, that white space is really bothering me.
How can I get rid of that?
begin{document}
and `begin{tikzpicture}'. Delete that empty line and the problem goes away, see: tex.stackexchange.com/questions/437887/…