1

I'm trying to include a figure (a pdf chart) in my document and wrap around it, but it's giving me tons of overfull hbox errors. Here is the code:

\documentclass{article}

\usepackage{wrapfig} \usepackage{graphicx} \usepackage{lipsum} \begin{document}

\lipsum[2] \begin{wrapfigure}{r}{0.6\textwidth} \centering \includegraphics[width=0.55\textwidth]{example-image-a} \caption{\label{fig:simpres}Residual values plot} \end{wrapfigure}\lipsum \end{document}

I get all of these warnings: enter image description here

They go away if I remove the wrapfigure part, but obviously then I lose the ability to wrap around the figure which is important here. Any ideas?

leonard
  • 11
  • the log you show is not from the code, and the code is incomplete and can not be run to see the issue, so it is really impossible to say anything to help. Make a small but complete document (you can use example-image as the image) that shows the problem and show the log of the posted document (as text from the log file, not as a screenshot) – David Carlisle Sep 10 '20 at 09:34
  • I've included a full test document, I get this error : test.tex|5 warning| Underfull \hbox (badness 10000) in paragraph at lines 5--9 test.tex|9 warning| Overfull \hbox (154.66953pt too wide) in paragraph at lines 9--10 – leonard Sep 10 '20 at 09:53
  • The english hyphenation patterns can not hyphenate asdfasfasdfasfasdfasfasdfasfasdfasfasdfasfasdfasdfasdfasdfasdfasdf so you get a bad line break. That is all, it is just a warning not an error,. – David Carlisle Sep 10 '20 at 09:55
  • make a real example which shows bad line breaks in real text and replace that screenshot by the actual warnings that you get (as text) from the docuemnt that you post. There is no general fix, it is just about linebreaking the specific text in the paragraph. – David Carlisle Sep 10 '20 at 09:56
  • Sorry - just updated with an edit, I just used the comment below because even that gives me overfull hbox warnings - is this an issue with my compiler? – leonard Sep 10 '20 at 10:01
  • No it is an issue with the text (your new text is using lipsum, which is mock-latin, which also is hard to hyphenate using the English hyphenation rules. The warnings are just about the specific text in the paragraph, unless you actually want fake latin text in your final document then the warnings are not relevant. – David Carlisle Sep 10 '20 at 10:04
  • (Bad title because most of the warnings shown are underfull boxes, with only one overfull.) – Donald Arseneau Sep 10 '20 at 11:30

2 Answers2

1

Two documents - the one shown as an example, and the one with all the overfull warnings.

The example code has an underfull box because you forced a line break with wrapfigure, by using it as part of the paragraph. Documentation of wrapfig, on page 2, says:

  • It is convenient to begin the environment between paragraphs, but if you want placement in the middle of a paragraph, you must put the environment between two words where there is a natural line break.

If at all possible, put the environment between paragraphs (leave a blank line before it).

It has an overfull box because the nonsense

asdfasfasdfasfasdfasfasdfasfasdfasfasdfasfasdfasdfasdfasdfasdfasdf

is wider than the line and has no separate words.

Back to the original list of multiple warnings. Look at the document output pdf and see what formatting happened. See if there are big words or formulas that can't fit in the narrow portion of the text. The underfull warnings, especially, are to be expected in narrow columns. Using package "microtype" can help the typesetting in narrow columns. Also make sure you have the proper language selected for hyphenation.

0

Works fine with article class

enter image description here

\documentclass{article}

\usepackage{wrapfig} \usepackage{graphicx} \usepackage{lipsum} \begin{document}

\lipsum[2] \begin{wrapfigure}{r}{0.6\textwidth} \centering \includegraphics[width=0.55\textwidth]{example-image-a} \caption{\label{fig:simpres}Residual values plot} \end{wrapfigure}\lipsum \end{document}

js bibra
  • 21,280
  • This gives me tons of overfull and underfull hbox warnings at lines 13--14 - is that normal? – leonard Sep 10 '20 at 09:54
  • 1
    This really is not an answer at all, it gives exactly the warnings that are asked about in the question. – David Carlisle Sep 10 '20 at 15:20
  • 1
    @sawsuh even without the warnings in the log you can see the boxes are underfull, eg the excessive space before vulpatate near the center of the mage. But this is setting latin text in narrow column with English hyphenation rules, so some difficult line breaks are not unexpected. It would typically do better with English text (or using latin hyphenation rules) – David Carlisle Sep 10 '20 at 15:23