我正在使用 amsbook 包,但不喜欢定理和证明环境开头的缩进。
我已经尝试了提出的解决方案这里,并且它在缩进方面有效,但是,它似乎抑制了 amsbook 中类似定理的环境的字体,即\scshape
,相反,它显然切换回\bfseries
。
然而,该解决方案的作者声称他的方法确实适用于 amsbook。
我尝试插入
\patchcmd{\@begintheorem}{\scshape}{}{}{}
\patchcmd{\@opargbegintheorem}{\scshape}{}{}{}
手动,但仍然无济于事。
如果不想点击链接,可以参考以下建议的代码来删除缩进:
\makeatletter
\patchcmd\@thm
{\let\thm@indent\indent}{\let\thm@indent\noindent}%
{}{}
\makeatother
兼容代码:
\documentclass{amsbook}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage[top=1in, bottom=1.15in, left=1.15in, right=1.15in]{geometry}
\usepackage{etoolbox}
\makeatletter
\patchcmd\@thm
{\let\thm@indent\indent}{\let\thm@indent\noindent}%
{}{}
\patchcmd{\@begintheorem}{\scshape}{}{}{}
\patchcmd{\@opargbegintheorem}{\scshape}{}{}{}
\makeatother
\expandafter\patchcmd\csname\string\proof\endcsname
{\normalparindent}{0pt }{}{}
\expandafter\patchcmd\csname\string\theorem\endcsname
{\normalparindent}{0pt }{}{}
\usepackage{hyperref}
\hypersetup{
colorlinks = true,
urlcolor = blue,
linkcolor = blue,
citecolor = red
}
\usepackage{mathrsfs}
\usepackage{enumitem}
\renewcommand\labelenumi{(\theenumi)}
\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[chapter]
\begin{document}
\chapter{This is}
\begin{theorem}
This is a theorem.
\end{theorem}
\begin{proof}
Proof by contradiction. If it wasn't, then I wouldn't put it inside t
theorem environment.
\end{proof}
\end{document}
如果这个问题本质上很愚蠢,我深感抱歉,因为我对 LaTeX 还很陌生。
答案1
您可以使用钩子来更改缩进,而无需修补命令。在这里,我们在每个定理标题(命令)之前设置\thm@indent
为,并且由于 amsbook 的环境缩进为,我们将此维度本地设置为零。\noindent
\@begintheorem
proof
\normalparindent
\documentclass{amsbook}
\usepackage{kantlipsum}
\makeatletter
\AddToHook{cmd/@begintheorem/before}{\let\thm@indent\noindent}
\AddToHook{env/proof/begin}{\setlength{\normalparindent}{0pt}}
\makeatother
\theoremstyle{definition}
\newtheorem{theorem}{Theorem}[chapter]
\begin{document}
\chapter{This is}
\kant[1][1]
\begin{theorem}[heading]
This is a theorem.
\end{theorem}
\kant[2][1]
\begin{proof}
Proof by contradiction.
\end{proof}
\kant[3][1]
\end{document}
请注意,此解决方案特定于 AMS 类。