使用 macos 和 overleaf 编译时可以编译文档,但在基于 linux 的系统上编译时会失败

使用 macos 和 overleaf 编译时可以编译文档,但在基于 linux 的系统上编译时会失败

我无法仅在 Linux 机器上编译测验文档。我的代码如下:

%% Language and font encodings
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}

%% Sets page size and margins
\usepackage[a4paper,margin=1cm]{geometry}

%% Useful packages
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{paralist}
\setlength\FrameSep{4pt}


\begin{document}
\vspace{5mm}
\begin{center}
\fbox{\fbox{\parbox{2in}{\centering
Quiz 1}}}

\vspace{5mm}

\makebox[\textwidth]{Name:\enspace\hrulefill}
\vspace{5mm}
\makebox[\textwidth]{Section:\enspace\hrulefill}
%questions being here

\begin{questions}
    \question[2]{Sample Question}
    \begin{framed}
        \begin{compactenum}[a.]
        \item option 1.
        \item Option 2.
        \item option 3.
        \item none of the above.
        \end{compactenum}
\end{framed}
\end{questions}
\end{center}
\end{document} 

此代码可在 Mac 系统以及 Overleaf 等在线服务上编译,但在 Linux 系统上会失败。错误文件如下

This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
(./newQuizCopy.tex
LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 84 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/exam/exam.cls
Document Class: exam 2017/12/17 Version 2.603 by Philip Hirschhorn
(/usr/share/texlive/texmf-dist/tex/latex/base/ifthen.sty)
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo)))
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.sty
(/usr/share/texlive/texmf-dist/tex/generic/babel/switch.def)
(/usr/share/texlive/texmf-dist/tex/generic/babel-english/english.ldf
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.def
(/usr/share/texlive/texmf-dist/tex/generic/babel/txtbabel.def))))
(/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/ucs/utf8x.def))
(/usr/share/texlive/texmf-dist/tex/latex/ucs/ucs.sty
(/usr/share/texlive/texmf-dist/tex/latex/ucs/data/uni-global.def))
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.def))
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/dvips.def)))
(/usr/share/texlive/texmf-dist/tex/latex/paralist/paralist.sty)

! LaTeX Error: Missing \begin{document}.

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


l.15 \setlength\FrameSep{4pt}

文件log显示

