Underfull \hbox (or \vbox) and Overfull \hbox (or \vbox) [duplicate]

I'm currently using the dis class with strong requirements on text with and text heigth. After compilation of my latex file I got a lot of warnings of the following kinds

Underfull \hbox (badness 10000) or Overfull \hbox (3.7778pt too wide)

for instance. As a consequence some black boxes appear at the end of some lines or in some diagrams of the generated pdf file.

How can I take care of these warnings ?

To be more specific, please find below a few lines of code that causes a warning "Overfull \hbox (3.778 too wide)":

$$\xymatrix{\underset{~}{Z}\ar[rr]^t \ar@{ >->}[dd]_*[@]{\hbox to 4pt{\sim}}_-{h\quad}&&X\ar[dd]^f\\&\circlearrowright&\\Z'\ar[rr]_u &&X'}$$ one has $$\xymatrix{\underset{~}{Z}\ar[rr]^t \ar@{ >->}[dd]_*[@]{\hbox to 4pt{\sim}}_-{h\quad}&&X\ar[rr]^r \ar[dd]^f&&Y\ar@{->>}[dd]^g\\&\circlearrowright&&\circlearrowright&\\Z'\ar[rr]_u&&X'\ar[rr]_{r'}&&Y'}$$


If I change the 4pt{$\sim$} by 8pt{$\sim$} then the warning disappears and the small undesired black box in the pdf file does too. However by incrementing to 8pt the \sim symbol is a bit too far above the arrow for my taste but it's not a big problem.

Do you have a better solution ? Especially for avoiding to make this change by hand in every single diagram where the problem occurs ?

Thanks

• underfull \hbox indicates a line with a line break but no content, or if inside an environment that doesn't expect a line break, overfull \hbox is a line where the content exceeds the current page margin. Your editor should tell you the line where these problems occur, check the line. It should appear like path/to/file.tex:<line number> ... Feb 6 '16 at 17:00
• Feb 6 '16 at 17:02
• underfull badness 10000 means infinitely bad and usually it is caused by using \\  at the end of a paragraph, but in general an underful box just means there is not enough text or stretch space to fill the specified width, so impossible to say in general what you should do: either add more text to the box, or make it less wide. Feb 6 '16 at 18:52
• Hello, thanks for your comments I read the links provided but I'm still a bit confused, hence I edited my question with a specific problem to see if someone can help a bit more.
– user77998
Feb 7 '16 at 14:10
• First of all, you need to understand, how works TeX. For example what does mean \hbox to4pt{$\sim$}? Why do you write this? Where do you get inspiration? The list in the \hbox does not include shrinkable nor stretchable element, so there is probability equal to 100% that the box will have no 4pt width and the overfull or underfull warning occurs. Feb 7 '16 at 16:15