# does not compile and gives LaTeX Error: Option clash for package inputenc

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{graphicx}
\usepackage{subcaption}
\usepackage{subfig}
\usepackage{multicol}
\usepackage{siunitx}
\usepackage{wrapfig}
\usepackage{amsmath}
\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}
[utf8]
There has now been an attempt to load it with options
[utf8x]
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


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{graphicx}
\usepackage{subcaption}
\usepackage{subfig}
\usepackage{multicol}
\usepackage{siunitx}
\usepackage{wrapfig}
\usepackage{hyperref}
\usepackage{amsmath}
\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

\end{enumerate}

\end{document}


• Welcome to TeX.SX! Could you please turn your code snippet into a minimal working example (MWE), a complete small example document that allows others to reproduce the issue you describe? – leandriis Aug 9 '19 at 18:53
• Most likely unrelated to the actual error message, but your cod will result in an error due to loading subcaption and subfig that are incompatible with each other. – leandriis Aug 9 '19 at 18:54
• Also, the excerpt of your log file contains quite some packages that are not part of the preamble that you included in your question. – leandriis Aug 9 '19 at 18:56
• leandriis should i remove subcaption in that case? also is it an issue that some packages aren't used? like will it cause issues? (i'm kind of new to latex and my code had been working fine but now that i had to troubleshoot i'm feeling way out of my league here. Any help would be welcome thanks) – Daniel Colalillo Aug 9 '19 at 19:00
• @Regarding subfig/subcaption: Decide which one you prefer to use and remove the other. Regarding the packages, I again suggest making a MWE. Make a copy of your document, comment out a part, recompile and see if the error persists. If so, repeat. Do the smae for the packages. This way, you can create the smallest document possible that still reproduces the issue. Edit your question to include this minimal document. – leandriis Aug 9 '19 at 19:02

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:

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

\usepackage{textcomp}
\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/} }

\begin{document}

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

\begin{enumerate}

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

\end{enumerate}

\end{document}

• well thanks for the help that seems to have fixed the issue for now. im still getting plenty of other issues when i put my code back but im going to try debugging myself before asking again. thanks again – Daniel Colalillo Aug 9 '19 at 19:56