我沒有寫 inputenc 兩次。至少我的主 tex 檔案中沒有它。我不確定是什麼原因導致此錯誤,並且可以使用一些幫助來排除故障。
這是我在文件開始之前寫的所有內容:
% -----------------------------------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----------------------------------------
這是我收到的錯誤:
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
所以我把範圍縮小到這一行。回滾到專案運行時並慢慢添加回更改後,這是導致程式碼無法編譯的行。
% -----------------------------------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}
答案1
您的文檔程式碼有幾個常見問題:
載入
hyperref
包最後的。有很少此規則的例外情況。 (該cleveref
套件是這些例外之一:它必須在 後加載hyperref
。)不要同時加載
subfig
和subcaption
。它們互不相容。只選其一,但不是兩者都。指令
\lstset{frame=, basicstyle={\footnotesize\ttfamily}
有故障。除了必須載入
listings
套件(您的程式碼無法執行的操作)之外,為了啟動\lstset
宏,指令應該是\lstset{frame=, basicstyle={\footnotesize\ttfamily}}
讓它發揮作用。您看得出來差別嗎?
不要
\bf
在 LaTeX 文件中使用 Plain-TeX 指令。代替使用\bfseries
。不要不必要地使用
{
and}
——它只會造成程式碼混亂。因此,代替\begin{center} {\large\bf{Abstract}} \end{center}
寫吧
\begin{center} \large\bf Abstract \end{center}
或者,更好的是,
\begin{center} \large\bfseries Abstract \end{center}
請檢查您是否確實需要加載所有這些包。我不禁產生這樣的印象:其中一些內容正在無緣無故地被加載。
實施上述建議後,得到的輸出如下:
\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}