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