# Is there a recommended strategy to handle/prevent 'overfull \hbox' with tikzpicture?

For some tikepictures I use the default coordinate system.

Like the example below the coordinates (seem to) have a fixed default distance, such that the maximum y and xcoordinates is defined by the document size. This this example x is limited to about 11. Otherwise the tikzpicture exceeds the document bounds.

In the example the below, I get a Overfull \hbox (5.444pt too wide) in paragraph at lines 17--18 warning.

How much should I care about an Overfull \hbox warning?

Is there a better way to prevent an overful hbox other than adjusting the coordinates until everything fits?

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{shapes,backgrounds}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[background rectangle/.style={fill=olive!45}, show background rectangle]

\draw (0,0) -- (12,0);

\end{tikzpicture}
\end{figure}{}
\end{document}

• Well, you can use the page parameters to avoid the problem. If you use \draw (0,0) -- (\textwidth-2ex,0); there won't be a problem. -2ex because /tikz/inner frame xsep is (initially) 1ex. Other than that you could use adjustbox to shrink the picture, or figure out by how much it overshoots and then shrink it. (This can be automatized.) – Schrödinger's cat Sep 29 at 20:53