latex3 / hyperref

Hypertext support for LaTeX
165 stars 35 forks source link

Argument of \Hy@setref@link has an extra } #215

Closed linwaytin closed 2 years ago

linwaytin commented 2 years ago

I got this error

Argument of \Hy@setref@link has an extra }.

when using the template for "Progress of Theoretical and Experimental Physics". The template can be found in https://www.overleaf.com/latex/templates/progress-of-theoretical-and-experimental-physics/fhzxgvpwqrsd

The template contains a line for hyperref, so I assume it was designed for using with this package. Is there any recent change possibly breaking this?

Thanks.

u-fischer commented 2 years ago

Please provide a small but complete example. Don't link to external templates.

linwaytin commented 2 years ago

The error happens when I use the document class ptephy_v1. I know the error is due to the document class, not hyperref. I appreciate if anybody can identify some possible source of the error.

The simplest example:

\documentclass{ptephy_v1}
\usepackage{hyperref}

\begin{document}
Test
\end{document}

The error message:

ERROR: Argument of \Hy@setref@link has an extra }.

--- TeX said ---
<inserted text> 
                \par 
l.6 \end{document}

--- HELP ---
From the .log file...

I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.
u-fischer commented 2 years ago

the class tries to set a LastPage label in a way that isn't compatible with hyperref. You can disable this e.g. like this

\documentclass{ptephy_v1}
\makeatletter
\def\lastpage@putlabel{}
\makeatother
\usepackage{lastpage,hyperref}

\begin{document}
Test
\end{document}

Report this to overleaf, they should correct the template.

linwaytin commented 2 years ago

Thanks a lot!!! This problem bothered me for several hours. I will report this to the journal.