Please see update at the end!

My latex editor (TexStudio) complains, when the log file is too big. So I have to get rid of the warnings, which are mostly

Marginpar on page x moved

My document has about 1000 pages and I use \cite in the margin. So I have thousands of these warnings.

My idea was to use package silence and set the appropriate filters. But when I include


in the preamble, even with no filters, options or respective commands set yet, rendering to PDF time seems to be unlimited. On my very fast machine usually rendering takes 1-2 minutes. With silence it goes indefinitely, several hours at least. I can see from the log, when I interrupt, that only the first few of my about 60 chapters have been scanned. If filters had been set, the respective warnings were filtered out correctly. Of course, these rendering times make it impossible to work. The package silence is installed correctly, as I can see in the MikTeX package manager. I have included the \usepackage command right after the \documentclass command, but the behavior is the same if I include it at a later position in the preamble. I have dozens of other packages installed and never experienced anything like that.

What is the problem and what can I do?


By further testing I found out that the following code in one of my subfiles causes the indefinite loop of package silence:

\subsection{text … $ \mathbb{R} $ … text}

Using math mode in a section heading, but only in conjunction with the macros \mathbb, \mathcal. Other macros work well, even self-defined ones. Possibly there are more macros which cause the hang-up, but so far I found only these two. Changing the length of the rest of the section heading text has no effect. Elimination of these macros in the math mode within the 2 section headings concerned causes the respective subfile to be processed rapidly and correctly. All unwanted warnings are gone.

  • 1
    could be related to any part of your code. please provide an MWE and people have an easier time checking for errors.
    – naphaneal
    Mar 30, 2019 at 19:53
  • @naphaneal, where to start with a 1000 page document? This will take weeks, won't it? Mar 30, 2019 at 20:25
  • Depending on your filter settings, that package seems to do several string comparisons which are slow in (La)TeX. You could start with a document that only contains the first chapter of your document and check how long compilation takes. Then experiment with the filter settings to see if the situation improves.
    – siracusa
    Mar 30, 2019 at 20:28
  • 2
    If some pages have been output after several minutes, it could mean that there are very slow loops or that at some point, an infinite loop starts. Since you say that after interruption some chapters have been processed, can you try moving \end{document} at the end of the first chapter and see what happens?
    – egreg
    Mar 30, 2019 at 21:06
  • @egreg, thanks a lot for this idea! In fact, I found what causes the indefinite loops. Please see my update to the question. But I have no idea why this causes the problem. Mar 31, 2019 at 12:55

1 Answer 1


The following would produce an infinite loop:




\section{Something about $\mathbb{R}$, plus other things}


On the other hand, this will compile flawlessly.



\WarningFilter{latex}{Marginpar on page}
\WarningFilter{hyperref}{Token not allowed}



\section{Something about $\mathbb{R}$, plus other things}


Much better would be to use

\section{Something about \texorpdfstring{$\mathbb{R}$}{R}, plus other things}

Where does the problem arise? It's when hyperref macros try to produce the text for the bookmarks. For some reason, a \sl@Terminator escapes being gobbled, because silence redefines \@gobble under certain circumstances, but hyperref does things differently than the other package expects. Since the definition of \sl@Terminator is


this starts an infinite loop.

  • could you please also explain why the above mentioned statement would cause infinite loop. Mar 31, 2019 at 14:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .