考虑以下 MWE,其中我试图proof
通过钩子更改环境的文本颜色env/proof/begin
。但是,在遵循定理类型环境时,使用\color
会提供额外的垂直空间。有什么方法可以修复此行为吗?
\documentclass{article}
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{blindtext}
\newtheorem{theorem}{Theorem}
\AddToHook{env/proof/begin}{\color{blue}}
\begin{document}
\begin{theorem}
\blindtext
\end{theorem}
\begin{proof}
\blindtext
\end{proof}
\end{document}
答案1
按照评论中 Ulrike Fischer 的建议:
\documentclass{article}
\usepackage{xcolor}
\usepackage{amsthm}
\usepackage{blindtext}
\usepackage{hyperref}
\newtheorem{theorem}{Theorem}
\makeatletter
\AddToHook{env/proof/begin}{%
\Hy@SaveLastskip
\color{blue}%
\Hy@RestoreLastskip
}
\makeatother
\begin{document}
\begin{theorem}
\blindtext
\end{theorem}
\begin{proof}
\blindtext
\end{proof}
\end{document}