我今天看到了一个非常有趣的案例,其中子部分由阴影环境开始
\documentclass{amsbook}%{amsart}
\usepackage{xcolor}
\usepackage{framed}
\newtheorem{theorem}{Theorem}[section]
\newenvironment{Shaded}{%
\def\FrameCommand{\fboxsep1pt \colorbox{shadecolor}}%
\MakeFramed {\FrameRestore}}%
{\endMakeFramed}
\newenvironment{ShadedTheorem}
{
\definecolor{shadecolor}{rgb}{.94,.96,.94}%
\begin{Shaded}%
\begin{theorem}%
}{%
\end{theorem}%
\end{Shaded}%
}
\begin{document}
\subsection{Bad Subsection}
\begin{ShadedTheorem}
Bad Theorem: is moved
\end{ShadedTheorem}
\subsection{Okay without shading}
\begin{theorem}
Good theorem
\end{theorem}
\subsection{Subsection with text first}
Okay if shaded theorem is not the first object
\begin{ShadedTheorem}
Theorem Statement
\end{ShadedTheorem}
\subsection{Subsection with space first OK}~
\begin{ShadedTheorem}
Theorem Statement
\end{ShadedTheorem}
\subsection{Subsection with \texttt{\textbackslash par} first: not okay}\par
\begin{ShadedTheorem}
Theorem Statement
\end{ShadedTheorem}
\subsection{Subsection, leave vertical mode first, then enter vertical mode again.}\leavevmode\par
\begin{ShadedTheorem}
Theorem Statement
\end{ShadedTheorem}
\end{document}
在所有情况下,阴影定理都应出现在章节标题之后。但输出结果并非如此。
总的来说,正如你所见,有办法解决。然而,有人可能会看到类似的情况并需要一些解决方案。也可能有与我发现的解决方案不同的解决方案