代码在 ubuntu 中编译通过但在 win7 中无法运行

代码在 ubuntu 中编译通过但在 win7 中无法运行

我在 ubuntu 的 gedit 中输入我的论文并在终端中进行编译,一切运行正常,但现在由于某些原因,我在电脑上安装了 Windows 7,但相同的代码在 texmaker 中无法运行。当我编译我的代码时,我看到了这些错误。

错误-1-第 11 行 - 命令 \proof 已定义。

错误-2 第 22 行 - \qed 已经定义。

这是我的(示例)代码-

\documentclass{article}
\usepackage{graphicx}
\usepackage{amsmath,amsfonts,amssymb,amsthm,epsfig,epstopdf,titling,url,array}
\usepackage[a4paper, total={5in, 10in}]{geometry}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}

\newenvironment{proof}[1][Proof]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{definition}[1][Definition]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{example}[1][Example]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{remark}[1][Remark]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}

\newcommand{\qed}{\nobreak \ifvmode \relax \else
  \ifdim\lastskip<1.5em \hskip-\lastskip
  \hskip1.5em plus0em minus0.5em \fi \nobreak
  \vrule height0.75em width0.5em depth0.25em\fi}

\begin{document}

\title{An Introduction to Differential Algebra-(Notes)}
\author{Jagdeep Singh}

\maketitle
\section{GENERALITIES CONCERNING DIFFERENTIAL RINGS}

\subsection{Derivations}
\begin{definition} - A derivation of a ring A is an additive mapping $ a \mathbb{\to} a'$ of A into itself satisfying 

$$ (ab)' = a'b + ab' $$
\end{definition}

\end{document}

答案1

正如 barbara beeton 在评论中指出的那样,问题在于amsthm定义proof\qed。因此,当您加载amsthm然后有:

\newcommand{\qed}{\nobreak \ifvmode \relax \else
  \ifdim\lastskip<1.5em \hskip-\lastskip
  \hskip1.5em plus0em minus0.5em \fi \nobreak
  \vrule height0.75em width0.5em depth0.25em\fi}

这是个问题,因为

Command \qed already defined.

换句话说,\qed当命令\qed已经定义时,如何定义新命令?不能。你需要关于-定义它,因此:

\renewcommand{\qed}{\nobreak \ifvmode \relax \else
  \ifdim\lastskip<1.5em \hskip-\lastskip
  \hskip1.5em plus0em minus0.5em \fi \nobreak
  \vrule height0.75em width0.5em depth0.25em\fi}

相似地

\renewenvironment{proof}[1][Proof]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}

为我,

\documentclass{article}
\usepackage{graphicx}
\usepackage{amsmath,amsfonts,amssymb,amsthm,epsfig,epstopdf,titling,url,array}
\usepackage[a4paper, total={5in, 10in}]{geometry}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}

\renewenvironment{proof}[1][Proof]{\begin{trivlist}
    \item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{definition}[1][Definition]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{example}[1][Example]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{remark}[1][Remark]{\begin{trivlist}
\item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}

\renewcommand{\qed}{\nobreak \ifvmode \relax \else
  \ifdim\lastskip<1.5em \hskip-\lastskip
  \hskip1.5em plus0em minus0.5em \fi \nobreak
  \vrule height0.75em width0.5em depth0.25em\fi}

\begin{document}

\title{An Introduction to Differential Algebra-(Notes)}
\author{Jagdeep Singh}

\maketitle
\section{GENERALITIES CONCERNING DIFFERENTIAL RINGS}

\subsection{Derivations}
\begin{definition} - A derivation of a ring A is an additive mapping
  $ a \mathbb{\to} a'$ of A into itself satisfying

$$ (ab)' = a'b + ab' $$
\end{definition}

\end{document}

编译成功。

在此处输入图片描述

然而,您应该避免$$ ... $$在 LaTeX 中使用 而应使用 来代替它们\[ ... \]

您还应该删除显示等式前的空白行:

\begin{definition} - A derivation of a ring A is an additive mapping
  $ a \mathbb{\to} a'$ of A into itself satisfying    
  \[
    (ab)' = a'b + ab'
  \]
\end{definition}

\to我真的不明白你通过包装想要达到什么目的,\mathbb{}但你破坏了箭头周围的二进制间距,这是故意的吗?

相关内容