[Tex/LaTex] does not compile and gives LaTeX Error: Option clash for package inputenc

compilation errorcompilingerrorsinput-encodings

I dont have inputenc written twice. at least i dont have it in my main tex file. i'm not sure what could be causing this error and could use some help in troubleshooting it.

heres everything i have writteh right before the document starts:

% -----------------------------------Initialize Document----------------------------------------
\documentclass[12pt]{article}  
\usepackage{textcomp}  
\usepackage[headheight=12pt, headsep=0pt, nohead, nofoot]{geometry}  
\usepackage{graphicx}  
\usepackage{subcaption}  
\usepackage{subfig}  
\usepackage{multicol}  
\usepackage{siunitx}  
\usepackage{wrapfig}  
\usepackage{amsmath}  
\usepackage[colorlinks]{hyperref}  
\usepackage[utf8]{inputenc}  
\usepackage{lipsum}  

\setlength{\footskip}{40pt}  

\DeclareSIUnit\gauss{G}  
\input{style/common.tex}  
\input{style/scala.tex}  
\lstset{frame=, basicstyle={\footnotesize\ttfamily}}  
\graphicspath{ {images/} }  


%-----------------------------------------Cover Page----------------------------------------  

and heres the error I'm getting:

 LaTeX Error: Option clash for package inputenc.  

See the LaTeX manual or LaTeX Companion for explanation.  
Type  H <return>  for immediate help.  
 ...                                                

l.2 \usepackage  
               [british,UKenglish]{babel}  
The package inputenc has already been loaded with options:  
  [utf8]  
There has now been an attempt to load it with options  
  [utf8x]  
Adding the global options:  
  utf8,utf8x  
to your \documentclass declaration may fix this.  
Try typing  <return>  to proceed.  