This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=latex 2018.10.31)  27 FEB 2019 23:07
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**newQuizCopy.tex
(./newQuizCopy.tex
LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 84 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/exam/exam.cls
Document Class: exam 2017/12/17 Version 2.603 by Philip Hirschhorn
(/usr/share/texlive/texmf-dist/tex/latex/base/ifthen.sty
Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
)
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
)
\c@part=\count79
\c@section=\count80
\c@subsection=\count81
\c@subsubsection=\count82
\c@paragraph=\count83
\c@subparagraph=\count84
\c@figure=\count85
\c@table=\count86
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
\@extrawidth=\skip43
\@rightmargin=\skip44
\@extrahead=\skip45
\@extrafoot=\skip46
\run@exhd=\skip47
\fp@exhd=\skip48
\run@exft=\skip49
\fp@exft=\skip50
\covrun@exhd=\skip51
\covfp@exhd=\skip52
\covrun@exft=\skip53
\covfp@exft=\skip54
\c@num@coverpages=\count87
\c@latest@ques=\count88
\c@ques@end=\count89
\c@last@object=\count90
\c@incmp@ques=\count91
\c@next@ques=\count92
\c@next@page=\count93
\c@tmp@hlfcntr=\count94
\c@ifpos@cntr=\count95
\c@question=\count96
\c@partno=\count97
\c@subpart=\count98
\c@subsubpart=\count99
\c@choice=\count100
\c@numpoints=\count101
\c@numbonuspoints=\count102
\c@pointsof@thisquestion=\count103
\c@bonuspointsof@thisquestion=\count104
\c@numquestions=\count105
\c@numparts=\count106
\c@numsubparts=\count107
\c@numsubsubparts=\count108
\c@Curr@Page=\count109
\c@@pagepoints=\count110
\c@@pagebonuspoints=\count111
\c@pageof@pagepoints=\count112
\c@pageof@pagebonuspoints=\count113
\c@latest@points=\count114
\c@latest@bonuspoints=\count115
\pageinfo@commands=\toks14
\temp@toks=\toks15
\pagepoint@commands=\toks16
\point@toks=\toks17
\c@ques@object=\count116
\marginpointssep=\skip55
\rightpointsmargin=\skip56
\choice@toks=\toks18
\answerlinelength=\skip57
\answerskip=\skip58
\answerclearance=\skip59
\fillinlinelength=\skip60
\linefillheight=\skip61
\linefillthickness=\skip62
\dottedlinefillheight=\skip63
\gridsize=\skip64
\gridlinewidth=\skip65
\minboxheight=\skip66
\c@@iterator=\count117
\@cellwidth=\skip67
\c@tbl@points=\count118
\c@tbl@bonuspoints=\count119
\c@pq@index=\count120
\c@pq@index@pts=\count121
\c@pq@index@bpts=\count122
\c@num@cols=\count123
\c@num@rows=\count124
\c@current@row=\count125
\c@cols@done=\count126
\exam@box=\box26
\saved@totalleftmargin=\dimen103
\@sollistdepth=\count127
\exam@FrameRule=\dimen104
\exam@FrameSep=\dimen105
)
(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.sty
Package: babel 2018/02/14 3.18 The Babel package

(/usr/share/texlive/texmf-dist/tex/generic/babel/switch.def
File: switch.def 2018/02/14 3.18 Babel switching mechanism
)
(/usr/share/texlive/texmf-dist/tex/generic/babel-english/english.ldf
Language: english 2017/06/06 v3.3r English support from the babel system

(/usr/share/texlive/texmf-dist/tex/generic/babel/babel.def
File: babel.def 2018/02/14 3.18 Babel common definitions
\babel@savecnt=\count128
\U@D=\dimen106

(/usr/share/texlive/texmf-dist/tex/generic/babel/txtbabel.def)
\bbl@dirlevel=\count129
)
\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/latex/base/inputenc.sty
Package: inputenc 2015/03/17 v1.2c Input encoding file
\inpenc@prehook=\toks19
\inpenc@posthook=\toks20

(/usr/share/texlive/texmf-dist/tex/latex/ucs/utf8x.def
File: utf8x.def 2004/10/17 UCS: Input encoding UTF-8
))
(/usr/share/texlive/texmf-dist/tex/latex/ucs/ucs.sty
Package: ucs 2013/05/11 v2.2 UCS: Unicode input support

(/usr/share/texlive/texmf-dist/tex/latex/ucs/data/uni-global.def
File: uni-global.def 2013/05/13 UCS: Unicode global data
)
\uc@secondtry=\count130
\uc@combtoks=\toks21
\uc@combtoksb=\toks22
\uc@temptokena=\toks23
)
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty
Package: fontenc 2017/04/05 v2.0i Standard LaTeX package

(/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.def
File: t1enc.def 2017/04/05 v2.0i Standard LaTeX file
LaTeX Font Info:    Redeclaring font encoding T1 on input line 48.
))
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
Package: geometry 2010/09/12 v5.6 Page Geometry

(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks24
)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty
Package: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch
)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty
Package: ifvtex 2016/05/16 v1.6 Detect VTeX and its facilities (HO)
Package ifvtex Info: VTeX not detected.
)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty
Package: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional
)
\Gm@cnth=\count131
\Gm@cntv=\count132
\c@Gm@tempcnt=\count133
\Gm@bindingoffset=\dimen107
\Gm@wd@mp=\dimen108
\Gm@odd@mp=\dimen109
\Gm@even@mp=\dimen110
\Gm@layoutwidth=\dimen111
\Gm@layoutheight=\dimen112
\Gm@layouthoffset=\dimen113
\Gm@layoutvoffset=\dimen114
\Gm@dimlist=\toks25
)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
Package: amsmath 2017/09/02 v2.17a AMS math features
\@mathmargin=\skip68

For additional information on amsmath, use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
Package: amstext 2000/06/29 v2.01 AMS text

