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.?

einpoklum
  • 12,311

2 Answers2

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.

Moriambar
  • 11,466
  • (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 03 '17 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 03 '17 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. – barbara beeton Apr 03 '17 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)

David Carlisle
  • 757,742
  • But emacs lacks a decent texteditor :) – Skillmon Apr 03 '17 at 21:09
  • Isn't it the case that underfull boxes are rarely a problem? At least in flowing text (not math). –  Apr 03 '17 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. – David Carlisle Apr 04 '17 at 07:21