2

Consider this example:

\documentclass{article}
\usepackage{tikz}
\usepackage[showframe]{geometry}
\usepackage{lipsum}
\begin{document}
\lipsum[1]

\noindent\begin{tikzpicture}
\draw (0,0)--(\linewidth,0);
\end{tikzpicture}
\end{document}

It gets a warning

Overfull \hbox (0.4pt too wide) in paragraph at lines 8--11

On my viewer, I can't even see the "too wide" part

enter image description here

Of course, it is very difficult to see it, because it is only 0.4pt! However, I don't like having such warnings pop-up, so how to make sure that the line perfectly fits the margin, i.e. set the "inner sep" of the "node" TikZ picture to exactly 0pt?

I know I can use \rule, etc. for this, but I have to draw something more in TikZ, so I use TikZ in the whole picture.

Thank you in advance!

Bonus question: You can see that I am using \noindent. Without modifications to \parindent, are there any better ways to do that?

1

2 Answers 2

1

This is more like a work-around, but the real cause for this issue is most probably related to the tikz environment internals.

\documentclass{article}
\usepackage{tikz}
\usepackage[showframe]{geometry}
\usepackage{lipsum}
\begin{document}
\lipsum[1]

\noindent\makebox[\linewidth]{%
\begin{tikzpicture}
\draw (0,0)--(\linewidth,0);
\end{tikzpicture}%
}

\end{document}
0

Lets fuzz it out using \hfuzz=0.4pt in your preamble.

\documentclass{article}
\usepackage{tikz}
\usepackage[showframe]{geometry}
\usepackage{lipsum}
\hfuzz=0.4pt
\begin{document}
\lipsum[1]
%https://tex.stackexchange.com/questions/50830/do-i-have-to-care-about-bad-boxes/50850#50850
\noindent\begin{tikzpicture}
\draw (0,0)--(\linewidth,0);
\end{tikzpicture}
\end{document}

For more information: Please visit the linked question for which @DavidCarlisle provided a great answer. Also, I think this answer only covers your bonus part :-).

6
  • Thanks for your quick answer. However, if I do so, the picture is still too wide by 0.4pt. I want the picture to be perfectly fit to the margin :)) Also, if I fuzz it out, I will miss some other warnings which don't come from these pictures.
    – Someone
    Mar 12, 2019 at 12:25
  • You made the wrong typo in "the". There's a long way to imitate David Carlisle :D
    – TeXnician
    Mar 12, 2019 at 12:25
  • @TeXnician I don't think I would catch up with him, sometimes, I don't even understand the flow in his answers :D. Did I forget to mention that includes @egreg? Mar 12, 2019 at 12:26
  • @Someone Please dont use this as a complete answer. It just tries to answer the bonus part ;) I will try to look into that. But as of now, the answer for your remark is quite beyond my TeX knowledge. Mar 12, 2019 at 12:27
  • 1
    @Someone your reply was quite ironical though ;-). Mar 12, 2019 at 12:30

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