0

I have a class file in my LaTeX project. When I include the package \usepackage{hyperref} I get the following error:

LaTeX Error: Option clash for package inputenc.

The cls file:

% http://ctan.mirrors.hoobly.com/macros/latex/doc/clsguide.pdf
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{SCmastersthesis}[2021/11/30 SC Master''s Thesis class]

\LoadClass[12pt, a4paper, openright]{report}

% Usefull packages
\usepackage[arabic, french, english]{babel}
\usepackage[cp1256,cp1256,cp1256,cp1256,utf8x]{inputenc}
\usepackage[hidelinks]{hyperref}
\usepackage{float}
\usepackage{subfigure}
\usepackage{amsmath}
\usepackage{lscape}
\usepackage{amssymb}
\usepackage{import}
\usepackage{enumerate}


\RequirePackage{microtype}   % Improves typography
\RequirePackage[T1]{fontenc}
\RequirePackage{lmodern}
\RequirePackage[pdftex]{graphicx}
\RequirePackage{color}
\RequirePackage{geometry}
\RequirePackage{tabto}       % Tabulation
\RequirePackage{anyfontsize} % size of fonts
% For all sorts of hyperlinks in the PDF output.

% Commands for title, readers, authors, dates, specialities,...
\RequirePackage{etoolbox}
\newcommand{\subtitle}[1]{\def\@subtitle{#1}}
\newcommand{\secondauthor}[1]{\def\@secondauthor{#1}}
\newcommand{\thirdauthor}[1]{\def\@thirdauthor{#1}}
\newcommand{\supervisor}[1]{\def\@supervisor{#1}}
\newcommand{\secondsupervisor}[1]{\def\@secondsupervisor{#1}}
\newcommand{\thirdsupervisor}[1]{\def\@thirdsupervisor{#1}}
\newcommand{\degreetitle}[1]{\def\@degreetitle{#1}}
\newcommand{\options}[1]{\def\@myoptions{#1}}
\newcommand{\readerone}[1]{\def\@readerone{#1}}
\newcommand{\readertwo}[1]{\def\@readertwo{#1}}
\newcommand{\readerthree}[1]{\def\@readerthree{#1}}
\newcommand{\readerfour}[1]{\def\@readerfour{#1}}
\newcommand{\readerfive}[1]{\def\@readerfive{#1}}
\newcommand{\years}[1]{\def\@years{#1}}

% Lenghts
\newlength{\tabAuthor}
\newlength{\tabSupervisor}
\newlength{\tabReader}

% Title creation
\renewcommand{\maketitle}{
  \begin{titlepage}
    \thispagestyle{empty}
    \newgeometry{top=0cm,bottom=0cm,left=3cm,right=2.5cm}
    
    % background
    \noindent \hspace{-3cm} 
    \includegraphics{_frontbanner_SC-master-thesis_3.pdf}\\
    \vspace*{-\textheight}
    
    % Font
    \color{white} \fontfamily{phv} \selectfont
    
    % Define lengths
    \setlength{\tabAuthor}{
        \ifdef{\@secondauthor}{1.7cm}{1.6cm}
    }
    \setlength{\tabSupervisor}{
        \ifdef{\@secondsupervisor}{2.55cm}{2.45cm}
    }
    \setlength{\tabReader}{
        \ifdef{\@readertwo}{1.9cm}{1.8cm}
    }    
    
    \vspace*{9cm}
    
    % Title and subtitle
    \noindent
    \begin{minipage}[t][10cm][c]{1\textwidth}
    \raggedright
    %\vspace*{2cm}
    {
      \fontsize{26}{36}\selectfont \textbf{\@title}
      
      \vspace*{12pt}
      
      \ifdef{\@subtitle}{\fontsize{20}{30} \selectfont \@subtitle}{$ $} \\
    } 
    \end{minipage}
    
    
    % Metadata
    \vspace*{4cm}
    \noindent \hspace{1.7cm}
    \begin{minipage}[l]{.85\textwidth}
      % authors
      \ifdef{\@secondauthor}{Auteurs:}{Auteur:}{\bfseries
        \tabto{\tabAuthor}\@author
        \ifdef{\@secondauthor}{, \@secondauthor}{}
        \ifdef{\@thirdauthor}{, \@thirdauthor}{}}
      \\
      % supervisors
      \ifdef{\@secondsupervisor}{Promoteurs:}{Promoteur:}{\bfseries
        \tabto{\tabSupervisor}\@supervisor
        \ifdef{\@secondsupervisor}{, \@secondsupervisor}{}\ifdef{\@thirdsupervisor}{, \@thirdsupervisor}{}}
      \\
      % readers
      \ifdef{\@readertwo}{Lecteurs:}{Lecteur:}{\bfseries
        \tabto{\tabReader}\@readerone
        \ifdef{\@readertwo}{, \@readertwo}{}\ifdef{\@readerthree}{, \@readerthree}{}\ifdef{\@readerfour}{, \@readerfour}{}\ifdef{\@readerfive}{, \@readerfive}{}}
      \\
      % academic year
      Année académique \@years
      \\
      % degree title
      \@degreetitle      
    \end{minipage}
  \end{titlepage}
}

% Front cover page
\newcommand{\frontpage}
{
  \begin{titlepage}
  \end{titlepage}
}

% Back cover page
\newcommand{\backcoverpage}
{
  \newpage
  \thispagestyle{empty}
  \newgeometry{top=0cm,bottom=0cm,left=0cm,right=0cm}
  \includegraphics{_backbanner_SC-master-thesis.pdf}

}

\endinput
7
  • 4
    what do you intend \usepackage[cp1256,cp1256,cp1256,cp1256,utf8x]{inputenc} to do?? It can not do anythig useful, a file can only be in one encoding at a time, and utf-8 is the default, so just delete the whole line. Aug 20, 2022 at 11:44
  • Thank you , but that doesn't resolve the problem
    – userB
    Aug 20, 2022 at 11:45
  • But the problem occurs only when I add the instruction : \usepackage{hyperref}
    – userB
    Aug 20, 2022 at 11:53
  • No it shows hyperref but only becuse that is on the following line, delete the inputec line and the error will go (I just tried your class) Aug 20, 2022 at 11:54
  • your class already loads hyperref, so why are you trying to add hyperref again? Aug 20, 2022 at 11:59

1 Answer 1

1

Given a test file

\documentclass{SCmastersthesis}

\begin{document}

a
\end{document}

You get

! LaTeX Error: Option clash for package inputenc.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.10 \usepackage
                [hidelinks]{hyperref}
? 

But hyperref is not involved here, in fact the linebreak in the message shows [hidelinks]{hyperref} has not even been read yet.

The error is on the previous line

\usepackage[cp1256,cp1256,cp1256,cp1256,utf8x]{inputenc}

Which could never do anything useful, and can simply be deleted. Without this line the example runs without error

6
  • hm, one get the clash because arabic loads inputenc with cp1256 so simply removing the line means that the document is read as cp1256. One should probably switch the encoding, but this could break arabic ... Aug 20, 2022 at 12:14
  • I think one must load \usepackage[utf8]{inputenc} before arabic, then it won't try to load it itself. Aug 20, 2022 at 12:26
  • @UlrikeFischer the class shouldn't be specifying the document encoding anyway Aug 20, 2022 at 12:40
  • the problem is \usepackage[arabic]{babel} which will load inputenc. (arabic.ldf contains \@ifpackageloaded{inputenc}{}{\RequirePackage[cp1256]{inputenc}}}` Aug 20, 2022 at 12:44
  • @UlrikeFischer the class shouldn't be setting the document language either:-) Aug 20, 2022 at 12:48

You must log in to answer this question.

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