如何避免定理和插入标题之间出现空行

如何避免定理和插入标题之间出现空行

我在将自定义部分样式与定理环境相结合时遇到了一些麻烦。如何防止定理将部分的第一行留空?这是我的代码和当前输出。

\documentclass[a5paper, 10pt]{article}

\usepackage[showframe]{geometry}
\usepackage[latin]{babel}
\usepackage{stix2}
\usepackage{xparse}
\usepackage{amsthm}
\usepackage{thmtools}

\makeatletter
\NewDocumentCommand\mysection{m}{
    \@startsection
        {paragraph}{2}{\z@}
        {3.25ex \@plus 1ex \@minus .2ex}
        {\z@}
        {\normalfont\normalsize}*
        {\makebox[0pt][r]{(#1)\hspace\labelsep}}
}
\makeatother

\declaretheorem[name=Theorema]{theorem}

\begin{document}
\mysection{A}
Sed ornare non felis in hendrerit. Maecenas eros est, consequat ac tellus non, aliquam ultrices dui.

\mysection{B}
\begin{theorem}
    Etiam ipsum erat, tristique sit amet ante non, porta iaculis odio. Ut tempus suscipit urna, in semper arcu mollis nec
    \[
        1 + 1 = 2.
    \]
\end{theorem}

\begin{theorem} $1 \ne 0$.
\end{theorem}
\begin{proof}
\dots
\end{proof}
\end{document}

在此处输入图片描述

答案1

这是一个解决方案。

\documentclass[a5paper, 10pt]{article}

\usepackage[showframe]{geometry}
\usepackage[latin]{babel}
%\usepackage{stix2}
\usepackage{xparse}
\usepackage{amsthm}
\usepackage{thmtools}

\makeatletter
\NewDocumentCommand\mysection{m}{
    \@startsection
        {paragraph}{2}{\z@}
        {3.25ex \@plus 1ex \@minus .2ex}
        {\z@}
        {\normalfont\normalsize}*
        {\makebox[0pt][r]{(#1)\hspace\labelsep}}
}
\newcommand{\compress}{@minipagetrue}
\makeatother

\declaretheorem[name=Theorema]{theorem}

\begin{document}

\mysection{A}
Sed ornare non felis in hendrerit. Maecenas eros est, consequat ac tellus non, aliquam ultrices dui.

\mysection{B}\leavevmode \vspace*{-\dimexpr\baselineskip + \topsep\relax}
\begin{theorem}
    Etiam ipsum erat, tristique sit amet ante non, porta iaculis odio. Ut tempus suscipit urna, in semper arcu mollis nec
    \[
        1 + 1 = 2.
    \]
\end{theorem}

\begin{theorem} $1 \ne 0$.
\end{theorem}
\begin{proof}
\dots
\end{proof}

\end{document} 

无关:既然你使用 babel-latin,也许你应该用 QED(甚至是 EOΔ)替换证明结束符号。;O) 在此处输入图片描述

相关内容