(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.sty  
Package: babel 2016/04/23 3.9r The Babel package  
(/usr/share/texlive/texmf-dist/tex/generic/babel-english/english.ldf  
Language: english 2012/08/20 v3.3p English support from the babel system  
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.def  
File: babel.def 2016/04/23 3.9r Babel common definitions  
\babel@savecnt=\count173  
\U@D=\dimen190  
)  
\l@canadian = a dialect from \language\l@american   
\l@australian = a dialect from \language\l@british   
\l@newzealand = a dialect from \language\l@british   
) (/usr/share/texlive/texmf-dist/tex/generic/babel-english/english.ldf  
Language: english 2012/08/20 v3.3p English support from the babel system  
)) (/usr/share/texlive/texmf-dist/tex/latex/graphics/color.sty  
Package: color 2016/07/10 v1.1e Standard LaTeX Color (DPC)  
(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/color.cfg  
File: color.cfg 2016/01/02 v1.6 sample color configuration  
)  
Package color Info: Driver file: pdftex.def on input line 147.  
) (/usr/share/texlive/texmf-dist/tex/latex/fancyref/fancyref.sty  
Package: fancyref 1999/02/03 v0.9c Fancy cross-referencing  
(/usr/share/texlive/texmf-dist/tex/latex/tools/varioref.sty  
Package: varioref 2016/02/16 v1.5c package for extended references (FMi)  
\c@vrcnt=\count174  
)) (/usr/share/texlive/texmf-dist/tex/latex/float/float.sty  
Package: float 2001/11/08 v1.3d Float enhancements (AL)  
\c@float@type=\count175  
\float@exts=\toks25  
\float@box=\box78  
\@float@everytoks=\toks26  
\@floatcapt=\box79  
) (/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrextend.sty  
Package: scrextend 2016/06/14 v3.21 KOMA-Script package (extend other classes   with features of KOMA-Script classes)  
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrkbase.sty  
Package: scrkbase 2016/06/14 v3.21 KOMA-Script package (KOMA-Script-dependent   basics and keyval usage)  
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrbase.sty  
Package: scrbase 2016/06/14 v3.21 KOMA-Script package (KOMA-Script-independent   basics and keyval usage)  
(/usr/share/texlive/texmf-dist/tex/latex/koma-script/scrlfile.sty  
Package: scrlfile 2016/06/14 v3.21 KOMA-Script package (loading files)  
Package scrlfile, 2016/06/14 v3.21 KOMA-Script package (loading files)  
                  Copyright (C) Markus Kohm  

so i narrowed it down to this one line. after rolling back to when the project was working and slowly adding back the changes this is the line causing the code not to compile.


% -----------------------------------Initialize Document----------------------------------------
\documentclass[12pt]{article}
\usepackage{textcomp}
\usepackage[headheight=12pt, headsep=0pt, nohead, nofoot]{geometry}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{subfig}
\usepackage{multicol}
\usepackage{siunitx}
\usepackage{wrapfig}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage[colorlinks]{hyperref}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}

\setlength{\footskip}{40pt}

\DeclareSIUnit\gauss{G}
\input{style/common.tex}
\input{style/scala.tex}
\lstset{frame=, basicstyle={\footnotesize\ttfamily}}
\graphicspath{ {images/} }


%-----------------------------------------Cover Page----------------------------------------
\begin{document}

%-----------------------------------------ABSTRACT-------------------------------------
\begin{center}
{\large\bf{Abstract}}
\end{center}
\begin{enumerate}

%this line
\item click on "\textbf{\textit{Manage Passwords}". 

\end{enumerate}

\end{document}



Best Answer

Your document's code suffers from several commonly-encountered problems:

  • Load the hyperref package last. There are very few exceptions to this rule. (The cleveref package is one of those exceptions: It must be loaded after hyperref.)

  • Don't load both subfig and subcaption. They are not mutually compatible. Choose only one or the other, but not both.

  • The instruction

    \lstset{frame=, basicstyle={\footnotesize\ttfamily}
    

    is faulty. Apart from having to load the listings package -- something your code fails to do -- in order to activate the \lstset macro, the instruction should be

    \lstset{frame=, basicstyle={\footnotesize\ttfamily}}
    

    for it to work. Can you spot the difference?

  • Don't use the Plain-TeX instruction \bf in a LaTeX document. Use \bfseries instead.

  • Don't use { and } needlessly -- it just creates code clutter. Thus, instead of

    \begin{center}
    {\large\bf{Abstract}}
    \end{center}
    

    just write

    \begin{center}
    \large\bf Abstract
    \end{center}
    

    or, better still,

    \begin{center}
    \large\bfseries Abstract
    \end{center}
    
  • Do check if you really need to load all those packages. I can't help getting the impression that some of them are being loaded for no discernible reason.

With the recommendations above put in place, this is the output one gets:

enter image description here

\documentclass[12pt]{article}
\usepackage[utf8]{inputenc} % it's usually a good idea to load this package early

\usepackage{textcomp}
\usepackage[headheight=12pt, headsep=0pt, nohead, nofoot]{geometry}
\usepackage{graphicx}

\usepackage{subcaption}
%\usepackage{subfig}

\usepackage{multicol}
\usepackage{siunitx}
\DeclareSIUnit\gauss{G}

\usepackage{wrapfig}
\usepackage{amsmath}

\usepackage{lipsum} % filler text

\setlength{\footskip}{40pt} % why??

% Commented out since I don't have the files 'common.tex' and 'scala.tex':
%\input{style/common.tex} 
%\input{style/scala.tex}

\usepackage{listings} % previously missing
\lstset{frame=, basicstyle={\footnotesize\ttfamily}}
\graphicspath{ {images/} }

\usepackage[colorlinks]{hyperref} % load this package LAST

\begin{document}

%--------------------------ABSTRACT---------------------
\begin{center}
\large\bfseries Abstract 
\end{center}

\begin{enumerate}

\item Click on ``\textbf{\textit{Manage Passwords}}''

\end{enumerate}

\end{document}