6

The horizontal bar from the following MWE does not start at the left edge of the paper as expected, but rather a bit more to the right. The line is 17cm long and the page width is also 17cm, which results in the warning

Overfull \hbox (1.59978pt too wide) in paragraph at lines 9--10

I tried adding '%' signs at the end of all the lines without any effect. What am I missing please?

\documentclass{article}
\usepackage[a4paper, showframe, margin=2cm]{geometry}
\usepackage{tikz}
\setlength{\parindent}{0pt}

\begin{document}
\begin{tikzpicture}
\draw[ultra thick] (0,0) -- (17,0);
\end{tikzpicture}
\end{document}

screenshot

1 Answer 1

8

You are not missing anything; apparently TikZ adds some padding equal to the line width (you can see this by using different values for line width in your \draw). You can prevent the undesired space using the overlay option (either globally for the whole tikzpicture, or locally for just the \draw):

\documentclass{article}
\usepackage[a4paper, showframe, margin=2cm]{geometry}
\usepackage{tikz}
\setlength{\parindent}{0pt}

\begin{document}

\begin{tikzpicture}
\draw[overlay,ultra thick] (0,0) -- (17cm,0);
\end{tikzpicture}

\end{document}

The result:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .