我创建了一个非常简单的环境来在方程环境内显示一个文本框,因此它会得到一个方程编号(就像一个断言)。
当我使用环境时,下面的段落在第一个字符之前有一个小的额外空格。如果我复制环境代码而不是使用它,则不会出现问题。这个额外的空间来自哪里?
以下是代码:
\documentclass[reqno]{amsart}
\usepackage{lipsum, mathtools}
\newlength\claimlen
\setlength\claimlen{\textwidth-2cm}
\newenvironment{claim}
{% begin code
\begin{equation}
\begin{minipage}{\claimlen}
}%
{% end code
\end{minipage}
\end{equation}
}
\begin{document}
This is a test of a claim:
\begin{claim}
\lipsum[1]
\end{claim}
And this is the line after, which is supposed to not be indented at all but as
you can see there is a small space at the beginning.
Now the same, but without the environment:
\begin{equation}
\begin{minipage}{\claimlen}
\lipsum[1]
\end{minipage}
\end{equation}
And this is the line after, which is supposed to not be indented at all and in
this case there is really no spurious space at the beginning.
\end{document}
答案1
您正在添加两个空格
\end{equation}SPACE%
}
和
\end{claim}SPACE%
A
您需要不添加第一个并告诉 latex 忽略第二个
结束定义
\end{equation}% NO SPACE HERE
\ignorespacesafterend
}