KOMA 腳本和 amsthm 的 parskip 選項間距不一致

KOMA 腳本和 amsthm 的 parskip 選項間距不一致

這個問題類似於問題 25346,但是建議的解決方案並不能解決我的問題。

\documentclass[parskip=full]{scrreprt}

\usepackage{amsmath, amsthm}

\theoremstyle{definition}
\newtheorem{definition}{Definition}[chapter]

\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\begin{definition} 
In luctus mattis felis ac tristique.
\end{definition}

Nunc vulputate lectus at eros vehicula.

Aliquam fermentum eu justo in lobortis. 
\end{document}

產生不一致的間距:


在此輸入影像描述


添加

\begingroup
    \makeatletter
    \@for\theoremstyle:=definition,remark,plain\do{%
        \expandafter\g@addto@macro\csname th@\theoremstyle\endcsname{%
            \addtolength\thm@preskip\parskip
            }%
        }
\endgroup

到序言,如建議的問題 25346產生


在此輸入影像描述


但這個空間現在明顯大於段落跳過。我希望 text-to-theorem-skip 的大小與 parskip 的大小相同。謝謝!

答案1

您的程式碼在\parskip定義之前和之後基本上會產生兩個 s 。在定理之前,您可以\parskip透過使用\setlength而不是\addtolength在調整中設定間距\thm@preskip。因為在定理之後,相關數量是\thm@postskip,但這需要設定為零,因為\parskip無論如何都會有:

樣本輸出

\documentclass[parskip=full]{scrreprt}

\usepackage{amsmath, amsthm}

\begingroup
    \makeatletter
    \@for\theoremstyle:=definition,remark,plain\do{%
        \expandafter\g@addto@macro\csname th@\theoremstyle\endcsname{%
            \setlength\thm@preskip\parskip
            \setlength\thm@postskip{0pt}
            }%
        }
\endgroup

\theoremstyle{definition}
\newtheorem{definition}{Definition}[chapter]

\begin{document}
\show\definition

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\begin{definition} 
In luctus mattis felis ac tristique.
\end{definition}

Nunc vulputate lectus at eros vehicula.

Aliquam fermentum eu justo in lobortis. 

\end{document}

相關內容