10

I'm using the following package for convert a PDF to a PDF/A format

\usepackage[a-1b]{pdfx}

When I compile, I receive the following error.

"Option clash for package hyperref"

I've searched within TEX but until now I didn't find any valid solution.

I compile with Mac OS Tex in TexShop. The typeset is set as LaTex.

Thank you in advance.

Edit

Here a small example of what I'm trying to achieve

\documentclass[english,lof,lot]{thesis} 
\errorcontextlines=9

\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}

\usepackage{lmodern}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Added Packages
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{caption}
\usepackage{algorithmic}
\usepackage{array}
\usepackage{amssymb}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage[figuresright]{rotating}
\usepackage{float}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PDF/A
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[a-1b]{pdfx}

// begin document here...

where thesis.cls is a document class that contains the following

\RequirePackage{ifpdf}
\ifpdf
  \RequirePackage[pdfpagelabels]{hyperref}
\else
  \RequirePackage{hyperref}
\fi

Since I didn't write the class, I would like to know if how is it possible to overcome the error.

When I try to compile with this configuration, the error is the following

The package hyperref has already been loaded with options: [pdfpagelabels]. There has now been an attempt to load with option [pdftex,pdfa] Adding the global options:pdfpagelabels,pdftex,pdfa to your \documentclass declaration may fix this.

10
  • 3
    if you type h to the prompt it should tell you which option clashed and suggest a possible workaround Commented Jan 3, 2013 at 0:05
  • 2
    The package pdfx already loads hyperref; if you need to set other options for this one, use \hypersetup{<options>}
    – egreg
    Commented Jan 3, 2013 at 0:06
  • @DavidCarlisle Thank you. The compiler gives me: The package hyperref has already been loaded with options: [pdfpagelabels] There has now been an attempt to load with option [pdftex,latex] Adding the global options:pdfpagelabels,pdftex,pdfa to your \documentclass declaration may fix this
    – Lorenzo B
    Commented Jan 3, 2013 at 0:10
  • @egreg Thank you. What do you mean with your comment? I'm not very expert about this.
    – Lorenzo B
    Commented Jan 3, 2013 at 0:10
  • 1
    On the next line it will have said Adding the global options:... to your \documentclass declaration may fix this. add the options it says to \documentclass (this can fail but it works in most cases) Commented Jan 3, 2013 at 0:12

2 Answers 2

5

that should be

\RequirePackage{ifpdf}
\ifpdf \PassOptionsToPackage{pdfpagelabels}{hyperref} \fi
\RequirePackage{hyperref}
6
  • +1 for you support. Do I need to replace your code in my cls file? Why the else statement is removed? Thanks.
    – Lorenzo B
    Commented Jan 3, 2013 at 9:10
  • copy the thesis.cls to mythesis.cls and change that part of code. For a test put mythesis.cls into your documents directory and use \documentclass{mythesis}. The else part is not needed because hyperrefis loaded anyway.
    – user2478
    Commented Jan 3, 2013 at 9:15
  • Always the same error. The log has changed a bit: [pdfpagelabels,] There has now been an attempt to load it with options [pdftex,pdfa] Adding the global options: pdfpagelabels,,pdftex,pdfa
    – Lorenzo B
    Commented Jan 3, 2013 at 9:20
  • before you load pdfax do a \PassOptionsToPackage{pdfpagelabels}{hyperref} And do not use the option pdftex. Is the thesis.cls for download anywhere?
    – user2478
    Commented Jan 3, 2013 at 9:46
  • Well, Does pdfax is the same of pdfx? I tried to use \PassOptionsToPackage{pdfpagelabels}{hyperref} before documentclass, but no chance. I'm not using pdftex option anywhere. I searched in the class but I cannot find it. Now I'm compiling under Windows with pdfLatex. I didn't write the class, so I'm not sure I can share it. Thank you for your support.
    – Lorenzo B
    Commented Jan 3, 2013 at 9:56
3

Following @egreg comment

The package pdfx already loads hyperref; if you need to set other options for this one, use \hypersetup{options here}

I removed this code in the class file

\RequirePackage{ifpdf}
\ifpdf
  \RequirePackage[pdfpagelabels]{hyperref}
\else
  \RequirePackage{hyperref}
\fi

and in .tex file I did the following

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PDF/A
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[a-1b]{pdfx}
\hypersetup{pdfpagelabels}

Now it compiles and when I open it trough Adobe, it says me that is PDF/A compliant.

I think this works since I compile through PdfLaTex, but I'm not sure. I'm not an expert on this.

If exists a better solution, let me know. I will try it and remove the mark for my answer.

P.S. @Herbert, thank you for the support.

You must log in to answer this question.

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