# Package incompatibility with hyperxmp and silence?

I was wondering how to dig into this further. I believe I saw in the silence package's changelog that it had to make some changes to be compatible with hyperref, so I wonder if I'm hitting a new bug now.

Here's a minimal example that makes my machine hang, and the order the packages are loaded in doesn't make a difference:

\documentclass{article}
\usepackage{silence}
\usepackage{hyperref,hyperxmp}
\begin{document}
\end{document}


So I was wondering what I could do about this, or who I should report the bug to: hyperxmp, or silence.

I might have got a clue from using \RequirePackage before the preamble. That gives me this error:

! LaTeX Error: Command \maketitle already defined.
Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...

l.235 }


• Welcome to TeX.SE! Well,why do you need silence? THe given code compiles without it ... – Mensch Sep 6 '19 at 1:58
• @Mensch because I'm using a non-article document class that gives useless warnings (but for the sake of reproducing the bug, I mentioned article in my post). The answer below fixes the hang with article, but not my document class, so maybe I'll just find a new one. – John Sep 6 '19 at 17:56
• @Mensch it's res.cls from rpi.edu/dept/arc/training/latex/resumes and it still hangs on a minimal file loading the packages and specifying title and author as below. I get bogus warnings about "Unused global options:[11pt]" being given to res.cls even though it does in fact work and change the size – John Sep 6 '19 at 17:59
• 'res.cls' is a very outdated class and should not be used any longer. Use a more modern template, for example moderncv, style banking ... – Mensch Sep 6 '19 at 18:07
• @John You're out of luck. I dug up a bit further and found out why these packages plus the res class (which is outdated!) will hang. The underlying reason is the same as in my answer: fragile code inside the error message. However differently from article, which you can simply provide a title and the problem goes away, the res class always inserts fragile code in \@title (formatting stuff: font change, alignment, etc.). So it's sort of impossible to get that combination of packages working with res.cls without a considerable amount of change in the code... – Phelype Oleinik Sep 6 '19 at 21:17

The correct solution is to not use the silence package. Really, don't use it. You'll thank me later :-)

However if you insist on that, then you need to add a \title and an \author to the code, before the \begin{document}, and it won't hang anymore:

\documentclass{article}
\usepackage{silence}
\usepackage{hyperref,hyperxmp}
\begin{document}
\end{document}


This happens because hyperxmp tries to set pdf metadata, such as title and author. To do that, it uses LaTeX's \@title and \@author macros which hold, you guessed, the title and the author of the document. However, when no \title (or \author) is given, LaTeX's default is an error message (!) which says "No \title given" (or a "No \author given" warning). And do you know who messes up all of LaTeX's messages? Yes! silence tries to be clever and hide the error messages, but it chokes on the unexpandable tokens \title and \author and hell breaks loose.

A slightly more detailed explanation is here: https://tex.stackexchange.com/a/451568/134574. The code is different, but it boils down to the same issue and solution. In your case the easy way out is to give a \title and an \author.

But please, don't use silence. Every time you are tempted to use silence remember that every error/warning message had to be written by someone so that you can find out what went wrong more easily. Loading silence will just make the finding out process more difficult (as you just witnessed :-).

• From silence's documentation, I was under the impression that just loading it wasn't supposed to do anything and I'd need to invoke other commands to make it hide errors and warnings. – John Sep 6 '19 at 17:44
• @John That's correct, to some extent. Just loading the package indeed does not hide any errors or warnings, wowever silence's machinery is still installed in LaTeX's message system. This means that even though no message is being hidden, the package has already redefined LaTeX's message commands, such as user level commands like \PackageError, and internal LaTeX commands, such as \@latex@error. – Phelype Oleinik Sep 6 '19 at 17:52

I had an older document using now deprecated packages. I just wanted to update some links in this document. Because of the new warnings about the deprecation I included silence with some \WarningFilter commands oppressing these warnings (I planned to deal with replacement later) and run, too, into endless loading. For me it turned out that moving \hypersetup before ´\begin{document}´ was the solution. There is nowhere an \author or \title included here, but the hypersetup contains pdftitle and pdfauthor! Without the latter the endless loading will return!

\documentclass{article}
\usepackage{silence}
\usepackage{duckuments}
\usepackage{hyperref,hyperxmp}

%\begin{document}

\hypersetup{
pdftitle={Test of package "silence"},
pdfauthor={Anne O. Nymus},
pdfcreator={pdfTeX},

Make the other begin{document} active or comment out pdftitle and pdfauthor.
The reason why I had \hypersetup after document begin was, if I remember correctly, the encoding (non ASCII characters in pdftitle), but this doesn’t matter anymore now if everything is converted into UTF-8.