13

I am using the lipics documentclass, which loads hyperref. Since I want my figures boxed, I added the following

\usepackage{float}
\floatstyle{boxed}
\restylefloat{figure}

The problem: I receive warnings of the kind

name{figure.1} has been referenced but does not exist,replaced by a fixed one

which use to happen when I load the float package after hyperref.

The question: is there any correct way to do this without redefining the class?

4

In the KOMA-Script-bundle, Markus Kohm’s replacement for the standard LaTeX-classes and much more, he includes a package called scrlfile, that is designed to execute actions both before and after the loading of files. May be that package can solve your problems. It can be used on a stand alone basis.

If you do not read German, the author has started the work on improving the English manual. He describes scrlfile on pages 248ff. You will find KOMA-Script at CTAN and BerliOS.

Links to the new, improved, English manual you will find here.

  • Love this solution! But for some reason I cannot make it work. I uploaded the package scrlfile and put the following commands \BeforePackage{hyperref}{\usepackage{float} \floatstyle{boxed} \restylefloat{figure}} But they are never executed (the figures are not boxed). Any insight? – Alejandro DC Apr 6 '12 at 20:23
  • 1
    @AlejandroDíaz-Caro No, I have never used the program. I suggest you ask the author, Markus Kohm, at komascript.de. Even if the site is in German, you can ask questions and get replies in English. – Sveinung Apr 7 '12 at 7:27
  • 1
    @AlejandroDíaz-Caro: Your comment is actually a new question, so I suggest you copy it to a new question to tex.stackexchange.com – Sveinung Apr 7 '12 at 14:08
  • Thanks. I just raised a new question about this issue. – Alejandro DC Apr 7 '12 at 16:45
  • 1
    Instead of using \BeforePackage{hyperref} to load float, just load it \AfterClass{article}}. This is not the "right" way, but works. (I don't yet understand how to fix \BeforePackage as that seems like the "right" way that does not work:-) See my answer. – mforbes Apr 7 '12 at 22:32
10

Short version: yes, you'll have to redefine the class, or at least patch their hyperref inclusion.

I ran into a similar problem with my hyperref-using thesis class (which was originally a package). When it was a package, I could have students load packages before or after my thesis package, and hyperref would then be in the right order. Once I made a class, though, all my packages would be loaded first in the \documentclass line, which made it impossible for anyone to work around hyperref. Rather than abandon hyperref entirely, I added the following to the class:

\IfFileExists{\jobname-packages-loaded-before-hyperref.sty}{%
  \RequirePackage{\jobname-packages-loaded-before-hyperref}
}{}

% For all sorts of hyperlinks in the PDF output.
\RequirePackage[pdfcreator={pdfLaTeX with hyperref},
  plainpages=false,
  pdfpagelabels,
  hypertexnames=true,
  colorlinks=false]{hyperref}

\IfFileExists{\jobname-packages-loaded-after-hyperref.sty}{%
  \RequirePackage{\jobname-packages-loaded-after-hyperref}%
}{}

and now my students just have to put all their extra \usepackage or \RequirePackage entries in one of two .sty files. Examples: before package, after package, and class.

7

It is well-known (and should be to class authors) that hyperref needs to be loaded as late as possible. Hence, the class should really be changed not to load hyperref.

2

In my case, I added:

\RequirePackage{fooPackage}
\PassOptionsToPackage{bookmarks=false}{hyperref}

BEFORE \documentclass, which fixed the issue I was having without modifying the class.

  • 1
    This is a good option if it is possible (it might not always work because the loading order requires more than just "load before hyperref" or because the hyperref options get mangled or reset in the class). – moewe Nov 30 '18 at 21:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.