![当我输入 \newtheorem{definition}{Definition}[section] 时,它无法编译!我猜这与我使用的包有关](https://linux22.com/image/342194/%E5%BD%93%E6%88%91%E8%BE%93%E5%85%A5%20%5Cnewtheorem%7Bdefinition%7D%7BDefinition%7D%5Bsection%5D%20%E6%97%B6%EF%BC%8C%E5%AE%83%E6%97%A0%E6%B3%95%E7%BC%96%E8%AF%91%EF%BC%81%E6%88%91%E7%8C%9C%E8%BF%99%E4%B8%8E%E6%88%91%E4%BD%BF%E7%94%A8%E7%9A%84%E5%8C%85%E6%9C%89%E5%85%B3.png)
%\documentclass[manuscript]{biometrika}
\documentclass[lineno]{biometrika}
\usepackage{amsmath}
%% Please use the following statements for
%% managing the text and math fonts for your papers:
\usepackage{times}
%\usepackage[cmbold]{mathtime}
\usepackage{bm}
\usepackage{natbib}
\usepackage[plain,noend]{algorithm2e}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage[T1]{fontenc}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{through}
\newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
\def\tikz@AngleOfLine(#1)(#2)#3{%
\pgfmathanglebetweenpoints{%
\pgfpointanchor{#1}{center}}{%
\pgfpointanchor{#2}{center}}
\pgfmathsetmacro{#3}{\pgfmathresult}%
}
\def\roundloop[#1]#2#3{%
\coordinate (rla) at (#2.east);
\path (#2)--++(#1) coordinate (rlb);
\tkzTgtFromP(#2,rla)(rlb)
\node (rlb) at (rlb) [circle through={(tkzFirstPointResult)}] {};
\coordinate (rlc) at (intersection 2 of #2 and rlb);
\coordinate (rld) at (intersection 1 of #2 and rlb);
\tikzAngleOfLine(rlb)(rld){\AngleStart}
\tikzAngleOfLine(rlb)(rlc){\AngleEnd}
\tikzAngleOfLine(#2)(rlb){\AngleLabel}
\ifdim\AngleStart pt<\AngleEnd pt
\draw[red,thick,->]%
let \p1 = ($ (rlb) - (rld) $), \n2 = {veclen(\x1,\y1)}
in
(rlb) ++(\AngleLabel:\n2) node[fill=white]{#3}
(rld) arc (\AngleStart:\AngleEnd:\n2);
\else
\draw[black,thick,->]%
let \p1 = ($ (rlb) - (rld) $), \n2 = {veclen(\x1,\y1)}
in
(rlb) ++(\AngleLabel:\n2) node[fill=white]{#3}
(rld) arc (\AngleStart-360:\AngleEnd:\n2);
\fi
}
\usetikzlibrary{shapes.multipart}
\makeatletter
\renewcommand{\algocf@captiontext}[2]{#1\algocf@typo. \AlCapFnt{}#2} % text of caption
\renewcommand{\AlTitleFnt}[1]{#1\unskip}% default definition
\def\@algocf@capt@plain{top}
\renewcommand{\algocf@makecaption}[2]{%
\addtolength{\hsize}{\algomargin}%
\sbox\@tempboxa{\algocf@captiontext{#1}{#2}}%
\ifdim\wd\@tempboxa >\hsize% % if caption is longer than a line
\hskip .5\algomargin%
\parbox[t]{\hsize}{\algocf@captiontext{#1}{#2}}% then caption is not centered
\else%
\global\@minipagefalse%
\hbox to\hsize{\box\@tempboxa}% else caption is centered
\fi%
\addtolength{\hsize}{-\algomargin}%
}
\makeatother
%%% User-defined macros should be placed here, but keep them to a minimum.
\def\Bka{{\it Biometrika}}
\def\AIC{\textsc{aic}}
\def\T{{ \mathrm{\scriptscriptstyle T} }}
\def\v{{\varepsilon}}
\begin{document}
\newtheorem{definition}{Definition}[section]
\begin{definition}
The \textit{moment generating function} (MGF) of a random variable $T$ is defined by
\begin{equation}
M_T(s)=E(e^{sT})=\int_{-\infty}^{+\infty}e^{st}f_T(t)dt,
\end{equation}
provided that $M_T$ exists for $s \in (-a,a)$ and some $a > 0$.
\end{definition}
\end{document]
答案1
这个答案使用了biometrika
来自的类(和相关文件)http://www.oxfordjournals.org/our_journals/biomet/for_authors/
MWE 中有一些错误,\end{document]
应该是\end{document}
,环境中的空白行equation
会导致错误。amsmath
包也被加载了两次。纠正这些错误并使用article
类而不是biometrika
将启用编译。
然而,该类biometrika
却引发了进一步的问题。biometrika
该类调用ntheorem
与以下程序包存在冲突amsthm
,删除amsthm
包留下了一个进一步的错误,即该definition
定理已经由biometrika
类定义,删除该行\newtheorem{definition}{Definition}[section]
允许编译(这是建议的,因为definition
环境将按照日志的要求出现)。
因此,使用以下示例,我能够编译 OP 的 MWE
%\documentclass[manuscript]{biometrika}
\documentclass[lineno]{biometrika}
\usepackage{amsmath}
%% Please use the following statements for
%% managing the text and math fonts for your papers:
\usepackage{times}
%\usepackage[cmbold]{mathtime}
\usepackage{bm}
\usepackage{natbib}
\usepackage[plain,noend]{algorithm2e}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage[T1]{fontenc}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{through}
\newcommand{\tikzAngleOfLine}{\tikz@AngleOfLine}
\def\tikz@AngleOfLine(#1)(#2)#3{%
\pgfmathanglebetweenpoints{%
\pgfpointanchor{#1}{center}}{%
\pgfpointanchor{#2}{center}}
\pgfmathsetmacro{#3}{\pgfmathresult}%
}
\def\roundloop[#1]#2#3{%
\coordinate (rla) at (#2.east);
\path (#2)--++(#1) coordinate (rlb);
\tkzTgtFromP(#2,rla)(rlb)
\node (rlb) at (rlb) [circle through={(tkzFirstPointResult)}] {};
\coordinate (rlc) at (intersection 2 of #2 and rlb);
\coordinate (rld) at (intersection 1 of #2 and rlb);
\tikzAngleOfLine(rlb)(rld){\AngleStart}
\tikzAngleOfLine(rlb)(rlc){\AngleEnd}
\tikzAngleOfLine(#2)(rlb){\AngleLabel}
\ifdim\AngleStart pt<\AngleEnd pt
\draw[red,thick,->]%
let \p1 = ($ (rlb) - (rld) $), \n2 = {veclen(\x1,\y1)}
in
(rlb) ++(\AngleLabel:\n2) node[fill=white]{#3}
(rld) arc (\AngleStart:\AngleEnd:\n2);
\else
\draw[black,thick,->]%
let \p1 = ($ (rlb) - (rld) $), \n2 = {veclen(\x1,\y1)}
in
(rlb) ++(\AngleLabel:\n2) node[fill=white]{#3}
(rld) arc (\AngleStart-360:\AngleEnd:\n2);
\fi
}
\usetikzlibrary{shapes.multipart}
\makeatletter
\renewcommand{\algocf@captiontext}[2]{#1\algocf@typo. \AlCapFnt{}#2} % text of caption
\renewcommand{\AlTitleFnt}[1]{#1\unskip}% default definition
\def\@algocf@capt@plain{top}
\renewcommand{\algocf@makecaption}[2]{%
\addtolength{\hsize}{\algomargin}%
\sbox\@tempboxa{\algocf@captiontext{#1}{#2}}%
\ifdim\wd\@tempboxa >\hsize% % if caption is longer than a line
\hskip .5\algomargin%
\parbox[t]{\hsize}{\algocf@captiontext{#1}{#2}}% then caption is not centered
\else%
\global\@minipagefalse%
\hbox to\hsize{\box\@tempboxa}% else caption is centered
\fi%
\addtolength{\hsize}{-\algomargin}%
}
\makeatother
%%% User-defined macros should be placed here, but keep them to a minimum.
\def\Bka{{\it Biometrika}}
\def\AIC{\textsc{aic}}
\def\T{{ \mathrm{\scriptscriptstyle T} }}
\def\v{{\varepsilon}}
\begin{document}
\begin{definition}
The \textit{moment generating function} (MGF) of a random variable $T$ is defined by
\begin{equation}
M_T(s)=E(e^{sT})=\int_{-\infty}^{+\infty}e^{st}f_T(t)dt,
\end{equation}
provided that $M_T$ exists for $s \in (-a,a)$ and some $a > 0$.
\end{definition}
\end{document}
这ntheorem
软件包宣称它可以与amsth
通过将amsthm
选项传递给ntheorem
包裹 (amsthm
不应为此加载)。这可以传递给ntheorem
通过放置\PassOptionsToPackage{amsthm}{ntheorem}
在前面\documentclass
,尽管这似乎没有必要使 OP 给出的代码可编译。