(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty
File: amsgen.sty 1999/11/30 v2.0 generic functions
\@emptytoks=\toks26
\ex@=\dimen115
))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty
Package: amsbsy 1999/11/29 v1.2d Bold Symbols
\pmbraise@=\dimen116
)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty
Package: amsopn 2016/03/08 v2.02 operator names
)
\inf@bad=\count134
LaTeX Info: Redefining \frac on input line 213.
\uproot@=\count135
\leftroot@=\count136
LaTeX Info: Redefining \overline on input line 375.
\classnum@=\count137
\DOTSCASE@=\count138
LaTeX Info: Redefining \ldots on input line 472.
LaTeX Info: Redefining \dots on input line 475.
LaTeX Info: Redefining \cdots on input line 596.
\Mathstrutbox@=\box27
\strutbox@=\box28
\big@size=\dimen117
LaTeX Font Info:    Redeclaring font encoding OML on input line 712.
LaTeX Font Info:    Redeclaring font encoding OMS on input line 713.
\macc@depth=\count139
\c@MaxMatrixCols=\count140
\dotsspace@=\muskip10
\c@parentequation=\count141
\dspbrk@lvl=\count142
\tag@help=\toks27
\row@=\count143
\column@=\count144
\maxfields@=\count145
\andhelp@=\toks28
\eqnshift@=\dimen118
\alignsep@=\dimen119
\tagshift@=\dimen120
\tagwidth@=\dimen121
\totwidth@=\dimen122
\lineht@=\dimen123
\@envbody=\toks29
\multlinegap=\skip69
\multlinetaggap=\skip70
\mathdisplay@stack=\toks30
LaTeX Info: Redefining \[ on input line 2817.
LaTeX Info: Redefining \] on input line 2818.
)
(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty
Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)

(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty
Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)

(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
)
(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: dvips.def on input line 99.

(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/dvips.def
File: dvips.def 2017/06/20 v3.1d Graphics/color driver for dvips
))
\Gin@req@height=\dimen124
\Gin@req@width=\dimen125
)
(/usr/share/texlive/texmf-dist/tex/latex/paralist/paralist.sty
Package: paralist 2017/01/22 v2.7 Extended list environments
\pltopsep=\skip71
\plpartopsep=\skip72
\plitemsep=\skip73
\plparsep=\skip74
\pl@lab=\toks31
)

! LaTeX Error: Missing \begin{document}.

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

l.15 \setlength\FrameSep{4pt}

? X

Here is how much of TeX's memory you used:
 3770 strings out of 492983
 50639 string characters out of 6134921
 140557 words of memory out of 5000000
 7327 multiletter control sequences out of 15000+600000
 4403 words of font info for 15 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 29i,0n,32p,335b,37s stack positions out of 5000i,500n,10000p,200000b,80000s
No pages of output.

我是 LaTeX 的新手,所以请帮助我。

答案1

嗯,您没有在给定的代码中添加您正在使用 class exam。所以我\documentclass{exam}在以下 MWE 中添加了。如果您使用的是 special,对于问题相关的 class 选项,exam请将它们添加到您的问题中。

编译然后返回错误

! Undefined control sequence.
<argument> \FrameSep 

l.17 \setlength\FrameSep{4pt}

framed这意味着你错过了在序言中调用包

\usepackage{framed} 

以下完整的 MWE

\documentclass{exam} % <================================================
%% Language and font encodings
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}

%% Sets page size and margins
\usepackage[a4paper,margin=1cm]{geometry}

%% Useful packages
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{paralist}

\usepackage{framed} % <=================================================
\setlength\FrameSep{4pt}


\begin{document}
\vspace{5mm}
\begin{center}
\fbox{\fbox{\parbox{2in}{\centering
Quiz 1}}}

\vspace{5mm}

\makebox[\textwidth]{Name:\enspace\hrulefill}
\vspace{5mm}
\makebox[\textwidth]{Section:\enspace\hrulefill}
%questions being here

\begin{questions}
    \question[2]{Sample Question}
    \begin{framed}
        \begin{compactenum}[a.]
        \item option 1.
        \item Option 2.
        \item option 3.
        \item none of the above.
        \end{compactenum}
\end{framed}
\end{questions}
\end{center}
\end{document} 

结果是

生成的 pdf

相关内容