26

A lot of the times I get warnings like "hbox overfull" when a specific part of my document is meant to be extra wide on purpose --> so I am purposefully violating the default width threshold. Or to put it another way I am interested in suppressing any warning that the author "willfully disregards".

In the above example, I purposefully violate some threshold... so IMO the generated warning should be suppressed. Anytime I purposefully break some suggestion I would like to suppress the warning. How do you suppress specific warnings generated by pdflatex?

So for example how would you suppress one specific "hbox overfull" or one specific "paragraph has no preceding subsection" warning?

(For the specific case of "hbox overfull" warning I saw that one solution is to change the default threshold for the entire document but I don't want to change the default threshold. I think the default threshold is good... I am only breaking the rule once... all the other times I want a warning to be generated so I can fix it.)


The reason I ask is because when I work I would like to have zero warnings. That way when a warning is generated it is the only warning and I can fix it right away asap... as opposed to having 5 warnings... and then when I get another warning I don't notice till later when I am already past the part that generated the warning.

  • You can change e.g. \hfuzz locally. But if I want to insert something large in a document I write the code so that I don't get warnings. – Ulrike Fischer Aug 13 '12 at 14:53
  • hfuzz sounds like it might suppress the warning locally for the specific warning of "hbox overfull" but what about any other warning? – Trevor Boyd Smith Aug 13 '12 at 15:01
  • For example in Java programming language when you do something that generates a warning and you want that code to stay that way on purpose --> you can use the @SuppressWarnings("stringDescription"). – Trevor Boyd Smith Aug 13 '12 at 15:05
  • 1
    There is also the silence package for dealing with LaTeX warnings, but note that this will not allow you to supress warnings that are not generated through the LaTeX methods, e.g. it won't help with the overfull hboxes generated by TeX. – cyberSingularity Aug 21 '12 at 12:46
16

here my solution (exemplified by my concrete problem with hyperref) inspired by cyberSingularity's comment. it looks like it can be adapted for many cases. (i know of texorpdfstring, this is not the point here.)

in the preamble (apparently silence must be included before hyperref) i have

\usepackage{silence}
\WarningFilter[pdftoc]{hyperref}{Token not allowed in a PDF string}
...
\usepackage{hyperref}

then in the document my infringing captions look like

\ActivateWarningFilters[pdftoc]
\subsection{pdf toc cannot display $f_n$}
\DeactivateWarningFilters[pdftoc]
12

There are two ways in that case.

Locally say \hbadness=10000 which will set the threshold at which warnings start to be effectively infinite.

Or prevent the box from being overfull so if you go for example

 \noindent\parbox{\2\textwidth}{....}\hspace{-\textwidth}

The surrounding line is not overfull even though visually it contains a box twice as wide as the text measure, as the negative space gets you back within limits.

  • 1
    So you would put \hbadness=10000 and it applies for the rest of document? Wouldn't you have to reset it back to the default so it only suppresses warnings for one specific place of the document? – Trevor Boyd Smith Aug 13 '12 at 15:06
  • 3
    I was using the "hbox overfull" only as an example to illustrate the kinds of warnings I wish to suppress. My question's intent was meant to cover warnings in general. Because of the questions generality maybe you could expand on the hbadness. – Trevor Boyd Smith Aug 13 '12 at 15:13
  • 1
    By "locally" I meant set it within a group, so it would automatically reset. (Same as a local font change). For the more general question about other warnings the issues are the same, you always have a choice between turning off warnings or arranging that TeX does not feel the need to warn See the longer discussion here: tex.stackexchange.com/questions/50830/… – David Carlisle Aug 13 '12 at 15:50
  • Inside \marginnote, neither solution works for me. Setting \hfuzz to something large works, though. – Raphael Oct 9 '13 at 14:08
  • 1
    @peter it suppresses overfull box warnings from the underlying tex engine, it has no effect on any warnings made by latex or latex packages. – David Carlisle Mar 11 '14 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.