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.

(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}
```
