# How do you suppress specific warnings generated by pdflatex?

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
@Kurt, I am well aware of the meaning of what warnings indicate when creating a Latex document. The type of warnings I am interested in suppressing are when I am purposefully choosing to do something despite what the warning says. –  Trevor Boyd Smith Aug 13 '12 at 15:08
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

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.

-
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
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
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
does not seem to work for package hyperref warnings (specifically those that say that the caption string is simplified for the pdf toc). –  peter Mar 11 '14 at 10:58

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]

-