将 pdfpages 添加到当前类和/或 tex 文件时出现问题

将 pdfpages 添加到当前类和/或 tex 文件时出现问题

以下 .tex 脚本在我的计算机上完美运行:

\documentclass{report}
\usepackage[final]{pdfpages}
\begin{document}
\includepdf{Elanderphdmath.pdf}
\end{document}

然而,无论我把

\RequirePackage{pdfpages}

在类文件中,或者如果我把

\usepackage{pdfpages}

在使用类文件的主tex文件中,我得到了相同的错误,主要是

! Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...

这发生在一些通常不会出现问题的随机位置。同样,这些错误只是通过添加 \usepackage 或 \RequirePackage 命令而发生的。有没有人听说过这个包和其他包有冲突?我完全不知道它为什么不工作。提前谢谢!

更新 20110419 0955:我在 Windows 7 上使用 MikTex 2.9。我刚刚添加了 pdfpages 正常运行所需的所有软件包(我希望如此)。我假设这是真的,因为示例代码运行完美(见上文)。我有两个文件,类文件和主文件。这是类文件的标题:

\NeedsTeXFormat{LaTeX2e}[1995/12/01]     % Minimal LaTeX version required
\ProvidesClass{unlvmathesis}[2010/3/13 UNLV Math Thesis class v1.0]
\LoadClassWithOptions{report}

% REQUIRED PACKAGES ----------------------------------------------------------
% Note that they are also included as comments where they are used.

\RequirePackage{amsmath, amsthm, amsfonts, amssymb}
\RequirePackage{epsfig}
\RequirePackage{float}
\RequirePackage{caption}
\RequirePackage{geometry}
\RequirePackage{tocloft}
%\RequirePackage{hyperref}
\RequirePackage{pdfpages}

这是主 TEX 文档的标题:

\documentclass[12pt]{unlvmathesis}
%\usepackage{pdfpages}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{tocloft}
\usepackage{ulem}
\usepackage{wrapfig}
%\usepackage{subfig}
\usepackage{float,caption,array,multirow}
\usepackage{graphicx,graphics,epsfig,pictexwd}
\usepackage{rotating}
\usepackage{psfrag}
\usepackage{layout}
\usepackage{hyperref}
\usepackage{listings}

如果我可以提供更多有用的信息,请告诉我。

更新:下午 4:21。经过一番阅读,我发现 calc 包影响了 setcounter 函数。错误仅发生在 \section 位置。在类文件中,这是我看到的唯一与节编号相关的行:

\setcounter{secnumdepth}{1}    % SUBSECTIONS ARE NOT NUMBERED

也许 calc 包中有些东西未定义?是否所有东西都必须初始化?

下午 4:50 更新:在第一章的第一部分,我收到以下所有错误消息:

! Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...
l.4 \section{History of Metamaterials}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\@calc@post@scan ...fi \fi \fi \fi \fi \calc@next 

l.4 \section{History of Metamaterials}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...
l.4 \section{History of Metamaterials}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\@calc@post@scan ...fi \fi \fi \fi \fi \calc@next 

l.4 \section{History of Metamaterials}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Missing number, treated as zero.
<to be read again> 
                   \begingroup 
l.4 \section{History of Metamaterials}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Missing number, treated as zero.
<to be read again> 
                   \afterassignment 
l.4 \section{History of Metamaterials}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)


! Undefined control sequence.
\GenericError  ...                                
                                                  \let \@err@               ...
l.4 \section{History of Metamaterials}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Missing { inserted.
<to be read again> 
                   \let 
l.4 \section{History of Metamaterials}

A left brace was mandatory here, so I've put one in.
You might want to delete and/or insert some corrections
so that I will find a matching right brace soon.
(If you're confused by all this, try typing `I}' now.)

! Extra }, or forgotten \endgroup.
\@hangfrom #1->\setbox \@tempboxa \hbox {{#1}}
                                              \hangindent \wd \@tempboxa \no...
l.4 \section{History of Metamaterials}

I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.

! Extra }, or forgotten \endgroup.
\H@old@sect ...c }\interlinepenalty \@M #8\@@par }
                                                  \endgroup \csname #1mark\e...
l.4 \section{History of Metamaterials}

