3

Sometimes I compile a document with a lot of overfull/underfull line/box messages, which fill up my terminal and I can't make heads or tails of them without very careful scrutiny & scrolling.

Is it possible to get pdfTeX to mark these boxes and lines somehow? Say, with a box of some color, a dot, an underline, a side-bar, etc.?

8
  • Does not work in all cases but two strategies: 1) compile with draft option, all horizontal boxes sticking out into the margin will be marked with a black bar 2) look at the line number of the warning, with a good editor that support synctex, you can just jump to the right place. Apr 3, 2017 at 18:44
  • 1
    There are lots of questions about overfull and underfull boxes already on TeX.sx – with lots of helpful advice how to debug them. But I'm too lazy (!) to search them for you… No doubt this is a duplicate question.
    – cgnieder
    Apr 3, 2017 at 18:45
  • 1
    Related/duplicate: Is it possible to make LaTeX mark overfull boxes in the output?
    – Werner
    Apr 3, 2017 at 18:46
  • @samcarter: Which document classes does that apply to?
    – einpoklum
    Apr 3, 2017 at 18:53
  • 2
    @einpoklum Just had a look into IEEE and ACM, they also have a draft option. And for the many others, most of them will be based on one of the standard ones, so they will know the draft option, too. Apr 3, 2017 at 19:20

2 Answers 2

7

Yes, using the \overfullrule command in your preamble. This has to be set to a length (I usually set it to be ~5pt) and it prints out a black rectangle near overfull hboxes.

Here is an example (words are not meaningful, but this way they can't be hyphenated, thus creating overfull hboxes)

\documentclass{article}
\overfullrule=5pt
\begin{document}
adfhafashfk jahsdkjash kjsahdkjashdkjhshskjdhkjhdkjdsh qwioeuqwoieuoqwiueoiw kwlqjewqejoqwiejowqiejoqwjewoqiejowqej oqwj oeijwqoie jqwoj eiwoi jeowijewjeejejeejlwkkkkkwwllwlwlwlwwlwlwlwlwlw jkljdlajkslsadj
\end{document}

With the fantastic result: enter image description here

About draft:

Sometimes it's not either advisable or useful providing a draft option to the class, otherwise some packages (e.g. microtype) do not work as they would in the final stages.

3
  • (1) Does \underfullrule work similarly? (2) Is this only for boxes or for lines as well? Or are overfull lines a special case of overfull hboxes?
    – einpoklum
    Apr 3, 2017 at 19:00
  • (1) AFAIK there's no \underfullrule command, or anything of that sort; (2) I don't understand what you mean by lines
    – Moriambar
    Apr 3, 2017 at 19:11
  • to (la)tex, a line of type on a page is a box. so an "overfull hbox" (usually) means a line of type. (but a too-wide display, table or figure is also considered a single "line", so the result of one being too wide will be a {possibly very long) rule in the margin. if draft is not usable for the reason given, you can explicitly set `\overfullrule=5pt'. just don't forget to get rid of it when you're ready to compile the final version. Apr 3, 2017 at 21:46
1

The log file gives the line number of the bad lines so your editor should be able to locate them in the source. in emacs for example this is optional: you can toggle (C-c C-w) TeX-toggle-debug-bad-boxes, and when this is on, after running latex the usual next-error command (C-x`) will step through bad boxes moving the cursor at point to each bad line in turn, as if it had had an error. Other editors presumably have similar features (but I only know about emacs)

3
  • But emacs lacks a decent texteditor :)
    – Skillmon
    Apr 3, 2017 at 21:09
  • Isn't it the case that underfull boxes are rarely a problem? At least in flowing text (not math).
    – user103221
    Apr 3, 2017 at 23:26
  • 2
    @RobtA in straight text perhaps. Most common cause of underfull boxes by far is mis-using \\ but avoiding underfull boxes in text depends a lot on how well the hyphenation patterns fit the actual text which varies from language to language and community to community. Apr 4, 2017 at 7:21

You must log in to answer this question.

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