ypid/latex-packages

Hard to use doclicense in class file

kmccurley opened this issue · 2 comments

I'm finding it impossible to use use doclicense in a cls file because of fact that doclicense is so tightly dependent on hyperxmp. I have attached stripped down files to illustrate the problem. Suppose you have a cls file test.cls that does this:

\LoadClass{article}
\RequirePackage{etoolbox}
\AtEndPreamble{
  \RequirePackage{hyperref}
  \RequirePackage{hyperxmp}
  \RequirePackage[type={CC},modifier={by},version={4.0}]{doclicense}
}

Note that hyperref insists on being loaded last, which is why we have to put the load in \AtEndPreamble (there are a few exceptions to this rule, but we handle those in a way that is extraneous to this issue). The following file exhibits the problem:

\documentclass{test}
\begin{document}
This is a document.
\end{document}

If you compile this, it complains because \doclicenseLongTextForHyperref is defined after the calls to \hypersetup in \AtEndPreamble. I think this is caused by the fact that the \AtEndPreamble gets executed immediately when it is within \AtEndPreamble, and \doclicenseLongTextForHyperref has not been defined yet.

Note that the acmart cls file solved this problem by only having a dependency on doclicense for the images.

I can think of two possible solutions:

  1. delay the invocations of \hypersetup using \AtBeginDocument so that the entire doclicense package can finish loading.
  2. completely decouple doclicense from hyperxmp. The hyperxmp package is in a troubled state, and the author is having a hard time maintaining it in the face of changes to hyperref. Moreover, hyperxmp is being slowly replaced by the new pdfmanagement project in LaTeX.

Now that I see there is an option to \RequirePackage of hyperxmp=false, it's more clear how to proceed. The pdfmanagement-firstaid file now has a fix for this to set pdfcopyright and pdflicenseurl, so I think this can just be closed. You may still wish to wind back the integration of hyperxmp to be opt-in instead of opt-out, since hyperxmp is probably going bye-bye.

ypid commented

Thanks for reporting. I am not actively using TeX anymore (sadly) so I am also not to active using and testing doclicense. I opened #105. Can you test that?