I've deleted a group-closing symbol because it seems to be
spurious, as in `$x}$'. But perhaps the } is legitimate and
you forgot something else, as in `\hbox{$x}'. In such cases
the way to recover is to insert both the forgotten and the
deleted material, e.g., by typing `I$}'.

! Missing number, treated as zero.
<to be read again> 
                   \begingroup 
l.4 \section{History of Metamaterials}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Undefined control sequence.
\@calc@post@scan ...st@scan \else \def \calc@next 
                                                  {\calc@error #1}\fi \fi \f...
l.4 \section{History of Metamaterials}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\@calc@post@scan ...fi \fi \fi \fi \fi \calc@next 

l.4 \section{History of Metamaterials}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Missing \endgroup inserted.
<inserted text> 
                \endgroup 
l.4 \section{History of Metamaterials}

I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.

! Missing number, treated as zero.
<to be read again> 
                   \vskip 
l.4 \section{History of Metamaterials}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Missing } inserted.
<inserted text> 
                }
l.4 \section{History of Metamaterials}

I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.

! Missing } inserted.
<inserted text> 
                }
l.4 \section{History of Metamaterials}

I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.

LaTeX Font Info:    Try loading font information for U+msa on input line 6.
("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\amsfonts\umsa.fd"
File: umsa.fd 2009/06/22 v3.00 AMS symbols A
)
LaTeX Font Info:    Try loading font information for U+msb on input line 6.

("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\amsfonts\umsb.fd"
File: umsb.fd 2009/06/22 v3.00 AMS symbols B
)

我在每个章节的每个 \section 中都收到相同的错误消息。所以,这与合并 Calc 包和章节有关。

答案1

我遇到了几乎同样的问题,解决方法建议http://web.archiveorange.com/archive/v/tMRBZ9hKeamEnltObBFi解决了!它与 calc 和 apacite 以及计数器的相互作用有关。

希望能帮助到你!

---根据建议编辑以包含解决方法--- 以下是上述链接中建议的解决方法的摘录。(对该帖子的进一步回复表明,最新版本的 apacite 应该考虑到这一点并解决这个问题。但我还没有测试过。)

================ 提取开始 ============================

我测试了您的示例,发现不兼容问题是由使用 calc.sty 包引起的……

更具体地说,calc.sty 改变了 \setcounter 的工作方式。apacite.sty 中的编程没有考虑到这一点。使用 \citet 和 natbib.sty 定义的其他 \cite 命令变体时会出现问题,因为它们需要进行大量额外的解析,而 LaTeX 在没有 natbib 的情况下无法进行解析。

这是一个似乎有效的简单修复方法:

\usepackage[tocbib]{apacite}
%%  ----  RRM  2008/10/03
%% for compatibility with calc.sty
%% we need an extra \protect as below before  \setcounter
%%
\renewcommand{\BCnt}[1]{\protect\setcounter{BibCnt}{#1}\protect
\theBibCnt}
\renewcommand{\BCntIP}[1]{\protect\setcounter{BibCnt}{#1}\mbox{- 
\protect\theBibCnt}}
\renewcommand{\BCntND}[1]{\protect\setcounter{BibCnt}{#1}\mbox{- 
\protect\theBibCnt}}
...

这样可以避免 \setcounter 过早地在实际未使用的地方展开。在它实际未使用的地方,一切仍然正常工作。必需的。

一个替代的解决方案,也许是一个更好的解决方案,就是首先使命令 \BCnt \BCntIP \BCntND 变得健壮;例如 apacite.sty 应该使用

\DeclareRobustCommand{\BCnt}[1]{\setcounter{BibCnt}{#1}\theBibCnt}
\DeclareRobustCommand{\BCntIP}[1]{\setcounter{BibCnt}{#1}\mbox{- \theBibCnt}}
\DeclareRobustCommand{\BCntND}[1]{\setcounter{BibCnt}{#1}\mbox{- \theBibCnt}}

您可以将此解决方案干净地修补到现有文档中,如下所示:

...
\DeclareRobustCommand{\robustBCnt}[1]{\setcounter{BibCnt}{#1}\theBibCnt}
\DeclareRobustCommand{\robustBCntIP}[1]{\setcounter{BibCnt}{#1}\mbox{- 
\theBibCnt}}
\DeclareRobustCommand{\robustBCntND}[1]{\setcounter{BibCnt}{#1}\mbox{- 
\theBibCnt}}
\let\BCnt\robustBCnt
\let\BCntIP\robustBCntIP
\let\BCntND\robustBCntND
 ...

================ 提取结束===========================

相关内容