AMSTHM 包的章节

AMSTHM 包的章节

在撰写论文提交报告时,我将各章分成了单独的.tex文件,但我必须amsthm在各章中使用包。我将包包含在主.tex文件中,但不起作用;我也尝试将包包含在各个章节中,但仍然不起作用。有人可以指导我吗?

在主文件中,我使用命令输入章节

\input{chapters/chapter_1}

chapter_1.tex必须写出该定理的证明。

我使用了包,main.tex但它在那里不起作用。所以我将包包含在chapter_1.tex(第 1 章文件的名称.tex)中,但显示的消息是“只能在序言中使用”。

主文件

\documentclass[12pt]{report}
\usepackage[utf8]{inputenc}
\title{Sample}

\begin{document}
\maketitle


\input{sample_1}

\end{document}

以下是该章节的代码

\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}

\usepackage{amsthm}

\begin{lemma}
Lemma statement.
\end{lemma}

\begin{proof}
Suppose D is a $(v, k, \lambda)$-difference set. There are $k(k-1)$ ordered
pairs $(r_1, r_2)$, with $r_1$, $r_2$ distinct elements of $D$, and therefore $k(k-1)$ differences $r_1$ - $r_2$ in the multiset $\Delta$. However, since $D$ is a difference set, each of the $v - 1$ non-identity elements of $G$ appears
exactly $\lambda$ times among the elements listed in $\Delta$. 
\end{proof}
````

答案1

好吧,让我们首先用给定的代码片段构建一个 MWE:

\documentclass[12pt]{report}

\usepackage[utf8]{inputenc}
\title{Sample}


\begin{document}
\maketitle

%\input{sample_1}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}

\usepackage{amsthm}

\begin{lemma}
Lemma statement.
\end{lemma}

\begin{proof}
Suppose D is a $(v, k, \lambda)$-difference set. There are $k(k-1)$ ordered
pairs $(r_1, r_2)$, with $r_1$, $r_2$ distinct elements of $D$, and therefore $k(k-1)$ differences $r_1$ - $r_2$ in the multiset $\Delta$. However, since $D$ is a difference set, each of the $v - 1$ non-identity elements of $G$ appears
exactly $\lambda$ times among the elements listed in $\Delta$. 
\end{proof}

\end{document}

这导致第一个错误:

! LaTeX Error: Can be used only in preamble.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.15 \usepackage
                {amsthm}
Your command was ignored.
Type  I <command> <return>  to replace it with another command,
or  <return>  to continue without it.

正如您在第 15 行中看到的,错误是:命令\usepackage只能在序言中使用。因此,让我们将其移到序言中:

\documentclass[12pt]{report}

\usepackage[utf8]{inputenc}
\usepackage{amsthm}

\title{Sample}


\begin{document}
\maketitle

%\input{sample_1}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}

\begin{lemma}
Lemma statement.
\end{lemma}

\begin{proof}
Suppose D is a $(v, k, \lambda)$-difference set. There are $k(k-1)$ ordered
pairs $(r_1, r_2)$, with $r_1$, $r_2$ distinct elements of $D$, and therefore $k(k-1)$ differences $r_1$ - $r_2$ in the multiset $\Delta$. However, since $D$ is a difference set, each of the $v - 1$ non-identity elements of $G$ appears
exactly $\lambda$ times among the elements listed in $\Delta$. 
\end{proof}

\end{document}

它编译时出现一个警告(正确,没有给出作者!)并且没有错误。

最好将theoremcorollary和的定义移到lema序言中,这样我们就可以在所有章节中使用这些定义……

因此我们得到最终的代码:

\documentclass[12pt]{report}

\usepackage[utf8]{inputenc}
\usepackage{amsthm} % <=================================================
\newtheorem{theorem}{Theorem}[section]
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma} % <==================================

\title{Sample}


\begin{document}
\maketitle

%\input{sample_1}
\begin{lemma}
Lemma statement.
\end{lemma}

\begin{proof}
Suppose D is a $(v, k, \lambda)$-difference set. There are $k(k-1)$ ordered
pairs $(r_1, r_2)$, with $r_1$, $r_2$ distinct elements of $D$, and therefore $k(k-1)$ differences $r_1$ - $r_2$ in the multiset $\Delta$. However, since $D$ is a difference set, each of the $v - 1$ non-identity elements of $G$ appears
exactly $\lambda$ times among the elements listed in $\Delta$. 
\end{proof}

\end{document}

得到第二个 pdf 页的结果:

第二页

相关内容