tikz add tag
samcarter
How to remove the padding before and after lines drawn in tikz? 

The padding seems to depend on the `line width` (maybe `.5\pgflinewidth`?). I already tried to modify all `sep` keys I could think of, but as you can see in the following picture, some padding remained at the start and end of lines. 

![Screen Shot 2020-01-20 at 16.40.42.png](/image?hash=e48c286a80d8ef575322dd8de0b96e8e921f96bcba13501dd3b0d679dfc4972b) 

(the red arrows mark the excess padding I would like to get rid of)

```
\documentclass[tikz]{standalone}

\begin{document}

\begin{tikzpicture}[
		inner sep=0pt,
		inner xsep=0pt,
		inner ysep=0pt,		
		outer xsep=0pt,
		outer ysep=0pt,
		outer sep=0pt	
	]
	\draw[line width=5cm, green] (0,0) -- (\paperwidth,0);
\end{tikzpicture}

\begin{tikzpicture}[
		inner sep=0pt,
		inner xsep=0pt,
		inner ysep=0pt,		
		outer xsep=0pt,
		outer ysep=0pt,
		outer sep=0pt	
	]
	\draw[line width=1cm, green] (0,0) -- (\paperwidth,0);
\end{tikzpicture}

\end{document}
```



Top Answer
user 3.14159
A path always extends the bounding box as if it had `line cap=rect`, regardless of whether or not it really has. So one may want to dial that option, and subtract `\pgflinewidth` from its length to arrive at


```
\documentclass[tikz]{standalone}

\begin{document}

\begin{tikzpicture}
	\draw[line width=5cm, green,line cap=rect] (0,0) --
	(\paperwidth-\pgflinewidth,0);
\end{tikzpicture}

\begin{tikzpicture}
	\draw[line width=1cm, green,line cap=rect] (0,0) -- (\paperwidth-\pgflinewidth,0);
\end{tikzpicture}

\end{document}
```

![Screen Shot 2020-01-20 at 8.13.30 AM.png](/image?hash=a565c43f4ab327045f23e5c201066068f3a57d6c0e049dddfa50288989b7f7e0)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.