# [Tex/LaTex] How to word-wrap LaTeX warning/error output

documentclass-writingerrorspackage-writingwarnings

This question led to a new package:
hardwrap

In writing error messages and warnings for a package/class, I find it a pain to manually insert \MessageBreaks so that words don't get cruelly bisected because of TeX's max_print_line value (which typically is set to 79). In some cases it's not possible to predict where the \MessageBreak should go because a macro in the warning/error message may be expanded to any length of string.

I'd like to have a macro that would take my warning/error message, expand it (so that any macros are expanded to plain strings), and insert \MessageBreaks in the appropriate places based on the value of max_print_line and LaTeX's per-line prefixes (Package <XXX> Warning: and similar).

(If the value of max_print_line can't be accessed from within TeX, I'd settle for just implementing a greedy word-wrap algorithm with the default line length values.)

Follow-up: Will Robertson and I created the hardwrap package to achieve the desired affect.

The code is undocumented, but you should be able to see the gist of it by ignoring everthing before \begin{document}. If you find it useful, I suggest we write a package for CTAN with some documentation and a better interface.