# Silencing Warnings and Errors in LaTeX ## Statement of need Occasionally, `LaTeX` throws warnings and errors that I don't want to do anything about. In this sense, those warnings are redundant. In `LaTeX`, the `silence` package can be used to suppress unwanted output or error messages that can otherwise disrupt the formatting and appearance of a document. This helps streamline the `LaTeX` workflow by reducing the amount of extraneous information displayed during the document compilation process. ## The `silence` Package The `silence` package offers the following `macros` to help suppress various warnings and errors: | Command | Description | Usage | |------------------|------------------------------------------|----------------------------------------| | `\WarningFilter` | Suppresses warnings in logs | `\WarningFilter{}{}` | | `WarningsOff` | Suppresses warnings the brutal way | `\WarningsOff[]` | | `\ErrorsFilter` | Suppresses error messages in logs | `\ErrorsFilter{}{}` | | `\ErrorsOff` | Suppresses error messages the brutal way | `\ErrorsOff[

Even cruder

Using the starred versions \usepackage{silence} \WarningsOff* \ErrorsOff* suppresses all warnings and errors. ## Example A: Ignoring style (`.sty`) errors in Beamer I use the beamer `metropolis` theme quite a bit, but I get the following error when compiling on my desktop TeXstudio: ```latex ! Package beamerfontthememetropolis Error: Patching section title failed. See the beamerfontthememetropolis package documentation for explanation. ``` I have no intention of dealing with the error (not interested in dealing with `pdflatex` vs. `xelatex` vs. `lualatex`(??), etc.). My beamer slides still compile. An error I'm aware of but don't intend to deal with is just noise. So silencing the error is useful. The crude way of using `silence` is to filter error messages related to `beamerfontthememetropolis` ```latex \usepackage{silence} \ErrorsOff[beamerfontthememetropolis] ``` ## Example B: Float too large for page Another example is getting an error about floats being too large for the page. The warning I get is something like: ```latex Float too large for page by 17.91571pt on input line 22. ``` Again, not intending to tinker with formatting. The `silence` package also handles a more exquisite way of turning off warnings using the following syntax for a specific package and a type of warning. ```latex \usepackage{silence} \WarningFilter{}{} ``` So the following turns off the `Float too large warning for page` warning originating from the `latex` package. ```latex \usepackage{silence} \WarningFilter{latex}{Float too large for page} ``` ## Example C: Margin paragraph moved I tested out the Tufte-LaTeX class for producing notes. It allows notes to appear on the margins. But I get a warning if too many notes are defined close together in the same page. In which case LaTeX moves the notes accordingly to space them out gives the warning: ```latex LaTeX Warning: Marginpar on page 3 moved. LaTeX Warning: Marginpar on page 22 moved. ... ``` Again, no intention of dealing with it. Adding the following in the preamble turns the warnings off. ```latex \usepackage{silence} \WarningFilter{latex}{Marginpar on page} ``` ## Gotcha with load order The silence package is called as with any other package. ```latex \usepackage[]{silence} ``` As with any other package, it is only effective after it has been called. So compiling error messages and warnings thrown before `silence` is loaded will not be filtered. Place the `silence` loading at the top of the preamble to capture all messages. ## Resources * [silence – Selective filtering of error messages and warnings](https://ctan.org/pkg/silence?lang=en)